diff --git a/.clang-format b/.clang-format index f5e4a65be8..b7e76c83b9 100644 --- a/.clang-format +++ b/.clang-format @@ -6,9 +6,9 @@ AlignAfterOpenBracket: Align AlignConsecutiveMacros: false AlignConsecutiveAssignments: false AlignConsecutiveDeclarations: false -AlignEscapedNewlines: DontAlign +AlignEscapedNewlines: DontAlign AlignOperands: true -AlignTrailingComments: false +AlignTrailingComments: false AllowAllArgumentsOnNextLine: true AllowAllConstructorInitializersOnNextLine: true AllowAllParametersOfDeclarationOnNextLine: true @@ -73,7 +73,7 @@ PenaltyBreakTemplateDeclaration: 10 PenaltyExcessCharacter: 1000000 PenaltyReturnTypeOnItsOwnLine: 6000 PointerAlignment: Left -ReflowComments: false +ReflowComments: true SortIncludes: false SortUsingDeclarations: false SpaceAfterCStyleCast: false @@ -95,6 +95,7 @@ SpacesInCStyleCastParentheses: false SpacesInParentheses: false SpacesInSquareBrackets: false SpaceBeforeSquareBrackets: false +#InsertNewlineAtEOF: true Standard: c++17 StatementMacros: - Q_UNUSED diff --git a/Source/Activities/ActorEditor.cpp b/Source/Activities/ActorEditor.cpp index 40a3e5101e..3aac4083bd 100644 --- a/Source/Activities/ActorEditor.cpp +++ b/Source/Activities/ActorEditor.cpp @@ -1,15 +1,3 @@ -////////////////////////////////////////////////////////////////////////////////////////// -// File: ActorEditor.cpp -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Source file for the ActorEditor class. -// Project: Retro Terrain Engine -// Author(s): Daniel Tabar -// data@datarealms.com -// http://www.datarealms.com - -////////////////////////////////////////////////////////////////////////////////////////// -// Inclusions of header files - #include "ActorEditor.h" #include "PresetMan.h" @@ -17,11 +5,11 @@ #include "FrameMan.h" #include "CameraMan.h" #include "UInputMan.h" -//#include "AHuman.h" -//#include "MOPixel.h" +// #include "AHuman.h" +// #include "MOPixel.h" #include "SLTerrain.h" #include "Controller.h" -//#include "AtomGroup.h" +// #include "AtomGroup.h" #include "Actor.h" #include "AHuman.h" #include "ACRocket.h" @@ -35,22 +23,11 @@ namespace RTE { ConcreteClassInfo(ActorEditor, EditorActivity, 0); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Clear - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears all the member variables of this ActorEditor, effectively - // resetting the members of this abstraction level only. - void ActorEditor::Clear() { m_pEditedActor = 0; m_pPicker = 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes the ActorEditor object ready for use. - int ActorEditor::Create() { if (EditorActivity::Create() < 0) return -1; @@ -60,11 +37,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Creates a ActorEditor to be identical to another, by deep copy. - int ActorEditor::Create(const ActorEditor& reference) { if (EditorActivity::Create(reference) < 0) return -1; @@ -75,14 +47,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: ReadProperty - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Reads a property value from a reader stream. If the name isn't - // recognized by this class, then ReadProperty of the parent class - // is called. If the property isn't recognized by any of the base classes, - // false is returned, and the reader's position is untouched. - int ActorEditor::ReadProperty(const std::string_view& propName, Reader& reader) { StartPropertyList(return EditorActivity::ReadProperty(propName, reader)); /* @@ -93,22 +57,11 @@ namespace RTE { EndPropertyList; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Save - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Saves the complete state of this ActorEditor with a Writer for - // later recreation with Create(Reader &reader); - int ActorEditor::Save(Writer& writer) const { EditorActivity::Save(writer); return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destroys and resets (through Clear()) the ActorEditor object. - void ActorEditor::Destroy(bool notInherited) { delete m_pEditedActor; delete m_pPicker; @@ -118,12 +71,6 @@ namespace RTE { Clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Start - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Officially starts this. Creates all the data etc necessary to start - // the activity. - int ActorEditor::Start() { int error = EditorActivity::Start(); @@ -144,33 +91,17 @@ namespace RTE { return error; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Pause - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Pauses and unpauses the game. - void ActorEditor::SetPaused(bool pause) { // Override the pause m_Paused = false; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: End - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Forces the current game's end. - void ActorEditor::End() { EditorActivity::End(); m_ActivityState = ActivityState::Over; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Update - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the state of this ActorEditor. Supposed to be done every frame - // before drawing. - void ActorEditor::Update() { // And object hasn't been loaded yet, so get the loading picker going if (!m_pEditedActor) { @@ -245,11 +176,6 @@ namespace RTE { } } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: DrawGUI - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws the currently active GUI of a screen to a BITMAP of choice. - void ActorEditor::DrawGUI(BITMAP* pTargetBitmap, const Vector& targetPos, int which) { // Draw the edited actor and pie menu if (m_pEditedActor) { @@ -266,21 +192,10 @@ namespace RTE { EditorActivity::DrawGUI(pTargetBitmap, targetPos, which); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Draw - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws this ActorEditor's current graphical representation to a - // BITMAP of choice. This includes all game-related graphics. - void ActorEditor::Draw(BITMAP* pTargetBitmap, const Vector& targetPos) { EditorActivity::Draw(pTargetBitmap, targetPos); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: LoadActor - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Reloads the Actor itself and sets up the pie menu to match its setup. - bool ActorEditor::LoadActor(const Entity* pActorToLoad) { if (!pActorToLoad) return false; @@ -312,8 +227,6 @@ namespace RTE { return true; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool ActorEditor::ReloadActorData() { if (m_pEditedActor) { std::string presetName = m_pEditedActor->GetPresetName(); diff --git a/Source/Activities/ActorEditor.h b/Source/Activities/ActorEditor.h index 676276ab8d..87103a9b0a 100644 --- a/Source/Activities/ActorEditor.h +++ b/Source/Activities/ActorEditor.h @@ -1,18 +1,11 @@ #ifndef _RTEACTOREDITOR_ #define _RTEACTOREDITOR_ -////////////////////////////////////////////////////////////////////////////////////////// -// File: ActorEditor.h -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Header file for the ActorEditor class. -// Project: Retro Terrain Engine -// Author(s): Daniel Tabar -// data@datarealms.com -// http://www.datarealms.com - -////////////////////////////////////////////////////////////////////////////////////////// -// Inclusions of header files - +/// Header file for the ActorEditor class. +/// @author Daniel Tabar +/// data@datarealms.com +/// http://www.datarealms.com +/// Inclusions of header files #include "RTETools.h" #include "EditorActivity.h" @@ -32,183 +25,92 @@ namespace RTE { class GUILabel; class GUIComboBox; - ////////////////////////////////////////////////////////////////////////////////////////// - // Class: ActorEditor - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Activity for testing and quickly iterating on Actor data definitions. - // Parent(s): EditorActivity. - // Class history: 10/08/2007 ActorEditor Created. - + /// Activity for testing and quickly iterating on Actor data definitions. class ActorEditor : public EditorActivity { - ////////////////////////////////////////////////////////////////////////////////////////// - // Public member variable, method and friend function declarations - + /// Public member variable, method and friend function declarations public: // Concrete allocation and cloning definitions EntityAllocation(ActorEditor); SerializableOverrideMethods; ClassInfoGetters; - ////////////////////////////////////////////////////////////////////////////////////////// - // Constructor: ActorEditor - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Constructor method used to instantiate a ActorEditor object in system - // memory. Create() should be called before using the object. - // Arguments: None. - + /// Constructor method used to instantiate a ActorEditor object in system + /// memory. Create() should be called before using the object. ActorEditor() { Clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Destructor: ~ActorEditor - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destructor method used to clean up a ActorEditor object before deletion - // from system memory. - // Arguments: None. - + /// Destructor method used to clean up a ActorEditor object before deletion + /// from system memory. ~ActorEditor() override { Destroy(true); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes the ActorEditor object ready for use. - // Arguments: None. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Makes the ActorEditor object ready for use. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Create() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Creates a ActorEditor to be identical to another, by deep copy. - // Arguments: A reference to the ActorEditor to deep copy. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Creates a ActorEditor to be identical to another, by deep copy. + /// @param reference A reference to the ActorEditor to deep copy. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Create(const ActorEditor& reference); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Reset - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Resets the entire ActorEditor, including its inherited members, to their - // default settings or values. - // Arguments: None. - // Return value: None. - + /// Resets the entire ActorEditor, including its inherited members, to their + /// default settings or values. void Reset() override { Clear(); EditorActivity::Reset(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destroys and resets (through Clear()) the ActorEditor object. - // Arguments: Whether to only destroy the members defined in this derived class, or - // to destroy all inherited members also. - // Return value: None. - + /// Destroys and resets (through Clear()) the ActorEditor object. + /// @param notInherited Whether to only destroy the members defined in this derived class, or (default: false) + /// to destroy all inherited members also. void Destroy(bool notInherited = false) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetEditorMode - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the current mode of this editor. - // Arguments: The new mode to set to, see the EditorGUIMode enum. - // Return value: None. - + /// Sets the current mode of this editor. + /// @param newMode The new mode to set to, see the EditorGUIMode enum. void SetEditorMode(EditorActivity::EditorMode newMode) { m_EditorMode = newMode; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetEditorMode - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the current mode of this editor. - // Arguments: None. - // Return value: The current mode this is set to; see the EditorGUIMode enum. - + /// Gets the current mode of this editor. + /// @return The current mode this is set to; see the EditorGUIMode enum. EditorActivity::EditorMode GetEditorMode() const { return m_EditorMode; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Start - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Officially starts the game accroding to parameters previously set. - // Arguments: None. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Officially starts the game accroding to parameters previously set. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Start() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Pause - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Pauses and unpauses the game. - // Arguments: Whether to pause the game or not. - // Return value: None. - + /// Pauses and unpauses the game. + /// @param pause Whether to pause the game or not. (default: true) void SetPaused(bool pause = true) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: End - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Forces the current game's end. - // Arguments: None. - // Return value: None. - + /// Forces the current game's end. void End() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Update - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the state of this ActivityMan. Supposed to be done every frame - // before drawing. - // Arguments: None. - // Return value: None. - + /// Updates the state of this ActivityMan. Supposed to be done every frame + /// before drawing. void Update() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: DrawGUI - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws the currently active GUI of a screen to a BITMAP of choice. - // Arguments: A pointer to a screen-sized BITMAP to draw on. - // The absolute position of the target bitmap's upper left corner in the scene. - // Which screen's GUI to draw onto the bitmap. - // Return value: None. - + /// Draws the currently active GUI of a screen to a BITMAP of choice. + /// @param pTargetBitmap A pointer to a screen-sized BITMAP to draw on. + /// @param targetPos The absolute position of the target bitmap's upper left corner in the scene. (default: Vector()) + /// @param which Which screen's GUI to draw onto the bitmap. (default: 0) void DrawGUI(BITMAP* pTargetBitmap, const Vector& targetPos = Vector(), int which = 0) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Draw - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws this ActivityMan's current graphical representation to a - // BITMAP of choice. This includes all game-related graphics. - // Arguments: A pointer to a BITMAP to draw on. OWNERSHIP IS NOT TRANSFERRED! - // The absolute position of the target bitmap's upper left corner in the scene. - // Return value: None. - + /// Draws this ActivityMan's current graphical representation to a + /// BITMAP of choice. This includes all game-related graphics. + /// @param pTargetBitmap A pointer to a BITMAP to draw on. OWNERSHIP IS NOT TRANSFERRED! + /// @param targetPos The absolute position of the target bitmap's upper left corner in the scene. (default: Vector()) void Draw(BITMAP* pTargetBitmap, const Vector& targetPos = Vector()) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Protected member variable and method declarations - + /// Protected member variable and method declarations protected: - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: LoadActor - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Reloads the Actor itself and sets up the pie menu to match its setup. - // Arguments: An Entity Preset of the Actor to load into the editor. OWNERSHIP IS NOT TRANSFERRED! - // Return value: Whether the Actor was loaded successfully from the PresetMan. - + /// Reloads the Actor itself and sets up the pie menu to match its setup. + /// @param pActorToLoad An Entity Preset of the Actor to load into the editor. OWNERSHIP IS NOT TRANSFERRED! + /// @return Whether the Actor was loaded successfully from the PresetMan. bool LoadActor(const Entity* pActorToLoad); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ReloadActorData - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Reloads the ini with the currently edited Actor's definitions. - // Arguments: None. - // Return value: Whether the data file was successfully read. - + /// Reloads the ini with the currently edited Actor's definitions. + /// @return Whether the data file was successfully read. bool ReloadActorData(); // Member variables @@ -219,18 +121,10 @@ namespace RTE { // The picker for selecting which object to load ObjectPickerGUI* m_pPicker; - ////////////////////////////////////////////////////////////////////////////////////////// - // Private member variable and method declarations - + /// Private member variable and method declarations private: - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Clear - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears all the member variables of this Activity, effectively - // resetting the members of this abstraction level only. - // Arguments: None. - // Return value: None. - + /// Clears all the member variables of this Activity, effectively + /// resetting the members of this abstraction level only. void Clear(); }; diff --git a/Source/Activities/AreaEditor.cpp b/Source/Activities/AreaEditor.cpp index 0c7a022384..1b1b9f5ed1 100644 --- a/Source/Activities/AreaEditor.cpp +++ b/Source/Activities/AreaEditor.cpp @@ -1,15 +1,3 @@ -////////////////////////////////////////////////////////////////////////////////////////// -// File: AreaEditor.cpp -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Source file for the AreaEditor class. -// Project: Retro Terrain Engine -// Author(s): Daniel Tabar -// data@datarealms.com -// http://www.datarealms.com - -////////////////////////////////////////////////////////////////////////////////////////// -// Inclusions of header files - #include "AreaEditor.h" #include "WindowMan.h" @@ -42,22 +30,11 @@ namespace RTE { ConcreteClassInfo(AreaEditor, EditorActivity, 0); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Clear - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears all the member variables of this AreaEditor, effectively - // resetting the members of this abstraction level only. - void AreaEditor::Clear() { m_pEditorGUI = 0; m_pNewAreaName = 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes the AreaEditor object ready for use. - int AreaEditor::Create() { if (EditorActivity::Create() < 0) return -1; @@ -65,11 +42,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Creates a AreaEditor to be identical to another, by deep copy. - int AreaEditor::Create(const AreaEditor& reference) { if (EditorActivity::Create(reference) < 0) return -1; @@ -80,14 +52,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: ReadProperty - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Reads a property value from a reader stream. If the name isn't - // recognized by this class, then ReadProperty of the parent class - // is called. If the property isn't recognized by any of the base classes, - // false is returned, and the reader's position is untouched. - int AreaEditor::ReadProperty(const std::string_view& propName, Reader& reader) { StartPropertyList(return EditorActivity::ReadProperty(propName, reader)); /* @@ -98,22 +62,11 @@ namespace RTE { EndPropertyList; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Save - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Saves the complete state of this AreaEditor with a Writer for - // later recreation with Create(Reader &reader); - int AreaEditor::Save(Writer& writer) const { EditorActivity::Save(writer); return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destroys and resets (through Clear()) the AreaEditor object. - void AreaEditor::Destroy(bool notInherited) { delete m_pEditorGUI; @@ -122,12 +75,6 @@ namespace RTE { Clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Start - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Officially starts this. Creates all the data etc necessary to start - // the activity. - int AreaEditor::Start() { int error = EditorActivity::Start(); @@ -212,33 +159,17 @@ namespace RTE { return error; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Pause - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Pauses and unpauses the game. - void AreaEditor::SetPaused(bool pause) { // Override the pause m_Paused = false; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: End - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Forces the current game's end. - void AreaEditor::End() { EditorActivity::End(); m_ActivityState = ActivityState::Over; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Update - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the state of this AreaEditor. Supposed to be done every frame - // before drawing. - void AreaEditor::Update() { EditorActivity::Update(); @@ -498,29 +429,16 @@ namespace RTE { } } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: DrawGUI - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws the currently active GUI of a screen to a BITMAP of choice. - void AreaEditor::DrawGUI(BITMAP* pTargetBitmap, const Vector& targetPos, int which) { m_pEditorGUI->Draw(pTargetBitmap, targetPos); EditorActivity::DrawGUI(pTargetBitmap, targetPos, which); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Draw - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws this AreaEditor's current graphical representation to a - // BITMAP of choice. This includes all game-related graphics. - void AreaEditor::Draw(BITMAP* pTargetBitmap, const Vector& targetPos) { EditorActivity::Draw(pTargetBitmap, targetPos); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool AreaEditor::SaveScene(const std::string& saveAsName, bool forceOverwrite) { Scene* editedScene = g_SceneMan.GetScene(); editedScene->SetPresetName(saveAsName); @@ -589,22 +507,12 @@ namespace RTE { return false; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: UpdateNewDialog - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the New dialog box, populates its lists etc. - void AreaEditor::UpdateNewDialog() { // Reset the new Area name text field if (m_pNewAreaName->GetText().empty()) m_pNewAreaName->SetText("Test Area 1"); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: UpdateLoadDialog - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the Load dialog box, populates its lists etc. - void AreaEditor::UpdateLoadDialog() { // Clear out the control m_pLoadNameCombo->ClearList(); @@ -626,11 +534,6 @@ namespace RTE { m_pLoadNameCombo->SetSelectedIndex(0); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: UpdateSaveDialog - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the Save dialog box, populates its lists etc. - void AreaEditor::UpdateSaveDialog() { m_pSaveNameBox->SetText((g_SceneMan.GetScene()->GetPresetName() == "None" || !m_HasEverBeenSaved) ? "New Scene" : g_SceneMan.GetScene()->GetPresetName()); if (g_PresetMan.GetDataModule(m_ModuleSpaceID)->GetFileName() == c_UserScenesModuleName) @@ -639,11 +542,6 @@ namespace RTE { m_pSaveModuleLabel->SetText("Will save in " + g_PresetMan.GetDataModule(m_ModuleSpaceID)->GetFileName() + "/Scenes"); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: UpdateChangesDialog - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the Save Changes dialog box, populates its lists etc. - void AreaEditor::UpdateChangesDialog() { if (m_HasEverBeenSaved) { dynamic_cast(m_pGUIController->GetControl("ChangesExpLabel"))->SetText("Do you want to save your changes to:"); @@ -657,11 +555,6 @@ namespace RTE { } } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: UpdateOverwriteDialog - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the Overwrite dialog box, populates its lists etc. - void AreaEditor::UpdateOverwriteDialog() { if (g_PresetMan.GetDataModule(m_ModuleSpaceID)->GetFileName() == c_UserScenesModuleName) m_pOverwriteNameLabel->SetText(g_PresetMan.GetDataModule(m_ModuleSpaceID)->GetFileName() + "/" + g_SceneMan.GetScene()->GetPresetName()); diff --git a/Source/Activities/AreaEditor.h b/Source/Activities/AreaEditor.h index 26378b247d..52f4b183ae 100644 --- a/Source/Activities/AreaEditor.h +++ b/Source/Activities/AreaEditor.h @@ -1,18 +1,11 @@ #ifndef _RTEAREAEDITOR_ #define _RTEAREAEDITOR_ -////////////////////////////////////////////////////////////////////////////////////////// -// File: AreaEditor.h -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Header file for the AreaEditor class. -// Project: Retro Terrain Engine -// Author(s): Daniel Tabar -// data@datarealms.com -// http://www.datarealms.com - -////////////////////////////////////////////////////////////////////////////////////////// -// Inclusions of header files - +/// Header file for the AreaEditor class. +/// @author Daniel Tabar +/// data@datarealms.com +/// http://www.datarealms.com +/// Inclusions of header files #include "RTETools.h" #include "EditorActivity.h" @@ -30,218 +23,104 @@ namespace RTE { class GUILabel; class GUIComboBox; - ////////////////////////////////////////////////////////////////////////////////////////// - // Class: AreaEditor - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Activity for editing Scene:s' Area:s. - // Parent(s): EditorActivity. - // Class history: 7/21/2008 AreaEditor created, based off SceneEditor - + /// Activity for editing Scene:s' Area:s. class AreaEditor : public EditorActivity { - ////////////////////////////////////////////////////////////////////////////////////////// - // Public member variable, method and friend function declarations - + /// Public member variable, method and friend function declarations public: // Concrete allocation and cloning definitions EntityAllocation(AreaEditor); SerializableOverrideMethods; ClassInfoGetters; - ////////////////////////////////////////////////////////////////////////////////////////// - // Constructor: AreaEditor - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Constructor method used to instantiate a AreaEditor object in system - // memory. Create() should be called before using the object. - // Arguments: None. - + /// Constructor method used to instantiate a AreaEditor object in system + /// memory. Create() should be called before using the object. AreaEditor() { Clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Destructor: ~AreaEditor - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destructor method used to clean up a AreaEditor object before deletion - // from system memory. - // Arguments: None. - + /// Destructor method used to clean up a AreaEditor object before deletion + /// from system memory. ~AreaEditor() override { Destroy(true); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes the AreaEditor object ready for use. - // Arguments: None. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Makes the AreaEditor object ready for use. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Create() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Creates a AreaEditor to be identical to another, by deep copy. - // Arguments: A reference to the AreaEditor to deep copy. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Creates a AreaEditor to be identical to another, by deep copy. + /// @param reference A reference to the AreaEditor to deep copy. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Create(const AreaEditor& reference); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Reset - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Resets the entire AreaEditor, including its inherited members, to their - // default settings or values. - // Arguments: None. - // Return value: None. - + /// Resets the entire AreaEditor, including its inherited members, to their + /// default settings or values. void Reset() override { Clear(); EditorActivity::Reset(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destroys and resets (through Clear()) the AreaEditor object. - // Arguments: Whether to only destroy the members defined in this derived class, or - // to destroy all inherited members also. - // Return value: None. - + /// Destroys and resets (through Clear()) the AreaEditor object. + /// @param notInherited Whether to only destroy the members defined in this derived class, or (default: false) + /// to destroy all inherited members also. void Destroy(bool notInherited = false) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetEditorMode - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the current mode of this editor. - // Arguments: The new mode to set to, see the EditorGUIMode enum. - // Return value: None. - + /// Sets the current mode of this editor. + /// @param newMode The new mode to set to, see the EditorGUIMode enum. void SetEditorMode(EditorActivity::EditorMode newMode) { m_EditorMode = newMode; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetEditorMode - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the current mode of this editor. - // Arguments: None. - // Return value: The current mode this is set to; see the EditorGUIMode enum. - + /// Gets the current mode of this editor. + /// @return The current mode this is set to; see the EditorGUIMode enum. EditorActivity::EditorMode GetEditorMode() const { return m_EditorMode; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Start - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Officially starts the game accroding to parameters previously set. - // Arguments: None. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Officially starts the game accroding to parameters previously set. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Start() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Pause - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Pauses and unpauses the game. - // Arguments: Whether to pause the game or not. - // Return value: None. - + /// Pauses and unpauses the game. + /// @param pause Whether to pause the game or not. (default: true) void SetPaused(bool pause = true) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: End - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Forces the current game's end. - // Arguments: None. - // Return value: None. - + /// Forces the current game's end. void End() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Update - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the state of this ActivityMan. Supposed to be done every frame - // before drawing. - // Arguments: None. - // Return value: None. - + /// Updates the state of this ActivityMan. Supposed to be done every frame + /// before drawing. void Update() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: DrawGUI - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws the currently active GUI of a screen to a BITMAP of choice. - // Arguments: A pointer to a screen-sized BITMAP to draw on. - // The absolute position of the target bitmap's upper left corner in the scene. - // Which screen's GUI to draw onto the bitmap. - // Return value: None. - + /// Draws the currently active GUI of a screen to a BITMAP of choice. + /// @param pTargetBitmap A pointer to a screen-sized BITMAP to draw on. + /// @param targetPos The absolute position of the target bitmap's upper left corner in the scene. (default: Vector()) + /// @param which Which screen's GUI to draw onto the bitmap. (default: 0) void DrawGUI(BITMAP* pTargetBitmap, const Vector& targetPos = Vector(), int which = 0) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Draw - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws this ActivityMan's current graphical representation to a - // BITMAP of choice. This includes all game-related graphics. - // Arguments: A pointer to a BITMAP to draw on. OWNERSHIP IS NOT TRANSFERRED! - // The absolute position of the target bitmap's upper left corner in the scene. - // Return value: None. - + /// Draws this ActivityMan's current graphical representation to a + /// BITMAP of choice. This includes all game-related graphics. + /// @param pTargetBitmap A pointer to a BITMAP to draw on. OWNERSHIP IS NOT TRANSFERRED! + /// @param targetPos The absolute position of the target bitmap's upper left corner in the scene. (default: Vector()) void Draw(BITMAP* pTargetBitmap, const Vector& targetPos = Vector()) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Protected member variable and method declarations - + /// Protected member variable and method declarations protected: - /// /// Saves the current Scene to an appropriate ini file, and asks user if they want to overwrite first if scene of this name exists. - /// - /// The name of the new Scene to be saved. - /// Whether to force any existing Scene of that name to be overwritten if it already exists. - /// Whether actually managed to save. Will return false both if a scene of this name already exists, or if other error. + /// @param saveAsName The name of the new Scene to be saved. + /// @param forceOverwrite Whether to force any existing Scene of that name to be overwritten if it already exists. + /// @return Whether actually managed to save. Will return false both if a scene of this name already exists, or if other error. bool SaveScene(const std::string& saveAsName, bool forceOverwrite = false); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virutal method: UpdateNewDialog - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the New dialog box, populates its lists etc. - // Arguments: None. - // Return value: None. - + /// Updates the New dialog box, populates its lists etc. void UpdateNewDialog() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virutal method: UpdateLoadDialog - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the Load dialog box, populates its lists etc. - // Arguments: None. - // Return value: None. - + /// Updates the Load dialog box, populates its lists etc. void UpdateLoadDialog() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virutal method: UpdateSaveDialog - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the Save dialog box, populates its lists etc. - // Arguments: None. - // Return value: None. - + /// Updates the Save dialog box, populates its lists etc. void UpdateSaveDialog() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virutal method: UpdateChangesDialog - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the Save Changes dialog box, populates its lists etc. - // Arguments: None. - // Return value: None. - + /// Updates the Save Changes dialog box, populates its lists etc. void UpdateChangesDialog() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virutal method: UpdateOverwriteDialog - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the Overwrite dialog box, populates its lists etc. - // Arguments: None. - // Return value: None. - + /// Updates the Overwrite dialog box, populates its lists etc. void UpdateOverwriteDialog() override; // Member variables @@ -255,18 +134,10 @@ namespace RTE { // // Number which // int m_NewAreaNumber; - ////////////////////////////////////////////////////////////////////////////////////////// - // Private member variable and method declarations - + /// Private member variable and method declarations private: - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Clear - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears all the member variables of this Activity, effectively - // resetting the members of this abstraction level only. - // Arguments: None. - // Return value: None. - + /// Clears all the member variables of this Activity, effectively + /// resetting the members of this abstraction level only. void Clear(); }; diff --git a/Source/Activities/AssemblyEditor.cpp b/Source/Activities/AssemblyEditor.cpp index 20677ef294..1d59d5df33 100644 --- a/Source/Activities/AssemblyEditor.cpp +++ b/Source/Activities/AssemblyEditor.cpp @@ -1,15 +1,3 @@ -////////////////////////////////////////////////////////////////////////////////////////// -// File: AssemblyEditor.cpp -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Source file for the AssemblyEditor class. -// Project: Retro Terrain Engine -// Author(s): Daniel Tabar -// data@datarealms.com -// http://www.datarealms.com - -////////////////////////////////////////////////////////////////////////////////////////// -// Inclusions of header files - #include "AssemblyEditor.h" #include "WindowMan.h" @@ -42,22 +30,11 @@ namespace RTE { ConcreteClassInfo(AssemblyEditor, EditorActivity, 0); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Clear - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears all the member variables of this AssemblyEditor, effectively - // resetting the members of this abstraction level only. - void AssemblyEditor::Clear() { m_pEditorGUI = 0; m_pModuleCombo = 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes the AssemblyEditor object ready for use. - int AssemblyEditor::Create() { if (EditorActivity::Create() < 0) return -1; @@ -65,11 +42,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Creates a AssemblyEditor to be identical to another, by deep copy. - int AssemblyEditor::Create(const AssemblyEditor& reference) { if (EditorActivity::Create(reference) < 0) return -1; @@ -80,14 +52,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: ReadProperty - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Reads a property value from a reader stream. If the name isn't - // recognized by this class, then ReadProperty of the parent class - // is called. If the property isn't recognized by any of the base classes, - // false is returned, and the reader's position is untouched. - int AssemblyEditor::ReadProperty(const std::string_view& propName, Reader& reader) { StartPropertyList(return EditorActivity::ReadProperty(propName, reader)); /* @@ -98,22 +62,11 @@ namespace RTE { EndPropertyList; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Save - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Saves the complete state of this AssemblyEditor with a Writer for - // later recreation with Create(Reader &reader); - int AssemblyEditor::Save(Writer& writer) const { EditorActivity::Save(writer); return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destroys and resets (through Clear()) the AssemblyEditor object. - void AssemblyEditor::Destroy(bool notInherited) { delete m_pEditorGUI; @@ -122,12 +75,6 @@ namespace RTE { Clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Start - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Officially starts this. Creates all the data etc necessary to start - // the activity. - int AssemblyEditor::Start() { int error = EditorActivity::Start(); @@ -198,33 +145,17 @@ namespace RTE { return error; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Pause - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Pauses and unpauses the game. - void AssemblyEditor::SetPaused(bool pause) { // Override the pause m_Paused = false; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: End - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Forces the current game's end. - void AssemblyEditor::End() { EditorActivity::End(); m_ActivityState = ActivityState::Over; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Update - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the state of this AssemblyEditor. Supposed to be done every frame - // before drawing. - void AssemblyEditor::Update() { EditorActivity::Update(); @@ -427,33 +358,16 @@ namespace RTE { } } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: DrawGUI - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws the currently active GUI of a screen to a BITMAP of choice. - void AssemblyEditor::DrawGUI(BITMAP* pTargetBitmap, const Vector& targetPos, int which) { m_pEditorGUI->Draw(pTargetBitmap, targetPos); EditorActivity::DrawGUI(pTargetBitmap, targetPos, which); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Draw - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws this AssemblyEditor's current graphical representation to a - // BITMAP of choice. This includes all game-related graphics. - void AssemblyEditor::Draw(BITMAP* pTargetBitmap, const Vector& targetPos) { EditorActivity::Draw(pTargetBitmap, targetPos); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: BuildAssembly - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Creates and builds assembly which fits currently selected scheme and returns - // it's pointer. Owhership IS transfered. - BunkerAssembly* AssemblyEditor::BuildAssembly(std::string saveAsName) { // Create new bunker assembly to save BunkerAssembly* pBA = new BunkerAssembly(); @@ -531,8 +445,6 @@ namespace RTE { return pBA; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool AssemblyEditor::SaveAssembly(const std::string& saveAsName, bool forceOverwrite) { std::unique_ptr editedAssembly(BuildAssembly(saveAsName)); @@ -601,21 +513,9 @@ namespace RTE { return false; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virutal method: UpdateNewDialog - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the New dialog box, populates its lists etc. - // Arguments: None. - // Return value: None. - void AssemblyEditor::UpdateNewDialog() { } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: UpdateLoadDialog - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the Load dialog box, populates its lists etc. - void AssemblyEditor::UpdateLoadDialog() { int scenesIndex = 0; @@ -676,11 +576,6 @@ namespace RTE { m_pLoadNameCombo->SetSelectedIndex(0); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: UpdateSaveDialog - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the Save dialog box, populates its lists etc. - void AssemblyEditor::UpdateSaveDialog() { std::string defaultName = ""; @@ -692,11 +587,6 @@ namespace RTE { m_pSaveModuleLabel->SetText("Will save in " + g_PresetMan.GetDataModule(m_ModuleSpaceID)->GetFileName()); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: UpdateChangesDialog - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the Save Changes dialog box, populates its lists etc. - void AssemblyEditor::UpdateChangesDialog() { if (m_HasEverBeenSaved) { dynamic_cast(m_pGUIController->GetControl("ChangesExpLabel"))->SetText("Do you want to save your changes to:"); @@ -707,11 +597,6 @@ namespace RTE { } } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: UpdateOverwriteDialog - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the Overwrite dialog box, populates its lists etc. - void AssemblyEditor::UpdateOverwriteDialog() { m_pOverwriteNameLabel->SetText(m_pEditorGUI->GetCurrentAssemblyName()); } diff --git a/Source/Activities/AssemblyEditor.h b/Source/Activities/AssemblyEditor.h index 37e714b7c4..7adbfad149 100644 --- a/Source/Activities/AssemblyEditor.h +++ b/Source/Activities/AssemblyEditor.h @@ -1,18 +1,11 @@ #ifndef _RTEASSEMBLYEDITOR_ #define _RTEASSEMBLYEDITOR_ -////////////////////////////////////////////////////////////////////////////////////////// -// File: AssemblyEditor.h -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Header file for the AssemblyEditor class. -// Project: Retro Terrain Engine -// Author(s): Daniel Tabar -// data@datarealms.com -// http://www.datarealms.com - -////////////////////////////////////////////////////////////////////////////////////////// -// Inclusions of header files - +/// Header file for the AssemblyEditor class. +/// @author Daniel Tabar +/// data@datarealms.com +/// http://www.datarealms.com +/// Inclusions of header files #include "RTETools.h" #include "EditorActivity.h" #include "BunkerAssembly.h" @@ -31,229 +24,111 @@ namespace RTE { class GUILabel; class GUIComboBox; - ////////////////////////////////////////////////////////////////////////////////////////// - // Class: AssemblyEditor - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Activity for editing scenes. - // Parent(s): EditorActivity. - // Class history: 8/30/2007 AssemblyEditor created, inheriting directly from Activity. - // 9/17/2007 Spliced out and made to derive from EditorActivty - + /// Activity for editing scenes. + /// 9/17/2007 Spliced out and made to derive from EditorActivty class AssemblyEditor : public EditorActivity { - ////////////////////////////////////////////////////////////////////////////////////////// - // Public member variable, method and friend function declarations - + /// Public member variable, method and friend function declarations public: // Concrete allocation and cloning definitions EntityAllocation(AssemblyEditor); SerializableOverrideMethods; ClassInfoGetters; - ////////////////////////////////////////////////////////////////////////////////////////// - // Constructor: AssemblyEditor - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Constructor method used to instantiate a AssemblyEditor object in system - // memory. Create() should be called before using the object. - // Arguments: None. - + /// Constructor method used to instantiate a AssemblyEditor object in system + /// memory. Create() should be called before using the object. AssemblyEditor() { Clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Destructor: ~AssemblyEditor - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destructor method used to clean up a AssemblyEditor object before deletion - // from system memory. - // Arguments: None. - + /// Destructor method used to clean up a AssemblyEditor object before deletion + /// from system memory. ~AssemblyEditor() override { Destroy(true); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes the AssemblyEditor object ready for use. - // Arguments: None. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Makes the AssemblyEditor object ready for use. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Create() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Creates a AssemblyEditor to be identical to another, by deep copy. - // Arguments: A reference to the AssemblyEditor to deep copy. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Creates a AssemblyEditor to be identical to another, by deep copy. + /// @param reference A reference to the AssemblyEditor to deep copy. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Create(const AssemblyEditor& reference); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Reset - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Resets the entire AssemblyEditor, including its inherited members, to their - // default settings or values. - // Arguments: None. - // Return value: None. - + /// Resets the entire AssemblyEditor, including its inherited members, to their + /// default settings or values. void Reset() override { Clear(); EditorActivity::Reset(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destroys and resets (through Clear()) the AssemblyEditor object. - // Arguments: Whether to only destroy the members defined in this derived class, or - // to destroy all inherited members also. - // Return value: None. - + /// Destroys and resets (through Clear()) the AssemblyEditor object. + /// @param notInherited Whether to only destroy the members defined in this derived class, or (default: false) + /// to destroy all inherited members also. void Destroy(bool notInherited = false) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetEditorMode - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the current mode of this editor. - // Arguments: The new mode to set to, see the EditorGUIMode enum. - // Return value: None. - + /// Sets the current mode of this editor. + /// @param newMode The new mode to set to, see the EditorGUIMode enum. void SetEditorMode(EditorActivity::EditorMode newMode) { m_EditorMode = newMode; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetEditorMode - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the current mode of this editor. - // Arguments: None. - // Return value: The current mode this is set to; see the EditorGUIMode enum. - + /// Gets the current mode of this editor. + /// @return The current mode this is set to; see the EditorGUIMode enum. EditorActivity::EditorMode GetEditorMode() const { return m_EditorMode; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Start - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Officially starts the game accroding to parameters previously set. - // Arguments: None. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Officially starts the game accroding to parameters previously set. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Start() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Pause - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Pauses and unpauses the game. - // Arguments: Whether to pause the game or not. - // Return value: None. - + /// Pauses and unpauses the game. + /// @param pause Whether to pause the game or not. (default: true) void SetPaused(bool pause = true) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: End - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Forces the current game's end. - // Arguments: None. - // Return value: None. - + /// Forces the current game's end. void End() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Update - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the state of this ActivityMan. Supposed to be done every frame - // before drawing. - // Arguments: None. - // Return value: None. - + /// Updates the state of this ActivityMan. Supposed to be done every frame + /// before drawing. void Update() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: DrawGUI - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws the currently active GUI of a screen to a BITMAP of choice. - // Arguments: A pointer to a screen-sized BITMAP to draw on. - // The absolute position of the target bitmap's upper left corner in the scene. - // Which screen's GUI to draw onto the bitmap. - // Return value: None. - + /// Draws the currently active GUI of a screen to a BITMAP of choice. + /// @param pTargetBitmap A pointer to a screen-sized BITMAP to draw on. + /// @param targetPos The absolute position of the target bitmap's upper left corner in the scene. (default: Vector()) + /// @param which Which screen's GUI to draw onto the bitmap. (default: 0) void DrawGUI(BITMAP* pTargetBitmap, const Vector& targetPos = Vector(), int which = 0) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Draw - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws this ActivityMan's current graphical representation to a - // BITMAP of choice. This includes all game-related graphics. - // Arguments: A pointer to a BITMAP to draw on. OWNERSHIP IS NOT TRANSFERRED! - // The absolute position of the target bitmap's upper left corner in the scene. - // Return value: None. - + /// Draws this ActivityMan's current graphical representation to a + /// BITMAP of choice. This includes all game-related graphics. + /// @param pTargetBitmap A pointer to a BITMAP to draw on. OWNERSHIP IS NOT TRANSFERRED! + /// @param targetPos The absolute position of the target bitmap's upper left corner in the scene. (default: Vector()) void Draw(BITMAP* pTargetBitmap, const Vector& targetPos = Vector()) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Protected member variable and method declarations - + /// Protected member variable and method declarations protected: - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: BuildAssembly - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Creates and builds assembly which fits currently selected scheme and returns - // it's pointer. Owhership IS transfered. - // Arguments: New assembly name. - // Return value: Built BunkerAssembly - + /// Creates and builds assembly which fits currently selected scheme and returns + /// it's pointer. Owhership IS transfered. + /// @param saveAsName New assembly name. + /// @return Built BunkerAssembly BunkerAssembly* BuildAssembly(std::string saveAsName); - /// /// Saves the current BunkerAssembly to an appropriate ini file, and asks user if they want to overwrite first if a BunkerAssembly of this name exists. - /// - /// The name of the new BunkerAssembly to be saved. - /// Whether to force any existing BunkerAssembly of that name to be overwritten if it already exists. - /// Whether actually managed to save. Will return false both if a BunkerAssembly of this name already exists, or if other error. + /// @param saveAsName The name of the new BunkerAssembly to be saved. + /// @param forceOverwrite Whether to force any existing BunkerAssembly of that name to be overwritten if it already exists. + /// @return Whether actually managed to save. Will return false both if a BunkerAssembly of this name already exists, or if other error. bool SaveAssembly(const std::string& saveAsName, bool forceOverwrite = false); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virutal method: UpdateNewDialog - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the New dialog box, populates its lists etc. - // Arguments: None. - // Return value: None. - + /// Updates the New dialog box, populates its lists etc. void UpdateNewDialog() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virutal method: UpdateLoadDialog - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the Load dialog box, populates its lists etc. - // Arguments: None. - // Return value: None. - + /// Updates the Load dialog box, populates its lists etc. void UpdateLoadDialog() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virutal method: UpdateSaveDialog - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the Save dialog box, populates its lists etc. - // Arguments: None. - // Return value: None. - + /// Updates the Save dialog box, populates its lists etc. void UpdateSaveDialog() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virutal method: UpdateChangesDialog - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the Save Changes dialog box, populates its lists etc. - // Arguments: None. - // Return value: None. - + /// Updates the Save Changes dialog box, populates its lists etc. void UpdateChangesDialog() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virutal method: UpdateOverwriteDialog - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the Overwrite dialog box, populates its lists etc. - // Arguments: None. - // Return value: None. - + /// Updates the Overwrite dialog box, populates its lists etc. void UpdateOverwriteDialog() override; // Member variables @@ -264,18 +139,10 @@ namespace RTE { GUIComboBox* m_pModuleCombo; - ////////////////////////////////////////////////////////////////////////////////////////// - // Private member variable and method declarations - + /// Private member variable and method declarations private: - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Clear - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears all the member variables of this Activity, effectively - // resetting the members of this abstraction level only. - // Arguments: None. - // Return value: None. - + /// Clears all the member variables of this Activity, effectively + /// resetting the members of this abstraction level only. void Clear(); }; diff --git a/Source/Activities/BaseEditor.cpp b/Source/Activities/BaseEditor.cpp index c533311d3d..a1c4daaab0 100644 --- a/Source/Activities/BaseEditor.cpp +++ b/Source/Activities/BaseEditor.cpp @@ -1,15 +1,3 @@ -////////////////////////////////////////////////////////////////////////////////////////// -// File: BaseEditor.cpp -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Source file for the BaseEditor class. -// Project: Retro Terrain Engine -// Author(s): Daniel Tabar -// data@datarealms.com -// http://www.datarealms.com - -////////////////////////////////////////////////////////////////////////////////////////// -// Inclusions of header files - #include "BaseEditor.h" #include "CameraMan.h" @@ -19,11 +7,11 @@ #include "UInputMan.h" #include "SceneMan.h" #include "MetaMan.h" -//#include "AHuman.h" -//#include "MOPixel.h" +// #include "AHuman.h" +// #include "MOPixel.h" #include "SLTerrain.h" #include "Controller.h" -//#include "AtomGroup.h" +// #include "AtomGroup.h" #include "Actor.h" #include "AHuman.h" #include "ACRocket.h" @@ -37,22 +25,11 @@ namespace RTE { ConcreteClassInfo(BaseEditor, Activity, 0); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Clear - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears all the member variables of this BaseEditor, effectively - // resetting the members of this abstraction level only. - void BaseEditor::Clear() { m_pEditorGUI = 0; m_NeedSave = false; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes the BaseEditor object ready for use. - int BaseEditor::Create() { if (Activity::Create() < 0) return -1; @@ -60,11 +37,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Creates a BaseEditor to be identical to another, by deep copy. - int BaseEditor::Create(const BaseEditor& reference) { if (Activity::Create(reference) < 0) return -1; @@ -75,14 +47,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: ReadProperty - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Reads a property value from a reader stream. If the name isn't - // recognized by this class, then ReadProperty of the parent class - // is called. If the property isn't recognized by any of the base classes, - // false is returned, and the reader's position is untouched. - int BaseEditor::ReadProperty(const std::string_view& propName, Reader& reader) { StartPropertyList(return Activity::ReadProperty(propName, reader)); /* @@ -93,22 +57,11 @@ namespace RTE { EndPropertyList; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Save - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Saves the complete state of this BaseEditor with a Writer for - // later recreation with Create(Reader &reader); - int BaseEditor::Save(Writer& writer) const { Activity::Save(writer); return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destroys and resets (through Clear()) the BaseEditor object. - void BaseEditor::Destroy(bool notInherited) { delete m_pEditorGUI; @@ -117,12 +70,6 @@ namespace RTE { Clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Start - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Officially starts this. Creates all the data etc necessary to start - // the activity. - int BaseEditor::Start() { // Set the split screen config before the Scene (and it SceneLayers, specifially) are loaded g_FrameMan.ResetSplitScreens(false, false); @@ -234,33 +181,17 @@ namespace RTE { return error; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Pause - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Pauses and unpauses the game. - void BaseEditor::SetPaused(bool pause) { // Override the pause m_Paused = false; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: End - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Forces the current game's end. - void BaseEditor::End() { Activity::End(); m_ActivityState = ActivityState::Over; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Update - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the state of this BaseEditor. Supposed to be done every frame - // before drawing. - void BaseEditor::Update() { Activity::Update(); @@ -291,33 +222,16 @@ namespace RTE { } } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: DrawGUI - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws the currently active GUI of a screen to a BITMAP of choice. - void BaseEditor::DrawGUI(BITMAP* pTargetBitmap, const Vector& targetPos, int which) { m_pEditorGUI->Draw(pTargetBitmap, targetPos); Activity::DrawGUI(pTargetBitmap, targetPos, which); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Draw - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws this BaseEditor's current graphical representation to a - // BITMAP of choice. This includes all game-related graphics. - void BaseEditor::Draw(BITMAP* pTargetBitmap, const Vector& targetPos) { Activity::Draw(pTargetBitmap, targetPos); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SaveScene - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Saves the current scene to an appropriate ini file, and asks user if - // they want to overwrite first if scene of this name exists. - bool BaseEditor::SaveScene(std::string saveAsName, bool forceOverwrite) { /* // Set the name of the current scene in effect diff --git a/Source/Activities/BaseEditor.h b/Source/Activities/BaseEditor.h index 555004ab79..90133cfabe 100644 --- a/Source/Activities/BaseEditor.h +++ b/Source/Activities/BaseEditor.h @@ -1,18 +1,11 @@ #ifndef _RTEBASEEDITOR_ #define _RTEBASEEDITOR_ -////////////////////////////////////////////////////////////////////////////////////////// -// File: BaseEditor.h -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Header file for the BaseEditor class. -// Project: Retro Terrain Engine -// Author(s): Daniel Tabar -// data@datarealms.com -// http://www.datarealms.com - -////////////////////////////////////////////////////////////////////////////////////////// -// Inclusions of header files - +/// Header file for the BaseEditor class. +/// @author Daniel Tabar +/// data@datarealms.com +/// http://www.datarealms.com +/// Inclusions of header files #include "RTETools.h" #include "EditorActivity.h" @@ -30,161 +23,85 @@ namespace RTE { class GUILabel; class GUIComboBox; - ////////////////////////////////////////////////////////////////////////////////////////// - // Class: BaseEditor - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Activity for editing designs only for the bases of each scene in a - // Campaign metagame. Doesn't need all the document-model dlg boxes. - // Parent(s): Activity. - // Class history: 04/30/2010 Created BaseEditor for the campaign base blueprint editing. - + /// Activity for editing designs only for the bases of each scene in a + /// Campaign metagame. Doesn't need all the document-model dlg boxes. class BaseEditor : public Activity { - ////////////////////////////////////////////////////////////////////////////////////////// - // Public member variable, method and friend function declarations - + /// Public member variable, method and friend function declarations public: // Concrete allocation and cloning definitions EntityAllocation(BaseEditor); SerializableOverrideMethods; ClassInfoGetters; - ////////////////////////////////////////////////////////////////////////////////////////// - // Constructor: BaseEditor - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Constructor method used to instantiate a BaseEditor object in system - // memory. Create() should be called before using the object. - // Arguments: None. - + /// Constructor method used to instantiate a BaseEditor object in system + /// memory. Create() should be called before using the object. BaseEditor() { Clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Destructor: ~BaseEditor - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destructor method used to clean up a BaseEditor object before deletion - // from system memory. - // Arguments: None. - + /// Destructor method used to clean up a BaseEditor object before deletion + /// from system memory. ~BaseEditor() override { Destroy(true); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes the BaseEditor object ready for use. - // Arguments: None. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Makes the BaseEditor object ready for use. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Create() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Creates a BaseEditor to be identical to another, by deep copy. - // Arguments: A reference to the BaseEditor to deep copy. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Creates a BaseEditor to be identical to another, by deep copy. + /// @param reference A reference to the BaseEditor to deep copy. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Create(const BaseEditor& reference); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Reset - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Resets the entire BaseEditor, including its inherited members, to their - // default settings or values. - // Arguments: None. - // Return value: None. - + /// Resets the entire BaseEditor, including its inherited members, to their + /// default settings or values. void Reset() override { Clear(); Activity::Reset(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destroys and resets (through Clear()) the BaseEditor object. - // Arguments: Whether to only destroy the members defined in this derived class, or - // to destroy all inherited members also. - // Return value: None. - + /// Destroys and resets (through Clear()) the BaseEditor object. + /// @param notInherited Whether to only destroy the members defined in this derived class, or (default: false) + /// to destroy all inherited members also. void Destroy(bool notInherited = false) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Start - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Officially starts the game accroding to parameters previously set. - // Arguments: None. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Officially starts the game accroding to parameters previously set. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Start() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Pause - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Pauses and unpauses the game. - // Arguments: Whether to pause the game or not. - // Return value: None. - + /// Pauses and unpauses the game. + /// @param pause Whether to pause the game or not. (default: true) void SetPaused(bool pause = true) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: End - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Forces the current game's end. - // Arguments: None. - // Return value: None. - + /// Forces the current game's end. void End() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Update - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the state of this ActivityMan. Supposed to be done every frame - // before drawing. - // Arguments: None. - // Return value: None. - + /// Updates the state of this ActivityMan. Supposed to be done every frame + /// before drawing. void Update() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: DrawGUI - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws the currently active GUI of a screen to a BITMAP of choice. - // Arguments: A pointer to a screen-sized BITMAP to draw on. - // The absolute position of the target bitmap's upper left corner in the scene. - // Which screen's GUI to draw onto the bitmap. - // Return value: None. - + /// Draws the currently active GUI of a screen to a BITMAP of choice. + /// @param pTargetBitmap A pointer to a screen-sized BITMAP to draw on. + /// @param targetPos The absolute position of the target bitmap's upper left corner in the scene. (default: Vector()) + /// @param which Which screen's GUI to draw onto the bitmap. (default: 0) void DrawGUI(BITMAP* pTargetBitmap, const Vector& targetPos = Vector(), int which = 0) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Draw - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws this ActivityMan's current graphical representation to a - // BITMAP of choice. This includes all game-related graphics. - // Arguments: A pointer to a BITMAP to draw on. OWNERSHIP IS NOT TRANSFERRED! - // The absolute position of the target bitmap's upper left corner in the scene. - // Return value: None. - + /// Draws this ActivityMan's current graphical representation to a + /// BITMAP of choice. This includes all game-related graphics. + /// @param pTargetBitmap A pointer to a BITMAP to draw on. OWNERSHIP IS NOT TRANSFERRED! + /// @param targetPos The absolute position of the target bitmap's upper left corner in the scene. (default: Vector()) void Draw(BITMAP* pTargetBitmap, const Vector& targetPos = Vector()) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Protected member variable and method declarations - + /// Protected member variable and method declarations protected: - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SaveScene - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Saves the current scene to an appropriate ini file, and asks user if - // they want to overwrite first if scene of this name exists. - // Arguments: The name of the new scene to be saved. - // Whetehr to force any existing Scene of that name to be overwritten if - // it already exists. - // Return value: Whether actually managed to save. Will return false both if a scene - // of this name already exists, or if other error. - + /// Saves the current scene to an appropriate ini file, and asks user if + /// they want to overwrite first if scene of this name exists. + /// @param saveAsName The name of the new scene to be saved. + /// @param forceOverwrite Whetehr to force any existing Scene of that name to be overwritten if (default: false) + /// it already exists. + /// @return Whether actually managed to save. Will return false both if a scene + /// of this name already exists, or if other error. bool SaveScene(std::string saveAsName, bool forceOverwrite = false); // Member variables @@ -196,18 +113,10 @@ namespace RTE { // Dirty Scene? bool m_NeedSave; - ////////////////////////////////////////////////////////////////////////////////////////// - // Private member variable and method declarations - + /// Private member variable and method declarations private: - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Clear - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears all the member variables of this Activity, effectively - // resetting the members of this abstraction level only. - // Arguments: None. - // Return value: None. - + /// Clears all the member variables of this Activity, effectively + /// resetting the members of this abstraction level only. void Clear(); }; diff --git a/Source/Activities/EditorActivity.cpp b/Source/Activities/EditorActivity.cpp index 3bc5874797..94797693f3 100644 --- a/Source/Activities/EditorActivity.cpp +++ b/Source/Activities/EditorActivity.cpp @@ -1,15 +1,3 @@ -////////////////////////////////////////////////////////////////////////////////////////// -// File: EditorActivity.cpp -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Source file for the EditorActivity class. -// Project: Retro Terrain Engine -// Author(s): Daniel Tabar -// data@datarealms.com -// http://www.datarealms.com - -////////////////////////////////////////////////////////////////////////////////////////// -// Inclusions of header files - #include "EditorActivity.h" #include "PresetMan.h" @@ -36,12 +24,6 @@ namespace RTE { AbstractClassInfo(EditorActivity, Activity); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Clear - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears all the member variables of this EditorActivity, effectively - // resetting the members of this abstraction level only. - void EditorActivity::Clear() { // Most editors are single player affairs m_MaxPlayerSupport = 1; @@ -80,11 +62,6 @@ namespace RTE { m_pOverwriteNoButton = 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes the EditorActivity object ready for use. - int EditorActivity::Create() { if (Activity::Create() < 0) return -1; @@ -92,11 +69,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Creates a EditorActivity to be identical to another, by deep copy. - int EditorActivity::Create(const EditorActivity& reference) { if (Activity::Create(reference) < 0) return -1; @@ -113,14 +85,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: ReadProperty - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Reads a property value from a reader stream. If the name isn't - // recognized by this class, then ReadProperty of the parent class - // is called. If the property isn't recognized by any of the base classes, - // false is returned, and the reader's position is untouched. - int EditorActivity::ReadProperty(const std::string_view& propName, Reader& reader) { StartPropertyList(Activity::ReadProperty(propName, reader)); /* @@ -131,22 +95,11 @@ namespace RTE { EndPropertyList; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Save - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Saves the complete state of this EditorActivity with a Writer for - // later recreation with Create(Reader &reader); - int EditorActivity::Save(Writer& writer) const { Activity::Save(writer); return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destroys and resets (through Clear()) the EditorActivity object. - void EditorActivity::Destroy(bool notInherited) { delete m_pGUIController; delete m_pGUIInput; @@ -157,12 +110,6 @@ namespace RTE { Clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Start - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Officially starts this. Creates all the data etc necessary to start - // the activity. - int EditorActivity::Start() { int error = 0; // Don't, too different @@ -211,33 +158,17 @@ namespace RTE { return error; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Pause - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Pauses and unpauses the game. - void EditorActivity::SetPaused(bool pause) { // Override the pause m_Paused = false; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: End - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Forces the current game's end. - void EditorActivity::End() { Activity::End(); m_ActivityState = ActivityState::Over; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Update - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the state of this EditorActivity. Supposed to be done every frame - // before drawing. - void EditorActivity::Update() { // Always show teh messages of the editor m_MessageTimer[0].Reset(); @@ -557,11 +488,6 @@ namespace RTE { */ } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: DrawGUI - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws the currently active GUI of a screen to a BITMAP of choice. - void EditorActivity::DrawGUI(BITMAP* pTargetBitmap, const Vector& targetPos, int which) { AllegroScreen drawScreen(pTargetBitmap); m_pGUIController->Draw(&drawScreen); @@ -569,12 +495,6 @@ namespace RTE { m_pGUIController->DrawMouse(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Draw - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws this EditorActivity's current graphical representation to a - // BITMAP of choice. This includes all game-related graphics. - void EditorActivity::Draw(BITMAP* pTargetBitmap, const Vector& targetPos) { } diff --git a/Source/Activities/EditorActivity.h b/Source/Activities/EditorActivity.h index aaf129e3ad..7a4096a2ef 100644 --- a/Source/Activities/EditorActivity.h +++ b/Source/Activities/EditorActivity.h @@ -1,18 +1,11 @@ #ifndef _RTEEDITORACTIVITY_ #define _RTEEDITORACTIVITY_ -////////////////////////////////////////////////////////////////////////////////////////// -// File: EditorActivity.h -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Header file for the EditorActivity class. -// Project: Retro Terrain Engine -// Author(s): Daniel Tabar -// data@datarealms.com -// http://www.datarealms.com - -////////////////////////////////////////////////////////////////////////////////////////// -// Inclusions of header files - +/// Header file for the EditorActivity class. +/// @author Daniel Tabar +/// data@datarealms.com +/// http://www.datarealms.com +/// Inclusions of header files #include "GUISound.h" #include "RTETools.h" #include "ActivityMan.h" @@ -32,19 +25,11 @@ namespace RTE { class GUILabel; class GUIComboBox; - ////////////////////////////////////////////////////////////////////////////////////////// - // Class: EditorActivity - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Activity for editing things; owns and manages all the dialog boxes - // etc for docuemnt model, ie new, load, save, etc. - // Parent(s): Activity. - // Class history: 9/17/2007 EditorActivity created. - + /// Activity for editing things; owns and manages all the dialog boxes + /// etc for docuemnt model, ie new, load, save, etc. class EditorActivity : public Activity { - ////////////////////////////////////////////////////////////////////////////////////////// - // Public member variable, method and friend function declarations - + /// Public member variable, method and friend function declarations public: SerializableOverrideMethods; ClassInfoGetters; @@ -61,192 +46,88 @@ namespace RTE { EDITORMODECOUNT }; - ////////////////////////////////////////////////////////////////////////////////////////// - // Constructor: EditorActivity - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Constructor method used to instantiate a EditorActivity object in system - // memory. Create() should be called before using the object. - // Arguments: None. - + /// Constructor method used to instantiate a EditorActivity object in system + /// memory. Create() should be called before using the object. EditorActivity() { Clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Destructor: ~EditorActivity - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destructor method used to clean up a EditorActivity object before deletion - // from system memory. - // Arguments: None. - + /// Destructor method used to clean up a EditorActivity object before deletion + /// from system memory. ~EditorActivity() override { Destroy(true); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes the EditorActivity object ready for use. - // Arguments: None. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Makes the EditorActivity object ready for use. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Create() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Creates a EditorActivity to be identical to another, by deep copy. - // Arguments: A reference to the EditorActivity to deep copy. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Creates a EditorActivity to be identical to another, by deep copy. + /// @param reference A reference to the EditorActivity to deep copy. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Create(const EditorActivity& reference); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Reset - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Resets the entire EditorActivity, including its inherited members, to their - // default settings or values. - // Arguments: None. - // Return value: None. - + /// Resets the entire EditorActivity, including its inherited members, to their + /// default settings or values. void Reset() override { Clear(); Activity::Reset(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destroys and resets (through Clear()) the EditorActivity object. - // Arguments: Whether to only destroy the members defined in this derived class, or - // to destroy all inherited members also. - // Return value: None. - + /// Destroys and resets (through Clear()) the EditorActivity object. + /// @param notInherited Whether to only destroy the members defined in this derived class, or (default: false) + /// to destroy all inherited members also. void Destroy(bool notInherited = false) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetEditorMode - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the current mode of this editor. - // Arguments: The new mode to set to, see the EditorGUIMode enum. - // Return value: None. - + /// Sets the current mode of this editor. + /// @param newMode The new mode to set to, see the EditorGUIMode enum. void SetEditorMode(EditorMode newMode) { m_EditorMode = newMode; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetEditorMode - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the current mode of this editor. - // Arguments: None. - // Return value: The current mode this is set to; see the EditorGUIMode enum. - + /// Gets the current mode of this editor. + /// @return The current mode this is set to; see the EditorGUIMode enum. EditorMode GetEditorMode() const { return m_EditorMode; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Start - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Officially starts the game accroding to parameters previously set. - // Arguments: None. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Officially starts the game accroding to parameters previously set. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Start() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Pause - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Pauses and unpauses the game. - // Arguments: Whether to pause the game or not. - // Return value: None. - + /// Pauses and unpauses the game. + /// @param pause Whether to pause the game or not. (default: true) void SetPaused(bool pause = true) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: End - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Forces the current game's end. - // Arguments: None. - // Return value: None. - + /// Forces the current game's end. void End() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Update - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the state of this ActivityMan. Supposed to be done every frame - // before drawing. - // Arguments: None. - // Return value: None. - + /// Updates the state of this ActivityMan. Supposed to be done every frame + /// before drawing. void Update() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: DrawGUI - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws the currently active GUI of a screen to a BITMAP of choice. - // Arguments: A pointer to a screen-sized BITMAP to draw on. - // The absolute position of the target bitmap's upper left corner in the scene. - // Which screen's GUI to draw onto the bitmap. - // Return value: None. - + /// Draws the currently active GUI of a screen to a BITMAP of choice. + /// @param pTargetBitmap A pointer to a screen-sized BITMAP to draw on. + /// @param targetPos The absolute position of the target bitmap's upper left corner in the scene. (default: Vector()) + /// @param which Which screen's GUI to draw onto the bitmap. (default: 0) void DrawGUI(BITMAP* pTargetBitmap, const Vector& targetPos = Vector(), int which = 0) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Draw - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws this ActivityMan's current graphical representation to a - // BITMAP of choice. This includes all game-related graphics. - // Arguments: A pointer to a BITMAP to draw on. OWNERSHIP IS NOT TRANSFERRED! - // The absolute position of the target bitmap's upper left corner in the scene. - // Return value: None. - + /// Draws this ActivityMan's current graphical representation to a + /// BITMAP of choice. This includes all game-related graphics. + /// @param pTargetBitmap A pointer to a BITMAP to draw on. OWNERSHIP IS NOT TRANSFERRED! + /// @param targetPos The absolute position of the target bitmap's upper left corner in the scene. (default: Vector()) void Draw(BITMAP* pTargetBitmap, const Vector& targetPos = Vector()) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Protected member variable and method declarations - + /// Protected member variable and method declarations protected: - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: UpdateNewDialog - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the New dialog box, populates its lists etc. - // Arguments: None. - // Return value: None. - + /// Updates the New dialog box, populates its lists etc. virtual void UpdateNewDialog() {} - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: UpdateLoadDialog - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the Load dialog box, populates its lists etc. - // Arguments: None. - // Return value: None. - + /// Updates the Load dialog box, populates its lists etc. virtual void UpdateLoadDialog() {} - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: UpdateSaveDialog - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the Save dialog box, populates its lists etc. - // Arguments: None. - // Return value: None. - + /// Updates the Save dialog box, populates its lists etc. virtual void UpdateSaveDialog() {} - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: UpdateChangesDialog - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the Save Changes dialog box, populates its lists etc. - // Arguments: None. - // Return value: None. - + /// Updates the Save Changes dialog box, populates its lists etc. virtual void UpdateChangesDialog() {} - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: UpdateOverwriteDialog - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the Overwrite dialog box, populates its lists etc. - // Arguments: None. - // Return value: None. - + /// Updates the Overwrite dialog box, populates its lists etc. virtual void UpdateOverwriteDialog() {} // Member variables @@ -322,18 +203,10 @@ namespace RTE { // The button for No resposnes to overwrite GUIButton* m_pOverwriteNoButton; - ////////////////////////////////////////////////////////////////////////////////////////// - // Private member variable and method declarations - + /// Private member variable and method declarations private: - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Clear - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears all the member variables of this Activity, effectively - // resetting the members of this abstraction level only. - // Arguments: None. - // Return value: None. - + /// Clears all the member variables of this Activity, effectively + /// resetting the members of this abstraction level only. void Clear(); }; diff --git a/Source/Activities/GAScripted.cpp b/Source/Activities/GAScripted.cpp index ece23f7c4a..17b5930521 100644 --- a/Source/Activities/GAScripted.cpp +++ b/Source/Activities/GAScripted.cpp @@ -1,15 +1,3 @@ -////////////////////////////////////////////////////////////////////////////////////////// -// File: GAScripted.cpp -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Source file for the GAScripted class. -// Project: Retro Terrain Engine -// Author(s): Daniel Tabar -// data@datarealms.com -// http://www.datarealms.com - -////////////////////////////////////////////////////////////////////////////////////////// -// Inclusions of header files - #include "GAScripted.h" #include "SceneMan.h" @@ -40,12 +28,6 @@ namespace RTE { ConcreteClassInfo(GAScripted, GameActivity, 0); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Clear - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears all the member variables of this GAScripted, effectively - // resetting the members of this abstraction level only. - void GAScripted::Clear() { m_ScriptPath.clear(); m_LuaClassName.clear(); @@ -53,11 +35,6 @@ namespace RTE { m_PieSlicesToAdd.clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes the GAScripted object ready for use. - int GAScripted::Create() { if (GameActivity::Create() < 0) { return -1; @@ -82,11 +59,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Creates a GAScripted to be identical to another, by deep copy. - int GAScripted::Create(const GAScripted& reference) { if (GameActivity::Create(reference) < 0) { return -1; @@ -104,14 +76,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: ReadProperty - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Reads a property value from a reader stream. If the name isn't - // recognized by this class, then ReadProperty of the parent class - // is called. If the property isn't recognized by any of the base classes, - // false is returned, and the reader's position is untouched. - int GAScripted::ReadProperty(const std::string_view& propName, Reader& reader) { StartPropertyList(return GameActivity::ReadProperty(propName, reader)); @@ -128,12 +92,6 @@ namespace RTE { EndPropertyList; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Save - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Saves the complete state of this GAScripted with a Writer for - // later recreation with Create(Reader &reader); - int GAScripted::Save(Writer& writer) const { // Hmm. We should probably be calling this prior to the writer Save, instead of const-casting. const_cast(this)->RunLuaFunction("OnSave"); @@ -150,11 +108,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destroys and resets (through Clear()) the GAScripted object. - void GAScripted::Destroy(bool notInherited) { // Delete global scripts for (std::vector::iterator sItr = m_GlobalScriptsList.begin(); sItr < m_GlobalScriptsList.end(); ++sItr) { @@ -170,14 +123,6 @@ namespace RTE { Clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: ReloadScripts - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Reloads the preset scripts of this object, from the same script file - // path as was originally defined. This will also update the original - // preset in the PresetMan with the updated scripts so future objects - // spawned will use the new scripts. - int GAScripted::ReloadScripts() { if (m_ScriptPath.empty()) { return 0; @@ -206,8 +151,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GAScripted::RefreshActivityFunctions() { m_ScriptFunctions.clear(); if (m_ScriptPath.empty()) { @@ -223,20 +166,10 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool GAScripted::HasSaveFunction() const { return m_ScriptFunctions.find("OnSave") != m_ScriptFunctions.end(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: SceneIsCompatible - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Tells if a particular Scene supports this specific Activity on it. - // Usually that means certain Area:s need to be defined in the Scene. - bool GAScripted::SceneIsCompatible(Scene* pScene, int teams) { if (!GameActivity::SceneIsCompatible(pScene, teams)) { return false; @@ -279,8 +212,6 @@ namespace RTE { return g_LuaMan.GetMasterScriptState().GlobalIsDefined("TestScene"); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GAScripted::HandleCraftEnteringOrbit(ACraft* orbitedCraft) { GameActivity::HandleCraftEnteringOrbit(orbitedCraft); @@ -292,14 +223,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Start - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Officially starts this. Creates all the data etc necessary to start - // the activity. - int GAScripted::Start() { ActivityState initialActivityState = m_ActivityState; @@ -349,11 +272,6 @@ namespace RTE { return error; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Pause - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Pauses and unpauses the game. - void GAScripted::SetPaused(bool pause) { GameActivity::SetPaused(pause); @@ -365,11 +283,6 @@ namespace RTE { } } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: End - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Forces the current game's end. - void GAScripted::End() { GameActivity::End(); @@ -400,12 +313,6 @@ namespace RTE { } */ - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Update - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the state of this GAScripted. Supposed to be done every frame - // before drawing. - void GAScripted::Update() { GameActivity::Update(); @@ -434,11 +341,6 @@ namespace RTE { } } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: UpdateGlobalScripts - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates globals scripts loaded with this activity. - void GAScripted::UpdateGlobalScripts(bool lateUpdate) { ZoneScoped; @@ -450,21 +352,10 @@ namespace RTE { } } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: DrawGUI - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws the currently active GUI of a screen to a BITMAP of choice. - void GAScripted::DrawGUI(BITMAP* pTargetBitmap, const Vector& targetPos, int which) { GameActivity::DrawGUI(pTargetBitmap, targetPos, which); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Draw - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws this GAScripted's current graphical representation to a - // BITMAP of choice. This includes all game-related graphics. - void GAScripted::Draw(BITMAP* pTargetBitmap, const Vector& targetPos) { GameActivity::Draw(pTargetBitmap, targetPos); } @@ -481,12 +372,6 @@ namespace RTE { return error; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: CollectRequiredAreas - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Goes through the script file and checks for any mentions and uses of - // Area:s that are required for this Activity to run in a Scene. - void GAScripted::CollectRequiredAreas() { // Open the script file so we can check it out std::ifstream scriptFile = std::ifstream(g_PresetMan.GetFullModulePath(m_ScriptPath.c_str())); @@ -543,8 +428,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GAScripted::AddPieSlicesToActiveActorPieMenus() { for (int player = Players::PlayerOne; player < Players::MaxPlayerCount; ++player) { if (m_IsActive[player] && m_IsHuman[player] && m_ControlledActor[player] && m_ViewState[player] != ViewState::DeathWatch && m_ViewState[player] != ViewState::ActorSelect && m_ViewState[player] != ViewState::AIGoToPoint && m_ViewState[player] != ViewState::UnitSelectCircle) { @@ -563,6 +446,4 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - } // namespace RTE diff --git a/Source/Activities/GAScripted.h b/Source/Activities/GAScripted.h index 080dc6e170..4752b75ba4 100644 --- a/Source/Activities/GAScripted.h +++ b/Source/Activities/GAScripted.h @@ -1,18 +1,11 @@ #ifndef _RTEGASCRIPTED_ #define _RTEGASCRIPTED_ -////////////////////////////////////////////////////////////////////////////////////////// -// File: GAScripted.h -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Header file for the ActivityMan class. -// Project: Retro Terrain Engine -// Author(s): Daniel Tabar -// data@datarealms.com -// http://www.datarealms.com - -////////////////////////////////////////////////////////////////////////////////////////// -// Inclusions of header files - +/// Header file for the ActivityMan class. +/// @author Daniel Tabar +/// data@datarealms.com +/// http://www.datarealms.com +/// Inclusions of header files #include "GameActivity.h" #include "GlobalScript.h" #include "Box.h" @@ -23,21 +16,13 @@ namespace RTE { class ACraft; - ////////////////////////////////////////////////////////////////////////////////////////// - // Class: GAScripted - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Scripted activity - // Parent(s): GameActivity. - // Class history: 07/03/2008 GAScripted created. - + /// Scripted activity class GAScripted : public GameActivity { friend class LuaMan; friend class ActivityMan; - ////////////////////////////////////////////////////////////////////////////////////////// - // Public member variable, method and friend function declarations - + /// Public member variable, method and friend function declarations public: ScriptFunctionNames("StartActivity", "UpdateActivity", "PauseActivity", "EndActivity", "OnSave", "CraftEnteredOrbit", "OnMessage", "OnGlobalMessage"); @@ -46,219 +31,116 @@ namespace RTE { SerializableOverrideMethods; ClassInfoGetters; - ////////////////////////////////////////////////////////////////////////////////////////// - // Constructor: GAScripted - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Constructor method used to instantiate a GAScripted object in system - // memory. Create() should be called before using the object. - // Arguments: None. - + /// Constructor method used to instantiate a GAScripted object in system + /// memory. Create() should be called before using the object. GAScripted() { Clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Destructor: ~GAScripted - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destructor method used to clean up a GAScripted object before deletion - // from system memory. - // Arguments: None. - + /// Destructor method used to clean up a GAScripted object before deletion + /// from system memory. ~GAScripted() override { Destroy(true); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes the GAScripted object ready for use. - // Arguments: None. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Makes the GAScripted object ready for use. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Create() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes the GAScripted object ready for use. - // Arguments: The filepath to the script that defines this' Lua-defined derivation - // of this class. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Makes the GAScripted object ready for use. + /// @param scriptPath The filepath to the script that defines this' Lua-defined derivation + /// of this class. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Create(std::string scriptPath, std::string scriptClassName) { m_ScriptPath = scriptPath; m_LuaClassName = scriptClassName; return Create(); }; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Creates a GAScripted to be identical to another, by deep copy. - // Arguments: A reference to the GAScripted to deep copy. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Creates a GAScripted to be identical to another, by deep copy. + /// @param reference A reference to the GAScripted to deep copy. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Create(const GAScripted& reference); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Reset - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Resets the entire GAScripted, including its inherited members, to their - // default settings or values. - // Arguments: None. - // Return value: None. - + /// Resets the entire GAScripted, including its inherited members, to their + /// default settings or values. void Reset() override { Clear(); Activity::Reset(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destroys and resets (through Clear()) the GAScripted object. - // Arguments: Whether to only destroy the members defined in this derived class, or - // to destroy all inherited members also. - // Return value: None. - + /// Destroys and resets (through Clear()) the GAScripted object. + /// @param notInherited Whether to only destroy the members defined in this derived class, or (default: false) + /// to destroy all inherited members also. void Destroy(bool notInherited = false) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: ReloadScripts - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Reloads the preset scripts of this object, from the same script file - // path as was originally defined. This will also update the original - // preset in the PresetMan with the updated scripts so future objects - // spawned will use the new scripts. - // Arguments: None. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Reloads the preset scripts of this object, from the same script file + /// path as was originally defined. This will also update the original + /// preset in the PresetMan with the updated scripts so future objects + /// spawned will use the new scripts. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int ReloadScripts() override; - /// /// Refreshes our activity functions to find any changes from script. - /// void RefreshActivityFunctions(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: GetLuaClassName - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the class name of the Lua-derived class defined in this' script. - // Arguments: None. - // Return value: A string with the friendly-formatted Lua type name of this object. - + /// Gets the class name of the Lua-derived class defined in this' script. + /// @return A string with the friendly-formatted Lua type name of this object. const std::string& GetLuaClassName() const { return m_LuaClassName; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: SceneIsCompatible - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Tells if a particular Scene supports this specific Activity on it. - // Usually that means certain Area:s need to be defined in the Scene. - // Arguments: The Scene to check if it supports this Activiy. Ownership IS NOT TRANSFERRED! - // How many teams we're checking for. Some scenes may support and activity - // but only for a limited number of teams. If -1, not applicable. - // Return value: Whether the Scene has the right stuff. - + /// Tells if a particular Scene supports this specific Activity on it. + /// Usually that means certain Area:s need to be defined in the Scene. + /// @param pScene The Scene to check if it supports this Activiy. Ownership IS NOT TRANSFERRED! + /// @param teams How many teams we're checking for. Some scenes may support and activity (default: -1) + /// but only for a limited number of teams. If -1, not applicable. + /// @return Whether the Scene has the right stuff. bool SceneIsCompatible(Scene* pScene, int teams = -1) override; - /// /// Handles when an ACraft has left the game scene and entered orbit, though does not delete it. Ownership is NOT transferred, as the ACraft's inventory is just 'unloaded'. - /// - /// The ACraft instance that entered orbit. Ownership is NOT transferred! + /// @param orbitedCraft The ACraft instance that entered orbit. Ownership is NOT transferred! void HandleCraftEnteringOrbit(ACraft* orbitedCraft) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Start - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Officially starts the game accroding to parameters previously set. - // Arguments: None. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Officially starts the game accroding to parameters previously set. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Start() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Pause - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Pauses and unpauses the game. - // Arguments: Whether to pause the game or not. - // Return value: None. - + /// Pauses and unpauses the game. + /// @param pause Whether to pause the game or not. (default: true) void SetPaused(bool pause = true) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: End - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Forces the current game's end. - // Arguments: None. - // Return value: None. - + /// Forces the current game's end. void End() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Update - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the state of this ActivityMan. Supposed to be done every frame - // before drawing. - // Arguments: None. - // Return value: None. - + /// Updates the state of this ActivityMan. Supposed to be done every frame + /// before drawing. void Update() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: UpdateGlobalScripts - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates globals scripts loaded with this activity. - // Arguments: Whether it's an early update, during Activity update, or late update, after MovableMan - // Return value: None. - + /// Updates globals scripts loaded with this activity. + /// @param lateUpdate Whether it's an early update, during Activity update, or late update, after MovableMan void UpdateGlobalScripts(bool lateUpdate); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: DrawGUI - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws the currently active GUI of a screen to a BITMAP of choice. - // Arguments: A pointer to a screen-sized BITMAP to draw on. - // The absolute position of the target bitmap's upper left corner in the scene. - // Which screen's GUI to draw onto the bitmap. - // Return value: None. - + /// Draws the currently active GUI of a screen to a BITMAP of choice. + /// @param pTargetBitmap A pointer to a screen-sized BITMAP to draw on. + /// @param targetPos The absolute position of the target bitmap's upper left corner in the scene. (default: Vector()) + /// @param which Which screen's GUI to draw onto the bitmap. (default: 0) void DrawGUI(BITMAP* pTargetBitmap, const Vector& targetPos = Vector(), int which = 0) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Draw - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws this ActivityMan's current graphical representation to a - // BITMAP of choice. This includes all game-related graphics. - // Arguments: A pointer to a BITMAP to draw on. - // The absolute position of the target bitmap's upper left corner in the scene. - // Return value: None. - + /// Draws this ActivityMan's current graphical representation to a + /// BITMAP of choice. This includes all game-related graphics. + /// @param pTargetBitmap A pointer to a BITMAP to draw on. + /// @param targetPos The absolute position of the target bitmap's upper left corner in the scene. (default: Vector()) void Draw(BITMAP* pTargetBitmap, const Vector& targetPos = Vector()) override; int RunLuaFunction(const std::string& functionName, const std::vector& functionEntityArguments = std::vector(), const std::vector& functionLiteralArguments = std::vector(), const std::vector& functionObjectArguments = std::vector()); - ////////////////////////////////////////////////////////////////////////////////////////// - // Protected member variable and method declarations - + /// Protected member variable and method declarations protected: - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: CollectRequiredAreas - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Goes through the script file and checks for any mentions and uses of - // Area:s that are required for this Activity to run in a Scene. - // Arguments: None. - // Return value: None. - + /// Goes through the script file and checks for any mentions and uses of + /// Area:s that are required for this Activity to run in a Scene. void CollectRequiredAreas(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: InitAIs - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Does nothing - we do this in script! Just overrides the base behaviour. - // Arguments: None. - // Return value: None. - + /// Does nothing - we do this in script! Just overrides the base behaviour. void InitAIs() override{}; // Member variables @@ -276,29 +158,17 @@ namespace RTE { std::unordered_map> m_ScriptFunctions; //!< A map of LuabindObjectWrappers that hold Lua functions. Used to maintain script execution order and avoid extraneous Lua calls. - ////////////////////////////////////////////////////////////////////////////////////////// - // Private member variable and method declarations - + /// Private member variable and method declarations private: - /// /// Returns whether this GAScripted has an OnSave function, to act as a default for whether saving is allowed or not. - /// - /// Whether this GAScripted has an OnSave function + /// @return Whether this GAScripted has an OnSave function bool HasSaveFunction() const; - /// /// Adds this GAScripted's PieSlices, and any active GlobalScripts' PieSlices, to any active PieMenus. - /// void AddPieSlicesToActiveActorPieMenus(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Clear - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears all the member variables of this Activity, effectively - // resetting the members of this abstraction level only. - // Arguments: None. - // Return value: None. - + /// Clears all the member variables of this Activity, effectively + /// resetting the members of this abstraction level only. void Clear(); }; diff --git a/Source/Activities/GATutorial.cpp b/Source/Activities/GATutorial.cpp index cdc004f1a8..aea32df802 100644 --- a/Source/Activities/GATutorial.cpp +++ b/Source/Activities/GATutorial.cpp @@ -1,15 +1,3 @@ -////////////////////////////////////////////////////////////////////////////////////////// -// File: GATutorial.cpp -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Source file for the GATutorial class. -// Project: Retro Terrain Engine -// Author(s): Daniel Tabar -// data@datarealms.com -// http://www.datarealms.com - -////////////////////////////////////////////////////////////////////////////////////////// -// Inclusions of header files - #include "GATutorial.h" #include "SceneMan.h" @@ -48,12 +36,6 @@ namespace RTE { } } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Clear - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears all the member variables of this GATutorial, effectively - // resetting the members of this abstraction level only. - void GATutorial::Clear() { m_TutorialPlayer = Players::PlayerOne; @@ -86,11 +68,6 @@ namespace RTE { m_pCPUBrain = 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes the GATutorial object ready for use. - int GATutorial::Create() { if (GameActivity::Create() < 0) return -1; @@ -100,11 +77,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Creates a GATutorial to be identical to another, by deep copy. - int GATutorial::Create(const GATutorial& reference) { if (GameActivity::Create(reference) < 0) return -1; @@ -138,14 +110,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: ReadProperty - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Reads a property value from a reader stream. If the name isn't - // recognized by this class, then ReadProperty of the parent class - // is called. If the property isn't recognized by any of the base classes, - // false is returned, and the reader's position is untouched. - int GATutorial::ReadProperty(const std::string_view& propName, Reader& reader) { StartPropertyList(return GameActivity::ReadProperty(propName, reader)); /* @@ -158,34 +122,17 @@ namespace RTE { EndPropertyList; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Save - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Saves the complete state of this GATutorial with a Writer for - // later recreation with Create(Reader &reader); - int GATutorial::Save(Writer& writer) const { GameActivity::Save(writer); return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destroys and resets (through Clear()) the GATutorial object. - void GATutorial::Destroy(bool notInherited) { if (!notInherited) GameActivity::Destroy(); Clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: SceneIsCompatible - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Tells if a particular Scene supports this specific Activity on it. - // Usually that means certain Area:s need to be defined in the Scene. - bool GATutorial::SceneIsCompatible(Scene* pScene, int teams) { if (!GameActivity::SceneIsCompatible(pScene, teams)) return false; @@ -197,12 +144,6 @@ namespace RTE { return false; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Start - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Officially starts this. Creates all the data etc necessary to start - // the activity. - int GATutorial::Start() { int error = GameActivity::Start(); @@ -355,11 +296,6 @@ namespace RTE { return error; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Pause - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Pauses and unpauses the game. - void GATutorial::SetPaused(bool pause) { GameActivity::SetPaused(pause); @@ -368,11 +304,6 @@ namespace RTE { SetupAreas(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: End - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Forces the current game's end. - void GATutorial::End() { GameActivity::End(); @@ -421,12 +352,6 @@ namespace RTE { } */ - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Update - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the state of this GATutorial. Supposed to be done every frame - // before drawing. - void GATutorial::Update() { // Avoid game logic when we're editing if (m_ActivityState == ActivityState::Editing) { @@ -741,11 +666,6 @@ namespace RTE { } } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: DrawGUI - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws the currently active GUI of a screen to a BITMAP of choice. - void GATutorial::DrawGUI(BITMAP* pTargetBitmap, const Vector& targetPos, int which) { GameActivity::DrawGUI(pTargetBitmap, targetPos, which); @@ -771,23 +691,10 @@ namespace RTE { } } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Draw - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws this GATutorial's current graphical representation to a - // BITMAP of choice. This includes all game-related graphics. - void GATutorial::Draw(BITMAP* pTargetBitmap, const Vector& targetPos) { GameActivity::Draw(pTargetBitmap, targetPos); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: InitAIs - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Goes through all Actor:s currently in the MovableMan and gives each - // one not controlled by a Controller a CAI and appropriate AIMode setting - // based on team and CPU team. - void GATutorial::InitAIs() { Actor* pActor = 0; Actor* pFirstActor = 0; @@ -822,12 +729,6 @@ namespace RTE { } } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: SetupAreas - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets up or resets the Tutorial Areas to show the current control - // mappings etc. - void GATutorial::SetupAreas() { int device = g_UInputMan.GetControlScheme(m_TutorialPlayer)->GetDevice(); int preset = g_UInputMan.GetControlScheme(m_TutorialPlayer)->GetPreset(); diff --git a/Source/Activities/GATutorial.h b/Source/Activities/GATutorial.h index f5379470a4..3267333c4b 100644 --- a/Source/Activities/GATutorial.h +++ b/Source/Activities/GATutorial.h @@ -1,18 +1,11 @@ #ifndef _RTEGATUTORIAL_ #define _RTEGATUTORIAL_ -////////////////////////////////////////////////////////////////////////////////////////// -// File: GATutorial.h -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Header file for the ActivityMan class. -// Project: Retro Terrain Engine -// Author(s): Daniel Tabar -// data@datarealms.com -// http://www.datarealms.com - -////////////////////////////////////////////////////////////////////////////////////////// -// Inclusions of header files - +/// Header file for the ActivityMan class. +/// @author Daniel Tabar +/// data@datarealms.com +/// http://www.datarealms.com +/// Inclusions of header files #include "GameActivity.h" #include "Box.h" @@ -20,180 +13,92 @@ namespace RTE { class Actor; - ////////////////////////////////////////////////////////////////////////////////////////// - // Class: GATutorial - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Tutorial mission with lots of special triggering logic. - // Parent(s): GameActivity. - // Class history: 10/13/2007 GATutorial created. - + /// Tutorial mission with lots of special triggering logic. class GATutorial : public GameActivity { - ////////////////////////////////////////////////////////////////////////////////////////// - // Public member variable, method and friend function declarations - + /// Public member variable, method and friend function declarations public: // Concrete allocation and cloning definitions EntityAllocation(GATutorial); SerializableOverrideMethods; ClassInfoGetters; - ////////////////////////////////////////////////////////////////////////////////////////// - // Constructor: GATutorial - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Constructor method used to instantiate a GATutorial object in system - // memory. Create() should be called before using the object. - // Arguments: None. - + /// Constructor method used to instantiate a GATutorial object in system + /// memory. Create() should be called before using the object. GATutorial() { Clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Destructor: ~GATutorial - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destructor method used to clean up a GATutorial object before deletion - // from system memory. - // Arguments: None. - + /// Destructor method used to clean up a GATutorial object before deletion + /// from system memory. ~GATutorial() override { Destroy(true); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes the GATutorial object ready for use. - // Arguments: None. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Makes the GATutorial object ready for use. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Create() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Creates a GATutorial to be identical to another, by deep copy. - // Arguments: A reference to the GATutorial to deep copy. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Creates a GATutorial to be identical to another, by deep copy. + /// @param reference A reference to the GATutorial to deep copy. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Create(const GATutorial& reference); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Reset - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Resets the entire GATutorial, including its inherited members, to their - // default settings or values. - // Arguments: None. - // Return value: None. - + /// Resets the entire GATutorial, including its inherited members, to their + /// default settings or values. void Reset() override { Clear(); Activity::Reset(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destroys and resets (through Clear()) the GATutorial object. - // Arguments: Whether to only destroy the members defined in this derived class, or - // to destroy all inherited members also. - // Return value: None. - + /// Destroys and resets (through Clear()) the GATutorial object. + /// @param notInherited Whether to only destroy the members defined in this derived class, or (default: false) + /// to destroy all inherited members also. void Destroy(bool notInherited = false) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: SceneIsCompatible - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Tells if a particular Scene supports this specific Activity on it. - // Usually that means certain Area:s need to be defined in the Scene. - // Arguments: The Scene to check if it supports this Activiy. Ownership IS NOT TRANSFERRED! - // How many teams we're checking for. Some scenes may support and activity - // but only for a limited number of teams. If -1, not applicable. - // Return value: Whether the Scene has the right stuff. - + /// Tells if a particular Scene supports this specific Activity on it. + /// Usually that means certain Area:s need to be defined in the Scene. + /// @param pScene The Scene to check if it supports this Activiy. Ownership IS NOT TRANSFERRED! + /// @param teams How many teams we're checking for. Some scenes may support and activity (default: -1) + /// but only for a limited number of teams. If -1, not applicable. + /// @return Whether the Scene has the right stuff. bool SceneIsCompatible(Scene* pScene, int teams = -1) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Start - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Officially starts the game accroding to parameters previously set. - // Arguments: None. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Officially starts the game accroding to parameters previously set. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Start() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Pause - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Pauses and unpauses the game. - // Arguments: Whether to pause the game or not. - // Return value: None. - + /// Pauses and unpauses the game. + /// @param pause Whether to pause the game or not. (default: true) void SetPaused(bool pause = true) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: End - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Forces the current game's end. - // Arguments: None. - // Return value: None. - + /// Forces the current game's end. void End() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Update - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the state of this ActivityMan. Supposed to be done every frame - // before drawing. - // Arguments: None. - // Return value: None. - + /// Updates the state of this ActivityMan. Supposed to be done every frame + /// before drawing. void Update() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: DrawGUI - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws the currently active GUI of a screen to a BITMAP of choice. - // Arguments: A pointer to a screen-sized BITMAP to draw on. - // The absolute position of the target bitmap's upper left corner in the scene. - // Which screen's GUI to draw onto the bitmap. - // Return value: None. - + /// Draws the currently active GUI of a screen to a BITMAP of choice. + /// @param pTargetBitmap A pointer to a screen-sized BITMAP to draw on. + /// @param targetPos The absolute position of the target bitmap's upper left corner in the scene. (default: Vector()) + /// @param which Which screen's GUI to draw onto the bitmap. (default: 0) void DrawGUI(BITMAP* pTargetBitmap, const Vector& targetPos = Vector(), int which = 0) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Draw - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws this ActivityMan's current graphical representation to a - // BITMAP of choice. This includes all game-related graphics. - // Arguments: A pointer to a BITMAP to draw on. - // The absolute position of the target bitmap's upper left corner in the scene. - // Return value: None. - + /// Draws this ActivityMan's current graphical representation to a + /// BITMAP of choice. This includes all game-related graphics. + /// @param pTargetBitmap A pointer to a BITMAP to draw on. + /// @param targetPos The absolute position of the target bitmap's upper left corner in the scene. (default: Vector()) void Draw(BITMAP* pTargetBitmap, const Vector& targetPos = Vector()) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Protected member variable and method declarations - + /// Protected member variable and method declarations protected: - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: InitAIs - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Goes through all Actor:s currently in the MovableMan and sets each - // one not controlled by a player to be AI controlled and AIMode setting - // based on team and CPU team. - // Arguments: None. - // Return value: None. - + /// Goes through all Actor:s currently in the MovableMan and sets each + /// one not controlled by a player to be AI controlled and AIMode setting + /// based on team and CPU team. void InitAIs() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetupAreas - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets up or resets the Tutorial Areas to show the current control - // mappings etc. - // Arguments: None. - // Return value: None. - + /// Sets up or resets the Tutorial Areas to show the current control + /// mappings etc. void SetupAreas(); enum TutorialArea { @@ -294,18 +199,10 @@ namespace RTE { // The CPU opponent brain; not owned! Actor* m_pCPUBrain; - ////////////////////////////////////////////////////////////////////////////////////////// - // Private member variable and method declarations - + /// Private member variable and method declarations private: - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Clear - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears all the member variables of this Activity, effectively - // resetting the members of this abstraction level only. - // Arguments: None. - // Return value: None. - + /// Clears all the member variables of this Activity, effectively + /// resetting the members of this abstraction level only. void Clear(); }; diff --git a/Source/Activities/GameActivity.cpp b/Source/Activities/GameActivity.cpp index 8b60ff6dee..751a6b7f2f 100644 --- a/Source/Activities/GameActivity.cpp +++ b/Source/Activities/GameActivity.cpp @@ -1,15 +1,3 @@ -////////////////////////////////////////////////////////////////////////////////////////// -// File: GameActivity.cpp -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Source file for the GameActivity class. -// Project: Retro Terrain Engine -// Author(s): Daniel Tabar -// data@datarealms.com -// http://www.datarealms.com - -////////////////////////////////////////////////////////////////////////////////////////// -// Inclusions of header files - #include "GameActivity.h" #include "CameraMan.h" @@ -49,12 +37,6 @@ namespace RTE { AbstractClassInfo(GameActivity, Activity); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Clear - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears all the member variables of this GameActivity, effectively - // resetting the members of this abstraction level only. - void GameActivity::Clear() { m_CPUTeam = -1; @@ -119,11 +101,6 @@ namespace RTE { m_WinnerTeam = -1; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes the GameActivity object ready for use. - int GameActivity::Create() { if (Activity::Create() < 0) return -1; @@ -143,11 +120,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Creates a GameActivity to be identical to another, by deep copy. - int GameActivity::Create(const GameActivity& reference) { if (Activity::Create(reference) < 0) return -1; @@ -209,14 +181,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: ReadProperty - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Reads a property value from a reader stream. If the name isn't - // recognized by this class, then ReadProperty of the parent class - // is called. If the property isn't recognized by any of the base classes, - // false is returned, and the reader's position is untouched. - int GameActivity::ReadProperty(const std::string_view& propName, Reader& reader) { StartPropertyList(return Activity::ReadProperty(propName, reader)); @@ -256,12 +220,6 @@ namespace RTE { EndPropertyList; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Save - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Saves the complete state of this GameActivity with a Writer for - // later recreation with Create(Reader &reader); - int GameActivity::Save(Writer& writer) const { Activity::Save(writer); @@ -280,11 +238,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destroys and resets (through Clear()) the GameActivity object. - void GameActivity::Destroy(bool notInherited) { for (int player = Players::PlayerOne; player < Players::MaxPlayerCount; ++player) { delete m_InventoryMenuGUI[player]; @@ -306,10 +259,6 @@ namespace RTE { Clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetTeamTech - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets tech module name for specified team. Module must set must be loaded. void GameActivity::SetTeamTech(int team, std::string tech) { if (team >= Teams::TeamOne && team < Teams::MaxTeamCount) { if (tech == "-All-" || tech == "-Random-") @@ -324,10 +273,6 @@ namespace RTE { } } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetCrabToHumanSpawnRatio - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns CrabToHumanSpawnRatio for specified module float GameActivity::GetCrabToHumanSpawnRatio(int moduleid) { if (moduleid > -1) { const DataModule* pDataModule = g_PresetMan.GetDataModule(moduleid); @@ -337,11 +282,6 @@ namespace RTE { return 0.25; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetCPUTeam - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the current CPU-assisted team, if any (NoTeam) - LEGACY function - void GameActivity::SetCPUTeam(int team) { if (team >= Teams::TeamOne && team < Teams::MaxTeamCount) { // Set the legacy var @@ -358,8 +298,6 @@ namespace RTE { */ } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool GameActivity::IsBuyGUIVisible(int which) const { if (which == -1) { for (short player = Players::PlayerOne; player < this->GetPlayerCount(); player++) { @@ -372,8 +310,6 @@ namespace RTE { return this->GetBuyGUI(which)->IsVisible(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool GameActivity::LockControlledActor(Players player, bool lock, Controller::InputMode lockToMode) { if (player >= Players::PlayerOne && player < Players::MaxPlayerCount) { bool prevLock = m_LuaLockActor[player]; @@ -384,12 +320,6 @@ namespace RTE { return false; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: SwitchToActor - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Forces the this to focus player control to a specific Actor for a - // specific team. OWNERSHIP IS NOT TRANSFERRED! - bool GameActivity::SwitchToActor(Actor* pActor, int player, int team) { // Computer players don't focus on any Actor if (!m_IsHuman[player]) @@ -407,12 +337,6 @@ namespace RTE { return Activity::SwitchToActor(pActor, player, team); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: SwitchToNextActor - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Forces the this to focus player control to the next Actor of a - // specific team, other than the current one focused on. - void GameActivity::SwitchToNextActor(int player, int team, Actor* pSkip) { m_InventoryMenuGUI[player]->SetEnabled(false); @@ -427,12 +351,6 @@ namespace RTE { } } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: SwitchToPrevActor - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Forces this to focus player control to the previous Actor of a - // specific team, other than the current one focused on. - void GameActivity::SwitchToPrevActor(int player, int team, Actor* pSkip) { m_InventoryMenuGUI[player]->SetEnabled(false); @@ -447,30 +365,14 @@ namespace RTE { } } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: AddObjectivePoint - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Created an objective point for one of the teams to show until cleared. - void GameActivity::AddObjectivePoint(std::string description, Vector objPos, int whichTeam, ObjectiveArrowDir arrowDir) { m_Objectives.push_back(ObjectivePoint(description, objPos, whichTeam, arrowDir)); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: YSortObjectivePoints - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sorts all objective points according to their positions on the Y axis. - void GameActivity::YSortObjectivePoints() { m_Objectives.sort(ObjPointYPosComparison()); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: AddOverridePurchase - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Adds somehting to the purchase list that will override what is set - // in the buy GUI next time CreateDelivery is called. - int GameActivity::AddOverridePurchase(const SceneObject* pPurchase, int player) { if (player >= Players::PlayerOne && player < Players::MaxPlayerCount) { // Add to purchase list if valid item @@ -503,12 +405,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetOverridePurchaseList - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: First clears and then adds all the stuff in a Loadout to the override - // purchase list. - int GameActivity::SetOverridePurchaseList(const Loadout* pLoadout, int player) { // First clear out the list ClearOverridePurchase(player); @@ -549,12 +445,6 @@ namespace RTE { return finalListCost; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetOverridePurchaseList - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: First clears and then adds all the stuff in a Loadout to the override - // purchase list. - int GameActivity::SetOverridePurchaseList(std::string loadoutName, int player) { // Find out the native module of this player int nativeModule = 0; @@ -572,12 +462,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: CreateDelivery - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Takes the current order out of a player's buy GUI, creates a Delivery - // based off it, and stuffs it into that player's delivery queue. - bool GameActivity::CreateDelivery(int player, int mode, Vector& waypoint, Actor* pTargetMO) { int team = m_Team[player]; if (team == Teams::NoTeam) @@ -767,12 +651,6 @@ namespace RTE { return false; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: SetupPlayers - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Precalculates the player-to-screen index map, counts the number of - // active players, teams etc. - void GameActivity::SetupPlayers() { Activity::SetupPlayers(); @@ -792,12 +670,6 @@ namespace RTE { } } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Start - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Officially starts this. Creates all the data etc necessary to start - // the activity. - int GameActivity::Start() { // Set the split screen config before the Scene (and it SceneLayers, specifially) are loaded int humanCount = GetHumanCount(); @@ -1001,20 +873,10 @@ namespace RTE { return error; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Pause - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Pauses and unpauses the game. - void GameActivity::SetPaused(bool pause) { Activity::SetPaused(pause); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: End - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Forces the current game's end. - void GameActivity::End() { Activity::End(); @@ -1073,12 +935,6 @@ namespace RTE { m_GameOverTimer.Reset(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: UpdateEditing - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: This is a special update step for when any player is still editing the - // scene. - void GameActivity::UpdateEditing() { // Editing the scene, just update the editor guis and see if players are ready to start or not if (m_ActivityState != ActivityState::Editing) @@ -1209,12 +1065,6 @@ namespace RTE { } } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Update - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the state of this GameActivity. Supposed to be done every frame - // before drawing. - void GameActivity::Update() { Activity::Update(); @@ -2010,11 +1860,6 @@ namespace RTE { */ } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: DrawGUI - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws the currently active GUI of a screen to a BITMAP of choice. - void GameActivity::DrawGUI(BITMAP* pTargetBitmap, const Vector& targetPos, int which) { if (which < 0 || which >= c_MaxScreenCount) return; @@ -2377,12 +2222,6 @@ namespace RTE { m_pBannerYellow[PoS]->Draw(pTargetBitmap); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Draw - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws this GameActivity's current graphical representation to a - // BITMAP of choice. This includes all game-related graphics. - void GameActivity::Draw(BITMAP* pTargetBitmap, const Vector& targetPos) { GUIFont* pLargeFont = g_FrameMan.GetLargeFont(); GUIFont* pSmallFont = g_FrameMan.GetSmallFont(); @@ -2457,13 +2296,6 @@ namespace RTE { } } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetActiveCPUTeamCount - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns active CPU team count. - // Arguments: None. - // Return value: Returns active CPU team count. - int GameActivity::GetActiveCPUTeamCount() const { int count = 0; @@ -2474,13 +2306,6 @@ namespace RTE { return count; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetActiveHumanTeamCount - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns active human team count. - // Arguments: None. - // Return value: Returns active human team count. - int GameActivity::GetActiveHumanTeamCount() const { int count = 0; @@ -2491,13 +2316,6 @@ namespace RTE { return count; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: OtherTeam - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the next other team number from the one passed in, if any. If there - // are more than two teams in this game, then the next one in the series - // will be returned here. - int GameActivity::OtherTeam(int team) { // Only one team in this game, so can't return another one if (m_TeamCount == 1) @@ -2520,12 +2338,6 @@ namespace RTE { return Teams::NoTeam; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: OneOrNoneTeamsLeft - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Indicates whether there is one and only one team left this game with - // a brain in its ranks. - bool GameActivity::OneOrNoneTeamsLeft() { // See if only one team remains with any brains int brainTeamCount = 0; @@ -2547,12 +2359,6 @@ namespace RTE { return false; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: WhichTeamLeft - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Indicates which single team is left, if any. - // Arguments: None. - int GameActivity::WhichTeamLeft() { int whichTeam = Teams::NoTeam; @@ -2575,11 +2381,6 @@ namespace RTE { return Teams::NoTeam; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: NoTeamLeft - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Indicates whether there are NO teams left with any brains at all! - bool GameActivity::NoTeamLeft() { for (int t = Teams::TeamOne; t < Teams::MaxTeamCount; ++t) { if (!m_TeamActive[t]) @@ -2590,13 +2391,6 @@ namespace RTE { return true; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: InitAIs - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Goes through all Actor:s currently in the MovableMan and gives each - // one not controlled by a Controller a CAI and appropriate AIMode setting - // based on team and CPU team. - void GameActivity::InitAIs() { Actor* pActor = 0; Actor* pFirstActor = 0; @@ -2629,13 +2423,6 @@ namespace RTE { } } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: DisableAIs - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Goes through all Actor:s currently in the MovableMan and gives each - // one not controlled by a Controller a CAI and appropriate AIMode setting - // based on team and CPU team. - void GameActivity::DisableAIs(bool disable, int whichTeam) { Actor* pActor = 0; Actor* pFirstActor = 0; @@ -2657,11 +2444,6 @@ namespace RTE { } } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Draw - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Simply draws this' arrow relative to a point on a bitmap. - void GameActivity::ObjectivePoint::Draw(BITMAP* pTargetBitmap, BITMAP* pArrowBitmap, const Vector& arrowPoint, ObjectiveArrowDir arrowDir) { if (!pTargetBitmap || !pArrowBitmap) return; diff --git a/Source/Activities/GameActivity.h b/Source/Activities/GameActivity.h index 0165b71764..5a6031bf9d 100644 --- a/Source/Activities/GameActivity.h +++ b/Source/Activities/GameActivity.h @@ -1,18 +1,11 @@ #ifndef _RTEGAMEACTIVITY_ #define _RTEGAMEACTIVITY_ -////////////////////////////////////////////////////////////////////////////////////////// -// File: GameActivity.h -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Header file for the ActivityMan class. -// Project: Retro Terrain Engine -// Author(s): Daniel Tabar -// data@datarealms.com -// http://www.datarealms.com - -////////////////////////////////////////////////////////////////////////////////////////// -// Inclusions of header files - +/// Header file for the ActivityMan class. +/// @author Daniel Tabar +/// data@datarealms.com +/// http://www.datarealms.com +/// Inclusions of header files #include "GUISound.h" #include "RTETools.h" #include "ActivityMan.h" @@ -33,13 +26,7 @@ namespace RTE { class GUIBanner; class Loadout; - ////////////////////////////////////////////////////////////////////////////////////////// - // Class: GameActivity - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Base class for all GameActivity:s, including game modes and editors. - // Parent(s): Activity. - // Class history: 8/7/2007 GameActivity created. - + /// Base class for all GameActivity:s, including game modes and editors. class GameActivity : public Activity { friend struct ActivityLuaBindings; @@ -60,9 +47,7 @@ namespace RTE { Timer timer; }; - ////////////////////////////////////////////////////////////////////////////////////////// - // Public member variable, method and friend function declarations - + /// Public member variable, method and friend function declarations public: SerializableOverrideMethods; ClassInfoGetters; @@ -79,133 +64,74 @@ namespace RTE { YELLOW }; - ////////////////////////////////////////////////////////////////////////////////////////// - // Constructor: GameActivity - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Constructor method used to instantiate a GameActivity object in system - // memory. Create() should be called before using the object. - // Arguments: None. - + /// Constructor method used to instantiate a GameActivity object in system + /// memory. Create() should be called before using the object. GameActivity() { Clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Destructor: ~GameActivity - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destructor method used to clean up a GameActivity object before deletion - // from system memory. - // Arguments: None. - + /// Destructor method used to clean up a GameActivity object before deletion + /// from system memory. ~GameActivity() override { Destroy(true); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes the GameActivity object ready for use. - // Arguments: None. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Makes the GameActivity object ready for use. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Create() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Creates a GameActivity to be identical to another, by deep copy. - // Arguments: A reference to the GameActivity to deep copy. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Creates a GameActivity to be identical to another, by deep copy. + /// @param reference A reference to the GameActivity to deep copy. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Create(const GameActivity& reference); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Reset - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Resets the entire GameActivity, including its inherited members, to their - // default settings or values. - // Arguments: None. - // Return value: None. - + /// Resets the entire GameActivity, including its inherited members, to their + /// default settings or values. void Reset() override { Clear(); Activity::Reset(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destroys and resets (through Clear()) the GameActivity object. - // Arguments: Whether to only destroy the members defined in this derived class, or - // to destroy all inherited members also. - // Return value: None. - + /// Destroys and resets (through Clear()) the GameActivity object. + /// @param notInherited Whether to only destroy the members defined in this derived class, or (default: false) + /// to destroy all inherited members also. void Destroy(bool notInherited = false) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetCPUTeam - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the current CPU-assisted team, if any (NoTeam) - LEGACY function - // Arguments: None. - // Return value: The current setting. NoTeam is no team is assisted. - + /// Gets the current CPU-assisted team, if any (NoTeam) - LEGACY function + /// @return The current setting. NoTeam is no team is assisted. int GetCPUTeam() const { return m_CPUTeam; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetCPUTeam - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the current CPU-assisted team, if any (NoTeam) - LEGACY function - // Arguments: The new setting. NoTeam is no team is assisted. - // Return value: None. - + /// Sets the current CPU-assisted team, if any (NoTeam) - LEGACY function + /// @param team The new setting. NoTeam is no team is assisted. (default: Activity::NoTeam) void SetCPUTeam(int team = Activity::NoTeam); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetObservationTarget - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the observation sceneman scroll targets, for when the game is - // over or a player is in observation mode - // Arguments: The new absolute position to observe. - // Which player to set it for. - // Return value: None. - + /// Sets the observation sceneman scroll targets, for when the game is + /// over or a player is in observation mode + /// @param newTarget The new absolute position to observe. + /// @param player Which player to set it for. (default: 0) void SetObservationTarget(const Vector& newTarget, int player = 0) { if (player >= Players::PlayerOne && player < Players::MaxPlayerCount) m_ObservationTarget[player] = newTarget; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetDeathViewTarget - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the player death sceneman scroll targets, for when a player- - // controlled actor dies and the view should go to his last position - // Arguments: The new absolute position to set as death view. - // Which player to set it for. - // Return value: None. - + /// Sets the player death sceneman scroll targets, for when a player- + /// controlled actor dies and the view should go to his last position + /// @param newTarget The new absolute position to set as death view. + /// @param player Which player to set it for. (default: 0) void SetDeathViewTarget(const Vector& newTarget, int player = 0) { if (player >= Players::PlayerOne && player < Players::MaxPlayerCount) m_DeathViewTarget[player] = newTarget; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetLandingZone - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the he last selected landing zone. - // Arguments: The new absolute position to set as the last selected landing zone. - // Which player to set it for. - // Return value: None. - + /// Sets the he last selected landing zone. + /// @param newZone The new absolute position to set as the last selected landing zone. + /// @param player Which player to set it for. (default: 0) void SetLandingZone(const Vector& newZone, int player = 0) { if (player >= Players::PlayerOne && player < Players::MaxPlayerCount) m_LandingZone[player] = newZone; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetLandingZone - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the he last selected landing zone. - // Arguments: Which player to get it for. - // Return value: The new absolute position to set as the last selected landing zone. - + /// Gets the he last selected landing zone. + /// @param player Which player to get it for. (default: 0) + /// @return The new absolute position to set as the last selected landing zone. Vector GetLandingZone(int player = 0) { if (player >= Players::PlayerOne && player < Players::MaxPlayerCount) return m_LandingZone[player]; @@ -213,652 +139,363 @@ namespace RTE { return Vector(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetActorSelectCursor - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the actor selection cursor position. - // Arguments: The new absolute position to put the cursor at. - // Which player to set it for. - // Return value: None. - + /// Sets the actor selection cursor position. + /// @param newPos The new absolute position to put the cursor at. + /// @param player Which player to set it for. (default: 0) void SetActorSelectCursor(const Vector& newPos, int player = 0) { if (player >= Players::PlayerOne && player < Players::MaxPlayerCount) m_ActorCursor[player] = newPos; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetBuyGUI - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the an in-game GUI Object for a specific player. - // Arguments: Which player to get the GUI for. - // Return value: A pointer to a BuyMenuGUI. Ownership is NOT transferred! - + /// Gets the an in-game GUI Object for a specific player. + /// @param which Which player to get the GUI for. (default: 0) + /// @return A pointer to a BuyMenuGUI. Ownership is NOT transferred! BuyMenuGUI* GetBuyGUI(unsigned int which = 0) const { return m_pBuyGUI[which]; } - /// /// Checks if the in-game GUI Object is visible for a specific player. - /// - /// Which player to check the GUI for. -1 will check all players. - /// Whether or not the BuyMenuGUI is visible for input player(s). + /// @param which Which player to check the GUI for. -1 will check all players. + /// @return Whether or not the BuyMenuGUI is visible for input player(s). bool IsBuyGUIVisible(int which = 0) const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetEditorGUI - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the an in-game editor GUI Object for a specific player. - // Arguments: Which player to get the GUI for. - // Return value: A pointer to a SceneEditorGUI. Ownership is NOT transferred! - + /// Gets the an in-game editor GUI Object for a specific player. + /// @param which Which player to get the GUI for. (default: 0) + /// @return A pointer to a SceneEditorGUI. Ownership is NOT transferred! SceneEditorGUI* GetEditorGUI(unsigned int which = 0) const { return m_pEditorGUI[which]; } - /// /// Locks a player controlled actor to a specific controller mode. /// Locking the actor will disable player input, including switching actors. - /// - /// Which player to lock the actor for. - /// Whether to lock or unlock the actor. (Default: true) - /// Which controller mode to lock the actor to. (Default: `CIM_AI`) - /// Whether the (un)lock was performed. + /// @param player Which player to lock the actor for. + /// @param lock Whether to lock or unlock the actor. (Default: true) + /// @param lockToMode Which controller mode to lock the actor to. (Default: `CIM_AI`) + /// @return Whether the (un)lock was performed. bool LockControlledActor(Players player, bool lock = true, Controller::InputMode lockToMode = Controller::InputMode::CIM_AI); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: SwitchToActor - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Forces the this to focus player control to a specific Actor for a - // specific team. OWNERSHIP IS NOT TRANSFERRED! - // Arguments: Which Actor to switch focus to. The team of this Actor will be set - // once it is passed in. Ownership IS NOT TRANSFERRED! The Actor should - // be added to MovableMan already. - // Return value: Whether the focus switch was successful or not. - + /// Forces the this to focus player control to a specific Actor for a + /// specific team. OWNERSHIP IS NOT TRANSFERRED! + /// @param pActor Which Actor to switch focus to. The team of this Actor will be set + /// once it is passed in. Ownership IS NOT TRANSFERRED! The Actor should + /// be added to MovableMan already. + /// @return Whether the focus switch was successful or not. bool SwitchToActor(Actor* pActor, int player = 0, int team = 0) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: SwitchToNextActor - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Forces the this to focus player control to the next Actor of a - // specific team, other than the current one focused on. - // Arguments: Which team to switch to next actor on. - // An actor pointer to skip in the sequence. - // Return value: None. - + /// Forces the this to focus player control to the next Actor of a + /// specific team, other than the current one focused on. + /// @param player Which team to switch to next actor on. + /// @param team An actor pointer to skip in the sequence. void SwitchToNextActor(int player, int team, Actor* pSkip = 0) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: SwitchToPrevActor - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Forces this to focus player control to the previous Actor of a - // specific team, other than the current one focused on. - // Arguments: Which team to switch to next actor on. - // An actor pointer to skip in the sequence. - // Return value: None. - + /// Forces this to focus player control to the previous Actor of a + /// specific team, other than the current one focused on. + /// @param player Which team to switch to next actor on. + /// @param team An actor pointer to skip in the sequence. void SwitchToPrevActor(int player, int team, Actor* pSkip = 0) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetWinnerTeam - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets which team is the winner, when the game is over. - // Arguments: The team number of the winning team. 0 is team #1. Negative number - // means the game isn't over yet. - // Return value: None. - + /// Sets which team is the winner, when the game is over. + /// @param winnerTeam The team number of the winning team. 0 is team #1. Negative number + /// means the game isn't over yet. void SetWinnerTeam(int winnerTeam) { m_WinnerTeam = winnerTeam; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetWinnerTeam - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Indicates which team is the winner, when the game is over. - // Arguments: None. - // Return value: The team number of the winning team. 0 is team #1. Negative number - // means the game isn't over yet. - + /// Indicates which team is the winner, when the game is over. + /// @return The team number of the winning team. 0 is team #1. Negative number + /// means the game isn't over yet. int GetWinnerTeam() const { return m_WinnerTeam; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetBanner - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets access to the huge banner of any player that can display - // messages which can not be missed or ignored. - // Arguments: Which color banner to get - see the GameActivity::BannerColor enum. - // Which player's banner to get. - // Return value: A pointer to the GUIBanner object that we can - + /// Gets access to the huge banner of any player that can display + /// messages which can not be missed or ignored. + /// @param whichColor Which color banner to get - see the GameActivity::BannerColor enum. (default: YELLOW) + /// @param player Which player's banner to get. (default: Players::PlayerOne) + /// @return A pointer to the GUIBanner object that we can GUIBanner* GetBanner(int whichColor = YELLOW, int player = Players::PlayerOne) { return whichColor == YELLOW ? m_pBannerYellow[player] : m_pBannerRed[player]; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetLZArea - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the Area within which a team can land things. - // Arguments: The number of the team we're setting for. - // The Area we're setting to limit their landings within. - // Return value: None. - + /// Sets the Area within which a team can land things. + /// @param team The number of the team we're setting for. + /// @param newArea The Area we're setting to limit their landings within. void SetLZArea(int team, const Scene::Area& newArea) { m_LandingZoneArea[team].Reset(); m_LandingZoneArea[team].Create(newArea); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetLZArea - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the Area within which a team can land things. OWNERSHIP IS NOT TRANSFERRED! - // Arguments: The number of the team we're setting for. - // Return value: The Area we're using to limit their landings within. OWNERSHIP IS NOT TRANSFERRED! - + /// Gets the Area within which a team can land things. OWNERSHIP IS NOT TRANSFERRED! + /// @param team The number of the team we're setting for. + /// @return The Area we're using to limit their landings within. OWNERSHIP IS NOT TRANSFERRED! const Scene::Area& GetLZArea(int team) const { return m_LandingZoneArea[team]; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetBrainLZWidth - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the width of the landing zone box that follows around a player's - // brain. - // Arguments: The number of the in-game player we're setting for. - // The width of the box, in pixels. 0 means disabled. - // Return value: None. - + /// Sets the width of the landing zone box that follows around a player's + /// brain. + /// @param player The number of the in-game player we're setting for. + /// @param width The width of the box, in pixels. 0 means disabled. void SetBrainLZWidth(int player, int width) { m_BrainLZWidth[player] = width; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetBrainLZWidth - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the width of the landing zone box that follows around a player's - // brain. - // Arguments: The number of the player we're getting for. - // Return value: The width in pixels of the landing zone. - + /// Gets the width of the landing zone box that follows around a player's + /// brain. + /// @param player The number of the player we're getting for. + /// @return The width in pixels of the landing zone. int GetBrainLZWidth(int player) const { return m_BrainLZWidth[player]; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: AddObjectivePoint - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Created an objective point for one of the teams to show until cleared. - // Arguments: The team number of the team to give objective. 0 is team #1. - // The very short description of what the objective is (three short words max) - // The absolute scene coordiante position of the objective. - // The desired direction of the arrow when the point is on screen. - // Return value: None. - + /// Created an objective point for one of the teams to show until cleared. + /// @param description The team number of the team to give objective. 0 is team #1. + /// @param objPos The very short description of what the objective is (three short words max) + /// @param whichTeam The absolute scene coordiante position of the objective. (default: Teams::TeamOne) + /// @param arrowDir The desired direction of the arrow when the point is on screen. (default: ARROWDOWN) void AddObjectivePoint(std::string description, Vector objPos, int whichTeam = Teams::TeamOne, ObjectiveArrowDir arrowDir = ARROWDOWN); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: YSortObjectivePoints - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sorts all objective points according to their positions on the Y axis. - // Arguments: None. - // Return value: None. - + /// Sorts all objective points according to their positions on the Y axis. void YSortObjectivePoints(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ClearObjectivePoints - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears all objective points previously added, for both teams. - // Arguments: None. - // Return value: None. - + /// Clears all objective points previously added, for both teams. void ClearObjectivePoints() { m_Objectives.clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: AddOverridePurchase - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Adds somehting to the purchase list that will override what is set - // in the buy guy next time CreateDelivery is called. - // Arguments: The SceneObject preset to add to the override purchase list. OWNERSHIP IS NOT TRANSFERRED! - // Which player's list to add an override purchase item to. - // Return value: The new total value of what's in the override purchase list. - + /// Adds somehting to the purchase list that will override what is set + /// in the buy guy next time CreateDelivery is called. + /// @param pPurchase The SceneObject preset to add to the override purchase list. OWNERSHIP IS NOT TRANSFERRED! + /// @param player Which player's list to add an override purchase item to. + /// @return The new total value of what's in the override purchase list. int AddOverridePurchase(const SceneObject* pPurchase, int player); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetOverridePurchaseList - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: First clears and then adds all the stuff in a Loadout to the override - // purchase list. - // Arguments: The Loadout preset to set the override purchase list to reflect. OWNERSHIP IS NOT TRANSFERRED! - // The player we're talking about. - // Return value: The new total value of what's in the override purchase list. - + /// First clears and then adds all the stuff in a Loadout to the override + /// purchase list. + /// @param pLoadout The Loadout preset to set the override purchase list to reflect. OWNERSHIP IS NOT TRANSFERRED! + /// @param player The player we're talking about. + /// @return The new total value of what's in the override purchase list. int SetOverridePurchaseList(const Loadout* pLoadout, int player); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetOverridePurchaseList - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: First clears and then adds all the stuff in a Loadout to the override - // purchase list. - // Arguments: The name of the Loadout preset to set the override purchase list to - // represent. - // Return value: The new total value of what's in the override purchase list. - + /// First clears and then adds all the stuff in a Loadout to the override + /// purchase list. + /// @param loadoutName The name of the Loadout preset to set the override purchase list to + /// represent. + /// @return The new total value of what's in the override purchase list. int SetOverridePurchaseList(std::string loadoutName, int player); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ClearOverridePurchase - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears all items from a specific player's override purchase list. - // Arguments: Which player's override purchase list to clear. - // Return value: None. - + /// Clears all items from a specific player's override purchase list. + /// @param m_PurchaseOverride[player].clear( Which player's override purchase list to clear. void ClearOverridePurchase(int player) { m_PurchaseOverride[player].clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: CreateDelivery - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Takes the current order out of a player's buy GUI, creates a Delivery - // based off it, and stuffs it into that player's delivery queue. - // Arguments: Which player to create the delivery for. Cargo AI mode and waypoint. - // Return value: Success or not. - + /// Takes the current order out of a player's buy GUI, creates a Delivery + /// based off it, and stuffs it into that player's delivery queue. + /// @param player Which player to create the delivery for. Cargo AI mode and waypoint. + /// @return Success or not. bool CreateDelivery(int player, int mode, Vector& waypoint) { return CreateDelivery(player, mode, waypoint, NULL); }; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: CreateDelivery - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Takes the current order out of a player's buy GUI, creates a Delivery - // based off it, and stuffs it into that player's delivery queue. - // Arguments: Which player to create the delivery for. Cargo AI mode and TargetMO. - // Return value: Success or not. - + /// Takes the current order out of a player's buy GUI, creates a Delivery + /// based off it, and stuffs it into that player's delivery queue. + /// @param player Which player to create the delivery for. Cargo AI mode and TargetMO. + /// @return Success or not. bool CreateDelivery(int player, int mode, Actor* pTargetMO) { Vector point(-1, -1); return CreateDelivery(player, mode, point, pTargetMO); }; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: CreateDelivery - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Takes the current order out of a player's buy GUI, creates a Delivery - // based off it, and stuffs it into that player's delivery queue. - // Arguments: Which player to create the delivery for and Cargo AI mode. - // Return value: Success or not. - + /// Takes the current order out of a player's buy GUI, creates a Delivery + /// based off it, and stuffs it into that player's delivery queue. + /// @param player Which player to create the delivery for and Cargo AI mode. + /// @return Success or not. bool CreateDelivery(int player, int mode) { Vector point(-1, -1); return CreateDelivery(player, mode, point, NULL); }; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: CreateDelivery - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Takes the current order out of a player's buy GUI, creates a Delivery - // based off it, and stuffs it into that player's delivery queue. - // Arguments: Which player to create the delivery for. - // Return value: Success or not. - + /// Takes the current order out of a player's buy GUI, creates a Delivery + /// based off it, and stuffs it into that player's delivery queue. + /// @param player Which player to create the delivery for. + /// @return Success or not. bool CreateDelivery(int player) { Vector point(-1, -1); return CreateDelivery(player, Actor::AIMODE_SENTRY, point, NULL); }; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetDeliveryCount - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Shows how many deliveries this team has pending. - // Arguments: Which team to check the delivery count for. - // Return value: The number of deliveries this team has coming. - + /// Shows how many deliveries this team has pending. + /// @param m_Deliveries[team].size( Which team to check the delivery count for. + /// @return The number of deliveries this team has coming. int GetDeliveryCount(int team) { return m_Deliveries[team].size(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: SetupPlayers - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Precalculates the player-to-screen index map, counts the number of - // active players etc. - // Arguments: None. - // Return value: None. - + /// Precalculates the player-to-screen index map, counts the number of + /// active players etc. void SetupPlayers() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Start - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Officially starts the game accroding to parameters previously set. - // Arguments: None. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Officially starts the game accroding to parameters previously set. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Start() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Pause - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Pauses and unpauses the game. - // Arguments: Whether to pause the game or not. - // Return value: None. - + /// Pauses and unpauses the game. + /// @param pause Whether to pause the game or not. (default: true) void SetPaused(bool pause = true) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: End - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Forces the current game's end. - // Arguments: None. - // Return value: None. - + /// Forces the current game's end. void End() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: UpdateEditing - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: This is a special update step for when any player is still editing the - // scene. - // Arguments: None. - // Return value: None. - + /// This is a special update step for when any player is still editing the + /// scene. void UpdateEditing(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Update - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the state of this ActivityMan. Supposed to be done every frame - // before drawing. - // Arguments: None. - // Return value: None. - + /// Updates the state of this ActivityMan. Supposed to be done every frame + /// before drawing. void Update() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: DrawGUI - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws the currently active GUI of a screen to a BITMAP of choice. - // Arguments: A pointer to a screen-sized BITMAP to draw on. - // The absolute position of the target bitmap's upper left corner in the scene. - // Which screen's GUI to draw onto the bitmap. - // Return value: None. - + /// Draws the currently active GUI of a screen to a BITMAP of choice. + /// @param pTargetBitmap A pointer to a screen-sized BITMAP to draw on. + /// @param targetPos The absolute position of the target bitmap's upper left corner in the scene. (default: Vector()) + /// @param which Which screen's GUI to draw onto the bitmap. (default: 0) void DrawGUI(BITMAP* pTargetBitmap, const Vector& targetPos = Vector(), int which = 0) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Draw - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws this ActivityMan's current graphical representation to a - // BITMAP of choice. This includes all game-related graphics. - // Arguments: A pointer to a BITMAP to draw on. OWNERSHIP IS NOT TRANSFERRED! - // The absolute position of the target bitmap's upper left corner in the scene. - // Return value: None. - + /// Draws this ActivityMan's current graphical representation to a + /// BITMAP of choice. This includes all game-related graphics. + /// @param pTargetBitmap A pointer to a BITMAP to draw on. OWNERSHIP IS NOT TRANSFERRED! + /// @param targetPos The absolute position of the target bitmap's upper left corner in the scene. (default: Vector()) void Draw(BITMAP* pTargetBitmap, const Vector& targetPos = Vector()) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetTeamTech - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns the name of the tech module selected for this team during scenario setup - // Arguments: Team to return tech module for - // Return value: Tech module name, for example Dummy.rte, or empty string if there is no team + /// Returns the name of the tech module selected for this team during scenario setup + /// @param team Team to return tech module for + /// @return Tech module name, for example Dummy.rte, or empty string if there is no team std::string GetTeamTech(int team) const { return (team >= Teams::TeamOne && team < Teams::MaxTeamCount) ? m_TeamTech[team] : ""; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetTeamTech - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets tech module name for specified team. Module must set must be loaded. - // Arguments: Team to set module, module name, for example Dummy.rte - // Return value: None + /// Sets tech module name for specified team. Module must set must be loaded. + /// @param team Team to set module, module name, for example Dummy.rte void SetTeamTech(int team, std::string tech); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: TeamIsCPU - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Indicates whether a specific team is assigned a CPU player in the current game. - // Arguments: Which team index to check. - // Return value: Whether the team is assigned a CPU player in the current activity. + /// Indicates whether a specific team is assigned a CPU player in the current game. + /// @param team Which team index to check. + /// @return Whether the team is assigned a CPU player in the current activity. bool TeamIsCPU(int team) const { return (team >= Teams::TeamOne && team < Teams::MaxTeamCount) ? m_TeamIsCPU[team] : false; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetActiveCPUTeamCount - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns active CPU team count. - // Arguments: None. - // Return value: Returns active CPU team count. + /// Returns active CPU team count. + /// @return Returns active CPU team count. int GetActiveCPUTeamCount() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetActiveHumanTeamCount - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns active human team count. - // Arguments: None. - // Return value: Returns active human team count. + /// Returns active human team count. + /// @return Returns active human team count. int GetActiveHumanTeamCount() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetStartingGold - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Changes how much starting gold was selected in scenario setup dialog. 20000 - infinite amount. - // Arguments: Starting gold amount - // Return value: None. + /// Changes how much starting gold was selected in scenario setup dialog. 20000 - infinite amount. + /// @param amount Starting gold amount void SetStartingGold(int amount) { m_StartingGold = amount; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetStartingGold - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns how much starting gold was selected in scenario setup dialog. 20000 - infinite amount. - // Arguments: None. - // Return value: How much starting gold must be given to human players. + /// Returns how much starting gold was selected in scenario setup dialog. 20000 - infinite amount. + /// @return How much starting gold must be given to human players. int GetStartingGold() { return m_StartingGold; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetFogOfWarEnabled - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Changes whether fog of war must be enabled for this activity or not. - // Never hides or reveals anything, just changes internal flag. - // Arguments: New fog of war state. true = enabled. - // Return value: None. + /// Changes whether fog of war must be enabled for this activity or not. + /// Never hides or reveals anything, just changes internal flag. + /// @param enable New fog of war state. true = enabled. + /// Return value: None. void SetFogOfWarEnabled(bool enable) { m_FogOfWarEnabled = enable; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetFogOfWareEnabled - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns whether fog of war must be enabled for this activity or not. - // Call it to determine whether you should call MakeAllUnseen or not at the start of activity. - // Arguments: None. - // Return value: Whether Fog of war flag was checked during scenario setup dialog. + /// Returns whether fog of war must be enabled for this activity or not. + /// Call it to determine whether you should call MakeAllUnseen or not at the start of activity. + /// @return Whether Fog of war flag was checked during scenario setup dialog. bool GetFogOfWarEnabled() { return m_FogOfWarEnabled; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetRequireClearPathToOrbit - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Tells whether player activity requires a cleat path to orbit to place brain - // - // Arguments: None. - // Return value: Whether we need a clear path to orbit to place brains. + /// Tells whether player activity requires a cleat path to orbit to place brain + /// Return value: Whether we need a clear path to orbit to place brains. bool GetRequireClearPathToOrbit() const { return m_RequireClearPathToOrbit; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetRequireClearPathToOrbit - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Tells whether player activity requires a cleat path to orbit to place brain - // - // Arguments: Whether we need a clear path to orbit to place brains. - // Return value: None. + /// Tells whether player activity requires a cleat path to orbit to place brain + /// @param newvalue Whether we need a clear path to orbit to place brains. + /// Return value: None. void SetRequireClearPathToOrbit(bool newvalue) { m_RequireClearPathToOrbit = newvalue; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: - // Arguments: None. - // Return value: + /// Method: + /// Description: + /// Return value: int GetDefaultFogOfWar() const { return m_DefaultFogOfWar; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: - // Arguments: None. - // Return value: + /// Method: + /// Description: + /// Return value: int GetDefaultRequireClearPathToOrbit() const { return m_DefaultRequireClearPathToOrbit; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: - // Arguments: None. - // Return value: + /// Method: + /// Description: + /// Return value: int GetDefaultDeployUnits() const { return m_DefaultDeployUnits; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: - // Arguments: None. - // Return value: + /// Method: + /// Description: + /// Return value: int GetDefaultGoldCakeDifficulty() const { return m_DefaultGoldCakeDifficulty; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: - // Arguments: None. - // Return value: + /// Method: + /// Description: + /// Return value: int GetDefaultGoldEasyDifficulty() const { return m_DefaultGoldEasyDifficulty; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: - // Arguments: None. - // Return value: + /// Method: + /// Description: + /// Return value: int GetDefaultGoldMediumDifficulty() const { return m_DefaultGoldMediumDifficulty; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: - // Arguments: None. - // Return value: + /// Method: + /// Description: + /// Return value: int GetDefaultGoldHardDifficulty() const { return m_DefaultGoldHardDifficulty; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: - // Arguments: None. - // Return value: + /// Method: + /// Description: + /// Return value: int GetDefaultGoldNutsDifficulty() const { return m_DefaultGoldNutsDifficulty; } - /// /// Gets the default gold for max difficulty. - /// - /// The default gold for max difficulty. + /// @return The default gold for max difficulty. int GetDefaultGoldMaxDifficulty() const { return m_DefaultGoldMaxDifficulty; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: - // Arguments: None. - // Return value: + /// Method: + /// Description: + /// Return value: bool GetFogOfWarSwitchEnabled() const { return m_FogOfWarSwitchEnabled; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: - // Arguments: None. - // Return value: + /// Method: + /// Description: + /// Return value: bool GetDeployUnitsSwitchEnabled() const { return m_DeployUnitsSwitchEnabled; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: - // Arguments: None. - // Return value: - + /// Method: + /// Description: + /// Return value: bool GetGoldSwitchEnabled() const { return m_GoldSwitchEnabled; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: - // Arguments: None. - // Return value: - + /// Method: + /// Description: + /// Return value: bool GetRequireClearPathToOrbitSwitchEnabled() const { return m_RequireClearPathToOrbitSwitchEnabled; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetCrabToHumanSpawnRatio - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns CrabToHumanSpawnRatio for specified module - // Arguments: None. - // Return value: Crab-To-Human spawn ratio value set for specified module, 0.25 is default. - + /// Returns CrabToHumanSpawnRatio for specified module + /// @return Crab-To-Human spawn ratio value set for specified module, 0.25 is default. float GetCrabToHumanSpawnRatio(int moduleid); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetDeliveryDelay - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns current delivery delay - // Arguments: None. - // Return value: Returns current delivery delay - + /// Returns current delivery delay + /// @return Returns current delivery delay long GetDeliveryDelay() const { return m_DeliveryDelay; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetDeliveryDelay - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets delivery delay - // Arguments: New delivery delay value in ms - // Return value: None - + /// Sets delivery delay + /// @param newDeliveryDelay New delivery delay value in ms void SetDeliveryDelay(long newDeliveryDelay) { m_DeliveryDelay = newDeliveryDelay > 1 ? newDeliveryDelay : 1; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetBuyMenuEnabled - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns whether buy menu is enabled in this activity. - // Arguments: True if buy menu enabled false otherwise - // Return value: None. - + /// Returns whether buy menu is enabled in this activity. + /// @param True if buy menu enabled false otherwise bool GetBuyMenuEnabled() const { return m_BuyMenuEnabled; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetBuyMenuEnabled - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets whether buy menu is enabled in this activity - // Arguments: True to enable buy menu, false otherwise - // Return value: None. - + /// Sets whether buy menu is enabled in this activity + /// @param newValue True to enable buy menu, false otherwise void SetBuyMenuEnabled(bool newValue) { m_BuyMenuEnabled = newValue; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetNetworkPlayerName - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns network player name - // Arguments: Player - // Return value: Network player name - + /// Returns network player name + /// @param player Player + /// @return Network player name std::string& GetNetworkPlayerName(int player); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetNetworkPlayerName - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets network player name - // Arguments: Player number, player name - // Return value: None - + /// Sets network player name + /// @param player Player number, player name void SetNetworkPlayerName(int player, std::string name); - ////////////////////////////////////////////////////////////////////////////////////////// - // Protected member variable and method declarations - + /// Protected member variable and method declarations protected: - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: CreateDelivery - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Takes the current order out of a player's buy GUI, creates a Delivery - // based off it, and stuffs it into that player's delivery queue. - // Arguments: Which player to create the delivery for. Cargo AI mode waypoint or TargetMO. - // Return value: Success or not. - + /// Takes the current order out of a player's buy GUI, creates a Delivery + /// based off it, and stuffs it into that player's delivery queue. + /// @param player Which player to create the delivery for. Cargo AI mode waypoint or TargetMO. + /// @return Success or not. bool CreateDelivery(int player, int mode, Vector& waypoint, Actor* pTargetMO); - ////////////////////////////////////////////////////////////////////////////////////////// - // Struct: ObjectivePoint - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: A struct to keep all data about a mission objective. - // Parent(s): None. - // Class history: 11/17/2008 ObjectivePoint - + /// A struct to keep all data about a mission objective. struct ObjectivePoint { ObjectivePoint() { m_Description.clear(); @@ -873,16 +510,11 @@ namespace RTE { m_ArrowDir = arrowDir; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Draw - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Simply draws this' arrow relative to a point on a bitmap. - // Arguments: A pointer to the BITMAP to draw on. - // The arrow bitmap to draw, assuming it points downward. - // The absolute position on the bitmap to draw the point of the arrow at. - // Which orientation to draw the arrow in, relative to the point. - // Return value: None. - + /// Simply draws this' arrow relative to a point on a bitmap. + /// @param pTargetBitmap A pointer to the BITMAP to draw on. + /// @param pArrowBitmap The arrow bitmap to draw, assuming it points downward. + /// @param arrowPoint The absolute position on the bitmap to draw the point of the arrow at. + /// @param arrowDir Which orientation to draw the arrow in, relative to the point. (default: ARROWDOWN) void Draw(BITMAP* pTargetBitmap, BITMAP* pArrowBitmap, const Vector& arrowPoint, ObjectiveArrowDir arrowDir = ARROWDOWN); // The description of this objective point @@ -900,67 +532,37 @@ namespace RTE { bool operator()(ObjectivePoint& rhs, ObjectivePoint& lhs) { return rhs.m_ScenePos.m_Y < lhs.m_ScenePos.m_Y; } }; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: OtherTeam - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the next other team number from the one passed in, if any. If there - // are more than two teams in this game, then the next one in the series - // will be returned here. - // Arguments: The team not to get. - // Return value: The other team's number. - + /// Gets the next other team number from the one passed in, if any. If there + /// are more than two teams in this game, then the next one in the series + /// will be returned here. + /// @param team The team not to get. + /// @return The other team's number. int OtherTeam(int team); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: OneOrNoneTeamsLeft - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Indicates whether there is less than two teams left in this game with - // a brain in its ranks. - // Arguments: None. - // Return value: Whether less than two teams have brains in them left. - + /// Indicates whether there is less than two teams left in this game with + /// a brain in its ranks. + /// @return Whether less than two teams have brains in them left. bool OneOrNoneTeamsLeft(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: WhichTeamLeft - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Indicates which single team is left, if any. - // Arguments: None. - // Return value: Which team stands alone with any brains in its ranks, if any. NoTeam - // is returned if there's either more than one team, OR there are no - // teams at all left with brains in em. - + /// Indicates which single team is left, if any. + /// @return Which team stands alone with any brains in its ranks, if any. NoTeam + /// is returned if there's either more than one team, OR there are no + /// teams at all left with brains in em. int WhichTeamLeft(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: NoTeamLeft - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Indicates whether there are NO teams left with any brains at all! - // Arguments: None. - // Return value: Whether any team has a brain in it at all. - + /// Indicates whether there are NO teams left with any brains at all! + /// @return Whether any team has a brain in it at all. bool NoTeamLeft(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: InitAIs - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Goes through all Actor:s currently in the MovableMan and sets each - // one not controlled by a player to be AI controlled and AIMode setting - // based on team and CPU team. - // Arguments: None. - // Return value: None. - + /// Goes through all Actor:s currently in the MovableMan and sets each + /// one not controlled by a player to be AI controlled and AIMode setting + /// based on team and CPU team. virtual void InitAIs(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: DisableAIs - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Goes through all Actor:s currently in the MovableMan and disables or - // enables each one with a Controller set to AI input. - // Arguments: Whether to disable or enable them; - // Which team to do this to. If all, then pass Teams::NoTeam - // Return value: None. - + /// Goes through all Actor:s currently in the MovableMan and disables or + /// enables each one with a Controller set to AI input. + /// @param disable Whether to disable or enable them; (default: true) + /// @param whichTeam Which team to do this to. If all, then pass Teams::NoTeam (default: Teams::NoTeam) void DisableAIs(bool disable = true, int whichTeam = Teams::NoTeam); // Member variables @@ -1065,18 +667,10 @@ namespace RTE { std::string m_NetworkPlayerNames[Players::MaxPlayerCount]; - ////////////////////////////////////////////////////////////////////////////////////////// - // Private member variable and method declarations - + /// Private member variable and method declarations private: - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Clear - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears all the member variables of this Activity, effectively - // resetting the members of this abstraction level only. - // Arguments: None. - // Return value: None. - + /// Clears all the member variables of this Activity, effectively + /// resetting the members of this abstraction level only. void Clear(); }; diff --git a/Source/Activities/GibEditor.cpp b/Source/Activities/GibEditor.cpp index 69e56ecab5..d9ef134bf1 100644 --- a/Source/Activities/GibEditor.cpp +++ b/Source/Activities/GibEditor.cpp @@ -1,15 +1,3 @@ -////////////////////////////////////////////////////////////////////////////////////////// -// File: GibEditor.cpp -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Source file for the GibEditor class. -// Project: Retro Terrain Engine -// Author(s): Daniel Tabar -// data@datarealms.com -// http://www.datarealms.com - -////////////////////////////////////////////////////////////////////////////////////////// -// Inclusions of header files - #include "GibEditor.h" #include "WindowMan.h" @@ -17,11 +5,11 @@ #include "MovableMan.h" #include "FrameMan.h" #include "UInputMan.h" -//#include "AHuman.h" -//#include "MOPixel.h" +// #include "AHuman.h" +// #include "MOPixel.h" #include "SLTerrain.h" #include "Controller.h" -//#include "AtomGroup.h" +// #include "AtomGroup.h" #include "Actor.h" #include "AHuman.h" #include "ACRocket.h" @@ -43,12 +31,6 @@ namespace RTE { ConcreteClassInfo(GibEditor, EditorActivity, 0); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Clear - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears all the member variables of this GibEditor, effectively - // resetting the members of this abstraction level only. - void GibEditor::Clear() { m_pEditedObject = 0; m_pTestingObject = 0; @@ -57,11 +39,6 @@ namespace RTE { m_pEditorGUI = 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes the GibEditor object ready for use. - int GibEditor::Create() { if (EditorActivity::Create() < 0) return -1; @@ -69,11 +46,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Creates a GibEditor to be identical to another, by deep copy. - int GibEditor::Create(const GibEditor& reference) { if (EditorActivity::Create(reference) < 0) return -1; @@ -84,14 +56,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: ReadProperty - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Reads a property value from a reader stream. If the name isn't - // recognized by this class, then ReadProperty of the parent class - // is called. If the property isn't recognized by any of the base classes, - // false is returned, and the reader's position is untouched. - int GibEditor::ReadProperty(const std::string_view& propName, Reader& reader) { StartPropertyList(return EditorActivity::ReadProperty(propName, reader)); /* @@ -102,22 +66,11 @@ namespace RTE { EndPropertyList; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Save - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Saves the complete state of this GibEditor with a Writer for - // later recreation with Create(Reader &reader); - int GibEditor::Save(Writer& writer) const { EditorActivity::Save(writer); return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destroys and resets (through Clear()) the GibEditor object. - void GibEditor::Destroy(bool notInherited) { delete m_pEditedObject; delete m_pTestingObject; @@ -128,12 +81,6 @@ namespace RTE { Clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Start - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Officially starts this. Creates all the data etc necessary to start - // the activity. - int GibEditor::Start() { int error = EditorActivity::Start(); @@ -220,33 +167,17 @@ namespace RTE { return error; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Pause - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Pauses and unpauses the game. - void GibEditor::SetPaused(bool pause) { // Override the pause m_Paused = false; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: End - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Forces the current game's end. - void GibEditor::End() { EditorActivity::End(); m_ActivityState = ActivityState::Over; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Update - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the state of this GibEditor. Supposed to be done every frame - // before drawing. - void GibEditor::Update() { // And object hasn't been loaded yet, so get the loading picker going if (!m_pEditedObject && !m_pObjectToLoad) { @@ -594,11 +525,6 @@ namespace RTE { } } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: DrawGUI - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws the currently active GUI of a screen to a BITMAP of choice. - void GibEditor::DrawGUI(BITMAP* pTargetBitmap, const Vector& targetPos, int which) { // Testing mode if (m_EditorMode == EditorActivity::TESTINGOBJECT) { @@ -619,18 +545,10 @@ namespace RTE { } } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Draw - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws this GibEditor's current graphical representation to a - // BITMAP of choice. This includes all game-related graphics. - void GibEditor::Draw(BITMAP* pTargetBitmap, const Vector& targetPos) { EditorActivity::Draw(pTargetBitmap, targetPos); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool GibEditor::SaveObject(const std::string& saveAsName, bool forceOverwrite) { if (!m_pEditedObject) { return false; @@ -694,12 +612,6 @@ namespace RTE { return false; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: StuffEditedGibs - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Replaces all the gibs owned by the passed in MOSR with the ones being - // edited that represent the new gibbing setup. - void GibEditor::StuffEditedGibs(MOSRotating* pEditedObject) { if (!pEditedObject) return; @@ -726,11 +638,6 @@ namespace RTE { } } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: UpdateNewDialog - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the New dialog box, populates its lists etc. - void GibEditor::UpdateNewDialog() { /* // Only refill modules if empty @@ -784,21 +691,11 @@ namespace RTE { */ } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: UpdateLoadDialog - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the Load dialog box, populates its lists etc. - void GibEditor::UpdateLoadDialog() { if (m_pObjectToLoad) dynamic_cast(m_pGUIController->GetControl("LoadNameLabel"))->SetText("Load object named " + m_pObjectToLoad->GetPresetName() + "?"); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: UpdateSaveDialog - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the Save dialog box, populates its lists etc. - void GibEditor::UpdateSaveDialog() { if (!m_pEditedObject) return; @@ -808,11 +705,6 @@ namespace RTE { m_pSaveModuleLabel->SetText("Will save in " + g_PresetMan.GetDataModule(m_ModuleSpaceID)->GetFileName() + "/NewData/"); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: UpdateChangesDialog - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the Save Changes dialog box, populates its lists etc. - void GibEditor::UpdateChangesDialog() { if (!m_pEditedObject) return; @@ -826,18 +718,11 @@ namespace RTE { } } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: UpdateOverwriteDialog - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the Overwrite dialog box, populates its lists etc. - void GibEditor::UpdateOverwriteDialog() { if (m_pEditedObject) m_pOverwriteNameLabel->SetText(g_PresetMan.GetDataModule(m_ModuleSpaceID)->GetFileName() + "/NewData/" + m_pEditedObject->GetPresetName() + ".ini"); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GibEditor::ClearTestArea() const { clear_bitmap(g_SceneMan.GetTerrain()->GetFGColorBitmap()); clear_bitmap(g_SceneMan.GetTerrain()->GetBGColorBitmap()); diff --git a/Source/Activities/GibEditor.h b/Source/Activities/GibEditor.h index 757f3bb0f4..2b01c8ddbb 100644 --- a/Source/Activities/GibEditor.h +++ b/Source/Activities/GibEditor.h @@ -1,18 +1,11 @@ #ifndef _RTEGIBEDITOR_ #define _RTEGIBEDITOR_ -////////////////////////////////////////////////////////////////////////////////////////// -// File: GibEditor.h -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Header file for the GibEditor class. -// Project: Retro Terrain Engine -// Author(s): Daniel Tabar -// data@datarealms.com -// http://www.datarealms.com - -////////////////////////////////////////////////////////////////////////////////////////// -// Inclusions of header files - +/// Header file for the GibEditor class. +/// @author Daniel Tabar +/// data@datarealms.com +/// http://www.datarealms.com +/// Inclusions of header files #include "RTETools.h" #include "EditorActivity.h" @@ -31,228 +24,109 @@ namespace RTE { class GUILabel; class GUIComboBox; - ////////////////////////////////////////////////////////////////////////////////////////// - // Class: GibEditor - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Activity for editing gib placement within MOSRotating:s. - // Parent(s): EditorActivity. - // Class history: 9/17/2007 GibEditor Created. - + /// Activity for editing gib placement within MOSRotating:s. class GibEditor : public EditorActivity { - ////////////////////////////////////////////////////////////////////////////////////////// - // Public member variable, method and friend function declarations - + /// Public member variable, method and friend function declarations public: // Concrete allocation and cloning definitions EntityAllocation(GibEditor); SerializableOverrideMethods; ClassInfoGetters; - ////////////////////////////////////////////////////////////////////////////////////////// - // Constructor: GibEditor - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Constructor method used to instantiate a GibEditor object in system - // memory. Create() should be called before using the object. - // Arguments: None. - + /// Constructor method used to instantiate a GibEditor object in system + /// memory. Create() should be called before using the object. GibEditor() { Clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Destructor: ~GibEditor - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destructor method used to clean up a GibEditor object before deletion - // from system memory. - // Arguments: None. - + /// Destructor method used to clean up a GibEditor object before deletion + /// from system memory. ~GibEditor() override { Destroy(true); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes the GibEditor object ready for use. - // Arguments: None. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Makes the GibEditor object ready for use. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Create() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Creates a GibEditor to be identical to another, by deep copy. - // Arguments: A reference to the GibEditor to deep copy. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Creates a GibEditor to be identical to another, by deep copy. + /// @param reference A reference to the GibEditor to deep copy. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Create(const GibEditor& reference); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Reset - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Resets the entire GibEditor, including its inherited members, to their - // default settings or values. - // Arguments: None. - // Return value: None. - + /// Resets the entire GibEditor, including its inherited members, to their + /// default settings or values. void Reset() override { Clear(); EditorActivity::Reset(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destroys and resets (through Clear()) the GibEditor object. - // Arguments: Whether to only destroy the members defined in this derived class, or - // to destroy all inherited members also. - // Return value: None. - + /// Destroys and resets (through Clear()) the GibEditor object. + /// @param notInherited Whether to only destroy the members defined in this derived class, or (default: false) + /// to destroy all inherited members also. void Destroy(bool notInherited = false) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetEditorMode - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the current mode of this editor. - // Arguments: The new mode to set to, see the EditorGUIMode enum. - // Return value: None. - + /// Sets the current mode of this editor. + /// @param newMode The new mode to set to, see the EditorGUIMode enum. void SetEditorMode(EditorActivity::EditorMode newMode) { m_EditorMode = newMode; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetEditorMode - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the current mode of this editor. - // Arguments: None. - // Return value: The current mode this is set to; see the EditorGUIMode enum. - + /// Gets the current mode of this editor. + /// @return The current mode this is set to; see the EditorGUIMode enum. EditorActivity::EditorMode GetEditorMode() const { return m_EditorMode; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Start - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Officially starts the game accroding to parameters previously set. - // Arguments: None. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Officially starts the game accroding to parameters previously set. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Start() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Pause - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Pauses and unpauses the game. - // Arguments: Whether to pause the game or not. - // Return value: None. - + /// Pauses and unpauses the game. + /// @param pause Whether to pause the game or not. (default: true) void SetPaused(bool pause = true) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: End - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Forces the current game's end. - // Arguments: None. - // Return value: None. - + /// Forces the current game's end. void End() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Update - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the state of this ActivityMan. Supposed to be done every frame - // before drawing. - // Arguments: None. - // Return value: None. - + /// Updates the state of this ActivityMan. Supposed to be done every frame + /// before drawing. void Update() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: DrawGUI - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws the currently active GUI of a screen to a BITMAP of choice. - // Arguments: A pointer to a screen-sized BITMAP to draw on. - // The absolute position of the target bitmap's upper left corner in the scene. - // Which screen's GUI to draw onto the bitmap. - // Return value: None. - + /// Draws the currently active GUI of a screen to a BITMAP of choice. + /// @param pTargetBitmap A pointer to a screen-sized BITMAP to draw on. + /// @param targetPos The absolute position of the target bitmap's upper left corner in the scene. (default: Vector()) + /// @param which Which screen's GUI to draw onto the bitmap. (default: 0) void DrawGUI(BITMAP* pTargetBitmap, const Vector& targetPos = Vector(), int which = 0) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Draw - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws this ActivityMan's current graphical representation to a - // BITMAP of choice. This includes all game-related graphics. - // Arguments: A pointer to a BITMAP to draw on. OWNERSHIP IS NOT TRANSFERRED! - // The absolute position of the target bitmap's upper left corner in the scene. - // Return value: None. - + /// Draws this ActivityMan's current graphical representation to a + /// BITMAP of choice. This includes all game-related graphics. + /// @param pTargetBitmap A pointer to a BITMAP to draw on. OWNERSHIP IS NOT TRANSFERRED! + /// @param targetPos The absolute position of the target bitmap's upper left corner in the scene. (default: Vector()) void Draw(BITMAP* pTargetBitmap, const Vector& targetPos = Vector()) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Protected member variable and method declarations - + /// Protected member variable and method declarations protected: - /// /// Saves the current object to an appropriate ini file, and asks user if they want to overwrite first if object of this name exists. - /// - /// The name of the new object to be saved. - /// Whether to force any existing Object of that name to be overwritten if it already exists. - /// Whether actually managed to save. Will return false both if an object of this name already exists (and not overwriting), or if other error. + /// @param saveAsName The name of the new object to be saved. + /// @param forceOverwrite Whether to force any existing Object of that name to be overwritten if it already exists. + /// @return Whether actually managed to save. Will return false both if an object of this name already exists (and not overwriting), or if other error. bool SaveObject(const std::string& saveAsName, bool forceOverwrite = false); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: StuffEditedGibs - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Replaces all the gibs owned by the passed in MOSR with the ones being - // edited that represent the new gibbing setup. - // Arguments: The MOSRotating to replace the gibs of. Ownership is NOT trnasferred! - // Return value: None. - + /// Replaces all the gibs owned by the passed in MOSR with the ones being + /// edited that represent the new gibbing setup. + /// @param pEditedObject The MOSRotating to replace the gibs of. Ownership is NOT trnasferred! void StuffEditedGibs(MOSRotating* pEditedObject); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virutal method: UpdateNewDialog - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the New dialog box, populates its lists etc. - // Arguments: None. - // Return value: None. - + /// Updates the New dialog box, populates its lists etc. void UpdateNewDialog() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virutal method: UpdateLoadDialog - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the Load dialog box, populates its lists etc. - // Arguments: None. - // Return value: None. - + /// Updates the Load dialog box, populates its lists etc. void UpdateLoadDialog() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virutal method: UpdateSaveDialog - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the Save dialog box, populates its lists etc. - // Arguments: None. - // Return value: None. - + /// Updates the Save dialog box, populates its lists etc. void UpdateSaveDialog() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virutal method: UpdateChangesDialog - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the Save Changes dialog box, populates its lists etc. - // Arguments: None. - // Return value: None. - + /// Updates the Save Changes dialog box, populates its lists etc. void UpdateChangesDialog() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virutal method: UpdateOverwriteDialog - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the Overwrite dialog box, populates its lists etc. - // Arguments: None. - // Return value: None. - + /// Updates the Overwrite dialog box, populates its lists etc. void UpdateOverwriteDialog() override; // Member variables @@ -269,23 +143,13 @@ namespace RTE { // The editor GUI GibEditorGUI* m_pEditorGUI; - ////////////////////////////////////////////////////////////////////////////////////////// - // Private member variable and method declarations - + /// Private member variable and method declarations private: - /// /// Clears all the layers of the testing area terrain so nothing that somehow settled lingers between edited object changes and testing phases. - /// void ClearTestArea() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Clear - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears all the member variables of this Activity, effectively - // resetting the members of this abstraction level only. - // Arguments: None. - // Return value: None. - + /// Clears all the member variables of this Activity, effectively + /// resetting the members of this abstraction level only. void Clear(); }; diff --git a/Source/Activities/MultiplayerGame.cpp b/Source/Activities/MultiplayerGame.cpp index f534f76024..3a5c11520c 100644 --- a/Source/Activities/MultiplayerGame.cpp +++ b/Source/Activities/MultiplayerGame.cpp @@ -1,13 +1,3 @@ -////////////////////////////////////////////////////////////////////////////////////////// -// File: MultiplayerGame.cpp -////////////////////////////////////////////////////////////////////////////////////////// -// Description: -// Project: Retro Terrain Engine -// Author(s): - -////////////////////////////////////////////////////////////////////////////////////////// -// Inclusions of header files - #include "MultiplayerGame.h" #include "WindowMan.h" @@ -44,12 +34,6 @@ namespace RTE { ConcreteClassInfo(MultiplayerGame, Activity, 0); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Clear - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears all the member variables of this MultiplayerGame, effectively - // resetting the members of this abstraction level only. - void MultiplayerGame::Clear() { m_pGUIController = 0; m_pGUIInput = 0; @@ -74,22 +58,12 @@ namespace RTE { m_LastMusicPos = 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes the MultiplayerGame object ready for use. - int MultiplayerGame::Create() { if (Activity::Create() < 0) return -1; return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Creates a MultiplayerGame to be identical to another, by deep copy. - int MultiplayerGame::Create(const MultiplayerGame& reference) { if (Activity::Create(reference) < 0) return -1; @@ -100,34 +74,15 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: ReadProperty - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Reads a property value from a reader stream. If the name isn't - // recognized by this class, then ReadProperty of the parent class - // is called. If the property isn't recognized by any of the base classes, - // false is returned, and the reader's position is untouched. - int MultiplayerGame::ReadProperty(const std::string_view& propName, Reader& reader) { return Activity::ReadProperty(propName, reader); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Save - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Saves the complete state of this MultiplayerGame with a Writer for - // later recreation with Create(Reader &reader); - int MultiplayerGame::Save(Writer& writer) const { Activity::Save(writer); return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destroys and resets (through Clear()) the MultiplayerGame object. - void MultiplayerGame::Destroy(bool notInherited) { g_FrameMan.SetDrawNetworkBackBuffer(false); g_NetworkClient.Disconnect(); @@ -141,12 +96,6 @@ namespace RTE { Clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Start - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Officially starts this. Creates all the data etc necessary to start - // the activity. - int MultiplayerGame::Start() { int error = Activity::Start(); @@ -211,11 +160,6 @@ namespace RTE { return error; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Pause - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Pauses and unpauses the game. - void MultiplayerGame::SetPaused(bool pause) { // Override the pause // m_Paused = false; @@ -238,11 +182,6 @@ namespace RTE { } } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: End - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Forces the current game's end. - void MultiplayerGame::End() { Activity::End(); @@ -250,12 +189,6 @@ namespace RTE { g_FrameMan.SetDrawNetworkBackBuffer(false); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Update - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the state of this MultiplayerGame. Supposed to be done every frame - // before drawing. - void MultiplayerGame::Update() { Activity::Update(); diff --git a/Source/Activities/MultiplayerGame.h b/Source/Activities/MultiplayerGame.h index 66efb10480..e183378d0b 100644 --- a/Source/Activities/MultiplayerGame.h +++ b/Source/Activities/MultiplayerGame.h @@ -1,16 +1,9 @@ #ifndef _RTEMULTIPLAYERGAME_ #define _RTEMULTIPLAYERGAME_ -////////////////////////////////////////////////////////////////////////////////////////// -// File: MultiplayerGame.h -////////////////////////////////////////////////////////////////////////////////////////// -// Description: -// Project: Retro Terrain Engine -// Author(s): - -////////////////////////////////////////////////////////////////////////////////////////// -// Inclusions of header files - +/// Description: +/// Author(s): +/// Inclusions of header files #include "RTETools.h" #include "ActivityMan.h" @@ -28,19 +21,11 @@ namespace RTE { class GUILabel; class GUIComboBox; - ////////////////////////////////////////////////////////////////////////////////////////// - // Class: MultiplayerGame - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Activity for editing scenes. - // Parent(s): EditorActivity. - // Class history: 8/30/2007 MultiplayerGame created, inheriting directly from Activity. - // 9/17/2007 Spliced out and made to derive from EditorActivty - + /// Activity for editing scenes. + /// 9/17/2007 Spliced out and made to derive from EditorActivty class MultiplayerGame : public Activity { - ////////////////////////////////////////////////////////////////////////////////////////// - // Public member variable, method and friend function declarations - + /// Public member variable, method and friend function declarations public: // Concrete allocation and cloning definitions EntityAllocation(MultiplayerGame); @@ -53,130 +38,66 @@ namespace RTE { GAMEPLAY }; - ////////////////////////////////////////////////////////////////////////////////////////// - // Constructor: MultiplayerGame - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Constructor method used to instantiate a MultiplayerGame object in system - // memory. Create() should be called before using the object. - // Arguments: None. - + /// Constructor method used to instantiate a MultiplayerGame object in system + /// memory. Create() should be called before using the object. MultiplayerGame() { Clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Destructor: ~MultiplayerGame - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destructor method used to clean up a MultiplayerGame object before deletion - // from system memory. - // Arguments: None. - + /// Destructor method used to clean up a MultiplayerGame object before deletion + /// from system memory. ~MultiplayerGame() override { Destroy(true); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes the MultiplayerGame object ready for use. - // Arguments: None. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Makes the MultiplayerGame object ready for use. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Create() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Creates a MultiplayerGame to be identical to another, by deep copy. - // Arguments: A reference to the MultiplayerGame to deep copy. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Creates a MultiplayerGame to be identical to another, by deep copy. + /// @param reference A reference to the MultiplayerGame to deep copy. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Create(const MultiplayerGame& reference); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Reset - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Resets the entire MultiplayerGame, including its inherited members, to their - // default settings or values. - // Arguments: None. - // Return value: None. - + /// Resets the entire MultiplayerGame, including its inherited members, to their + /// default settings or values. void Reset() override { Clear(); Activity::Reset(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destroys and resets (through Clear()) the MultiplayerGame object. - // Arguments: Whether to only destroy the members defined in this derived class, or - // to destroy all inherited members also. - // Return value: None. - + /// Destroys and resets (through Clear()) the MultiplayerGame object. + /// @param notInherited Whether to only destroy the members defined in this derived class, or (default: false) + /// to destroy all inherited members also. void Destroy(bool notInherited = false) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Start - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Officially starts the game accroding to parameters previously set. - // Arguments: None. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Officially starts the game accroding to parameters previously set. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Start() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Pause - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Pauses and unpauses the game. - // Arguments: Whether to pause the game or not. - // Return value: None. - + /// Pauses and unpauses the game. + /// @param pause Whether to pause the game or not. (default: true) void SetPaused(bool pause = true) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: End - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Forces the current game's end. - // Arguments: None. - // Return value: None. - + /// Forces the current game's end. void End() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Update - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the state of this ActivityMan. Supposed to be done every frame - // before drawing. - // Arguments: None. - // Return value: None. - + /// Updates the state of this ActivityMan. Supposed to be done every frame + /// before drawing. void Update() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: DrawGUI - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws the currently active GUI of a screen to a BITMAP of choice. - // Arguments: A pointer to a screen-sized BITMAP to draw on. - // The absolute position of the target bitmap's upper left corner in the scene. - // Which screen's GUI to draw onto the bitmap. - // Return value: None. - + /// Draws the currently active GUI of a screen to a BITMAP of choice. + /// @param pTargetBitmap A pointer to a screen-sized BITMAP to draw on. + /// @param targetPos The absolute position of the target bitmap's upper left corner in the scene. (default: Vector()) + /// @param which Which screen's GUI to draw onto the bitmap. (default: 0) void DrawGUI(BITMAP* pTargetBitmap, const Vector& targetPos = Vector(), int which = 0) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Draw - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws this ActivityMan's current graphical representation to a - // BITMAP of choice. This includes all game-related graphics. - // Arguments: A pointer to a BITMAP to draw on. OWNERSHIP IS NOT TRANSFERRED! - // The absolute position of the target bitmap's upper left corner in the scene. - // Return value: None. - + /// Draws this ActivityMan's current graphical representation to a + /// BITMAP of choice. This includes all game-related graphics. + /// @param pTargetBitmap A pointer to a BITMAP to draw on. OWNERSHIP IS NOT TRANSFERRED! + /// @param targetPos The absolute position of the target bitmap's upper left corner in the scene. (default: Vector()) void Draw(BITMAP* pTargetBitmap, const Vector& targetPos = Vector()) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Protected member variable and method declarations - + /// Protected member variable and method declarations protected: // Member variables static Entity::ClassInfo m_sClass; @@ -221,18 +142,10 @@ namespace RTE { // Position of music being played, used to recover playback state after pause double m_LastMusicPos; - ////////////////////////////////////////////////////////////////////////////////////////// - // Private member variable and method declarations - + /// Private member variable and method declarations private: - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Clear - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears all the member variables of this Activity, effectively - // resetting the members of this abstraction level only. - // Arguments: None. - // Return value: None. - + /// Clears all the member variables of this Activity, effectively + /// resetting the members of this abstraction level only. void Clear(); }; diff --git a/Source/Activities/MultiplayerServerLobby.cpp b/Source/Activities/MultiplayerServerLobby.cpp index 43debc89c8..0d94e8ee4b 100644 --- a/Source/Activities/MultiplayerServerLobby.cpp +++ b/Source/Activities/MultiplayerServerLobby.cpp @@ -1,13 +1,3 @@ -////////////////////////////////////////////////////////////////////////////////////////// -// File: MultiplayerServerLobby.cpp -////////////////////////////////////////////////////////////////////////////////////////// -// Description: -// Project: Retro Terrain Engine -// Author(s): - -////////////////////////////////////////////////////////////////////////////////////////// -// Inclusions of header files - #include "MultiplayerServerLobby.h" #include "PresetMan.h" @@ -44,12 +34,6 @@ namespace RTE { ConcreteClassInfo(MultiplayerServerLobby, Activity, 0); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Clear - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears all the member variables of this MultiplayerServerLobby, effectively - // resetting the members of this abstraction level only. - void MultiplayerServerLobby::Clear() { // m_pEditorGUI = 0; m_pGUIController = 0; @@ -103,11 +87,6 @@ namespace RTE { m_pUIDrawBitmap = 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes the MultiplayerServerLobby object ready for use. - int MultiplayerServerLobby::Create() { if (Activity::Create() < 0) return -1; @@ -115,11 +94,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Creates a MultiplayerServerLobby to be identical to another, by deep copy. - int MultiplayerServerLobby::Create(const MultiplayerServerLobby& reference) { if (Activity::Create(reference) < 0) return -1; @@ -130,34 +104,15 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: ReadProperty - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Reads a property value from a reader stream. If the name isn't - // recognized by this class, then ReadProperty of the parent class - // is called. If the property isn't recognized by any of the base classes, - // false is returned, and the reader's position is untouched. - int MultiplayerServerLobby::ReadProperty(const std::string_view& propName, Reader& reader) { return Activity::ReadProperty(propName, reader); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Save - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Saves the complete state of this MultiplayerServerLobby with a Writer for - // later recreation with Create(Reader &reader); - int MultiplayerServerLobby::Save(Writer& writer) const { Activity::Save(writer); return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destroys and resets (through Clear()) the MultiplayerServerLobby object. - void MultiplayerServerLobby::Destroy(bool notInherited) { delete m_pGUIController; delete m_pGUIInput; @@ -175,12 +130,6 @@ namespace RTE { Clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Start - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Officially starts this. Creates all the data etc necessary to start - // the activity. - int MultiplayerServerLobby::Start() { int error = GameActivity::Start(); @@ -1024,13 +973,6 @@ namespace RTE { UpdateInput(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: UpdateInput - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the user input processing. - // Arguments: None. - // Return value: None. - void MultiplayerServerLobby::UpdateInput() { // Move the dialog to the center of the player 0 screen so it could operate in absoute mouse coordintaes of the player 0 screen // During draw we move the dialog to 0,0 before drawing to draw it properly into the intermediate buffer co we can draw it centered on other player's screens. diff --git a/Source/Activities/MultiplayerServerLobby.h b/Source/Activities/MultiplayerServerLobby.h index 03fa83e5ea..49840cc973 100644 --- a/Source/Activities/MultiplayerServerLobby.h +++ b/Source/Activities/MultiplayerServerLobby.h @@ -1,16 +1,9 @@ #ifndef _RTEMULTIPLAYERSERVERLOBBY_ #define _RTEMULTIPLAYERSERVERLOBBY_ -////////////////////////////////////////////////////////////////////////////////////////// -// File: MultiplayerServerLobby.h -////////////////////////////////////////////////////////////////////////////////////////// -// Description: -// Project: Retro Terrain Engine -// Author(s): - -////////////////////////////////////////////////////////////////////////////////////////// -// Inclusions of header files - +/// Description: +/// Author(s): +/// Inclusions of header files #include "RTETools.h" #include "ActivityMan.h" #include "GameActivity.h" @@ -32,144 +25,74 @@ namespace RTE { class Scene; class Activity; - ////////////////////////////////////////////////////////////////////////////////////////// - // Class: MultiplayerServerLobby - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Activity for editing scenes. - // Parent(s): EditorActivity. - // Class history: 8/30/2007 MultiplayerServerLobby created, inheriting directly from Activity. - // 9/17/2007 Spliced out and made to derive from EditorActivty - + /// Activity for editing scenes. + /// 9/17/2007 Spliced out and made to derive from EditorActivty class MultiplayerServerLobby : public GameActivity { - ////////////////////////////////////////////////////////////////////////////////////////// - // Public member variable, method and friend function declarations - + /// Public member variable, method and friend function declarations public: // Concrete allocation and cloning definitions EntityAllocation(MultiplayerServerLobby); SerializableOverrideMethods; ClassInfoGetters; - ////////////////////////////////////////////////////////////////////////////////////////// - // Constructor: MultiplayerServerLobby - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Constructor method used to instantiate a MultiplayerServerLobby object in system - // memory. Create() should be called before using the object. - // Arguments: None. - + /// Constructor method used to instantiate a MultiplayerServerLobby object in system + /// memory. Create() should be called before using the object. MultiplayerServerLobby() { Clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Destructor: ~MultiplayerServerLobby - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destructor method used to clean up a MultiplayerServerLobby object before deletion - // from system memory. - // Arguments: None. - + /// Destructor method used to clean up a MultiplayerServerLobby object before deletion + /// from system memory. ~MultiplayerServerLobby() override { Destroy(true); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes the MultiplayerServerLobby object ready for use. - // Arguments: None. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Makes the MultiplayerServerLobby object ready for use. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Create() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Creates a MultiplayerServerLobby to be identical to another, by deep copy. - // Arguments: A reference to the MultiplayerServerLobby to deep copy. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Creates a MultiplayerServerLobby to be identical to another, by deep copy. + /// @param reference A reference to the MultiplayerServerLobby to deep copy. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Create(const MultiplayerServerLobby& reference); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Reset - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Resets the entire MultiplayerServerLobby, including its inherited members, to their - // default settings or values. - // Arguments: None. - // Return value: None. - + /// Resets the entire MultiplayerServerLobby, including its inherited members, to their + /// default settings or values. void Reset() override { Clear(); Activity::Reset(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destroys and resets (through Clear()) the MultiplayerServerLobby object. - // Arguments: Whether to only destroy the members defined in this derived class, or - // to destroy all inherited members also. - // Return value: None. - + /// Destroys and resets (through Clear()) the MultiplayerServerLobby object. + /// @param notInherited Whether to only destroy the members defined in this derived class, or (default: false) + /// to destroy all inherited members also. void Destroy(bool notInherited = false) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Start - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Officially starts the game accroding to parameters previously set. - // Arguments: None. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Officially starts the game accroding to parameters previously set. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Start() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Pause - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Pauses and unpauses the game. - // Arguments: Whether to pause the game or not. - // Return value: None. - + /// Pauses and unpauses the game. + /// @param pause Whether to pause the game or not. (default: true) void SetPaused(bool pause = true) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: End - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Forces the current game's end. - // Arguments: None. - // Return value: None. - + /// Forces the current game's end. void End() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Update - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the state of this ActivityMan. Supposed to be done every frame - // before drawing. - // Arguments: None. - // Return value: None. - + /// Updates the state of this ActivityMan. Supposed to be done every frame + /// before drawing. void Update() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: DrawGUI - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws the currently active GUI of a screen to a BITMAP of choice. - // Arguments: A pointer to a screen-sized BITMAP to draw on. - // The absolute position of the target bitmap's upper left corner in the scene. - // Which screen's GUI to draw onto the bitmap. - // Return value: None. - + /// Draws the currently active GUI of a screen to a BITMAP of choice. + /// @param pTargetBitmap A pointer to a screen-sized BITMAP to draw on. + /// @param targetPos The absolute position of the target bitmap's upper left corner in the scene. (default: Vector()) + /// @param which Which screen's GUI to draw onto the bitmap. (default: 0) void DrawGUI(BITMAP* pTargetBitmap, const Vector& targetPos = Vector(), int which = 0) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Draw - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws this ActivityMan's current graphical representation to a - // BITMAP of choice. This includes all game-related graphics. - // Arguments: A pointer to a BITMAP to draw on. OWNERSHIP IS NOT TRANSFERRED! - // The absolute position of the target bitmap's upper left corner in the scene. - // Return value: None. - + /// Draws this ActivityMan's current graphical representation to a + /// BITMAP of choice. This includes all game-related graphics. + /// @param pTargetBitmap A pointer to a BITMAP to draw on. OWNERSHIP IS NOT TRANSFERRED! + /// @param targetPos The absolute position of the target bitmap's upper left corner in the scene. (default: Vector()) void Draw(BITMAP* pTargetBitmap, const Vector& targetPos = Vector()) override; void UpdateInput(); @@ -192,9 +115,7 @@ namespace RTE { int PlayerCount(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Protected member variable and method declarations - + /// Protected member variable and method declarations protected: // These add on the player and team max counts enum PlayerColumns { @@ -271,18 +192,10 @@ namespace RTE { // The map of Activity:ies, and the Scene:s compatible with each, neither of which are owned here std::map> m_Activities; - ////////////////////////////////////////////////////////////////////////////////////////// - // Private member variable and method declarations - + /// Private member variable and method declarations private: - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Clear - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears all the member variables of this Activity, effectively - // resetting the members of this abstraction level only. - // Arguments: None. - // Return value: None. - + /// Clears all the member variables of this Activity, effectively + /// resetting the members of this abstraction level only. void Clear(); }; diff --git a/Source/Activities/SceneEditor.cpp b/Source/Activities/SceneEditor.cpp index 70737d6454..fab32e5d63 100644 --- a/Source/Activities/SceneEditor.cpp +++ b/Source/Activities/SceneEditor.cpp @@ -1,15 +1,3 @@ -////////////////////////////////////////////////////////////////////////////////////////// -// File: SceneEditor.cpp -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Source file for the SceneEditor class. -// Project: Retro Terrain Engine -// Author(s): Daniel Tabar -// data@datarealms.com -// http://www.datarealms.com - -////////////////////////////////////////////////////////////////////////////////////////// -// Inclusions of header files - #include "SceneEditor.h" #include "WindowMan.h" @@ -43,12 +31,6 @@ namespace RTE { ConcreteClassInfo(SceneEditor, EditorActivity, 0); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Clear - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears all the member variables of this SceneEditor, effectively - // resetting the members of this abstraction level only. - void SceneEditor::Clear() { m_pEditorGUI = 0; m_pNewTerrainCombo = 0; @@ -57,11 +39,6 @@ namespace RTE { m_pNewBG3Combo = 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes the SceneEditor object ready for use. - int SceneEditor::Create() { if (EditorActivity::Create() < 0) return -1; @@ -69,11 +46,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Creates a SceneEditor to be identical to another, by deep copy. - int SceneEditor::Create(const SceneEditor& reference) { if (EditorActivity::Create(reference) < 0) return -1; @@ -84,14 +56,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: ReadProperty - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Reads a property value from a reader stream. If the name isn't - // recognized by this class, then ReadProperty of the parent class - // is called. If the property isn't recognized by any of the base classes, - // false is returned, and the reader's position is untouched. - int SceneEditor::ReadProperty(const std::string_view& propName, Reader& reader) { StartPropertyList(return EditorActivity::ReadProperty(propName, reader)); /* @@ -102,22 +66,11 @@ namespace RTE { EndPropertyList; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Save - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Saves the complete state of this SceneEditor with a Writer for - // later recreation with Create(Reader &reader); - int SceneEditor::Save(Writer& writer) const { EditorActivity::Save(writer); return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destroys and resets (through Clear()) the SceneEditor object. - void SceneEditor::Destroy(bool notInherited) { delete m_pEditorGUI; @@ -126,12 +79,6 @@ namespace RTE { Clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Start - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Officially starts this. Creates all the data etc necessary to start - // the activity. - int SceneEditor::Start() { int error = EditorActivity::Start(); @@ -225,33 +172,17 @@ namespace RTE { return error; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Pause - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Pauses and unpauses the game. - void SceneEditor::SetPaused(bool pause) { // Override the pause m_Paused = false; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: End - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Forces the current game's end. - void SceneEditor::End() { EditorActivity::End(); m_ActivityState = ActivityState::Over; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Update - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the state of this SceneEditor. Supposed to be done every frame - // before drawing. - void SceneEditor::Update() { EditorActivity::Update(); @@ -550,29 +481,16 @@ namespace RTE { } } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: DrawGUI - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws the currently active GUI of a screen to a BITMAP of choice. - void SceneEditor::DrawGUI(BITMAP* pTargetBitmap, const Vector& targetPos, int which) { m_pEditorGUI->Draw(pTargetBitmap, targetPos); EditorActivity::DrawGUI(pTargetBitmap, targetPos, which); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Draw - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws this SceneEditor's current graphical representation to a - // BITMAP of choice. This includes all game-related graphics. - void SceneEditor::Draw(BITMAP* pTargetBitmap, const Vector& targetPos) { EditorActivity::Draw(pTargetBitmap, targetPos); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool SceneEditor::SaveScene(const std::string& saveAsName, bool forceOverwrite) { Scene* editedScene = g_SceneMan.GetScene(); editedScene->SetPresetName(saveAsName); @@ -641,11 +559,6 @@ namespace RTE { return false; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: UpdateNewDialog - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the New dialog box, populates its lists etc. - void SceneEditor::UpdateNewDialog() { int scenesIndex = 0; @@ -717,11 +630,6 @@ namespace RTE { m_pNewBG3Combo->SetSelectedIndex(0); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: UpdateLoadDialog - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the Load dialog box, populates its lists etc. - void SceneEditor::UpdateLoadDialog() { // Clear out the control m_pLoadNameCombo->ClearList(); @@ -743,11 +651,6 @@ namespace RTE { m_pLoadNameCombo->SetSelectedIndex(0); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: UpdateSaveDialog - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the Save dialog box, populates its lists etc. - void SceneEditor::UpdateSaveDialog() { m_pSaveNameBox->SetText((g_SceneMan.GetScene()->GetPresetName() == "None" || !m_HasEverBeenSaved) ? "New Scene" : g_SceneMan.GetScene()->GetPresetName()); @@ -757,11 +660,6 @@ namespace RTE { m_pSaveModuleLabel->SetText("Will save in " + g_PresetMan.GetDataModule(m_ModuleSpaceID)->GetFileName() + "/Scenes"); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: UpdateChangesDialog - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the Save Changes dialog box, populates its lists etc. - void SceneEditor::UpdateChangesDialog() { if (m_HasEverBeenSaved) { dynamic_cast(m_pGUIController->GetControl("ChangesExpLabel"))->SetText("Do you want to save your changes to:"); @@ -775,11 +673,6 @@ namespace RTE { } } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: UpdateOverwriteDialog - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the Overwrite dialog box, populates its lists etc. - void SceneEditor::UpdateOverwriteDialog() { if (g_PresetMan.GetDataModule(m_ModuleSpaceID)->GetFileName() == c_UserScenesModuleName) m_pOverwriteNameLabel->SetText(g_PresetMan.GetDataModule(m_ModuleSpaceID)->GetFileName() + "/" + g_SceneMan.GetScene()->GetPresetName()); diff --git a/Source/Activities/SceneEditor.h b/Source/Activities/SceneEditor.h index 784628a8cd..225cd0936c 100644 --- a/Source/Activities/SceneEditor.h +++ b/Source/Activities/SceneEditor.h @@ -1,18 +1,11 @@ #ifndef _RTESCENEEDITOR_ #define _RTESCENEEDITOR_ -////////////////////////////////////////////////////////////////////////////////////////// -// File: SceneEditor.h -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Header file for the SceneEditor class. -// Project: Retro Terrain Engine -// Author(s): Daniel Tabar -// data@datarealms.com -// http://www.datarealms.com - -////////////////////////////////////////////////////////////////////////////////////////// -// Inclusions of header files - +/// Header file for the SceneEditor class. +/// @author Daniel Tabar +/// data@datarealms.com +/// http://www.datarealms.com +/// Inclusions of header files #include "RTETools.h" #include "EditorActivity.h" @@ -30,219 +23,105 @@ namespace RTE { class GUILabel; class GUIComboBox; - ////////////////////////////////////////////////////////////////////////////////////////// - // Class: SceneEditor - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Activity for editing scenes. - // Parent(s): EditorActivity. - // Class history: 8/30/2007 SceneEditor created, inheriting directly from Activity. - // 9/17/2007 Spliced out and made to derive from EditorActivty - + /// Activity for editing scenes. + /// 9/17/2007 Spliced out and made to derive from EditorActivty class SceneEditor : public EditorActivity { - ////////////////////////////////////////////////////////////////////////////////////////// - // Public member variable, method and friend function declarations - + /// Public member variable, method and friend function declarations public: // Concrete allocation and cloning definitions EntityAllocation(SceneEditor); SerializableOverrideMethods; ClassInfoGetters; - ////////////////////////////////////////////////////////////////////////////////////////// - // Constructor: SceneEditor - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Constructor method used to instantiate a SceneEditor object in system - // memory. Create() should be called before using the object. - // Arguments: None. - + /// Constructor method used to instantiate a SceneEditor object in system + /// memory. Create() should be called before using the object. SceneEditor() { Clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Destructor: ~SceneEditor - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destructor method used to clean up a SceneEditor object before deletion - // from system memory. - // Arguments: None. - + /// Destructor method used to clean up a SceneEditor object before deletion + /// from system memory. ~SceneEditor() override { Destroy(true); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes the SceneEditor object ready for use. - // Arguments: None. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Makes the SceneEditor object ready for use. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Create() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Creates a SceneEditor to be identical to another, by deep copy. - // Arguments: A reference to the SceneEditor to deep copy. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Creates a SceneEditor to be identical to another, by deep copy. + /// @param reference A reference to the SceneEditor to deep copy. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Create(const SceneEditor& reference); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Reset - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Resets the entire SceneEditor, including its inherited members, to their - // default settings or values. - // Arguments: None. - // Return value: None. - + /// Resets the entire SceneEditor, including its inherited members, to their + /// default settings or values. void Reset() override { Clear(); EditorActivity::Reset(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destroys and resets (through Clear()) the SceneEditor object. - // Arguments: Whether to only destroy the members defined in this derived class, or - // to destroy all inherited members also. - // Return value: None. - + /// Destroys and resets (through Clear()) the SceneEditor object. + /// @param notInherited Whether to only destroy the members defined in this derived class, or (default: false) + /// to destroy all inherited members also. void Destroy(bool notInherited = false) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetEditorMode - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the current mode of this editor. - // Arguments: The new mode to set to, see the EditorGUIMode enum. - // Return value: None. - + /// Sets the current mode of this editor. + /// @param newMode The new mode to set to, see the EditorGUIMode enum. void SetEditorMode(EditorActivity::EditorMode newMode) { m_EditorMode = newMode; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetEditorMode - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the current mode of this editor. - // Arguments: None. - // Return value: The current mode this is set to; see the EditorGUIMode enum. - + /// Gets the current mode of this editor. + /// @return The current mode this is set to; see the EditorGUIMode enum. EditorActivity::EditorMode GetEditorMode() const { return m_EditorMode; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Start - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Officially starts the game accroding to parameters previously set. - // Arguments: None. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Officially starts the game accroding to parameters previously set. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Start() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Pause - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Pauses and unpauses the game. - // Arguments: Whether to pause the game or not. - // Return value: None. - + /// Pauses and unpauses the game. + /// @param pause Whether to pause the game or not. (default: true) void SetPaused(bool pause = true) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: End - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Forces the current game's end. - // Arguments: None. - // Return value: None. - + /// Forces the current game's end. void End() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Update - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the state of this ActivityMan. Supposed to be done every frame - // before drawing. - // Arguments: None. - // Return value: None. - + /// Updates the state of this ActivityMan. Supposed to be done every frame + /// before drawing. void Update() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: DrawGUI - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws the currently active GUI of a screen to a BITMAP of choice. - // Arguments: A pointer to a screen-sized BITMAP to draw on. - // The absolute position of the target bitmap's upper left corner in the scene. - // Which screen's GUI to draw onto the bitmap. - // Return value: None. - + /// Draws the currently active GUI of a screen to a BITMAP of choice. + /// @param pTargetBitmap A pointer to a screen-sized BITMAP to draw on. + /// @param targetPos The absolute position of the target bitmap's upper left corner in the scene. (default: Vector()) + /// @param which Which screen's GUI to draw onto the bitmap. (default: 0) void DrawGUI(BITMAP* pTargetBitmap, const Vector& targetPos = Vector(), int which = 0) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Draw - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws this ActivityMan's current graphical representation to a - // BITMAP of choice. This includes all game-related graphics. - // Arguments: A pointer to a BITMAP to draw on. OWNERSHIP IS NOT TRANSFERRED! - // The absolute position of the target bitmap's upper left corner in the scene. - // Return value: None. - + /// Draws this ActivityMan's current graphical representation to a + /// BITMAP of choice. This includes all game-related graphics. + /// @param pTargetBitmap A pointer to a BITMAP to draw on. OWNERSHIP IS NOT TRANSFERRED! + /// @param targetPos The absolute position of the target bitmap's upper left corner in the scene. (default: Vector()) void Draw(BITMAP* pTargetBitmap, const Vector& targetPos = Vector()) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Protected member variable and method declarations - + /// Protected member variable and method declarations protected: - /// /// Saves the current Scene to an appropriate ini file, and asks user if they want to overwrite first if scene of this name exists. - /// - /// The name of the new Scene to be saved. - /// Whether to force any existing Scene of that name to be overwritten if it already exists. - /// Whether actually managed to save. Will return false both if a scene of this name already exists, or if other error. + /// @param saveAsName The name of the new Scene to be saved. + /// @param forceOverwrite Whether to force any existing Scene of that name to be overwritten if it already exists. + /// @return Whether actually managed to save. Will return false both if a scene of this name already exists, or if other error. bool SaveScene(const std::string& saveAsName, bool forceOverwrite = false); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virutal method: UpdateNewDialog - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the New dialog box, populates its lists etc. - // Arguments: None. - // Return value: None. - + /// Updates the New dialog box, populates its lists etc. void UpdateNewDialog() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virutal method: UpdateLoadDialog - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the Load dialog box, populates its lists etc. - // Arguments: None. - // Return value: None. - + /// Updates the Load dialog box, populates its lists etc. void UpdateLoadDialog() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virutal method: UpdateSaveDialog - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the Save dialog box, populates its lists etc. - // Arguments: None. - // Return value: None. - + /// Updates the Save dialog box, populates its lists etc. void UpdateSaveDialog() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virutal method: UpdateChangesDialog - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the Save Changes dialog box, populates its lists etc. - // Arguments: None. - // Return value: None. - + /// Updates the Save Changes dialog box, populates its lists etc. void UpdateChangesDialog() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virutal method: UpdateOverwriteDialog - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the Overwrite dialog box, populates its lists etc. - // Arguments: None. - // Return value: None. - + /// Updates the Overwrite dialog box, populates its lists etc. void UpdateOverwriteDialog() override; // Member variables @@ -260,18 +139,10 @@ namespace RTE { // The combobox which lists all the background SceneLayer:s that can be loaded for a new scene, far/sky GUIComboBox* m_pNewBG3Combo; - ////////////////////////////////////////////////////////////////////////////////////////// - // Private member variable and method declarations - + /// Private member variable and method declarations private: - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Clear - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears all the member variables of this Activity, effectively - // resetting the members of this abstraction level only. - // Arguments: None. - // Return value: None. - + /// Clears all the member variables of this Activity, effectively + /// resetting the members of this abstraction level only. void Clear(); }; diff --git a/Source/Entities/ACDropShip.cpp b/Source/Entities/ACDropShip.cpp index e0a1a20d7e..95f5d0b582 100644 --- a/Source/Entities/ACDropShip.cpp +++ b/Source/Entities/ACDropShip.cpp @@ -1,15 +1,3 @@ -////////////////////////////////////////////////////////////////////////////////////////// -// File: ACDropShip.cpp -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Source file for the ACDropShip class. -// Project: Retro Terrain Engine -// Author(s): Daniel Tabar -// data@datarealms.com -// http://www.datarealms.com - -////////////////////////////////////////////////////////////////////////////////////////// -// Inclusions of header files - #include "ACDropShip.h" #include "AtomGroup.h" #include "Controller.h" @@ -23,12 +11,6 @@ namespace RTE { ConcreteClassInfo(ACDropShip, ACraft, 10); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Clear - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears all the member variables of this ACDropShip, effectively - // resetting the members of this abstraction level only. - void ACDropShip::Clear() { m_pBodyAG = 0; m_pRThruster = 0; @@ -46,11 +28,6 @@ namespace RTE { m_HoverHeightModifier = 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes the ACDropShip object ready for use. - int ACDropShip::Create() { if (ACraft::Create() < 0) return -1; @@ -62,11 +39,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Creates a ACDropShip to be identical to another, by deep copy. - int ACDropShip::Create(const ACDropShip& reference) { if (reference.m_pRThruster) { m_ReferenceHardcodedAttachableUniqueIDs.insert(reference.m_pRThruster->GetUniqueID()); @@ -124,14 +96,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: ReadProperty - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Reads a property value from a reader stream. If the name isn't - // recognized by this class, then ReadProperty of the parent class - // is called. If the property isn't recognized by any of the base classes, - // false is returned, and the reader's position is untouched. - int ACDropShip::ReadProperty(const std::string_view& propName, Reader& reader) { StartPropertyList(return ACraft::ReadProperty(propName, reader)); @@ -150,12 +114,6 @@ namespace RTE { EndPropertyList; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Save - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Saves the complete state of this ACDropShip with a Writer for - // later recreation with Create(Reader &reader); - int ACDropShip::Save(Writer& writer) const { ACraft::Save(writer); @@ -184,11 +142,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destroys and resets (through Clear()) the ACDropShip object. - void ACDropShip::Destroy(bool notInherited) { delete m_pBodyAG; @@ -197,12 +150,6 @@ namespace RTE { Clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: GetAltitude - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the altitide of this' pos (or appropriate low point) over the - // terrain, in pixels. - float ACDropShip::GetAltitude(int max, int accuracy) { // Check altitude both thrusters, and report the one closest to the ground. Vector rPos, lPos; @@ -230,11 +177,6 @@ namespace RTE { return MIN(cAlt, MIN(rAlt, lAlt)); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: DetectObstacle - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Checks for obstacles in the travel direction. - MOID ACDropShip::DetectObstacle(float distance) { // Check altitude both thrusters, and report the one closest to the ground. Vector rPos, lPos; @@ -278,8 +220,6 @@ namespace RTE { return false; } - ////////////////////////////////////////////////////////////////////////////////////////// - void ACDropShip::PreControllerUpdate() { ZoneScoped; @@ -491,8 +431,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ACDropShip::SetRightThruster(AEmitter* newThruster) { if (m_pRThruster && m_pRThruster->IsAttached()) { RemoveAndDeleteAttachable(m_pRThruster); @@ -516,8 +454,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ACDropShip::SetLeftThruster(AEmitter* newThruster) { if (m_pLThruster && m_pLThruster->IsAttached()) { RemoveAndDeleteAttachable(m_pLThruster); @@ -541,8 +477,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ACDropShip::SetURightThruster(AEmitter* newThruster) { if (m_pURThruster && m_pURThruster->IsAttached()) { RemoveAndDeleteAttachable(m_pURThruster); @@ -565,8 +499,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ACDropShip::SetULeftThruster(AEmitter* newThruster) { if (m_pULThruster && m_pULThruster->IsAttached()) { RemoveAndDeleteAttachable(m_pULThruster); @@ -589,8 +521,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ACDropShip::SetRightHatch(Attachable* newHatch) { if (m_pRHatch && m_pRHatch->IsAttached()) { RemoveAndDeleteAttachable(m_pRHatch); @@ -612,8 +542,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ACDropShip::SetLeftHatch(Attachable* newHatch) { if (m_pLHatch && m_pLHatch->IsAttached()) { RemoveAndDeleteAttachable(m_pLHatch); diff --git a/Source/Entities/ACDropShip.h b/Source/Entities/ACDropShip.h index 3324024498..c935172d42 100644 --- a/Source/Entities/ACDropShip.h +++ b/Source/Entities/ACDropShip.h @@ -1,287 +1,164 @@ #ifndef _RTEACDROPSHIP_ #define _RTEACDROPSHIP_ -////////////////////////////////////////////////////////////////////////////////////////// -// File: ACDropShip.h -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Header file for the ACDropShip class. -// Project: Retro Terrain Engine -// Author(s): Daniel Tabar -// data@datarealms.com -// http://www.datarealms.com - -////////////////////////////////////////////////////////////////////////////////////////// -// Inclusions of header files - +/// Header file for the ACDropShip class. +/// @author Daniel Tabar +/// data@datarealms.com +/// http://www.datarealms.com +/// Inclusions of header files #include "ACraft.h" namespace RTE { class Attachable; - ////////////////////////////////////////////////////////////////////////////////////////// - // Class: ACDropShip - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: A hovering craft, with two engines on each attached on each end which - // tilt independently of the body to achieve steering. - // Parent(s): ACraft. - // Class history: 12/13/2006 ACDropShip created. - + /// A hovering craft, with two engines on each attached on each end which + /// tilt independently of the body to achieve steering. class ACDropShip : public ACraft { - ////////////////////////////////////////////////////////////////////////////////////////// - // Public member variable, method and friend function declarations - + /// Public member variable, method and friend function declarations public: // Concrete allocation and cloning definitions EntityAllocation(ACDropShip); SerializableOverrideMethods; ClassInfoGetters; - ////////////////////////////////////////////////////////////////////////////////////////// - // Constructor: ACDropShip - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Constructor method used to instantiate a ACDropShip object in system - // memory. Create() should be called before using the object. - // Arguments: None. - + /// Constructor method used to instantiate a ACDropShip object in system + /// memory. Create() should be called before using the object. ACDropShip() { Clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Destructor: ~ACDropShip - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destructor method used to clean up a ACDropShip object before deletion - // from system memory. - // Arguments: None. - + /// Destructor method used to clean up a ACDropShip object before deletion + /// from system memory. ~ACDropShip() override { Destroy(true); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes the ACDropShip object ready for use. - // Arguments: None. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Makes the ACDropShip object ready for use. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Create() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Creates a ACDropShip to be identical to another, by deep copy. - // Arguments: A reference to the ACDropShip to deep copy. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Creates a ACDropShip to be identical to another, by deep copy. + /// @param reference A reference to the ACDropShip to deep copy. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Create(const ACDropShip& reference); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Reset - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Resets the entire ACDropShip, including its inherited members, to their - // default settings or values. - // Arguments: None. - // Return value: None. - + /// Resets the entire ACDropShip, including its inherited members, to their + /// default settings or values. void Reset() override { Clear(); ACraft::Reset(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destroys and resets (through Clear()) the SceneLayer object. - // Arguments: Whether to only destroy the members defined in this derived class, or - // to destroy all inherited members also. - // Return value: None. - + /// Destroys and resets (through Clear()) the SceneLayer object. + /// @param notInherited Whether to only destroy the members defined in this derived class, or (default: false) + /// to destroy all inherited members also. void Destroy(bool notInherited = false) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: GetAltitude - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the altitide of this' pos (or appropriate low point) over the - // terrain, in pixels. - // Arguments: The max altitude you care to check for. 0 Means check the whole scene's height. - // The accuracy within which measurement is acceptable. Higher number - // here means less calculation. - // Return value: The rough altitude over the terrain, in pixels. - + /// Gets the altitide of this' pos (or appropriate low point) over the + /// terrain, in pixels. + /// @param max The max altitude you care to check for. 0 Means check the whole scene's height. (default: 0) + /// @param accuracy The accuracy within which measurement is acceptable. Higher number (default: 0) + /// here means less calculation. + /// @return The rough altitude over the terrain, in pixels. float GetAltitude(int max = 0, int accuracy = 0) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: DetectObstacle - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Checks for obstacles in the travel direction. - // Arguments: How far ahead of travel direction to check for obstacles. - // Return value: Which MOID was detected as obstacle. g_NoMOID means nothing was detected. - + /// Checks for obstacles in the travel direction. + /// @param distance How far ahead of travel direction to check for obstacles. + /// @return Which MOID was detected as obstacle. g_NoMOID means nothing was detected. MOID DetectObstacle(float distance); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: AutoStabilizing - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Tells whether this has the means and will try to right itself, or if - // that's up to the Controller to do. - // Arguments: None. - // Return value: Wheter this will try to auto stabilize. - + /// Tells whether this has the means and will try to right itself, or if + /// that's up to the Controller to do. + /// @return Wheter this will try to auto stabilize. bool AutoStabilizing() override { return true; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: PreControllerUpdate - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Update called prior to controller update. Ugly hack. Supposed to be done every frame. - // Arguments: None. - // Return value: None. - + /// Update called prior to controller update. Ugly hack. Supposed to be done every frame. void PreControllerUpdate() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: GetMaxPassengers - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: The recomended, not absolute, maximum number of actors that fit in the - // invetory. Used by the activity AI. - // Arguments: None. - // Return value: An integer with the recomended number of actors that fit in the craft. - // Default is four. - + /// Virtual method: GetMaxPassengers + /// The recomended, not absolute, maximum number of actors that fit in the + /// invetory. Used by the activity AI. + /// @return An integer with the recomended number of actors that fit in the craft. + /// Default is four. int GetMaxPassengers() const override { return m_MaxPassengers > -1 ? m_MaxPassengers : 4; } - /// /// Gets the right side thruster of this ACDropship. - /// - /// A pointer to the right side thruster of this ACDropship. Ownership is NOT transferred. + /// @return A pointer to the right side thruster of this ACDropship. Ownership is NOT transferred. AEmitter* GetRightThruster() const { return m_pRThruster; } - /// /// Sets the right side thruster for this ACDropship. - /// - /// The new thruster to use. + /// @param newThruster The new thruster to use. void SetRightThruster(AEmitter* newThruster); - /// /// Gets the left side thruster of this ACDropship. - /// - /// A pointer to the left side thruster of this ACDropship. Ownership is NOT transferred. + /// @return A pointer to the left side thruster of this ACDropship. Ownership is NOT transferred. AEmitter* GetLeftThruster() const { return m_pLThruster; } - /// /// Sets the left side thruster for this ACDropship. - /// - /// The new thruster to use. + /// @param newThruster The new thruster to use. void SetLeftThruster(AEmitter* newThruster); - /// /// Gets the right side secondary thruster of this ACDropship. - /// - /// A pointer to the right side secondary thruster of this ACDropship. Ownership is NOT transferred. + /// @return A pointer to the right side secondary thruster of this ACDropship. Ownership is NOT transferred. AEmitter* GetURightThruster() const { return m_pURThruster; } - /// /// Sets the right side secondary thruster for this ACDropship. - /// - /// The new thruster to use. + /// @param newThruster The new thruster to use. void SetURightThruster(AEmitter* newThruster); - /// /// Gets the left side secondary thruster of this ACDropship. - /// - /// A pointer to the left side secondary thruster of this ACDropship. Ownership is NOT transferred. + /// @return A pointer to the left side secondary thruster of this ACDropship. Ownership is NOT transferred. AEmitter* GetULeftThruster() const { return m_pULThruster; } - /// /// Sets the left side secondary thruster for this ACDropship. - /// - /// The new thruster to use. + /// @param newThruster The new thruster to use. void SetULeftThruster(AEmitter* newThruster); - /// /// Gets the left side hatch of this ACDropship. - /// - /// A pointer to the left side hatch of this ACDropship. Ownership is NOT transferred. + /// @return A pointer to the left side hatch of this ACDropship. Ownership is NOT transferred. Attachable* GetLeftHatch() const { return m_pLHatch; } - /// /// Sets the left side hatch for this ACDropship. - /// - /// The new hatch to use. + /// @param newHatch The new hatch to use. void SetLeftHatch(Attachable* newHatch); - /// /// Gets the right side hatch of this ACDropship. - /// - /// A pointer to the right side hatch of this ACDropship. Ownership is NOT transferred. + /// @return A pointer to the right side hatch of this ACDropship. Ownership is NOT transferred. Attachable* GetRightHatch() const { return m_pRHatch; } - /// /// Sets the right side hatch for this ACDropship. - /// - /// The new hatch to use. + /// @param newHatch The new hatch to use. void SetRightHatch(Attachable* newHatch); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: GetMaxEngineAngle - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Get max engine rotation angle in degrees. - // Arguments: None. - // Return value: Max engine angle in degrees. - + /// Get max engine rotation angle in degrees. + /// @return Max engine angle in degrees. float GetMaxEngineAngle() const { return m_MaxEngineAngle; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: SetMaxEngineAngle - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets max engine rotation angle in degrees. - // Arguments: Max engine angle in degrees. - // Return value: None. - + /// Sets max engine rotation angle in degrees. + /// @param newAngle Max engine angle in degrees. void SetMaxEngineAngle(float newAngle) { m_MaxEngineAngle = newAngle; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: GetLateralControlSpeed - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the abstract rate of LateralControl change. Default is 6 - // Arguments: None. - // Return value: Current lateral control speed value. - + /// Gets the abstract rate of LateralControl change. Default is 6 + /// @return Current lateral control speed value. float GetLateralControlSpeed() const { return m_LateralControlSpeed; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: SetLateralControlSpeed - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the abstract rate of LateralControl change. Default is 6 - // Arguments: New lateral control speed value. - // Return value: None. - + /// Sets the abstract rate of LateralControl change. Default is 6 + /// @param newSpeed New lateral control speed value. void SetLateralControlSpeed(float newSpeed) { m_LateralControl = newSpeed; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: GetLateralControl - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets lateral control value -1.0 to 1.0 control of sideways movement. 0 means try to stand still in X. - // Arguments: None. - // Return value: Current lateral control value. - + /// Sets lateral control value -1.0 to 1.0 control of sideways movement. 0 means try to stand still in X. + /// @return Current lateral control value. float GetLateralControl() const { return m_LateralControl; } - /// /// Gets the modifier for height at which this ACDropship should hover above terrain. - /// - /// The modifier for height at which this ACDropship should hover above terrain. + /// @return The modifier for height at which this ACDropship should hover above terrain. float GetHoverHeightModifier() const { return m_HoverHeightModifier; } - /// /// Sets the modifier for height at which this ACDropship should hover above terrain. - /// - /// The new modifier for height at which this ACDropship should hover above terrain. + /// @param newHoverHeightModifier The new modifier for height at which this ACDropship should hover above terrain. void SetHoverHeightModifier(float newHoverHeightModifier) { m_HoverHeightModifier = newHoverHeightModifier; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Protected member variable and method declarations - + /// Protected member variable and method declarations protected: // Member variables static Entity::ClassInfo m_sClass; @@ -315,18 +192,10 @@ namespace RTE { float m_HoverHeightModifier; //!< The modifier for the height at which this ACDropShip should hover above terrain when releasing its cargo. Used in cpp and Lua AI. - ////////////////////////////////////////////////////////////////////////////////////////// - // Private member variable and method declarations - + /// Private member variable and method declarations private: - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Clear - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears all the member variables of this ACDropShip, effectively - // resetting the members of this abstraction level only. - // Arguments: None. - // Return value: None. - + /// Clears all the member variables of this ACDropShip, effectively + /// resetting the members of this abstraction level only. void Clear(); // Disallow the use of some implicit methods. diff --git a/Source/Entities/ACRocket.cpp b/Source/Entities/ACRocket.cpp index 7219d80b4c..054370be5d 100644 --- a/Source/Entities/ACRocket.cpp +++ b/Source/Entities/ACRocket.cpp @@ -1,15 +1,3 @@ -////////////////////////////////////////////////////////////////////////////////////////// -// File: ACRocket.cpp -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Source file for the ACRocket class. -// Project: Retro Terrain Engine -// Author(s): Daniel Tabar -// data@datarealms.com -// http://www.datarealms.com - -////////////////////////////////////////////////////////////////////////////////////////// -// Inclusions of header files - #include "ACRocket.h" #include "AtomGroup.h" #include "Attachable.h" @@ -27,12 +15,6 @@ namespace RTE { ConcreteClassInfo(ACRocket, ACraft, 10); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Clear - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears all the member variables of this ACRocket, effectively - // resetting the members of this abstraction level only. - void ACRocket::Clear() { // m_pCapsule = 0; m_pRLeg = 0; @@ -55,11 +37,6 @@ namespace RTE { m_MaxGimbalAngle = 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes the ACRocket object ready for use. - int ACRocket::Create() { // Read all the properties if (ACraft::Create() < 0) @@ -80,11 +57,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Creates a ACRocket to be identical to another, by deep copy. - int ACRocket::Create(const ACRocket& reference) { if (reference.m_pRLeg) { m_ReferenceHardcodedAttachableUniqueIDs.insert(reference.m_pRLeg->GetUniqueID()); @@ -165,14 +137,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: ReadProperty - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Reads a property value from a reader stream. If the name isn't - // recognized by this class, then ReadProperty of the parent class - // is called. If the property isn't recognized by any of the base classes, - // false is returned, and the reader's position is untouched. - int ACRocket::ReadProperty(const std::string_view& propName, Reader& reader) { StartPropertyList(return ACraft::ReadProperty(propName, reader)); @@ -207,12 +171,6 @@ namespace RTE { EndPropertyList; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Save - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Saves the complete state of this ACRocket with a Writer for - // later recreation with Create(Reader &reader); - int ACRocket::Save(Writer& writer) const { ACraft::Save(writer); @@ -248,11 +206,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destroys and resets (through Clear()) the ACRocket object. - void ACRocket::Destroy(bool notInherited) { delete m_pBodyAG; delete m_pRFootGroup; @@ -267,12 +220,6 @@ namespace RTE { Clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: GetAltitude - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the altitide of this' pos (or appropriate low point) over the - // terrain, in pixels. - float ACRocket::GetAltitude(int max, int accuracy) { // Use the main thruster's position as the position ot measure from Vector pos; @@ -284,8 +231,6 @@ namespace RTE { return g_SceneMan.FindAltitude(pos, max, accuracy, true); } - ////////////////////////////////////////////////////////////////////////////////////////// - void ACRocket::PreControllerUpdate() { ACraft::PreControllerUpdate(); @@ -424,8 +369,6 @@ namespace RTE { } } - ////////////////////////////////////////////////////////////////////////////////////////// - void ACRocket::Update() { ACraft::Update(); @@ -452,8 +395,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ACRocket::SetRightLeg(Leg* newLeg) { if (m_pRLeg && m_pRLeg->IsAttached()) { RemoveAndDeleteAttachable(m_pRLeg); @@ -476,8 +417,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ACRocket::SetLeftLeg(Leg* newLeg) { if (m_pLLeg && m_pLLeg->IsAttached()) { RemoveAndDeleteAttachable(m_pLLeg); @@ -501,8 +440,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ACRocket::SetMainThruster(AEmitter* newThruster) { if (m_pMThruster && m_pMThruster->IsAttached()) { RemoveAndDeleteAttachable(m_pMThruster); @@ -526,8 +463,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ACRocket::SetRightThruster(AEmitter* newThruster) { if (m_pRThruster && m_pRThruster->IsAttached()) { RemoveAndDeleteAttachable(m_pRThruster); @@ -551,8 +486,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ACRocket::SetLeftThruster(AEmitter* newThruster) { if (m_pLThruster && m_pLThruster->IsAttached()) { RemoveAndDeleteAttachable(m_pLThruster); @@ -576,8 +509,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ACRocket::SetURightThruster(AEmitter* newThruster) { if (m_pURThruster && m_pURThruster->IsAttached()) { RemoveAndDeleteAttachable(m_pURThruster); @@ -601,8 +532,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ACRocket::SetULeftThruster(AEmitter* newThruster) { if (m_pULThruster && m_pULThruster->IsAttached()) { RemoveAndDeleteAttachable(m_pULThruster); @@ -626,8 +555,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ACRocket::Draw(BITMAP* pTargetBitmap, const Vector& targetPos, DrawMode mode, bool onlyPhysical) const { ACraft::Draw(pTargetBitmap, targetPos, mode, onlyPhysical); diff --git a/Source/Entities/ACRocket.h b/Source/Entities/ACRocket.h index 9434db876a..f7395d7264 100644 --- a/Source/Entities/ACRocket.h +++ b/Source/Entities/ACRocket.h @@ -1,18 +1,11 @@ #ifndef _RTEACROCKET_ #define _RTEACROCKET_ -////////////////////////////////////////////////////////////////////////////////////////// -// File: ACRocket.h -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Header file for the ACRocket class. -// Project: Retro Terrain Engine -// Author(s): Daniel Tabar -// data@datarealms.com -// http://www.datarealms.com - -////////////////////////////////////////////////////////////////////////////////////////// -// Inclusions of header files - +/// Header file for the ACRocket class. +/// @author Daniel Tabar +/// data@datarealms.com +/// http://www.datarealms.com +/// Inclusions of header files #include "ACraft.h" namespace RTE { @@ -22,15 +15,9 @@ namespace RTE { class Leg; // class LimbPath; - ////////////////////////////////////////////////////////////////////////////////////////// - // Class: ACRocket - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: A rocket craft, with main engine and rotation of the whole body as a - // means of steering. - // Parent(s): ACraft. - // Class history: 09/02/2004 ARocket created. - // 12/13/2006 ARocket changed names to ACRocket, parent changed to ACraft - + /// A rocket craft, with main engine and rotation of the whole body as a + /// means of steering. + /// 12/13/2006 ARocket changed names to ACRocket, parent changed to ACraft class ACRocket : public ACraft { friend struct EntityLuaBindings; @@ -42,227 +29,137 @@ namespace RTE { GearStateCount }; - ////////////////////////////////////////////////////////////////////////////////////////// - // Public member variable, method and friend function declarations - + /// Public member variable, method and friend function declarations public: // Concrete allocation and cloning definitions EntityAllocation(ACRocket); SerializableOverrideMethods; ClassInfoGetters; - ////////////////////////////////////////////////////////////////////////////////////////// - // Constructor: ACRocket - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Constructor method used to instantiate a ACRocket object in system - // memory. Create() should be called before using the object. - // Arguments: None. - + /// Constructor method used to instantiate a ACRocket object in system + /// memory. Create() should be called before using the object. ACRocket() { Clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Destructor: ~ACRocket - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destructor method used to clean up a ACRocket object before deletion - // from system memory. - // Arguments: None. - + /// Destructor method used to clean up a ACRocket object before deletion + /// from system memory. ~ACRocket() override { Destroy(true); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes the ACRocket object ready for use. - // Arguments: None. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Makes the ACRocket object ready for use. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Create() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Creates a ACRocket to be identical to another, by deep copy. - // Arguments: A reference to the ACRocket to deep copy. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Creates a ACRocket to be identical to another, by deep copy. + /// @param reference A reference to the ACRocket to deep copy. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Create(const ACRocket& reference); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Reset - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Resets the entire ACRocket, including its inherited members, to their - // default settings or values. - // Arguments: None. - // Return value: None. - + /// Resets the entire ACRocket, including its inherited members, to their + /// default settings or values. void Reset() override { Clear(); ACraft::Reset(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destroys and resets (through Clear()) the SceneLayer object. - // Arguments: Whether to only destroy the members defined in this derived class, or - // to destroy all inherited members also. - // Return value: None. - + /// Destroys and resets (through Clear()) the SceneLayer object. + /// @param notInherited Whether to only destroy the members defined in this derived class, or (default: false) + /// to destroy all inherited members also. void Destroy(bool notInherited = false) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: GetAltitude - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the altitide of this' pos (or appropriate low point) over the - // terrain, in pixels. - // Arguments: The max altitude you care to check for. 0 Means check the whole scene's height. - // The accuracy within which measurement is acceptable. Higher number - // here means less calculation. - // Return value: The rough altitude over the terrain, in pixels. - + /// Gets the altitide of this' pos (or appropriate low point) over the + /// terrain, in pixels. + /// @param max The max altitude you care to check for. 0 Means check the whole scene's height. (default: 0) + /// @param accuracy The accuracy within which measurement is acceptable. Higher number (default: 0) + /// here means less calculation. + /// @return The rough altitude over the terrain, in pixels. float GetAltitude(int max = 0, int accuracy = 0) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: PreControllerUpdate - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Update called prior to controller update. Ugly hack. Supposed to be done every frame. - // Arguments: None. - // Return value: None. - + /// Update called prior to controller update. Ugly hack. Supposed to be done every frame. void PreControllerUpdate() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Update - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates this MovableObject. Supposed to be done every frame. - // Arguments: Nosssssssne. - // Return value: None. - + /// Updates this MovableObject. Supposed to be done every frame. + /// @param Nosssssssne. void Update() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Draw - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws this ACRocket's current graphical representation to a - // BITMAP of choice. - // Arguments: A pointer to a BITMAP to draw on. - // The absolute position of the target bitmap's upper left corner in the Scene. - // In which mode to draw in. See the DrawMode enumeration for the modes. - // Whether to not draw any extra 'ghost' items of this MovableObject, - // indicator arrows or hovering HUD text and so on. - // Return value: None. - + /// Draws this ACRocket's current graphical representation to a + /// BITMAP of choice. + /// @param pTargetBitmap A pointer to a BITMAP to draw on. + /// @param targetPos The absolute position of the target bitmap's upper left corner in the Scene. (default: Vector()) + /// @param mode In which mode to draw in. See the DrawMode enumeration for the modes. (default: g_DrawColor) + /// @param onlyPhysical Whether to not draw any extra 'ghost' items of this MovableObject, (default: false) + /// indicator arrows or hovering HUD text and so on. void Draw(BITMAP* pTargetBitmap, const Vector& targetPos = Vector(), DrawMode mode = g_DrawColor, bool onlyPhysical = false) const override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: GetMaxPassengers - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: The recomended, not absolute, maximum number of actors that fit in the - // invetory. Used by the activity AI. - // Arguments: None. - // Return value: An integer with the recomended number of actors that fit in the craft. - // Default is two. - + /// Virtual method: GetMaxPassengers + /// The recomended, not absolute, maximum number of actors that fit in the + /// invetory. Used by the activity AI. + /// @return An integer with the recomended number of actors that fit in the craft. + /// Default is two. int GetMaxPassengers() const override { return m_MaxPassengers > -1 ? m_MaxPassengers : 2; } - /// /// Gets the right leg of this ACRocket. - /// - /// A pointer to the right Leg of this ACRocket. Ownership is NOT transferred. + /// @return A pointer to the right Leg of this ACRocket. Ownership is NOT transferred. Leg* GetRightLeg() const { return m_pRLeg; } - /// /// Sets the right Leg for this ACRocket. - /// - /// The new Leg to use. + /// @param newLeg The new Leg to use. void SetRightLeg(Leg* newLeg); - /// /// Gets the left Leg of this ACRocket. - /// - /// A pointer to the left Leg of this ACRocket. Ownership is NOT transferred. + /// @return A pointer to the left Leg of this ACRocket. Ownership is NOT transferred. Leg* GetLeftLeg() const { return m_pLLeg; } - /// /// Sets the left Leg for this ACRocket. - /// - /// The new Leg to use. + /// @param newLeg The new Leg to use. void SetLeftLeg(Leg* newLeg); - /// /// Gets the main thruster of this ACRocket. - /// - /// A pointer to the main thruster of this ACRocket. Ownership is NOT transferred. + /// @return A pointer to the main thruster of this ACRocket. Ownership is NOT transferred. AEmitter* GetMainThruster() const { return m_pMThruster; } - /// /// Sets the main thruster for this ACRocket. - /// - /// The new thruster to use. + /// @param newThruster The new thruster to use. void SetMainThruster(AEmitter* newThruster); - /// /// Gets the right side thruster of this ACRocket. - /// - /// A pointer to the right side thruster of this ACRocket. Ownership is NOT transferred. + /// @return A pointer to the right side thruster of this ACRocket. Ownership is NOT transferred. AEmitter* GetRightThruster() const { return m_pRThruster; } - /// /// Sets the right side thruster for this ACRocket. - /// - /// The new thruster to use. + /// @param newThruster The new thruster to use. void SetRightThruster(AEmitter* newThruster); - /// /// Gets the left side thruster of this ACRocket. - /// - /// A pointer to the left side thruster of this ACRocket. Ownership is NOT transferred. + /// @return A pointer to the left side thruster of this ACRocket. Ownership is NOT transferred. AEmitter* GetLeftThruster() const { return m_pLThruster; } - /// /// Sets the left side thruster for this ACRocket. - /// - /// The new thruster to use. + /// @param newThruster The new thruster to use. void SetLeftThruster(AEmitter* newThruster); - /// /// Gets the right side secondary thruster of this ACRocket. - /// - /// A pointer to the right side secondary thruster of this ACRocket. Ownership is NOT transferred. + /// @return A pointer to the right side secondary thruster of this ACRocket. Ownership is NOT transferred. AEmitter* GetURightThruster() const { return m_pURThruster; } - /// /// Sets the right side secondary thruster for this ACRocket. - /// - /// The new thruster to use. + /// @param newThruster The new thruster to use. void SetURightThruster(AEmitter* newThruster); - /// /// Gets the left side secondary thruster of this ACRocket. - /// - /// A pointer to the left side secondary thruster of this ACRocket. Ownership is NOT transferred. + /// @return A pointer to the left side secondary thruster of this ACRocket. Ownership is NOT transferred. AEmitter* GetULeftThruster() const { return m_pULThruster; } - /// /// Sets the left side secondary thruster for this ACRocket. - /// - /// The new thruster to use. + /// @param newThruster The new thruster to use. void SetULeftThruster(AEmitter* newThruster); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetGearState - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the the landing gear state - // Arguments: None. - // Return value: Current landing gear state. - + /// Method: GetGearState + /// Gets the the landing gear state + /// @return Current landing gear state. unsigned int GetGearState() const { return m_GearState; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Protected member variable and method declarations - + /// Protected member variable and method declarations protected: // Member variables static Entity::ClassInfo m_sClass; @@ -290,18 +187,10 @@ namespace RTE { LimbPath m_Paths[2][GearStateCount]; float m_MaxGimbalAngle; //!< How much the main engine is able to tilt in order to stabilize the rocket. - ////////////////////////////////////////////////////////////////////////////////////////// - // Private member variable and method declarations - + /// Private member variable and method declarations private: - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Clear - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears all the member variables of this ACRocket, effectively - // resetting the members of this abstraction level only. - // Arguments: None. - // Return value: None. - + /// Clears all the member variables of this ACRocket, effectively + /// resetting the members of this abstraction level only. void Clear(); // Disallow the use of some implicit methods. diff --git a/Source/Entities/ACrab.cpp b/Source/Entities/ACrab.cpp index ddbcd6068b..e9053b6e7d 100644 --- a/Source/Entities/ACrab.cpp +++ b/Source/Entities/ACrab.cpp @@ -1,15 +1,3 @@ -////////////////////////////////////////////////////////////////////////////////////////// -// File: ACrab.cpp -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Source file for the ACrab class. -// Project: Retro Terrain Engine -// Author(s): Daniel Tabar -// data@datarealms.com -// http://www.datarealms.com - -////////////////////////////////////////////////////////////////////////////////////////// -// Inclusions of header files - #include "ACrab.h" #include "AtomGroup.h" @@ -36,12 +24,6 @@ namespace RTE { ConcreteClassInfo(ACrab, Actor, 20); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Clear - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears all the member variables of this ACrab, effectively - // resetting the members of this abstraction level only. - void ACrab::Clear() { m_pTurret = 0; m_pLFGLeg = 0; @@ -91,11 +73,6 @@ namespace RTE { m_LockMouseAimInput = false; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes the ACrab object ready for use. - int ACrab::Create() { // Read all the properties if (Actor::Create() < 0) { @@ -156,11 +133,6 @@ namespace RTE { } */ - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Creates a ACrab to be identical to another, by deep copy. - int ACrab::Create(const ACrab& reference) { if (reference.m_pLBGLeg) { m_ReferenceHardcodedAttachableUniqueIDs.insert(reference.m_pLBGLeg->GetUniqueID()); @@ -269,14 +241,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: ReadProperty - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Reads a property value from a reader stream. If the name isn't - // recognized by this class, then ReadProperty of the parent class - // is called. If the property isn't recognized by any of the base classes, - // false is returned, and the reader's position is untouched. - int ACrab::ReadProperty(const std::string_view& propName, Reader& reader) { StartPropertyList(return Actor::ReadProperty(propName, reader)); @@ -369,12 +333,6 @@ namespace RTE { EndPropertyList; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Save - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Saves the complete state of this ACrab with a Writer for - // later recreation with Create(Reader &reader); - int ACrab::Save(Writer& writer) const { Actor::Save(writer); @@ -424,11 +382,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destroys and resets (through Clear()) the ACrab object. - void ACrab::Destroy(bool notInherited) { delete m_pLFGFootGroup; delete m_pLBGFootGroup; @@ -474,12 +427,6 @@ namespace RTE { } */ - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: GetEyePos - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the absoltue position of this' eye, or equivalent, where look - // vector starts from. - Vector ACrab::GetEyePos() const { if (m_pTurret && m_pTurret->IsAttached() && m_pTurret->HasMountedDevice()) return m_pTurret->GetFirstMountedDevice()->GetPos(); @@ -487,8 +434,6 @@ namespace RTE { return m_Pos; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ACrab::SetTurret(Turret* newTurret) { if (m_pTurret && m_pTurret->IsAttached()) { RemoveAndDeleteAttachable(m_pTurret); @@ -511,8 +456,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ACrab::SetJetpack(AEJetpack* newJetpack) { if (m_pJetpack && m_pJetpack->IsAttached()) { RemoveAndDeleteAttachable(m_pJetpack); @@ -537,8 +480,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ACrab::SetLeftFGLeg(Leg* newLeg) { if (m_pLFGLeg && m_pLFGLeg->IsAttached()) { RemoveAndDeleteAttachable(m_pLFGLeg); @@ -562,8 +503,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ACrab::SetLeftBGLeg(Leg* newLeg) { if (m_pLBGLeg && m_pLBGLeg->IsAttached()) { RemoveAndDeleteAttachable(m_pLBGLeg); @@ -587,8 +526,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ACrab::SetRightFGLeg(Leg* newLeg) { if (m_pRFGLeg && m_pRFGLeg->IsAttached()) { RemoveAndDeleteAttachable(m_pRFGLeg); @@ -611,8 +548,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ACrab::SetRightBGLeg(Leg* newLeg) { if (m_pRBGLeg && m_pRBGLeg->IsAttached()) { RemoveAndDeleteAttachable(m_pRBGLeg); @@ -635,19 +570,10 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - BITMAP* ACrab::GetGraphicalIcon() const { return m_GraphicalIcon ? m_GraphicalIcon : (m_pTurret ? m_pTurret->GetSpriteFrame(0) : GetSpriteFrame(0)); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: CollideAtPoint - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Calculates the collision response when another MO's Atom collides with - // this MO's physical representation. The effects will be applied - // directly to this MO, and also represented in the passed in HitData. - bool ACrab::CollideAtPoint(HitData& hd) { return Actor::CollideAtPoint(hd); @@ -712,8 +638,6 @@ namespace RTE { } */ - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool ACrab::HandlePieCommand(PieSlice::SliceType pieSliceIndex) { if (pieSliceIndex != PieSlice::SliceType::NoType) { if (pieSliceIndex == PieSlice::SliceType::Reload) { @@ -736,13 +660,6 @@ namespace RTE { return false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual Method: GetEquippedItem - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns whatever is equipped in the turret, if anything. OWNERSHIP IS NOT TRANSFERRED! - MovableObject* ACrab::GetEquippedItem() const { if (m_pTurret && m_pTurret->IsAttached() && m_pTurret->HasMountedDevice()) { return m_pTurret->GetFirstMountedDevice(); @@ -751,12 +668,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual Method: FirearmIsReady - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Indicates whether the currently held device's current mag is empty on - // ammo or not. - bool ACrab::FirearmIsReady() const { if (m_pTurret && m_pTurret->IsAttached() && m_pTurret->HasMountedDevice()) { for (const HeldDevice* mountedDevice: m_pTurret->GetMountedDevices()) { @@ -769,20 +680,10 @@ namespace RTE { return false; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual Method: FirearmIsEmpty - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Indicates whether the currently held HDFirearm's is out of ammo. - bool ACrab::FirearmIsEmpty() const { return !FirearmIsReady() && m_pTurret && m_pTurret->IsAttached() && m_pTurret->HasMountedDevice(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual Method: FirearmNeedsReload - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Indicates whether the currently held HDFirearm's is almost out of ammo. - bool ACrab::FirearmsAreFull() const { if (m_pTurret && m_pTurret->IsAttached() && m_pTurret->HasMountedDevice()) { for (const HeldDevice* mountedDevice: m_pTurret->GetMountedDevices()) { @@ -794,8 +695,6 @@ namespace RTE { return true; } - ////////////////////////////////////////////////////////////////////////////////////////// - bool ACrab::FirearmNeedsReload() const { if (m_pTurret && m_pTurret->IsAttached() && m_pTurret->HasMountedDevice()) { for (const HeldDevice* mountedDevice: m_pTurret->GetMountedDevices()) { @@ -808,11 +707,6 @@ namespace RTE { return false; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual Method: FirearmIsSemiAuto - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Indicates whether the currently held HDFirearm's is semi or full auto. - bool ACrab::FirearmIsSemiAuto() const { if (m_pTurret && m_pTurret->IsAttached() && m_pTurret->HasMountedDevice()) { HDFirearm* pWeapon = dynamic_cast(m_pTurret->GetFirstMountedDevice()); @@ -821,13 +715,6 @@ namespace RTE { return false; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual Method: ReloadFirearms - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Reloads the currently held firearms, if any. - // Arguments: None. - // Return value: None. - void ACrab::ReloadFirearms() { if (m_pTurret && m_pTurret->IsAttached() && m_pTurret->HasMountedDevice()) { for (HeldDevice* mountedDevice: m_pTurret->GetMountedDevices()) { @@ -838,12 +725,6 @@ namespace RTE { } } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual Method: FirearmActivationDelay - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns the currently held device's delay between pulling the trigger - // and activating. - int ACrab::FirearmActivationDelay() const { // Check if the currently held device is already the desired type if (m_pTurret && m_pTurret->IsAttached() && m_pTurret->HasMountedDevice()) { @@ -855,12 +736,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: IsWithinRange - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Tells whether a point on the scene is within range of the currently - // used device and aiming status, if applicable. - bool ACrab::IsWithinRange(Vector& point) const { if (m_SharpAimMaxedOut) return true; @@ -884,13 +759,6 @@ namespace RTE { return sqrDistance <= (range * range); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Look - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Casts an unseen-revealing ray in the direction of where this is facing. - // Arguments: The degree angle to deviate from the current view point in the ray - // casting. A random ray will be chosen out of this +-range. - bool ACrab::Look(float FOVSpread, float range) { if (!g_SceneMan.AnythingUnseen(m_Team)) return false; @@ -925,13 +793,6 @@ namespace RTE { return g_SceneMan.CastSeeRay(m_Team, aimPos, lookVector, ignored, 25, (int)g_SceneMan.GetUnseenResolution(m_Team).GetSmallest() / 2); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: LookForMOs - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Casts an MO detecting ray in the direction of where the head is looking - // at the time. Factors including head rotation, sharp aim mode, and - // other variables determine how this ray is cast. - MovableObject* ACrab::LookForMOs(float FOVSpread, unsigned char ignoreMaterial, bool ignoreAllTerrain) { MovableObject* pSeenMO = 0; Vector aimPos = m_Pos; @@ -998,8 +859,6 @@ namespace RTE { } } - ////////////////////////////////////////////////////////////////////////////////////////// - void ACrab::PreControllerUpdate() { ZoneScoped; @@ -1417,8 +1276,6 @@ namespace RTE { } } - ////////////////////////////////////////////////////////////////////////////////////////// - void ACrab::Update() { ZoneScoped; @@ -1551,8 +1408,6 @@ namespace RTE { // m_DeepCheck = true/*m_Status == DEAD*/; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ACrab::Draw(BITMAP* pTargetBitmap, const Vector& targetPos, DrawMode mode, bool onlyPhysical) const { Actor::Draw(pTargetBitmap, targetPos, mode, onlyPhysical); @@ -1571,12 +1426,6 @@ namespace RTE { } } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: DrawHUD - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws this Actor's current graphical HUD overlay representation to a - // BITMAP of choice. - void ACrab::DrawHUD(BITMAP* pTargetBitmap, const Vector& targetPos, int whichScreen, bool playerControlled) { m_HUDStack = -m_CharHeight / 2; @@ -1786,20 +1635,10 @@ namespace RTE { } } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: GetLimbPathSpeed - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Get walking limb path speed for the specified preset. - float ACrab::GetLimbPathSpeed(int speedPreset) const { return m_Paths[LEFTSIDE][FGROUND][WALK].GetSpeed(speedPreset); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: SetLimbPathSpeed - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Set walking limb path speed for the specified preset. - void ACrab::SetLimbPathSpeed(int speedPreset, float speed) { m_Paths[LEFTSIDE][FGROUND][WALK].OverrideSpeed(speedPreset, speed); m_Paths[RIGHTSIDE][FGROUND][WALK].OverrideSpeed(speedPreset, speed); @@ -1808,22 +1647,10 @@ namespace RTE { m_Paths[RIGHTSIDE][BGROUND][WALK].OverrideSpeed(speedPreset, speed); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: GetLimbPathPushForce - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the force that a limb traveling walking LimbPath can push against - // stuff in the scene with. - float ACrab::GetLimbPathPushForce() const { return m_Paths[LEFTSIDE][FGROUND][WALK].GetDefaultPushForce(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: SetLimbPathPushForce - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the default force that a limb traveling walking LimbPath can push against - // stuff in the scene with. - void ACrab::SetLimbPathPushForce(float force) { m_Paths[LEFTSIDE][FGROUND][WALK].OverridePushForce(force); m_Paths[RIGHTSIDE][FGROUND][WALK].OverridePushForce(force); @@ -1832,8 +1659,6 @@ namespace RTE { m_Paths[RIGHTSIDE][BGROUND][WALK].OverridePushForce(force); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int ACrab::WhilePieMenuOpenListener(const PieMenu* pieMenu) { int result = Actor::WhilePieMenuOpenListener(pieMenu); diff --git a/Source/Entities/ACrab.h b/Source/Entities/ACrab.h index 8258f884c8..3bef3a1df1 100644 --- a/Source/Entities/ACrab.h +++ b/Source/Entities/ACrab.h @@ -1,18 +1,11 @@ #ifndef _RTEACRAB_ #define _RTEACRAB_ -////////////////////////////////////////////////////////////////////////////////////////// -// File: ACrab.h -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Header file for the ACrab class. -// Project: Retro Terrain Engine -// Author(s): Daniel Tabar -// data@datarealms.com -// http://www.datarealms.com - -////////////////////////////////////////////////////////////////////////////////////////// -// Inclusions of header files - +/// Header file for the ACrab class. +/// @author Daniel Tabar +/// data@datarealms.com +/// http://www.datarealms.com +/// Inclusions of header files #include "Actor.h" #include "LimbPath.h" #include "Leg.h" @@ -24,13 +17,7 @@ namespace RTE { class Turret; class AEJetpack; - ////////////////////////////////////////////////////////////////////////////////////////// - // Class: ACrab - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: A crab-like actor with four legs. - // Parent(s): Actor. - // Class history: 10/24/2007 ACrab created. - + /// A crab-like actor with four legs. class ACrab : public Actor { friend struct EntityLuaBindings; @@ -46,9 +33,7 @@ namespace RTE { LAYERCOUNT }; - ////////////////////////////////////////////////////////////////////////////////////////// - // Public member variable, method and friend function declarations - + /// Public member variable, method and friend function declarations public: // Concrete allocation and cloning definitions EntityAllocation(ACrab); @@ -57,423 +42,245 @@ namespace RTE { ClassInfoGetters; DefaultPieMenuNameGetter(HasObjectInGroup("Turrets") ? "Default Turret Pie Menu" : "Default Crab Pie Menu"); - ////////////////////////////////////////////////////////////////////////////////////////// - // Constructor: ACrab - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Constructor method used to instantiate a ACrab object in system - // memory. Create() should be called before using the object. - // Arguments: None. - + /// Constructor method used to instantiate a ACrab object in system + /// memory. Create() should be called before using the object. ACrab() { Clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Destructor: ~ACrab - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destructor method used to clean up a ACrab object before deletion - // from system memory. - // Arguments: None. - + /// Destructor method used to clean up a ACrab object before deletion + /// from system memory. ~ACrab() override { Destroy(true); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes the ACrab object ready for use. - // Arguments: None. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Makes the ACrab object ready for use. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Create() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Creates a ACrab to be identical to another, by deep copy. - // Arguments: A reference to the ACrab to deep copy. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Creates a ACrab to be identical to another, by deep copy. + /// @param reference A reference to the ACrab to deep copy. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Create(const ACrab& reference); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Reset - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Resets the entire ACrab, including its inherited members, to their - // default settings or values. - // Arguments: None. - // Return value: None. - + /// Resets the entire ACrab, including its inherited members, to their + /// default settings or values. void Reset() override { Clear(); Actor::Reset(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destroys and resets (through Clear()) the SceneLayer object. - // Arguments: Whether to only destroy the members defined in this derived class, or - // to destroy all inherited members also. - // Return value: None. - + /// Destroys and resets (through Clear()) the SceneLayer object. + /// @param notInherited Whether to only destroy the members defined in this derived class, or (default: false) + /// to destroy all inherited members also. void Destroy(bool notInherited = false) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: GetEyePos - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the absoltue position of this' eye, or equivalent, where look - // vector starts from. - // Arguments: None. - // Return value: A Vector with the absolute position of this' eye or view point. - + /// Gets the absoltue position of this' eye, or equivalent, where look + /// vector starts from. + /// @return A Vector with the absolute position of this' eye or view point. Vector GetEyePos() const override; - /// /// Gets the Turret of this ACrab. - /// - /// A pointer to Turret of this ACrab. Ownership is NOT transferred! + /// @return A pointer to Turret of this ACrab. Ownership is NOT transferred! Turret* GetTurret() const { return m_pTurret; } - /// /// Sets the Turret for this ACrab. Ownership IS transferred! - /// - /// The new Turret to use. + /// @param newTurret The new Turret to use. void SetTurret(Turret* newTurret); - /// /// Gets the jetpack of this ACrab. - /// - /// A pointer to the jetpack of this ACrab. Ownership is NOT transferred! + /// @return A pointer to the jetpack of this ACrab. Ownership is NOT transferred! AEJetpack* GetJetpack() const { return m_pJetpack; } - /// /// Sets the jetpack for this ACrab. Ownership IS Transferred! - /// - /// The new jetpack to use. + /// @param newJetpack The new jetpack to use. void SetJetpack(AEJetpack* newJetpack); - /// /// Gets the left foreground Leg of this ACrab. - /// - /// A pointer to the left foreground Leg of this ACrab. Ownership is NOT transferred! + /// @return A pointer to the left foreground Leg of this ACrab. Ownership is NOT transferred! Leg* GetLeftFGLeg() const { return m_pLFGLeg; } - /// /// Sets the left foreground Leg for this ACrab. Ownership IS transferred! - /// - /// The new Leg to use. + /// @param newLeg The new Leg to use. void SetLeftFGLeg(Leg* newLeg); - /// /// Gets the left background Leg of this ACrab. - /// - /// A pointer to the left background Leg of this ACrab. Ownership is NOT transferred! + /// @return A pointer to the left background Leg of this ACrab. Ownership is NOT transferred! Leg* GetLeftBGLeg() const { return m_pLBGLeg; } - /// /// Sets the left background Leg for this ACrab. Ownership IS transferred! - /// - /// The new Leg to use. + /// @param newLeg The new Leg to use. void SetLeftBGLeg(Leg* newLeg); - /// /// Gets the right foreground Leg of this ACrab. - /// - /// A pointer to the right foreground Leg of this ACrab. Ownership is NOT transferred! + /// @return A pointer to the right foreground Leg of this ACrab. Ownership is NOT transferred! Leg* GetRightFGLeg() const { return m_pRFGLeg; } - /// /// Sets the right foreground Leg for this ACrab. Ownership IS transferred! - /// - /// The new Leg to use. + /// @param newLeg The new Leg to use. void SetRightFGLeg(Leg* newLeg); - /// /// Gets the right BG Leg of this ACrab. - /// - /// A pointer to the right background Leg of this ACrab. Ownership is NOT transferred! + /// @return A pointer to the right background Leg of this ACrab. Ownership is NOT transferred! Leg* GetRightBGLeg() const { return m_pRBGLeg; } - /// /// Sets the right background Leg for this ACrab. Ownership IS transferred! - /// - /// The new Leg to use. + /// @param newLeg The new Leg to use. void SetRightBGLeg(Leg* newLeg); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: CollideAtPoint - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Calculates the collision response when another MO's Atom collides with - // this MO's physical representation. The effects will be applied - // directly to this MO, and also represented in the passed in HitData. - // Arguments: Reference to the HitData struct which describes the collision. This - // will be modified to represent the results of the collision. - // Return value: Whether the collision has been deemed valid. If false, then disregard - // any impulses in the Hitdata. - + /// Calculates the collision response when another MO's Atom collides with + /// this MO's physical representation. The effects will be applied + /// directly to this MO, and also represented in the passed in HitData. + /// @param hitData Reference to the HitData struct which describes the collision. This + /// will be modified to represent the results of the collision. + /// @return Whether the collision has been deemed valid. If false, then disregard + /// any impulses in the Hitdata. bool CollideAtPoint(HitData& hitData) override; - /// /// Tries to handle the activated PieSlice in this object's PieMenu, if there is one, based on its SliceType. - /// - /// The SliceType of the PieSlice being handled. - /// Whether or not the activated PieSlice SliceType was able to be handled. + /// @param pieSliceType The SliceType of the PieSlice being handled. + /// @return Whether or not the activated PieSlice SliceType was able to be handled. bool HandlePieCommand(PieSlice::SliceType pieSliceType) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetEquippedItem - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns whatever is equipped in the turret, if anything. OWNERSHIP IS NOT TRANSFERRED! - // Arguments: None. - // Return value: The currently equipped item, if any. - + /// Returns whatever is equipped in the turret, if anything. OWNERSHIP IS NOT TRANSFERRED! + /// @return The currently equipped item, if any. MovableObject* GetEquippedItem() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: FirearmIsReady - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Indicates whether the currently held HDFirearm's is ready for use, and has - // ammo etc. - // Arguments: None. - // Return value: Whether a currently HDFirearm (if any) is ready for use. - + /// Indicates whether the currently held HDFirearm's is ready for use, and has + /// ammo etc. + /// @return Whether a currently HDFirearm (if any) is ready for use. bool FirearmIsReady() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: FirearmIsEmpty - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Indicates whether the currently held HDFirearm's is out of ammo. - // Arguments: None. - // Return value: Whether a currently HDFirearm (if any) is out of ammo. - + /// Indicates whether the currently held HDFirearm's is out of ammo. + /// @return Whether a currently HDFirearm (if any) is out of ammo. bool FirearmIsEmpty() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: FirearmNeedsReload - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Indicates whether the currently held HDFirearm's is almost out of ammo. - // Arguments: None. - // Return value: Whether a currently HDFirearm (if any) has less than half of ammo left. - + /// Indicates whether the currently held HDFirearm's is almost out of ammo. + /// @return Whether a currently HDFirearm (if any) has less than half of ammo left. bool FirearmNeedsReload() const; - /// /// Gets whether or not all of this ACrab's Turret's HDFirearms are full. - /// - /// Whether or not all of this ACrab's Turret's HDFirearms are full. Will return true if there is no Turret or no HDFirearms. + /// @return Whether or not all of this ACrab's Turret's HDFirearms are full. Will return true if there is no Turret or no HDFirearms. bool FirearmsAreFull() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: FirearmIsSemiAuto - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Indicates whether the currently held HDFirearm's is semi or full auto. - // Arguments: None. - // Return value: Whether a currently HDFirearm (if any) is a semi auto device. - + /// Indicates whether the currently held HDFirearm's is semi or full auto. + /// @return Whether a currently HDFirearm (if any) is a semi auto device. bool FirearmIsSemiAuto() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: FirearmActivationDelay - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns the currently held device's delay between pulling the trigger - // and activating. - // Arguments: None. - // Return value: Delay in ms or zero if not a HDFirearm. - + /// Returns the currently held device's delay between pulling the trigger + /// and activating. + /// @return Delay in ms or zero if not a HDFirearm. int FirearmActivationDelay() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ReloadFirearms - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Reloads the currently held firearms, if any. - // Arguments: None. - // Return value: None. - + /// Reloads the currently held firearms, if any. void ReloadFirearms(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: IsWithinRange - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Tells whether a point on the scene is within close range of the currently - // used device and aiming status, if applicable. - // Arguments: A Vector witht he aboslute coordinates of a point to check. - // Return value: Whether the point is within close range of this. - + /// Tells whether a point on the scene is within close range of the currently + /// used device and aiming status, if applicable. + /// @param point A Vector witht he aboslute coordinates of a point to check. + /// @return Whether the point is within close range of this. bool IsWithinRange(Vector& point) const override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Look - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Casts an unseen-revealing ray in the direction of where this is facing. - // Arguments: The degree angle to deviate from the current view point in the ray - // casting. A random ray will be chosen out of this +-range. - // The range, in pixels, beyond the actors sharp aim that the ray will have. - // Return value: Whether any unseen pixels were revealed by this look. - + /// Casts an unseen-revealing ray in the direction of where this is facing. + /// @param FOVSpread The degree angle to deviate from the current view point in the ray + /// casting. A random ray will be chosen out of this +-range. + /// @param range The range, in pixels, beyond the actors sharp aim that the ray will have. + /// @return Whether any unseen pixels were revealed by this look. bool Look(float FOVSpread, float range) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: LookForMOs - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Casts an MO detecting ray in the direction of where the head is looking - // at the time. Factors including head rotation, sharp aim mode, and - // other variables determine how this ray is cast. - // Arguments: The degree angle to deviate from the current view point in the ray - // casting. A random ray will be chosen out of this +-range. - // A specific material ID to ignore (see through) - // Whether to ignore all terrain or not (true means 'x-ray vision'). - // Return value: A pointer to the MO seen while looking. - + /// Casts an MO detecting ray in the direction of where the head is looking + /// at the time. Factors including head rotation, sharp aim mode, and + /// other variables determine how this ray is cast. + /// @param FOVSpread The degree angle to deviate from the current view point in the ray (default: 45) + /// casting. A random ray will be chosen out of this +-range. + /// @param ignoreMaterial A specific material ID to ignore (see through) (default: 0) + /// @param ignoreAllTerrain Whether to ignore all terrain or not (true means 'x-ray vision'). (default: false) + /// @return A pointer to the MO seen while looking. MovableObject* LookForMOs(float FOVSpread = 45, unsigned char ignoreMaterial = 0, bool ignoreAllTerrain = false); - /// /// Gets the GUI representation of this ACrab, only defaulting to its Turret or body if no GraphicalIcon has been defined. - /// - /// The graphical representation of this ACrab as a BITMAP. + /// @return The graphical representation of this ACrab as a BITMAP. BITMAP* GetGraphicalIcon() const override; - /// /// Gets whether this ACrab has just taken a stride this frame. - /// - /// Whether this ACrab has taken a stride this frame or not. + /// @return Whether this ACrab has taken a stride this frame or not. bool StrideFrame() const { return m_StrideFrame; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: PreControllerUpdate - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Update called prior to controller update. Ugly hack. Supposed to be done every frame. - // Arguments: None. - // Return value: None. - + /// Update called prior to controller update. Ugly hack. Supposed to be done every frame. void PreControllerUpdate() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Update - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates this MovableObject. Supposed to be done every frame. - // Arguments: None. - // Return value: None. - + /// Updates this MovableObject. Supposed to be done every frame. void Update() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Draw - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws this ACrab's current graphical representation to a - // BITMAP of choice. - // Arguments: A pointer to a BITMAP to draw on. - // The absolute position of the target bitmap's upper left corner in the Scene. - // In which mode to draw in. See the DrawMode enumeration for the modes. - // Whether to not draw any extra 'ghost' items of this MovableObject, - // indicator arrows or hovering HUD text and so on. - // Return value: None. - + /// Draws this ACrab's current graphical representation to a + /// BITMAP of choice. + /// @param pTargetBitmap A pointer to a BITMAP to draw on. + /// @param targetPos The absolute position of the target bitmap's upper left corner in the Scene. (default: Vector()) + /// @param mode In which mode to draw in. See the DrawMode enumeration for the modes. (default: g_DrawColor) + /// @param onlyPhysical Whether to not draw any extra 'ghost' items of this MovableObject, (default: false) + /// indicator arrows or hovering HUD text and so on. void Draw(BITMAP* pTargetBitmap, const Vector& targetPos = Vector(), DrawMode mode = g_DrawColor, bool onlyPhysical = false) const override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: DrawHUD - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws this Actor's current graphical HUD overlay representation to a - // BITMAP of choice. - // Arguments: A pointer to a BITMAP to draw on. - // The absolute position of the target bitmap's upper left corner in the Scene. - // Which player's screen this is being drawn to. May affect what HUD elements - // get drawn etc. - // Return value: None. - + /// Draws this Actor's current graphical HUD overlay representation to a + /// BITMAP of choice. + /// @param pTargetBitmap A pointer to a BITMAP to draw on. + /// @param targetPos The absolute position of the target bitmap's upper left corner in the Scene. (default: Vector()) + /// @param whichScreen Which player's screen this is being drawn to. May affect what HUD elements (default: 0) + /// get drawn etc. void DrawHUD(BITMAP* pTargetBitmap, const Vector& targetPos = Vector(), int whichScreen = 0, bool playerControlled = false) override; - /// /// Gets the LimbPath corresponding to the passed in Side, Layer and MovementState values. - /// - /// Whether to get the left or right side. - /// Whether to get foreground or background LimbPath. - /// Which movement state to get the LimbPath for. - /// The LimbPath corresponding to the passed in Layer and MovementState values. + /// @param side Whether to get the left or right side. + /// @param layer Whether to get foreground or background LimbPath. + /// @param movementState Which movement state to get the LimbPath for. + /// @return The LimbPath corresponding to the passed in Layer and MovementState values. LimbPath* GetLimbPath(Side side, Layer layer, MovementState movementState) { return &m_Paths[side][layer][movementState]; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetLimbPathSpeed - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Get walking limb path speed for the specified preset. - // Arguments: Speed preset to set 0 = LimbPath::SLOW, 1 = Limbpath::NORMAL, 2 = LimbPath::FAST - // Return value: Limb path speed for the specified preset in m/s. - + /// Get walking limb path speed for the specified preset. + /// @param speedPreset Speed preset to set 0 = LimbPath::SLOW, 1 = Limbpath::NORMAL, 2 = LimbPath::FAST + /// @return Limb path speed for the specified preset in m/s. float GetLimbPathSpeed(int speedPreset) const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetLimbPathSpeed - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Set walking limb path speed for the specified preset. - // Arguments: Speed preset to set 0 = LimbPath::SLOW, 1 = Limbpath::NORMAL, 2 = LimbPath::FAST. New speed value in m/s. - // Return value: None. - + /// Set walking limb path speed for the specified preset. + /// @param speedPreset Speed preset to set 0 = LimbPath::SLOW, 1 = Limbpath::NORMAL, 2 = LimbPath::FAST. New speed value in m/s. void SetLimbPathSpeed(int speedPreset, float speed); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetLimbPathPushForce - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the default force that a limb traveling walking LimbPath can push against - // stuff in the scene with. - // Arguments: None. - // Return value: The default set force maximum, in kg * m/s^2. - + /// Gets the default force that a limb traveling walking LimbPath can push against + /// stuff in the scene with. + /// @return The default set force maximum, in kg * m/s^2. float GetLimbPathPushForce() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetLimbPathPushForce - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the default force that a limb traveling walking LimbPath can push against - // stuff in the scene with. - // Arguments: The default set force maximum, in kg * m/s^2. - // Return value: None - + /// Sets the default force that a limb traveling walking LimbPath can push against + /// stuff in the scene with. + /// @param force The default set force maximum, in kg * m/s^2. void SetLimbPathPushForce(float force); - /// /// Gets this ACrab's stride sound. Ownership is NOT transferred! - /// - /// The SoundContainer for this ACrab's stride sound. + /// @return The SoundContainer for this ACrab's stride sound. SoundContainer* GetStrideSound() const { return m_StrideSound; } - /// /// Sets this ACrab's stride sound. Ownership IS transferred! - /// - /// The new SoundContainer for this ACrab's stride sound. + /// @param newSound The new SoundContainer for this ACrab's stride sound. void SetStrideSound(SoundContainer* newSound) { m_StrideSound = newSound; } - /// /// Gets the upper limit of this ACrab's aim range. - /// - /// The upper limit of this ACrab's aim range. + /// @return The upper limit of this ACrab's aim range. float GetAimRangeUpperLimit() const { return m_AimRangeUpperLimit; } - /// /// Sets the upper limit of this ACrab's aim range. - /// - /// The new upper limit of this ACrab's aim range. + /// @param aimRangeUpperLimit The new upper limit of this ACrab's aim range. void SetAimRangeUpperLimit(float aimRangeUpperLimit) { m_AimRangeUpperLimit = aimRangeUpperLimit; } - /// /// Gets the lower limit of this ACrab's aim range. - /// - /// The lower limit of this ACrab's aim range. + /// @return The lower limit of this ACrab's aim range. float GetAimRangeLowerLimit() const { return m_AimRangeLowerLimit; } - /// /// Sets the lower limit of this ACrab's aim range. - /// - /// The new lower limit of this ACrab's aim range. + /// @param aimRangeLowerLimit The new lower limit of this ACrab's aim range. void SetAimRangeLowerLimit(float aimRangeLowerLimit) { m_AimRangeLowerLimit = aimRangeLowerLimit; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Protected member variable and method declarations - + /// Protected member variable and method declarations protected: - /// /// Function that is called when we get a new movepath. /// This processes and cleans up the movepath. - /// void OnNewMovePath() override; // Member variables @@ -592,26 +399,16 @@ namespace RTE { bool m_LockMouseAimInput; #pragma region Event Handling - /// /// Event listener to be run while this ACrab's PieMenu is opened. - /// - /// The PieMenu this event listener needs to listen to. This will always be this' m_PieMenu and only exists for std::bind. - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @param pieMenu The PieMenu this event listener needs to listen to. This will always be this' m_PieMenu and only exists for std::bind. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int WhilePieMenuOpenListener(const PieMenu* pieMenu) override; #pragma endregion - ////////////////////////////////////////////////////////////////////////////////////////// - // Private member variable and method declarations - + /// Private member variable and method declarations private: - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Clear - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears all the member variables of this ACrab, effectively - // resetting the members of this abstraction level only. - // Arguments: None. - // Return value: None. - + /// Clears all the member variables of this ACrab, effectively + /// resetting the members of this abstraction level only. void Clear(); // Disallow the use of some implicit methods. diff --git a/Source/Entities/ACraft.cpp b/Source/Entities/ACraft.cpp index 4d7754271e..d3127568e3 100644 --- a/Source/Entities/ACraft.cpp +++ b/Source/Entities/ACraft.cpp @@ -1,15 +1,3 @@ -////////////////////////////////////////////////////////////////////////////////////////// -// File: ACraft.cpp -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Source file for the ACraft class. -// Project: Retro Terrain Engine -// Author(s): Daniel Tabar -// data@datarealms.com -// http://www.datarealms.com - -////////////////////////////////////////////////////////////////////////////////////////// -// Inclusions of header files - #include "ACraft.h" #include "AtomGroup.h" @@ -37,12 +25,6 @@ namespace RTE { #define EXITLINESPACING 7 #define EXITSUCKDELAYMS 1500 - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Clear - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears all the member variables of this Exit, effectively - // resetting the members of this abstraction level only. - void ACraft::Exit::Clear() { m_Offset.Reset(); m_Velocity.Reset(); @@ -53,11 +35,6 @@ namespace RTE { m_pIncomingMO = 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Creates a Exit to be identical to another, by deep copy. - int ACraft::Exit::Create(const Exit& reference) { m_Offset = reference.m_Offset; m_Velocity = reference.m_Velocity; @@ -69,11 +46,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes the Exit object ready for use. - int ACraft::Exit::Create() { if (Serializable::Create() < 0) return -1; @@ -81,14 +53,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: ReadProperty - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Reads a property value from a reader stream. If the name isn't - // recognized by this class, then ReadProperty of the parent class - // is called. If the property isn't recognized by any of the base classes, - // false is returned, and the reader's position is untouched. - int ACraft::Exit::ReadProperty(const std::string_view& propName, Reader& reader) { StartPropertyList(return Serializable::ReadProperty(propName, reader)); @@ -101,12 +65,6 @@ namespace RTE { EndPropertyList; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Save - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Saves the complete state of this Exit with a Writer for - // later recreation with Create(Reader &reader); - int ACraft::Exit::Save(Writer& writer) const { Serializable::Save(writer); @@ -124,12 +82,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: CheckIfClear - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Calculates whether this exit is currently clear enough of terrain to - // safely put things through without them ending up in the terrain. - bool ACraft::Exit::CheckIfClear(const Vector& pos, Matrix& rot, float size) { Vector notUsed; Vector ray = m_Velocity; @@ -137,14 +89,6 @@ namespace RTE { return m_Clear = !g_SceneMan.CastNotMaterialRay(pos + (m_Offset * rot), ray * rot, g_MaterialAir, notUsed); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: SuckInMOs - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Uses cast MO rays to see if anyhting is able to be drawn into this - // exit. If so, it will alter the positiona nd velocity of the objet so - // it flies into the exit until it is sufficiently inside and then it'll - // return the MO here, OWNERHIP NOT TRANSFERRED! It is still in MovableMan! - MOSRotating* ACraft::Exit::SuckInMOs(ACraft* pExitOwner) { if (!pExitOwner || !m_Clear) return 0; @@ -224,12 +168,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Clear - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears all the member variables of this ACraft, effectively - // resetting the members of this abstraction level only. - void ACraft::Clear() { m_AIMode = AIMODE_DELIVER; @@ -261,11 +199,6 @@ namespace RTE { m_ScuttleOnDeath = true; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes the ACraft object ready for use. - int ACraft::Create() { // Read all the properties if (Actor::Create() < 0) @@ -280,11 +213,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Creates a ACraft to be identical to another, by deep copy. - int ACraft::Create(const ACraft& reference) { Actor::Create(reference); @@ -323,14 +251,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: ReadProperty - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Reads a property value from a reader stream. If the name isn't - // recognized by this class, then ReadProperty of the parent class - // is called. If the property isn't recognized by any of the base classes, - // false is returned, and the reader's position is untouched. - int ACraft::ReadProperty(const std::string_view& propName, Reader& reader) { StartPropertyList(return Actor::ReadProperty(propName, reader)); @@ -363,12 +283,6 @@ namespace RTE { EndPropertyList; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Save - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Saves the complete state of this ACraft with a Writer for - // later recreation with Create(Reader &reader); - int ACraft::Save(Writer& writer) const { Actor::Save(writer); @@ -402,11 +316,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destroys and resets (through Clear()) the ACraft object. - void ACraft::Destroy(bool notInherited) { delete m_HatchOpenSound; delete m_HatchCloseSound; @@ -417,12 +326,6 @@ namespace RTE { Clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetTotalValue - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the total liquidation value of this Actor and all its carried - // gold and inventory. - float ACraft::GetTotalValue(int nativeModule, float foreignMult, float nativeMult) const { float totalValue = Actor::GetTotalValue(nativeModule, foreignMult, nativeMult); @@ -436,12 +339,6 @@ namespace RTE { return totalValue; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: HasObject - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Shows whether this carries a specifically named object in its inventory. - // Also looks through the inventories of potential passengers, as applicable. - bool ACraft::HasObject(std::string objectName) const { if (Actor::HasObject(objectName)) return true; @@ -454,13 +351,6 @@ namespace RTE { return false; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: HasObjectInGroup - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Shows whether this is or carries a specifically grouped object in its - // inventory. Also looks through the inventories of potential passengers, - // as applicable. - bool ACraft::HasObjectInGroup(std::string groupName) const { if (Actor::HasObjectInGroup(groupName)) return true; @@ -473,11 +363,6 @@ namespace RTE { return false; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: SetTeam - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets which team this belongs to, and all its inventory too. - void ACraft::SetTeam(int team) { Actor::SetTeam(team); @@ -490,8 +375,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool ACraft::HandlePieCommand(PieSlice::SliceType pieSliceIndex) { if (pieSliceIndex != PieSlice::SliceType::NoType) { if (pieSliceIndex == PieSlice::SliceType::Deliver) { @@ -524,15 +407,6 @@ namespace RTE { return false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: OpenHatch - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Opens the hatch doors, if they're closed. - // Arguments: None. - // Return value: None. - void ACraft::OpenHatch() { if (m_HatchState == CLOSED || m_HatchState == CLOSING) { m_HatchState = OPENING; @@ -545,13 +419,6 @@ namespace RTE { } } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: CloseHatch - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Closes the hatch doors, if they're open. - // Arguments: None. - // Return value: None. - void ACraft::CloseHatch() { if (m_HatchState == OPEN || m_HatchState == OPENING) { m_HatchState = CLOSING; @@ -572,13 +439,6 @@ namespace RTE { } } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual Method: AddInventoryItem - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Adds an inventory item to this Actor. - // Arguments: An pointer to the new item to add. Ownership IS TRANSFERRED! - // Return value: None.. - void ACraft::AddInventoryItem(MovableObject* pItemToAdd) { if (pItemToAdd) { // If the hatch is open, then only add the new item to the intermediate new inventory list @@ -604,14 +464,6 @@ namespace RTE { } } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: DropAllInventory - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Opens the hatches and makes everything in the Rocket fly out, including - // the passenger Actors, one after another. It may not happen - // instantaneously, so check for ejection being complete with - // IsInventoryEmpty(). - void ACraft::DropAllInventory() { if (m_HatchState == OPEN && !m_Exits.empty()) { // Cancel if we're not due to release @@ -730,8 +582,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - float ACraft::GetCollectedInventoryMass() const { float inventoryMass = 0.0F; for (const MovableObject* inventoryItem: m_CollectedInventory) { @@ -740,8 +590,6 @@ namespace RTE { return inventoryMass; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ACraft::GibThis(const Vector& impactImpulse, MovableObject* movableObjectToIgnore) { if (g_SettingsMan.CrabBombsEnabled() && !s_CrabBombInEffect) { s_CrabBombInEffect = true; @@ -764,19 +612,12 @@ namespace RTE { Actor::GibThis(impactImpulse, movableObjectToIgnore); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ACraft::ResetAllTimers() { MOSRotating::ResetAllTimers(); m_FlippedTimer.Reset(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Update - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates this ACraft. Supposed to be done every frame. - void ACraft::Update() { Actor::Update(); @@ -898,12 +739,6 @@ namespace RTE { m_DeepCheck = true /*m_Status == DEAD*/; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: DrawHUD - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws this Actor's current graphical HUD overlay representation to a - // BITMAP of choice. - void ACraft::DrawHUD(BITMAP* pTargetBitmap, const Vector& targetPos, int whichScreen, bool playerControlled) { m_HUDStack = -m_CharHeight / 2; diff --git a/Source/Entities/ACraft.h b/Source/Entities/ACraft.h index 28398613b7..dd954c2619 100644 --- a/Source/Entities/ACraft.h +++ b/Source/Entities/ACraft.h @@ -1,18 +1,11 @@ #ifndef _RTEACRAFT_ #define _RTEACRAFT_ -////////////////////////////////////////////////////////////////////////////////////////// -// File: ACraft.h -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Header file for the ACraft class. -// Project: Retro Terrain Engine -// Author(s): Daniel Tabar -// data@datarealms.com -// http://www.datarealms.com - -////////////////////////////////////////////////////////////////////////////////////////// -// Inclusions of header files - +/// Header file for the ACraft class. +/// @author Daniel Tabar +/// data@datarealms.com +/// http://www.datarealms.com +/// Inclusions of header files #include "Actor.h" #include "LimbPath.h" @@ -20,19 +13,11 @@ struct BITMAP; namespace RTE { - ////////////////////////////////////////////////////////////////////////////////////////// - // Class: ACraft - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: A flying Actor which carries other things and can drop them. - // Parent(s): Actor. - // Class history: 12/13/2006 ACraft created. - + /// A flying Actor which carries other things and can drop them. class ACraft : public Actor { friend struct EntityLuaBindings; - ////////////////////////////////////////////////////////////////////////////////////////// - // Public member variable, method and friend function declarations - + /// Public member variable, method and friend function declarations public: SerializableOverrideMethods; ClassInfoGetters; @@ -51,140 +36,77 @@ namespace RTE { LEFT }; - ////////////////////////////////////////////////////////////////////////////////////////// - // Nested class: Exit - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Something to bundle the properties of ACraft exits together. - // Parent(s): Serializable. - // Class history: 12/19/2006 Exit created. - + /// Something to bundle the properties of ACraft exits together. class Exit : public Serializable { friend class ACraft; - ////////////////////////////////////////////////////////////////////////////////////////// - // Public member variable, method and friend function declarations - + /// Public member variable, method and friend function declarations public: SerializableClassNameGetter; SerializableOverrideMethods; - ////////////////////////////////////////////////////////////////////////////////////////// - // Constructor: Exit - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Constructor method used to instantiate a Exit object in system - // memory. Create() should be called before using the object. - // Arguments: None. - + /// Constructor method used to instantiate a Exit object in system + /// memory. Create() should be called before using the object. Exit() { Clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes the Exit object ready for use. - // Arguments: None. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Makes the Exit object ready for use. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Create() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Creates a Exit to be identical to another, by deep copy. - // Arguments: A reference to the Exit to deep copy. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Creates a Exit to be identical to another, by deep copy. + /// @param reference A reference to the Exit to deep copy. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Create(const Exit& reference); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Reset - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Resets the entire Serializable, including its inherited members, to their - // default settings or values. - // Arguments: None. - // Return value: None. - + /// Resets the entire Serializable, including its inherited members, to their + /// default settings or values. void Reset() override { Clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetOffset - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the position offset of this exit from the position of its ACraft. - // Arguments: None. - // Return value: The coordinates relative to the m_Pos of this' ACraft. - + /// Gets the position offset of this exit from the position of its ACraft. + /// @return The coordinates relative to the m_Pos of this' ACraft. Vector GetOffset() const { return m_Offset; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetVelocity - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the velocity of anything that exits through this. - // Arguments: None. - // Return value: The velocity vector for anything exiting through this. - + /// Gets the velocity of anything that exits through this. + /// @return The velocity vector for anything exiting through this. Vector GetVelocity() const { return m_Velocity * (1.0F + m_VelSpread * RandomNormalNum()); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: GetRadius - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the width from the center tanget created by the velocity vector - // out from the offet point. This times two gives the total width of the - // opening. - // Arguments: None. - // Return value: Half the total width of the opening. - + /// Gets the width from the center tanget created by the velocity vector + /// out from the offet point. This times two gives the total width of the + /// opening. + /// @return Half the total width of the opening. float GetRadius() const { return m_Radius; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetRange - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the distance this exit can suck in objects from. - // Arguments: None. - // Return value: The sucking range of this. - + /// Gets the distance this exit can suck in objects from. + /// @return The sucking range of this. float GetRange() const { return m_Range; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: CheckIfClear - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Calculates whether this exit is currently clear enough of terrain to - // safely put things through without them ending up in the terrain. - // Arguments: The position of the parent ACraft of this. - // The rotation of the parent ACraft of this. - // How large (radius) the item is that is supposed to fit. - // Return value: If this has been determined clear to put anything through. - + /// Calculates whether this exit is currently clear enough of terrain to + /// safely put things through without them ending up in the terrain. + /// @param pos The position of the parent ACraft of this. + /// @param rot The rotation of the parent ACraft of this. + /// @param size How large (radius) the item is that is supposed to fit. (default: 20) + /// @return If this has been determined clear to put anything through. bool CheckIfClear(const Vector& pos, Matrix& rot, float size = 20); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: IsClear - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Tells if this is clear of the terrain to put things through. Faster than - // CheckIfClear(). - // Arguments: None. - // Return value: If this has been determined clear to put anything through. - + /// Tells if this is clear of the terrain to put things through. Faster than + /// CheckIfClear(). + /// @return If this has been determined clear to put anything through. bool IsClear() const { return m_Clear; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SuckInMOs - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Uses cast MO rays to see if anyhting is able to be drawn into this - // exit. If so, it will alter the positiona nd velocity of the objet so - // it flies into the exit until it is sufficiently inside and then it'll - // return the MO here, OWNERHIP NOT TRANSFERRED! It is still in MovableMan! - // Arguments: A pointer to the ACraft owner of this Exit. OWNERSHIP IS NOT TRANSFERRED! - // Return value: If an MO has been fully drawn into the exit, it will be returned here, - // OWNERSHIP NOT TRANSFERRED! - + /// Uses cast MO rays to see if anyhting is able to be drawn into this + /// exit. If so, it will alter the positiona nd velocity of the objet so + /// it flies into the exit until it is sufficiently inside and then it'll + /// return the MO here, OWNERHIP NOT TRANSFERRED! It is still in MovableMan! + /// @param pExitOwner A pointer to the ACraft owner of this Exit. OWNERSHIP IS NOT TRANSFERRED! + /// @return If an MO has been fully drawn into the exit, it will be returned here, + /// OWNERSHIP NOT TRANSFERRED! MOSRotating* SuckInMOs(ACraft* pExitOwner); - ////////////////////////////////////////////////////////////////////////////////////////// - // Protected member variable and method declarations - + /// Protected member variable and method declarations protected: // The offset of this exit relative the position of its ACraft Vector m_Offset; @@ -201,356 +123,204 @@ namespace RTE { // Movable Object that is being drawn into this exit MOSRotating* m_pIncomingMO; - ////////////////////////////////////////////////////////////////////////////////////////// - // Private member variable and method declarations - + /// Private member variable and method declarations private: static const std::string c_ClassName; //!< A string with the friendly-formatted type name of this object. - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Clear - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears all the member variables of this Exit, effectively - // resetting the members of this abstraction level only. - // Arguments: None. - // Return value: None. - + /// Clears all the member variables of this Exit, effectively + /// resetting the members of this abstraction level only. void Clear(); }; // Concrete allocation and cloning definitions // EntityAllocation(ACraft) - ////////////////////////////////////////////////////////////////////////////////////////// - // Constructor: ACraft - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Constructor method used to instantiate a ACraft object in system - // memory. Create() should be called before using the object. - // Arguments: None. - + /// Constructor method used to instantiate a ACraft object in system + /// memory. Create() should be called before using the object. ACraft() { Clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Destructor: ~ACraft - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destructor method used to clean up a ACraft object before deletion - // from system memory. - // Arguments: None. - + /// Destructor method used to clean up a ACraft object before deletion + /// from system memory. ~ACraft() override { Destroy(true); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes the ACraft object ready for use. - // Arguments: A Reader that the ACraft will create itself with. - // Whether there is a class name in the stream to check against to make - // sure the correct type is being read from the stream. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Makes the ACraft object ready for use. + /// @param A Reader that the ACraft will create itself with. + /// Whether there is a class name in the stream to check against to make + /// sure the correct type is being read from the stream. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Create() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Creates a ACraft to be identical to another, by deep copy. - // Arguments: A reference to the ACraft to deep copy. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Creates a ACraft to be identical to another, by deep copy. + /// @param reference A reference to the ACraft to deep copy. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Create(const ACraft& reference); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Reset - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Resets the entire ACraft, including its inherited members, to their - // default settings or values. - // Arguments: None. - // Return value: None. - + /// Resets the entire ACraft, including its inherited members, to their + /// default settings or values. void Reset() override { Clear(); Actor::Reset(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destroys and resets (through Clear()) the SceneLayer object. - // Arguments: Whether to only destroy the members defined in this derived class, or - // to destroy all inherited members also. - // Return value: None. - + /// Destroys and resets (through Clear()) the SceneLayer object. + /// @param notInherited Whether to only destroy the members defined in this derived class, or (default: false) + /// to destroy all inherited members also. void Destroy(bool notInherited = false) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetTotalValue - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the total liquidation value of this Actor and all its carried - // gold and inventory. - // Arguments: If this is supposed to be adjusted for a specific Tech's subjective - // value, then pass in the native DataModule ID of that tech. 0 means - // no Tech is specified and the base value is returned. - // How much to multiply the value if this happens to be a foreign Tech. - // Return value: The current value of this Actor and all his carried assets. - + /// Gets the total liquidation value of this Actor and all its carried + /// gold and inventory. + /// @param nativeModule If this is supposed to be adjusted for a specific Tech's subjective (default: 0) + /// value, then pass in the native DataModule ID of that tech. 0 means + /// no Tech is specified and the base value is returned. + /// @param foreignMult How much to multiply the value if this happens to be a foreign Tech. (default: 1.0) + /// @return The current value of this Actor and all his carried assets. float GetTotalValue(int nativeModule = 0, float foreignMult = 1.0, float nativeMult = 1.0) const override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: HasObject - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Shows whether this is or carries a specifically named object in its - // inventory. Also looks through the inventories of potential passengers, - // as applicable. - // Arguments: The Preset name of the object to look for. - // Return value: Whetehr the object was found carried by this. - + /// Shows whether this is or carries a specifically named object in its + /// inventory. Also looks through the inventories of potential passengers, + /// as applicable. + /// @param objectName The Preset name of the object to look for. + /// @return Whetehr the object was found carried by this. bool HasObject(std::string objectName) const override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: HasObjectInGroup - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Shows whether this is or carries a specifically grouped object in its - // inventory. Also looks through the inventories of potential passengers, - // as applicable. - // Arguments: The name of the group to look for. - // Return value: Whetehr the object in the group was found carried by this. - + /// Shows whether this is or carries a specifically grouped object in its + /// inventory. Also looks through the inventories of potential passengers, + /// as applicable. + /// @param groupName The name of the group to look for. + /// @return Whetehr the object in the group was found carried by this. bool HasObjectInGroup(std::string groupName) const override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetHatchState - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the current state of the hatch. - // Arguments: None. - // Return value: An int encoding the hatch state. See the HatchState enum. - + /// Gets the current state of the hatch. + /// @return An int encoding the hatch state. See the HatchState enum. unsigned int GetHatchState() const { return m_HatchState; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: SetTeam - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets which team this belongs to, and all its inventory too. - // Arguments: The assigned team number. - // Return value: None. - + /// Sets which team this belongs to, and all its inventory too. + /// @param team The assigned team number. void SetTeam(int team) override; - /// /// Tries to handle the activated PieSlice in this object's PieMenu, if there is one, based on its SliceType. - /// - /// The SliceType of the PieSlice being handled. - /// Whether or not the activated PieSlice SliceType was able to be handled. + /// @param pieSliceType The SliceType of the PieSlice being handled. + /// @return Whether or not the activated PieSlice SliceType was able to be handled. bool HandlePieCommand(PieSlice::SliceType pieSliceType) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: AutoStabilizing - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Tells whether this has the means and will try to right itself, or if - // that's up to the Controller to do. - // Arguments: None. - // Return value: Wheter this will try to auto stabilize. - + /// Tells whether this has the means and will try to right itself, or if + /// that's up to the Controller to do. + /// @return Wheter this will try to auto stabilize. virtual bool AutoStabilizing() { return false; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: OpenHatch - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Opens the hatch doors, if they're closed or closing. - // Arguments: None. - // Return value: None. - + /// Opens the hatch doors, if they're closed or closing. void OpenHatch(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: CloseHatch - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Closes the hatch doors, if they're open or opening. - // Arguments: None. - // Return value: None. - + /// Closes the hatch doors, if they're open or opening. void CloseHatch(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual Method: AddInventoryItem - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Adds an inventory item to this Actor. - // Arguments: An pointer to the new item to add. Ownership IS TRANSFERRED! - // Return value: None.. - + /// Adds an inventory item to this Actor. + /// @param pItemToAdd An pointer to the new item to add. Ownership IS TRANSFERRED! + /// @return None.. void AddInventoryItem(MovableObject* pItemToAdd) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: DropAllInventory - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Opens the hatches and makes everything in the Rocket fly out, including - // the passenger Actors, one after another. It may not happen - // instantaneously, so check for ejection being complete with - // IsInventoryEmpty(). - // Arguments: None. - // Return value: None. - + /// Opens the hatches and makes everything in the Rocket fly out, including + /// the passenger Actors, one after another. It may not happen + /// instantaneously, so check for ejection being complete with + /// IsInventoryEmpty(). void DropAllInventory() override; - /// /// Gets the mass of this ACraft's inventory of newly collected items. - /// - /// The mass of this ACraft's newly collected inventory. + /// @return The mass of this ACraft's newly collected inventory. float GetCollectedInventoryMass() const; - /// /// Gets the mass of this ACraft, including the mass of its Attachables, wounds and inventory. - /// - /// The mass of this ACraft, its inventory and all its Attachables and wounds in Kilograms (kg). + /// @return The mass of this ACraft, its inventory and all its Attachables and wounds in Kilograms (kg). float GetMass() const override { return Actor::GetMass() + GetCollectedInventoryMass(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: HasDelivered - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Indicated whether this has landed and delivered yet on its current run. - // Arguments: None. - // Return value: Whether this has delivered yet. - + /// Indicated whether this has landed and delivered yet on its current run. + /// @return Whether this has delivered yet. bool HasDelivered() { return m_HasDelivered; } - /// /// Resets all the timers related to this, including the scuttle timer. - /// void ResetAllTimers() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Update - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates this MovableObject. Supposed to be done every frame. - // Arguments: None. - // Return value: None. - + /// Updates this MovableObject. Supposed to be done every frame. void Update() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: DrawHUD - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws this Actor's current graphical HUD overlay representation to a - // BITMAP of choice. - // Arguments: A pointer to a BITMAP to draw on. - // The absolute position of the target bitmap's upper left corner in the Scene. - // Which player's screen this is being drawn to. May affect what HUD elements - // get drawn etc. - // Return value: None. - + /// Draws this Actor's current graphical HUD overlay representation to a + /// BITMAP of choice. + /// @param pTargetBitmap A pointer to a BITMAP to draw on. + /// @param targetPos The absolute position of the target bitmap's upper left corner in the Scene. (default: Vector()) + /// @param whichScreen Which player's screen this is being drawn to. May affect what HUD elements (default: 0) + /// get drawn etc. void DrawHUD(BITMAP* pTargetBitmap, const Vector& targetPos = Vector(), int whichScreen = 0, bool playerControlled = false) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: GetMaxPassengers - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: The recomended, not absolute, maximum number of actors that fit in the - // invetory. Used by the activity AI. - // Arguments: None. - // Return value: An integer with the recomended number of actors that fit in the craft. - // Default is -1 (unknown). - + /// Virtual method: GetMaxPassengers + /// The recomended, not absolute, maximum number of actors that fit in the + /// invetory. Used by the activity AI. + /// @return An integer with the recomended number of actors that fit in the craft. + /// Default is -1 (unknown). virtual int GetMaxPassengers() const { return m_MaxPassengers; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: SetMaxPassengers - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the recomended, not absolute, maximum number of actors that fit in the - // invetory. Used by the activity AI. - // Arguments: An integer with the recomended number of actors that fit in the craft. - // Default is -1 (unknown). - // Return value: None. - + /// Virtual method: SetMaxPassengers + /// Sets the recomended, not absolute, maximum number of actors that fit in the + /// invetory. Used by the activity AI. + /// @param max An integer with the recomended number of actors that fit in the craft. + /// Default is -1 (unknown). virtual void SetMaxPassengers(int max) { m_MaxPassengers = max; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetDeliveryDelayMultiplier - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns delivery delay multiplier. - // Arguments: None. - // Return value: Delivery delay multiplier. - + /// Description: Returns delivery delay multiplier. + /// @return Delivery delay multiplier. float GetDeliveryDelayMultiplier() const { return m_DeliveryDelayMultiplier; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetDeliveryDelayMultiplier - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets delivery delay multiplier. - // Arguments: Delivery delay multiplier. - // Return value: None. - + /// Description: Sets delivery delay multiplier. + /// @param newValue Delivery delay multiplier. void SetDeliveryDelayMultiplier(float newValue) { m_DeliveryDelayMultiplier = newValue; } - /// /// Gets whether this ACraft will scuttle automatically on death. - /// - /// Whether this ACraft will scuttle automatically on death. + /// @return Whether this ACraft will scuttle automatically on death. bool GetScuttleOnDeath() const { return m_ScuttleOnDeath; } - /// /// Sets whether this ACraft will scuttle automatically on death. - /// - /// Whether this ACraft will scuttle automatically on death. + /// @param scuttleOnDeath Whether this ACraft will scuttle automatically on death. void SetScuttleOnDeath(bool scuttleOnDeath) { m_ScuttleOnDeath = scuttleOnDeath; } - /// /// Gets the hatch opening/closing delay of this ACraft. - /// - /// The hatch delay of this ACraft. + /// @return The hatch delay of this ACraft. int GetHatchDelay() const { return m_HatchDelay; } - /// /// Sets the hatch opening/closing delay of this ACraft. - /// - /// The new hatch delay of this ACraft. + /// @param newDelay The new hatch delay of this ACraft. void SetHatchDelay(int newDelay) { m_HatchDelay = newDelay; } - /// /// Destroys this ACraft and creates its specified Gibs in its place with appropriate velocities. Any Attachables are removed and also given appropriate velocities. - /// - /// The impulse (kg * m/s) of the impact causing the gibbing to happen. - /// A pointer to an MO which the Gibs and Attachables should not be colliding with. + /// @param impactImpulse The impulse (kg * m/s) of the impact causing the gibbing to happen. + /// @param movableObjectToIgnore A pointer to an MO which the Gibs and Attachables should not be colliding with. void GibThis(const Vector& impactImpulse = Vector(), MovableObject* movableObjectToIgnore = nullptr) override; - /// /// Gets this ACraft's hatch opening sound. Ownership is NOT transferred! - /// - /// The SoundContainer for this ACraft's hatch opening sound. + /// @return The SoundContainer for this ACraft's hatch opening sound. SoundContainer* GetHatchOpenSound() const { return m_HatchOpenSound; } - /// /// Sets this ACraft's hatch opening sound. Ownership IS transferred! - /// - /// The new SoundContainer for this ACraft's hatch opening sound. + /// @param newSound The new SoundContainer for this ACraft's hatch opening sound. void SetHatchOpenSound(SoundContainer* newSound) { m_HatchOpenSound = newSound; } - /// /// Gets this ACraft's hatch closing sound. Ownership is NOT transferred! - /// - /// The SoundContainer for this ACraft's hatch closing sound. + /// @return The SoundContainer for this ACraft's hatch closing sound. SoundContainer* GetHatchCloseSound() const { return m_HatchCloseSound; } - /// /// Sets this ACraft's hatch closing sound. Ownership IS transferred! - /// - /// The new SoundContainer for this ACraft's hatch closing sound. + /// @param newSound The new SoundContainer for this ACraft's hatch closing sound. void SetHatchCloseSound(SoundContainer* newSound) { m_HatchCloseSound = newSound; } - /// /// Gets this ACraft's crash sound. Ownership is NOT transferred! - /// - /// The SoundContainer for this ACraft's crash sound. + /// @return The SoundContainer for this ACraft's crash sound. SoundContainer* GetCrashSound() const { return m_CrashSound; } - /// /// Sets this ACraft's crash sound. Ownership IS transferred! - /// - /// The new SoundContainer for this ACraft's crash sound. + /// @param newSound The new SoundContainer for this ACraft's crash sound. void SetCrashSound(SoundContainer* newSound) { m_CrashSound = newSound; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Protected member variable and method declarations - + /// Protected member variable and method declarations protected: // Member variables static Entity::ClassInfo m_sClass; @@ -621,18 +391,10 @@ namespace RTE { // Mutliplier to apply to default delivery time float m_DeliveryDelayMultiplier; - ////////////////////////////////////////////////////////////////////////////////////////// - // Private member variable and method declarations - + /// Private member variable and method declarations private: - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Clear - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears all the member variables of this ACraft, effectively - // resetting the members of this abstraction level only. - // Arguments: None. - // Return value: None. - + /// Clears all the member variables of this ACraft, effectively + /// resetting the members of this abstraction level only. void Clear(); // Disallow the use of some implicit methods. diff --git a/Source/Entities/ADSensor.cpp b/Source/Entities/ADSensor.cpp index f20266864b..06904a1e9c 100644 --- a/Source/Entities/ADSensor.cpp +++ b/Source/Entities/ADSensor.cpp @@ -5,16 +5,12 @@ namespace RTE { const std::string ADSensor::c_ClassName = "Sensor"; - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ADSensor::Clear() { m_StartOffset.Reset(); m_SensorRay.Reset(); m_Skip = 3; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int ADSensor::Create(const ADSensor& reference) { m_StartOffset = reference.m_StartOffset; m_SensorRay = reference.m_SensorRay; @@ -23,8 +19,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int ADSensor::ReadProperty(const std::string_view& propName, Reader& reader) { StartPropertyList(return Serializable::ReadProperty(propName, reader)); @@ -35,8 +29,6 @@ namespace RTE { EndPropertyList; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int ADSensor::Save(Writer& writer) const { Serializable::Save(writer); @@ -50,8 +42,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - Actor* ADSensor::SenseActor(const Vector& doorPos, const Matrix& doorRot, bool doorHFlipped, MOID ignoreMOID) { Actor* sensedActor = 0; MOID foundMOID = g_SceneMan.CastMORay(doorPos + m_StartOffset.GetXFlipped(doorHFlipped) * doorRot, m_SensorRay.GetXFlipped(doorHFlipped) * doorRot, ignoreMOID, Activity::NoTeam, 0, true, m_Skip); diff --git a/Source/Entities/ADSensor.h b/Source/Entities/ADSensor.h index 579592081d..16717f13c9 100644 --- a/Source/Entities/ADSensor.h +++ b/Source/Entities/ADSensor.h @@ -8,9 +8,7 @@ namespace RTE { class Actor; - /// /// The ray-casting sensor which triggers the door opening or closing, depending on the team of the Actor that broke the ray. - /// class ADSensor : public Serializable { public: @@ -18,73 +16,53 @@ namespace RTE { SerializableOverrideMethods; #pragma region Creation - /// /// Constructor method used to instantiate an ADSensor object in system memory. Create() should be called before using the object. - /// ADSensor() { Clear(); } - /// /// Makes the ADSensor object ready for use. - /// - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create() override { return Serializable::Create(); } - /// /// Creates an ADSensor to be identical to another, by deep copy. - /// - /// A reference to the ADSensor to deep copy. - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @param reference A reference to the ADSensor to deep copy. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create(const ADSensor& reference); #pragma endregion #pragma region Destruction - /// /// Destructor method used to clean up an ADSensor object before deletion from system memory. - /// ~ADSensor() { Destroy(); } - /// /// Destroys and resets (through Clear()) the ADSensor object. - /// - /// Whether to only destroy the members defined in this derived class, or to destroy all inherited members also. + /// @param notInherited Whether to only destroy the members defined in this derived class, or to destroy all inherited members also. void Destroy() { Clear(); } #pragma endregion #pragma region Getters and Setters - /// /// Gets the starting position offset of this ADSensor from the owning ADoor position. - /// - /// The starting coordinates relative to the m_Pos of this' ADoor. + /// @return The starting coordinates relative to the m_Pos of this' ADoor. Vector GetStartOffset() const { return m_StartOffset; } - /// /// Sets the starting position offset of this ADSensor from the owning ADoor position. - /// - /// The new starting coordinates relative to the m_Pos of this' ADoor. + /// @param startOffsetValue The new starting coordinates relative to the m_Pos of this' ADoor. void SetStartOffset(const Vector& startOffsetValue) { m_StartOffset = startOffsetValue; } - /// /// Gets the sensor ray vector out from the start offset's position. - /// - /// The sensor ray vector. + /// @return The sensor ray vector. Vector GetSensorRay() const { return m_SensorRay; } - /// /// Sets the sensor ray vector out from the start offset's position. - /// - /// The new sensor ray vector. + /// @param sensorRayValue The new sensor ray vector. void SetSensorRay(const Vector& sensorRayValue) { m_SensorRay = sensorRayValue; } #pragma endregion #pragma region Concrete Methods - /// /// Casts the ray along the sensor vector and returns any Actor that was found along it. - /// - /// Position of this ADSensor's ADoor. - /// Rotation of this ADSensor's ADoor. - /// Flipping of this ADSensor's ADoor. - /// Which MOID to ignore, if any. - /// The root Actor of the first MOID hit by the sensor ray. 0 if none. + /// @param doorPos Position of this ADSensor's ADoor. + /// @param doorRot Rotation of this ADSensor's ADoor. + /// @param doorHFlipped Flipping of this ADSensor's ADoor. + /// @param ignoreMOID Which MOID to ignore, if any. + /// @return The root Actor of the first MOID hit by the sensor ray. 0 if none. Actor* SenseActor(const Vector& doorPos, const Matrix& doorRot, bool doorHFlipped = false, MOID ignoreMOID = g_NoMOID); #pragma endregion @@ -97,9 +75,7 @@ namespace RTE { private: static const std::string c_ClassName; //!< A string with the friendly formatted type name of this object. - /// /// Clears all the member variables of this ADSensor, effectively resetting the members of this abstraction level only. - /// void Clear(); }; } // namespace RTE diff --git a/Source/Entities/ADoor.cpp b/Source/Entities/ADoor.cpp index beb9d20b72..e2feda0c24 100644 --- a/Source/Entities/ADoor.cpp +++ b/Source/Entities/ADoor.cpp @@ -12,8 +12,6 @@ namespace RTE { ConcreteClassInfo(ADoor, Actor, 20); - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ADoor::Clear() { m_InitialSpriteAnimDuration = 0; m_Sensors.clear(); @@ -53,8 +51,6 @@ namespace RTE { m_CanBeSquished = false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int ADoor::Create(const ADoor& reference) { if (reference.m_Door) { m_ReferenceHardcodedAttachableUniqueIDs.insert(reference.m_Door->GetUniqueID()); @@ -101,8 +97,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int ADoor::ReadProperty(const std::string_view& propName, Reader& reader) { StartPropertyList(return Actor::ReadProperty(propName, reader)); @@ -154,8 +148,6 @@ namespace RTE { EndPropertyList; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int ADoor::Save(Writer& writer) const { Actor::Save(writer); @@ -197,8 +189,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ADoor::Destroy(bool notInherited) { if (m_DoorMoveStartSound) { m_DoorMoveStartSound->Stop(); @@ -225,8 +215,6 @@ namespace RTE { Clear(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ADoor::SetDoor(Attachable* newDoor) { if (m_DoorMaterialDrawn) { RTEAssert(m_Door, "Door material drawn without an m_Door! This should've been cleared when the door was!"); @@ -250,8 +238,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ADoor::DrawDoorMaterial(bool disallowErasingMaterialBeforeDrawing, bool updateMaterialArea) { if (!m_Door || m_DoorMaterialTempErased || !g_SceneMan.GetTerrain() || !g_SceneMan.GetTerrain()->GetMaterialBitmap()) { return; @@ -270,8 +256,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool ADoor::EraseDoorMaterial(bool updateMaterialArea) { if (!g_SceneMan.GetTerrain() || !g_SceneMan.GetTerrain()->GetMaterialBitmap()) { return false; @@ -295,8 +279,6 @@ namespace RTE { return false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ADoor::TempEraseOrRedrawDoorMaterial(bool erase) { if (!g_SceneMan.GetTerrain() || !g_SceneMan.GetTerrain()->GetMaterialBitmap()) { return; @@ -314,8 +296,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ADoor::GibThis(const Vector& impactImpulse, MovableObject* movableObjectToIgnore) { if (m_Door && m_Door->IsAttached()) { EraseDoorMaterial(); @@ -325,8 +305,6 @@ namespace RTE { Actor::GibThis(impactImpulse, movableObjectToIgnore); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ADoor::CorrectAttachableAndWoundPositionsAndRotations() const { if (m_Door) { m_Door->SetParentOffset(m_ClosedByDefault ? m_ClosedOffset : m_OpenOffset); @@ -335,8 +313,6 @@ namespace RTE { MOSRotating::CorrectAttachableAndWoundPositionsAndRotations(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ADoor::OpenDoor() { if (m_DoorState == STOPPED) { SharedDoorControls(); @@ -350,8 +326,6 @@ namespace RTE { m_ResetToDefaultStateTimer.Reset(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ADoor::CloseDoor() { if (m_DoorState == STOPPED) { SharedDoorControls(); @@ -365,8 +339,6 @@ namespace RTE { m_ResetToDefaultStateTimer.Reset(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ADoor::StopDoor() { if (m_DoorState == OPENING || m_DoorState == CLOSING) { if (m_DrawMaterialLayerWhenOpen || m_DrawMaterialLayerWhenClosed) { @@ -384,8 +356,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ADoor::SharedDoorControls() { if (m_DoorState == OPEN || m_DoorState == CLOSED) { if (m_DoorMoveStartSound) { @@ -423,8 +393,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ADoor::Update() { ZoneScoped; @@ -476,8 +444,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ADoor::UpdateSensors() { const Actor* foundActor = nullptr; bool anySensorInput = false; @@ -509,8 +475,6 @@ namespace RTE { m_SensorTimer.Reset(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ADoor::UpdateDoorAttachableActions() { Vector startOffset; Vector endOffset; @@ -579,8 +543,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ADoor::DrawHUD(BITMAP* targetBitmap, const Vector& targetPos, int whichScreen, bool playerControlled) { m_HUDStack = -static_cast(m_CharHeight) / 2; diff --git a/Source/Entities/ADoor.h b/Source/Entities/ADoor.h index 3fc5fac83e..eba5b63cd6 100644 --- a/Source/Entities/ADoor.h +++ b/Source/Entities/ADoor.h @@ -8,9 +8,7 @@ namespace RTE { class Attachable; - /// /// A sliding or swinging door. - /// class ADoor : public Actor { public: @@ -28,40 +26,28 @@ namespace RTE { }; #pragma region Creation - /// /// Constructor method used to instantiate a ADoor object in system memory. Create() should be called before using the object. - /// ADoor() { Clear(); } - /// /// Makes the ADoor object ready for use. - /// - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create() override { return Actor::Create(); } - /// /// Creates a ADoor to be identical to another, by deep copy. - /// - /// A reference to the ADoor to deep copy. - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @param reference A reference to the ADoor to deep copy. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create(const ADoor& reference); #pragma endregion #pragma region Destruction - /// /// Destructor method used to clean up a ADoor object before deletion from system memory. - /// ~ADoor() override { Destroy(true); } - /// /// Destroys and resets (through Clear()) the ADoor object. - /// - /// Whether to only destroy the members defined in this derived class, or to destroy all inherited members also. + /// @param notInherited Whether to only destroy the members defined in this derived class, or to destroy all inherited members also. void Destroy(bool notInherited = false) override; - /// /// Resets the entire ADoor, including its inherited members, to their default settings or values. - /// void Reset() override { Clear(); Actor::Reset(); @@ -69,145 +55,99 @@ namespace RTE { #pragma endregion #pragma region Getters and Setters - /// /// Gets the moving door Attachable of this ADoor - /// - /// A pointer to the door Attachable of this. Ownership is NOT transferred! + /// @return A pointer to the door Attachable of this. Ownership is NOT transferred! Attachable* GetDoor() const { return m_Door; } - /// /// Sets the moving door Attachable for this ADoor. - /// - /// The new moving door attachable to use. + /// @param newDoor The new moving door attachable to use. void SetDoor(Attachable* newDoor); - /// /// Gets the current state of the door. - /// - /// The current state of this ADoor. See the DoorState enum. + /// @return The current state of this ADoor. See the DoorState enum. DoorState GetDoorState() const { return m_DoorState; } - /// /// Sets whether this ADoor closes (or opens) after a while by default. - /// - /// Whether the door by default goes to a closed position. If not, then it will open after a while. + /// @param closedByDefault Whether the door by default goes to a closed position. If not, then it will open after a while. void SetClosedByDefault(bool closedByDefault) { m_ClosedByDefault = closedByDefault; } - /// /// Tells whether the player can switch control to this at all. - /// - /// Whether a player can control this at all. + /// @return Whether a player can control this at all. bool IsControllable() const override { return false; } - /// /// Gets whether or not this ADoor's door material has been drawn. - /// - /// Whether or not this ADoor's door material has been drawn. + /// @return Whether or not this ADoor's door material has been drawn. bool GetDoorMaterialDrawn() const { return m_DoorMaterialDrawn; } - /// /// Gets this ADoor's door move start sound. Ownership is NOT transferred! - /// - /// The SoundContainer for this ADoor's door move start sound. + /// @return The SoundContainer for this ADoor's door move start sound. SoundContainer* GetDoorMoveStartSound() const { return m_DoorMoveStartSound.get(); } - /// /// Sets this ADoor's door move start sound. Ownership IS transferred! - /// - /// The new SoundContainer for this ADoor's door move start sound. + /// @param newSound The new SoundContainer for this ADoor's door move start sound. void SetDoorMoveStartSound(SoundContainer* newSound) { m_DoorMoveStartSound.reset(newSound); } - /// /// Gets this ADoor's door move sound. Ownership is NOT transferred! - /// - /// The SoundContainer for this ADoor's door move sound. + /// @return The SoundContainer for this ADoor's door move sound. SoundContainer* GetDoorMoveSound() const { return m_DoorMoveSound.get(); } - /// /// Sets this ADoor's door move sound. Ownership IS transferred! - /// - /// The new SoundContainer for this ADoor's door move sound. + /// @param newSound The new SoundContainer for this ADoor's door move sound. void SetDoorMoveSound(SoundContainer* newSound) { m_DoorMoveSound.reset(newSound); } - /// /// Gets this ADoor's door direction change sound. Ownership is NOT transferred! - /// - /// The SoundContainer for this ADoor's door direction change sound. + /// @return The SoundContainer for this ADoor's door direction change sound. SoundContainer* GetDoorDirectionChangeSound() const { return m_DoorDirectionChangeSound.get(); } - /// /// Sets this ADoor's door direction change sound. Ownership IS transferred! - /// - /// The new SoundContainer for this ADoor's door direction change sound. + /// @param newSound The new SoundContainer for this ADoor's door direction change sound. void SetDoorDirectionChangeSound(SoundContainer* newSound) { m_DoorDirectionChangeSound.reset(newSound); } - /// /// Gets this ADoor's door move end sound. Ownership is NOT transferred! - /// - /// The SoundContainer for this ADoor's door move end sound. + /// @return The SoundContainer for this ADoor's door move end sound. SoundContainer* GetDoorMoveEndSound() const { return m_DoorMoveEndSound.get(); } - /// /// Sets this ADoor's door move end sound. Ownership IS transferred! - /// - /// The new SoundContainer for this ADoor's door move end sound. + /// @param newSound The new SoundContainer for this ADoor's door move end sound. void SetDoorMoveEndSound(SoundContainer* newSound) { m_DoorMoveEndSound.reset(newSound); } #pragma endregion #pragma region Concrete Methods - /// /// Opens the door if it's closed. - /// void OpenDoor(); - /// /// Closes the door if it's open. - /// void CloseDoor(); - /// /// Force the door to stop at the exact position it is. - /// void StopDoor(); - /// /// Used to temporarily remove or add back the material drawing of this in the Scene. Used for making pathfinding work through doors. - /// - /// Whether to erase door material (true) or draw it (false). + /// @param erase Whether to erase door material (true) or draw it (false). void TempEraseOrRedrawDoorMaterial(bool erase); - /// /// Resets the sensor Timer for this ADoor, effectively making it ignore Actors. - /// void ResetSensorTimer() { m_SensorTimer.Reset(); } #pragma endregion #pragma region Virtual Override Methods - /// /// Destroys this ADoor and creates its specified Gibs in its place with appropriate velocities. /// Any Attachables are removed and also given appropriate velocities. - /// - /// The impulse (kg * m/s) of the impact causing the gibbing to happen. - /// A pointer to an MO which the Gibs and Attachables should not be colliding with. + /// @param impactImpulse The impulse (kg * m/s) of the impact causing the gibbing to happen. + /// @param movableObjectToIgnore A pointer to an MO which the Gibs and Attachables should not be colliding with. void GibThis(const Vector& impactImpulse = Vector(), MovableObject* movableObjectToIgnore = nullptr) override; - /// /// Ensures all attachables and wounds are positioned and rotated correctly. Must be run when this ADoor is added to MovableMan to avoid issues with Attachables spawning in at (0, 0). - /// void CorrectAttachableAndWoundPositionsAndRotations() const override; - /// /// Updates this ADoor. Supposed to be done every frame. - /// void Update() override; - /// /// Draws this ADoor's current graphical HUD overlay representation to a BITMAP of choice. - /// - /// A pointer to a BITMAP to draw on. - /// The absolute position of the target bitmap's upper left corner in the Scene. - /// Which player's screen this is being drawn to. May affect what HUD elements get drawn etc. - /// Whether or not this MovableObject is currently player controlled (not applicable for ADoor) + /// @param targetBitmap A pointer to a BITMAP to draw on. + /// @param targetPos The absolute position of the target bitmap's upper left corner in the Scene. + /// @param whichScreen Which player's screen this is being drawn to. May affect what HUD elements get drawn etc. + /// @param playerControlled Whether or not this MovableObject is currently player controlled (not applicable for ADoor) void DrawHUD(BITMAP* targetBitmap, const Vector& targetPos = Vector(), int whichScreen = 0, bool playerControlled = false) override; #pragma endregion @@ -259,40 +199,28 @@ namespace RTE { private: #pragma region Update Breakdown - /// /// Iterates through the sensor list looking for actors and acts accordingly. Resets to the default state if none are found and past the delay timer. This is called from Update(). - /// void UpdateSensors(); - /// /// Updates the door attachable position and movement based on the current state of this ADoor. This is called from Update(). - /// void UpdateDoorAttachableActions(); #pragma endregion - /// /// Shared method for the door opening/closing sequence. This is called from OpenDoor() and CloseDoor(). - /// void SharedDoorControls(); - /// /// Draws the material under the position of the door attachable, to create terrain collision detection for the doors. - /// - /// Whether to disallow calling EraseDoorMaterial before drawing. Defaults to false, which means normal behaviour applies and this may erase the material before drawing it. - /// Whether to tell the Scene's Terrain that this door has modified the material layer. + /// @param disallowErasingMaterialBeforeDrawing Whether to disallow calling EraseDoorMaterial before drawing. Defaults to false, which means normal behaviour applies and this may erase the material before drawing it. + /// @param updateMaterialArea Whether to tell the Scene's Terrain that this door has modified the material layer. void DrawDoorMaterial(bool disallowErasingMaterialBeforeDrawing = false, bool updateMaterialArea = true); - /// /// Flood-fills the material area under the last position of the door attachable that matches the material index of it. /// This is to get rid of the material footprint made with DrawDoorMaterial when the door part starts to move. - /// - /// Whether to tell the Scene's Terrain that this door has modified the material layer.. - /// Whether the fill erasure was successful (if the same material as the door was found and erased). + /// @param updateMaterialArea Whether to tell the Scene's Terrain that this door has modified the material layer.. + /// @return Whether the fill erasure was successful (if the same material as the door was found and erased). bool EraseDoorMaterial(bool updateMaterialArea = true); - /// /// Clears all the member variables of this ADoor, effectively resetting the members of this abstraction level only. - /// void Clear(); // Disallow the use of some implicit methods. diff --git a/Source/Entities/AEJetpack.cpp b/Source/Entities/AEJetpack.cpp index d66fcf09c9..21a050c898 100644 --- a/Source/Entities/AEJetpack.cpp +++ b/Source/Entities/AEJetpack.cpp @@ -7,8 +7,6 @@ namespace RTE { ConcreteClassInfo(AEJetpack, AEmitter, 20); - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void AEJetpack::Clear() { m_JetpackType = JetpackType::Standard; m_JetTimeTotal = 0.0F; @@ -21,8 +19,6 @@ namespace RTE { m_AdjustsThrottleForWeight = true; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int AEJetpack::Create() { if (Attachable::Create() < 0) { return -1; @@ -35,8 +31,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int AEJetpack::Create(const AEJetpack& reference) { AEmitter::Create(reference); @@ -52,8 +46,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int AEJetpack::ReadProperty(const std::string_view& propName, Reader& reader) { StartPropertyList(return AEmitter::ReadProperty(propName, reader)); @@ -85,8 +77,6 @@ namespace RTE { EndPropertyList; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int AEJetpack::Save(Writer& writer) const { AEmitter::Save(writer); @@ -111,8 +101,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void AEJetpack::UpdateBurstState(Actor& parentActor) { const Controller& controller = *parentActor.GetController(); @@ -189,8 +177,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void AEJetpack::Burst(Actor& parentActor, float fuelUseMultiplier) { parentActor.SetMovementState(Actor::JUMP); @@ -206,8 +192,6 @@ namespace RTE { m_JetTimeLeft -= fuelUsage; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void AEJetpack::Thrust(Actor& parentActor, float fuelUseMultiplier) { parentActor.SetMovementState(Actor::JUMP); @@ -218,8 +202,6 @@ namespace RTE { m_JetTimeLeft -= fuelUsage; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void AEJetpack::Recharge(Actor& parentActor) { EnableEmission(false); if (parentActor.GetMovementState() == Actor::JUMP) { diff --git a/Source/Entities/AEJetpack.h b/Source/Entities/AEJetpack.h index 305b4191f8..49fc25ed51 100644 --- a/Source/Entities/AEJetpack.h +++ b/Source/Entities/AEJetpack.h @@ -5,9 +5,7 @@ namespace RTE { - /// /// A jetpack MO, which can be used to generate thrust - /// class AEJetpack : public AEmitter { friend struct EntityLuaBindings; @@ -23,157 +21,107 @@ namespace RTE { }; #pragma region Creation - /// /// Constructor method used to instantiate a AEJetpack object in system memory. Create() should be called before using the object. - /// AEJetpack() { Clear(); } - /// /// Makes the AEJetpack object ready for use. - /// - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create() override; - /// /// Creates a AEJetpack to be identical to another, by deep copy. - /// - /// A reference to the AEJetpack to deep copy. - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @param reference A reference to the AEJetpack to deep copy. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create(const AEJetpack& reference); #pragma endregion #pragma region Destruction - /// /// Destructor method used to clean up a AEJetpack object before deletion from system memory. - /// ~AEJetpack() override { Destroy(true); } - /// /// Resets the entire AEJetpack, including its inherited members, to their default settings or values. - /// void Reset() override { Clear(); AEmitter::Reset(); } #pragma endregion - /// /// Updates this AEJetpack from our parent actor. - /// void UpdateBurstState(Actor& parentActor); - /// /// Returns whether or not this jetpack is fully fueled. - /// - /// Whether or not this jetpack is fully fueled. + /// @return Whether or not this jetpack is fully fueled. bool IsFullyFueled() const { return m_JetTimeLeft >= m_JetTimeTotal - (m_JetTimeTotal * std::numeric_limits::epsilon()); } - /// /// Returns whether or not this jetpack is out of fuel. - /// - /// Whether or not this jetpack is out of fuel. + /// @return Whether or not this jetpack is out of fuel. bool IsOutOfFuel() const { return m_JetTimeLeft <= std::numeric_limits::epsilon(); } - /// /// Gets the amount of time this jetpack can fire when filled, in ms. - /// - /// The amount of time this jetpack can fire when it's at max. + /// @return The amount of time this jetpack can fire when it's at max. float GetJetTimeTotal() const { return m_JetTimeTotal; } - /// /// Sets the amount of time this' jetpack can fire when filled, in ms. - /// - /// The amount of time this jetpack can fire when it's at max. + /// @param newValue The amount of time this jetpack can fire when it's at max. void SetJetTimeTotal(float newValue) { m_JetTimeTotal = newValue; } - /// /// Gets the amount of time this jetpack can still fire until out, in ms. - /// - /// The amount of time this jetpack can still fire before running out. + /// @return The amount of time this jetpack can still fire before running out. float GetJetTimeLeft() const { return m_JetTimeLeft; } - /// /// Sets the amount of time this' jetpack can still fire until out, in ms. - /// - /// The amount of time this' jetpack can still fire before running out. + /// @param newValue The amount of time this' jetpack can still fire before running out. void SetJetTimeLeft(float newValue) { m_JetTimeLeft = newValue < m_JetTimeTotal ? newValue : m_JetTimeTotal; } - /// /// Gets the ratio of jetpack time that is left. - /// - /// The ratio of jetpack time that is left. + /// @return The ratio of jetpack time that is left. float GetJetTimeRatio() { return m_JetTimeLeft / m_JetTimeTotal; } - /// /// Gets the rate at which this AHuman's jetpack is replenished during downtime. - /// - /// The rate at which the jetpack is replenished. + /// @return The rate at which the jetpack is replenished. float GetJetReplenishRate() const { return m_JetReplenishRate; } - /// /// Sets the rate at which this AHuman's jetpack is replenished during downtime. - /// - /// The rate at which the jetpack is replenished. + /// @param newValue The rate at which the jetpack is replenished. void SetJetReplenishRate(float newValue) { m_JetReplenishRate = newValue; } - /// /// Gets the rate at which this AHuman's jetpack is replenished during downtime. - /// - /// The rate at which the jetpack is replenished. + /// @return The rate at which the jetpack is replenished. float GetMinimumFuelRatio() const { return m_MinimumFuelRatio; } - /// /// Sets the rate at which this AHuman's jetpack is replenished during downtime. - /// - /// The rate at which the jetpack is replenished. + /// @param newValue The rate at which the jetpack is replenished. void SetMinimumFuelRatio(float newValue) { m_MinimumFuelRatio = newValue; } - /// /// Gets the scalar ratio at which this jetpack's thrust angle follows the aim angle of the user. - /// - /// The ratio at which this jetpack follows the aim angle of the user. + /// @return The ratio at which this jetpack follows the aim angle of the user. float GetJetAngleRange() const { return m_JetAngleRange; } - /// /// Sets the scalar ratio at which this jetpack's thrust angle follows the aim angle of the user. - /// - /// The ratio at which this jetpack follows the aim angle of the user. + /// @param newValue The ratio at which this jetpack follows the aim angle of the user. void SetJetAngleRange(float newValue) { m_JetAngleRange = newValue; } - /// /// Gets the type of this jetpack. - /// - /// The type of this jetpack. + /// @return The type of this jetpack. JetpackType GetJetpackType() const { return m_JetpackType; } - /// /// Sets the type of this jetpack. - /// - /// The new type of this jetpack. + /// @param newType The new type of this jetpack. void SetJetpackType(JetpackType newType) { m_JetpackType = newType; } - /// /// Returns whether the angle of this jetpack can adjust while firing, or if it can only be aimed while off. - /// - /// Whether the angle of this jetpack can adjust while firing. + /// @return Whether the angle of this jetpack can adjust while firing. bool GetCanAdjustAngleWhileFiring() const { return m_CanAdjustAngleWhileFiring; } - /// /// Sets whether the angle of this can adjust while firing, or if it can only be aimed while off. - /// - /// The new value for whether the angle of this jetpack can adjust while firing. + /// @param newValue The new value for whether the angle of this jetpack can adjust while firing. void SetCanAdjustAngleWhileFiring(bool newValue) { m_CanAdjustAngleWhileFiring = newValue; } - /// /// Returns whether this jetpack adjusts it's throttle to balance for extra weight. - /// - /// Whether this jetpack adjusts it's throttle to balance for extra weight. + /// @return Whether this jetpack adjusts it's throttle to balance for extra weight. bool GetAdjustsThrottleForWeight() const { return m_AdjustsThrottleForWeight; } - /// /// Sets whether this jetpack adjusts it's throttle to balance for extra weight. - /// - /// The new value for whether this jetpack adjusts it's throttle to balance for extra weight. + /// @param newValue The new value for whether this jetpack adjusts it's throttle to balance for extra weight. void SetAdjustsThrottleForWeight(bool newValue) { m_AdjustsThrottleForWeight = newValue; } protected: @@ -190,29 +138,21 @@ namespace RTE { bool m_AdjustsThrottleForWeight; //!< Whether or not the jetpack throttle auto-adjusts for weight, at the cost of fuel usage. private: - /// /// The logic to run when bursting. - /// - /// The parent actor using this jetpack. - /// The multiplier to fuel usage rate. + /// @param parentActor The parent actor using this jetpack. + /// @param fuelUseMultiplier The multiplier to fuel usage rate. void Burst(Actor& parentActor, float fuelUseMultiplier); - /// /// The logic to run when thrusting. - /// - /// The parent actor using this jetpack. - /// The multiplier to fuel usage rate. + /// @param parentActor The parent actor using this jetpack. + /// @param fuelUseMultiplier The multiplier to fuel usage rate. void Thrust(Actor& parentActor, float fuelUseMultiplier); - /// /// The logic to run when recharging. - /// - /// The parent actor using this jetpack. + /// @param parentActor The parent actor using this jetpack. void Recharge(Actor& parentActor); - /// /// Clears all the member variables of this AEJetpack, effectively resetting the members of this abstraction level only. - /// void Clear(); // Disallow the use of some implicit methods. diff --git a/Source/Entities/AEmitter.cpp b/Source/Entities/AEmitter.cpp index 3b50228d34..40f107c92e 100644 --- a/Source/Entities/AEmitter.cpp +++ b/Source/Entities/AEmitter.cpp @@ -1,15 +1,3 @@ -////////////////////////////////////////////////////////////////////////////////////////// -// File: AEmitter.cpp -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Source file for the AEmitter class. -// Project: Retro Terrain Engine -// Author(s): Daniel Tabar -// data@datarealms.com -// http://www.datarealms.com - -////////////////////////////////////////////////////////////////////////////////////////// -// Inclusions of header files - #include "AEmitter.h" #include "Atom.h" #include "Emission.h" @@ -19,12 +7,6 @@ namespace RTE { ConcreteClassInfo(AEmitter, Attachable, 100); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Clear - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears all the member variables of this AEmitter, effectively - // resetting the members of this abstraction level only. - void AEmitter::Clear() { m_EmissionList.clear(); m_EmissionSound = nullptr; @@ -60,11 +42,6 @@ namespace RTE { m_LoudnessOnEmit = 1.0F; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Creates a AEmitter to be identical to another, by deep copy. - int AEmitter::Create(const AEmitter& reference) { if (reference.m_pFlash) { m_ReferenceHardcodedAttachableUniqueIDs.insert(reference.m_pFlash->GetUniqueID()); @@ -112,14 +89,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: ReadProperty - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Reads a property value from a reader stream. If the name isn't - // recognized by this class, then ReadProperty of the parent class - // is called. If the property isn't recognized by any of the base classes, - // false is returned, and the reader's position is untouched. - int AEmitter::ReadProperty(const std::string_view& propName, Reader& reader) { StartPropertyList(return Attachable::ReadProperty(propName, reader)); @@ -181,12 +150,6 @@ namespace RTE { EndPropertyList; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Save - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Saves the complete state of this AEmitter with a Writer for - // later recreation with Create(Reader &reader); - int AEmitter::Save(Writer& writer) const { Attachable::Save(writer); @@ -246,11 +209,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destroys and resets (through Clear()) the AEmitter object. - void AEmitter::Destroy(bool notInherited) { // Stop playback of sounds gracefully if (m_EmissionSound) { @@ -271,23 +229,12 @@ namespace RTE { Clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ResetEmissionTimers - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Reset the timers of all emissions so they will start/stop at the - // correct relative offsets from now. - void AEmitter::ResetEmissionTimers() { m_LastEmitTmr.Reset(); for (auto eItr = m_EmissionList.begin(); eItr != m_EmissionList.end(); ++eItr) (*eItr).ResetEmissionTimers(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: EnableEmission - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets this AEmitter to start emitting at the set rate, or to stop. - void AEmitter::EnableEmission(bool enable) { if (!m_EmitEnabled && enable) { m_LastEmitTmr.Reset(); @@ -299,11 +246,6 @@ namespace RTE { m_EmitEnabled = enable; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: EstimateImpulse - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Calculates the forces this emitter applies on any parent. - float AEmitter::EstimateImpulse(bool burst) { // Calculate the impulse generated by the emissions, once and store the result if ((!burst && m_AvgImpulse < 0) || (burst && m_AvgBurstImpulse < 0)) { @@ -345,8 +287,6 @@ namespace RTE { return m_AvgImpulse * throttleFactor; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - float AEmitter::GetTotalParticlesPerMinute() const { float totalPPM = 0; for (const Emission& emission: m_EmissionList) { @@ -355,8 +295,6 @@ namespace RTE { return totalPPM; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int AEmitter::GetTotalBurstSize() const { int totalBurstSize = 0; for (const Emission& emission: m_EmissionList) { @@ -365,15 +303,11 @@ namespace RTE { return totalBurstSize; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - float AEmitter::GetScaledThrottle(float throttle, float multiplier) const { float throttleFactor = LERP(-1.0f, 1.0f, m_NegativeThrottleMultiplier, m_PositiveThrottleMultiplier, throttle); return LERP(m_NegativeThrottleMultiplier, m_PositiveThrottleMultiplier, -1.0f, 1.0f, throttleFactor * multiplier); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void AEmitter::SetFlash(Attachable* newFlash) { if (m_pFlash && m_pFlash->IsAttached()) { RemoveAndDeleteAttachable(m_pFlash); @@ -398,13 +332,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Update - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates this AEmitter. Supposed to be done every frame. - void AEmitter::Update() { Attachable::PreUpdate(); @@ -611,12 +538,6 @@ namespace RTE { } } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Draw - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws this AEmitter's current graphical representation to a - // BITMAP of choice. - void AEmitter::Draw(BITMAP* pTargetBitmap, const Vector& targetPos, DrawMode mode, diff --git a/Source/Entities/AEmitter.h b/Source/Entities/AEmitter.h index 5459480983..780384147a 100644 --- a/Source/Entities/AEmitter.h +++ b/Source/Entities/AEmitter.h @@ -1,35 +1,20 @@ #ifndef _RTEAEMITTER_ #define _RTEAEMITTER_ -////////////////////////////////////////////////////////////////////////////////////////// -// File: AEmitter.h -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Header file for the AEmitter class. -// Project: Retro Terrain Engine -// Author(s): Daniel Tabar -// data@datarealms.com -// http://www.datarealms.com - -////////////////////////////////////////////////////////////////////////////////////////// -// Inclusions of header files - +/// Header file for the AEmitter class. +/// @author Daniel Tabar +/// data@datarealms.com +/// http://www.datarealms.com +/// Inclusions of header files #include "Attachable.h" #include "Emission.h" namespace RTE { - ////////////////////////////////////////////////////////////////////////////////////////// - // Class: AEmitter - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: An attachable MO that creates and emits particle MO's. - // Parent(s): Attachable. - // Class history: 02/29/2004 AEmitter created. - + /// An attachable MO that creates and emits particle MO's. class AEmitter : public Attachable { - ////////////////////////////////////////////////////////////////////////////////////////// - // Public member variable, method and friend function declarations - + /// Public member variable, method and friend function declarations public: friend struct EntityLuaBindings; @@ -38,172 +23,92 @@ namespace RTE { SerializableOverrideMethods; ClassInfoGetters; - ////////////////////////////////////////////////////////////////////////////////////////// - // Constructor: AEmitter - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Constructor method used to instantiate a AEmitter object in system - // memory. Create() should be called before using the object. - // Arguments: None. - + /// Constructor method used to instantiate a AEmitter object in system + /// memory. Create() should be called before using the object. AEmitter() { Clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Destructor: ~AEmitter - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destructor method used to clean up a AEmitter object before deletion - // from system memory. - // Arguments: None. - + /// Destructor method used to clean up a AEmitter object before deletion + /// from system memory. ~AEmitter() override { Destroy(true); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Creates a AEmitter to be identical to another, by deep copy. - // Arguments: A reference to the AEmitter to deep copy. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Creates a AEmitter to be identical to another, by deep copy. + /// @param reference A reference to the AEmitter to deep copy. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Create(const AEmitter& reference); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Reset - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Resets the entire AEmitter, including its inherited members, to their - // default settings or values. - // Arguments: None. - // Return value: None. - + /// Resets the entire AEmitter, including its inherited members, to their + /// default settings or values. void Reset() override { Clear(); MOSRotating::Reset(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destroys and resets (through Clear()) the SceneLayer object. - // Arguments: Whether to only destroy the members defined in this derived class, or - // to destroy all inherited members also. - // Return value: None. - + /// Destroys and resets (through Clear()) the SceneLayer object. + /// @param notInherited Whether to only destroy the members defined in this derived class, or (default: false) + /// to destroy all inherited members also. void Destroy(bool notInherited = false) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: IsEmitting - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Indicates whether this AEmitter is currently enabled and emitting. - // Arguments: None. - // Return value: Whether it's emitting or not. - + /// Indicates whether this AEmitter is currently enabled and emitting. + /// @return Whether it's emitting or not. bool IsEmitting() const { return m_EmitEnabled; } - /// /// Returns whether this emitter was emitting last frame. - /// - /// Whether this emitter was emitting last frame. + /// @return Whether this emitter was emitting last frame. bool WasEmitting() const { return m_WasEmitting; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ResetEmissionTimers - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Reset the timers of all emissions so they will start/stop at the - // correct relative offsets from now. - // Arguments: None. - // Return value: None. - + /// Reset the timers of all emissions so they will start/stop at the + /// correct relative offsets from now. void ResetEmissionTimers(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: EnableEmission - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets this AEmitter to start emitting at the set rate, or to stop. - // Arguments: Whether to enable or disable emission. - // Return value: None. - + /// Sets this AEmitter to start emitting at the set rate, or to stop. + /// @param enable Whether to enable or disable emission. (default: true) void EnableEmission(bool enable = true); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: EstimateImpulse - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Calculates the forces this emitter applies on any parent. - // Arguments: Whether to calculate a burst update or not. - // Return value: The approximate impulse generated by the emitter. - + /// Calculates the forces this emitter applies on any parent. + /// @param burst Whether to calculate a burst update or not. (default: false) + /// @return The approximate impulse generated by the emitter. float EstimateImpulse(bool burst = false); - /// /// Gets the rate at which all of the Emissions of this AEmitter, combined, emit their particles. - /// - /// The combined particles per minute of all Emissions in this AEmitter. + /// @return The combined particles per minute of all Emissions in this AEmitter. float GetTotalParticlesPerMinute() const; - /// /// Gets the number of particles that will be emitted by all the Emissions of this AEmitter combined, in one shot when a burst is triggered. - /// - /// The combined burst size of all Emissions in this AEmitter. + /// @return The combined burst size of all Emissions in this AEmitter. int GetTotalBurstSize() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetBurstScale - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the scale factor that will be applied to the regular spread and - // emission velocity to get the burst particle parameters. - // Arguments: None. - // Return value: The scale factor. - + /// Gets the scale factor that will be applied to the regular spread and + /// emission velocity to get the burst particle parameters. + /// @return The scale factor. float GetBurstScale() const { return m_BurstScale; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetEmitAngle - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the angle of direction that the emitted particles will be shot at. - // Arguments: None. - // Return value: A float with the angle in radians. - + /// Gets the angle of direction that the emitted particles will be shot at. + /// @return A float with the angle in radians. float GetEmitAngle() const { return m_EmitAngle.GetRadAngle(); } const Matrix& GetEmitAngleMatrix() const { return m_EmitAngle; } - /// /// Gets the offset of the emission point from this' sprite center, which gets rotated with this. - /// - /// The emission offset. + /// @return The emission offset. Vector GetEmitOffset() const { return m_EmissionOffset; } - /// /// Sets the offset of the emission point from this' sprite center, which gets rotated with this. - /// - /// The new emission offset. + /// @param newOffset The new emission offset. void SetEmitOffset(const Vector& newOffset) { m_EmissionOffset = newOffset; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetEmitVector - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: A vector in the direction, including the rotation of the emitter, that - // the emitted particles will be shot at. - // Arguments: None. - // Return value: A unit vector. - + /// A vector in the direction, including the rotation of the emitter, that + /// the emitted particles will be shot at. + /// @return A unit vector. Vector GetEmitVector() const { return Vector(1, 0).RadRotate(m_HFlipped ? c_PI + m_Rotation.GetRadAngle() - m_EmitAngle.GetRadAngle() : m_Rotation.GetRadAngle() + m_EmitAngle.GetRadAngle()); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetRecoilVector - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: A vector in the opposite direction, including the rotation of the - // emitter, that the emitted particles will be shot at. - // Arguments: None. - // Return value: A unit vector. - + /// A vector in the opposite direction, including the rotation of the + /// emitter, that the emitted particles will be shot at. + /// @return A unit vector. Vector GetRecoilVector() const { return Vector(-1, 0).RadRotate(m_HFlipped ? c_PI + m_Rotation.GetRadAngle() - m_EmitAngle.GetRadAngle() : m_Rotation.GetRadAngle() + m_EmitAngle.GetRadAngle()); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetBurstSpacing - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the BurstSpacing for this emitter. - // Arguments: None. - // Return value: The BurstSpacing in ms. - + /// Gets the BurstSpacing for this emitter. + /// @return The BurstSpacing in ms. float GetBurstSpacing() const { return m_BurstSpacing; } /* @@ -242,64 +147,45 @@ namespace RTE { float GetEmitVelMax() const { return m_MaxVelocity; } */ - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetThrottle - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the normalized throttle scalar which controls how to affect the - // emission rate as per the emisison rate range. Depricated for Lua, use - // the Throttle property instead. - // Arguments: None. - // Return value: A float with the normalized throttle scalar. 1.0 means max throttle, - // 0 means normal, -1.0 means least emission rate. - + /// Gets the normalized throttle scalar which controls how to affect the + /// emission rate as per the emisison rate range. Depricated for Lua, use + /// the Throttle property instead. + /// @return A float with the normalized throttle scalar. 1.0 means max throttle, + /// 0 means normal, -1.0 means least emission rate. float GetThrottle() const { return m_Throttle; } - /// /// Gets the adjusted throttle multiplier that is factored into the emission rate of this AEmitter. - /// - /// The throttle strength as a multiplier. + /// @return The throttle strength as a multiplier. float GetThrottleFactor() const { return LERP(-1.0f, 1.0f, m_NegativeThrottleMultiplier, m_PositiveThrottleMultiplier, m_Throttle); } - /// /// Gets the throttle value that will achieve a given throttle factor that is factored into the emission rate of this AEmitter. - /// - /// The throttle value that will achieve the given throttle factor. + /// @return The throttle value that will achieve the given throttle factor. float GetThrottleForThrottleFactor(float throttleFactor) const { return LERP(m_NegativeThrottleMultiplier, m_PositiveThrottleMultiplier, -1.0f, 1.0f, throttleFactor); } - /// /// Returns a scaled throttle value that represents a linear increase of force. /// Because of (bad) reasons, throttle is in the range -1.0F to 1.0F, where -1.0F is "minimum force" and 1.0F is "maximum force". /// 0.0F is "whoever the fuck knows?" force. As such, multiplying throttle by 2 does not mean twice the force emitted, instead it means "whoever the fuck knows?" additional force emitted. /// All work and no play makes Jack a dull boy. All work and no play makes Jack a dull boy. All work and no play makes Jack a dull boy. /// ...this helper function lets us apply a scale to throttle and get a sensible result. - /// - /// The throttle value to be considered. - /// The multiplier to scale by, in terms of absolute force emitted. - /// Adjusted throttle value scaled by the multiplier value. + /// @param throttle The throttle value to be considered. + /// @param multiplier The multiplier to scale by, in terms of absolute force emitted. + /// @return Adjusted throttle value scaled by the multiplier value. float GetScaledThrottle(float throttle, float multiplier) const; - /// /// Gets the negative throttle multiplier of this AEmitter. - /// - /// The negative throttle multiplier of this AEmitter. + /// @return The negative throttle multiplier of this AEmitter. float GetNegativeThrottleMultiplier() const { return m_NegativeThrottleMultiplier; } - /// /// Gets the positive throttle multiplier of this AEmitter. - /// - /// The positive throttle multiplier of this AEmitter. + /// @return The positive throttle multiplier of this AEmitter. float GetPositiveThrottleMultiplier() const { return m_PositiveThrottleMultiplier; } - /// /// Sets the negative throttle multiplier of this AEmitter. - /// - /// The new throttle multiplier of this AEmitter. + /// @param newValue The new throttle multiplier of this AEmitter. void SetNegativeThrottleMultiplier(float newValue) { m_NegativeThrottleMultiplier = newValue; } - /// /// Sets the positive throttle multiplier of this AEmitter. - /// - /// The new throttle multiplier of this AEmitter. + /// @param newValue The new throttle multiplier of this AEmitter. void SetPositiveThrottleMultiplier(float newValue) { m_PositiveThrottleMultiplier = newValue; } /* @@ -325,75 +211,41 @@ namespace RTE { void SetBurstCount(const int count) { m_BurstSize = count; } */ - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetBurstScale - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the scale factor that will be applied to the regular spread and - // emission velocity to get the burst particle parameters. - // Arguments: The scale factor. - // Return value: None. - + /// Sets the scale factor that will be applied to the regular spread and + /// emission velocity to get the burst particle parameters. + /// @param scale The scale factor. void SetBurstScale(const float scale) { m_BurstScale = scale; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetBurstSpacing - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the BurstSpacing for this emitter. - // Arguments: The BurstSpacing in ms. - // Return value: None. - + /// Sets the BurstSpacing for this emitter. + /// @param spacing The BurstSpacing in ms. void SetBurstSpacing(const float spacing) { m_BurstSpacing = spacing; } - /// /// Gets the flash of this AEmitter. - /// - /// A pointer to the AEmitter's flash. Ownership is NOT transferred! + /// @return A pointer to the AEmitter's flash. Ownership is NOT transferred! Attachable* GetFlash() const { return m_pFlash; } - /// /// Sets the flash for this AEmitter. Ownership IS transferred! - /// - /// The new flash to use. + /// @param newFlash The new flash to use. void SetFlash(Attachable* newFlash); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetFlashScale - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the display scale factor of the flash effect. This is purely - // visual. - // Arguments: None. - // Return value: The scale factor of the flash draw. - + /// Gets the display scale factor of the flash effect. This is purely + /// visual. + /// @return The scale factor of the flash draw. float GetFlashScale() const { return m_FlashScale; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetFlashScale - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the display scale factor of the flash effect. This is purely - // visual. - // Arguments: The scale factor of the flash draw. - // Return value: None. - + /// Sets the display scale factor of the flash effect. This is purely + /// visual. + /// @param flashScale The scale factor of the flash draw. (default: 1.0f) void SetFlashScale(float flashScale = 1.0f) { m_FlashScale = flashScale; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetEmitAngle - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the angle of direction that the emitted particles will be shot at. - // Arguments: A float with the angle in radians. - // Return value: None. - + /// Sets the angle of direction that the emitted particles will be shot at. + /// @param m_EmitAngle.SetRadAngle(angle A float with the angle in radians. void SetEmitAngle(const float angle) { m_EmitAngle.SetRadAngle(angle); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetThrottle - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the normalized throttle scalar which controls how to affect the - // emission rate as per the emisison rate range. - // Arguments: A float with the normalized throttle scalar. 1.0 means max throttle, - // 0 means normal, -1.0 means least emission rate. - // Return value: None. - + /// Sets the normalized throttle scalar which controls how to affect the + /// emission rate as per the emisison rate range. + /// @param m_Throttle A float with the normalized throttle scalar. 1.0 means max throttle, (default: throttle > 1.0f ? 1.0f : (throttle < -1.0f ? -1.0f : throttle) + /// 0 means normal, -1.0 means least emission rate. void SetThrottle(float throttle) { m_Throttle = throttle > 1.0f ? 1.0f : (throttle < -1.0f ? -1.0f : throttle); } /* @@ -432,219 +284,118 @@ namespace RTE { void SetEmitVelMax(const float maxVel) { m_MaxVelocity = maxVel; } */ - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: TriggerBurst - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Triggers a one-shot burst of emissions in the number that has - // previously been set. The burst will happen during the next Update of - // this AEmitter. - // Arguments: None. - // Return value: None. - + /// Triggers a one-shot burst of emissions in the number that has + /// previously been set. The burst will happen during the next Update of + /// this AEmitter. void TriggerBurst() { m_BurstTriggered = true; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: CanTriggerBurst - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Checks if it is possible to trigger a one-shot burst of emissions during - // the next Update of this AEmitter. - // Arguments: None. - // Return value: If it is possible to trigger a burst. - + /// Checks if it is possible to trigger a one-shot burst of emissions during + /// the next Update of this AEmitter. + /// @return If it is possible to trigger a burst. bool CanTriggerBurst() { return m_BurstSpacing <= 0 || m_BurstTimer.IsPastSimMS(m_BurstSpacing); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: IsSetToBurst - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Indicates whether this AEmitter is set to burst next update or not. - // Arguments: None. - // Return value: Whether a burst is gonna happen or not.. - + /// Indicates whether this AEmitter is set to burst next update or not. + /// @return Whether a burst is gonna happen or not.. bool IsSetToBurst() const { return m_BurstTriggered; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: AlarmOnEmit - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Registers a new AlarmEvent if this emitter has a loudness above zero. - // Arguments: Team that will ignore this AlarmEvent. - // Return value: None. - + /// Registers a new AlarmEvent if this emitter has a loudness above zero. + /// @param Team Team that will ignore this AlarmEvent. void AlarmOnEmit(int Team) const { if (m_LoudnessOnEmit > 0) g_MovableMan.RegisterAlarmEvent(AlarmEvent(m_Pos, Team, m_LoudnessOnEmit)); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: ResetAllTimers - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Resest all the timers used by this. Can be emitters, etc. This is to - // prevent backed up emissions to come out all at once while this has been - // held dormant in an inventory. - // Arguments: None. - // Return value: None. - + /// Resest all the timers used by this. Can be emitters, etc. This is to + /// prevent backed up emissions to come out all at once while this has been + /// held dormant in an inventory. void ResetAllTimers() override { Attachable::ResetAllTimers(); m_BurstTimer.Reset(); m_LastEmitTmr.Reset(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Update - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates this MovableObject. Supposed to be done every frame. - // Arguments: None. - // Return value: None. - + /// Updates this MovableObject. Supposed to be done every frame. void Update() override; void PostUpdate() override { Attachable::PostUpdate(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetBurstDamage - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns burst damage of this emitter. - // Arguments: None. - // Return value: Burst damage of emitter. - + /// Returns burst damage of this emitter. + /// @return Burst damage of emitter. float GetBurstDamage() const { return m_BurstDamage * m_EmitterDamageMultiplier; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetBurstDamage - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets burst damage of this emitter. - // Arguments: Burst damage of emitter. - // Return value: None. - + /// Sets burst damage of this emitter. + /// @param newValue Burst damage of emitter. void SetBurstDamage(float newValue) { m_BurstDamage = newValue; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetEmitDamage - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns emit damage of this emitter. - // Arguments: None. - // Return value: Emit damage of emitter. - + /// Returns emit damage of this emitter. + /// @return Emit damage of emitter. float GetEmitDamage() const { return m_EmitDamage * m_EmitterDamageMultiplier; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetEmitDamage - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets emit damage of this emitter. - // Arguments: Emit damage of emitter. - // Return value: None. - + /// Sets emit damage of this emitter. + /// @param newValue Emit damage of emitter. void SetEmitDamage(float newValue) { m_EmitDamage = newValue; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetEmitterDamageMultiplier - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns damage multiplier of this emitter. - // Arguments: None. - // Return value: Damage multiplier of emitter. - + /// Returns damage multiplier of this emitter. + /// @return Damage multiplier of emitter. float GetEmitterDamageMultiplier() const { return m_EmitterDamageMultiplier; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetEmitterDamageMultiplier - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets damage multiplier of this emitter. - // Arguments: New damage multiplier of emitter - // Return value: None. - + /// Sets damage multiplier of this emitter. + /// @param newValue New damage multiplier of emitter void SetEmitterDamageMultiplier(float newValue) { m_EmitterDamageMultiplier = newValue; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Draw - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws this AEmitter's current graphical representation to a - // BITMAP of choice. - // Arguments: A pointer to a BITMAP to draw on. - // The absolute position of the target bitmap's upper left corner in the Scene. - // In which mode to draw in. See the DrawMode enumeration for the modes. - // Whether to not draw any extra 'ghost' items of this MovableObject, - // indicator arrows or hovering HUD text and so on. - // Return value: None. - + /// Draws this AEmitter's current graphical representation to a + /// BITMAP of choice. + /// @param pTargetBitmap A pointer to a BITMAP to draw on. + /// @param targetPos The absolute position of the target bitmap's upper left corner in the Scene. (default: Vector()) + /// @param mode In which mode to draw in. See the DrawMode enumeration for the modes. (default: g_DrawColor) + /// @param onlyPhysical Whether to not draw any extra 'ghost' items of this MovableObject, (default: false) + /// indicator arrows or hovering HUD text and so on. void Draw(BITMAP* pTargetBitmap, const Vector& targetPos = Vector(), DrawMode mode = g_DrawColor, bool onlyPhysical = false) const override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: IsDamaging - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Indicates whether this emitter deals damage. - // Arguments: None. - // Return value: Returns true if this emitter deals damage. - + /// Indicates whether this emitter deals damage. + /// @return Returns true if this emitter deals damage. bool IsDamaging() { return (m_EmitDamage > 0 || m_BurstDamage > 0) && m_EmitterDamageMultiplier > 0; } - /// /// Gets the number of emissions emitted since emission was last enabled. - /// - /// The number of emissions emitted since emission was last enabled. + /// @return The number of emissions emitted since emission was last enabled. long GetEmitCount() const { return m_EmitCount; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetEmitCountLimit - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the number of emissions left before emitter is disabled. - // Arguments: None. - // Return value: Returns the number of emissions left before emitter is disabled. - + /// Gets the number of emissions left before emitter is disabled. + /// @return Returns the number of emissions left before emitter is disabled. long GetEmitCountLimit() const { return m_EmitCountLimit; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetEmitCountLimit - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the number of emissions left before emitter is disabled. - // Arguments: New number of emissions left - // Return value: None. - + /// Sets the number of emissions left before emitter is disabled. + /// @param newValue New number of emissions left void SetEmitCountLimit(long newValue) { m_EmitCountLimit = newValue; } - /// /// Gets this AEmitter's emission sound. Ownership is NOT transferred! - /// - /// The SoundContainer for this AEmitter's emission sound. + /// @return The SoundContainer for this AEmitter's emission sound. SoundContainer* GetEmissionSound() const { return m_EmissionSound; } - /// /// Sets this AEmitter's emission sound. Ownership IS transferred! - /// - /// The new SoundContainer for this AEmitter's emission sound. + /// @param newSound The new SoundContainer for this AEmitter's emission sound. void SetEmissionSound(SoundContainer* newSound) { m_EmissionSound = newSound; } - /// /// Gets this AEmitter's burst sound. Ownership is NOT transferred! - /// - /// The SoundContainer for this AEmitter's burst sound. + /// @return The SoundContainer for this AEmitter's burst sound. SoundContainer* GetBurstSound() const { return m_BurstSound; } - /// /// Sets this AEmitter's burst sound. Ownership IS transferred! - /// - /// The new SoundContainer for this AEmitter's burst sound. + /// @param newSound The new SoundContainer for this AEmitter's burst sound. void SetBurstSound(SoundContainer* newSound) { m_BurstSound = newSound; } - /// /// Gets this AEmitter's end sound. Ownership is NOT transferred! - /// - /// The SoundContainer for this AEmitter's end sound. + /// @return The SoundContainer for this AEmitter's end sound. SoundContainer* GetEndSound() const { return m_EndSound; } - /// /// Sets this AEmitter's end sound. Ownership IS transferred! - /// - /// The new SoundContainer for this AEmitter's end sound. + /// @param newSound The new SoundContainer for this AEmitter's end sound. void SetEndSound(SoundContainer* newSound) { m_EndSound = newSound; } - /// /// Returns whether this emitter just started emitting this frame. - /// - /// Whether this emitter just started emitting this frame. + /// @return Whether this emitter just started emitting this frame. bool JustStartedEmitting() const { return !m_WasEmitting && m_EmitEnabled; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Protected member variable and method declarations - + /// Protected member variable and method declarations protected: // Member variables static Entity::ClassInfo m_sClass; @@ -707,18 +458,10 @@ namespace RTE { // Whether the burst sound follows the emitter bool m_BurstSoundFollowsEmitter; - ////////////////////////////////////////////////////////////////////////////////////////// - // Private member variable and method declarations - + /// Private member variable and method declarations private: - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Clear - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears all the member variables of this AEmitter, effectively - // resetting the members of this abstraction level only. - // Arguments: None. - // Return value: None. - + /// Clears all the member variables of this AEmitter, effectively + /// resetting the members of this abstraction level only. void Clear(); // Disallow the use of some implicit methods. diff --git a/Source/Entities/AHuman.cpp b/Source/Entities/AHuman.cpp index 8ce1510a20..f22695d91f 100644 --- a/Source/Entities/AHuman.cpp +++ b/Source/Entities/AHuman.cpp @@ -1,15 +1,3 @@ -////////////////////////////////////////////////////////////////////////////////////////// -// File: AHuman.cpp -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Source file for the AHuman class. -// Project: Retro Terrain Engine -// Author(s): Daniel Tabar -// data@datarealms.com -// http://www.datarealms.com - -////////////////////////////////////////////////////////////////////////////////////////// -// Inclusions of header files - #include "AHuman.h" #include "AtomGroup.h" @@ -37,12 +25,6 @@ namespace RTE { ConcreteClassInfo(AHuman, Actor, 20); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Clear - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears all the member variables of this AHuman, effectively - // resetting the members of this abstraction level only. - void AHuman::Clear() { m_pHead = 0; m_LookToAimRatio = 0.7F; @@ -108,11 +90,6 @@ namespace RTE { m_JumpTimer.Reset(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes the AHuman object ready for use. - int AHuman::Create() { if (Actor::Create() < 0) { return -1; @@ -149,11 +126,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Creates a AHuman to be identical to another, by deep copy. - int AHuman::Create(const AHuman& reference) { if (reference.m_pBGArm) { m_ReferenceHardcodedAttachableUniqueIDs.insert(reference.m_pBGArm->GetUniqueID()); @@ -261,14 +233,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: ReadProperty - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Reads a property value from a reader stream. If the name isn't - // recognized by this class, then ReadProperty of the parent class - // is called. If the property isn't recognized by any of the base classes, - // false is returned, and the reader's position is untouched. - int AHuman::ReadProperty(const std::string_view& propName, Reader& reader) { StartPropertyList(return Actor::ReadProperty(propName, reader)); @@ -334,12 +298,6 @@ namespace RTE { EndPropertyList; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Save - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Saves the complete state of this AHuman with a Writer for - // later recreation with Create(Reader &reader); - int AHuman::Save(Writer& writer) const { Actor::Save(writer); @@ -401,11 +359,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destroys and resets (through Clear()) the AHuman object. - void AHuman::Destroy(bool notInherited) { delete m_pFGHandGroup; delete m_pBGHandGroup; @@ -420,12 +373,6 @@ namespace RTE { Clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetTotalValue - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the total liquidation value of this Actor and all its carried - // gold and inventory. - float AHuman::GetTotalValue(int nativeModule, float foreignMult, float nativeMult) const { float totalValue = Actor::GetTotalValue(nativeModule, foreignMult, nativeMult); @@ -436,12 +383,6 @@ namespace RTE { return totalValue; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: HasObject - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Shows whether this carries a specifically named object in its inventory. - // Also looks through the inventories of potential passengers, as applicable. - bool AHuman::HasObject(std::string objectName) const { bool found = Actor::HasObject(objectName); @@ -454,13 +395,6 @@ namespace RTE { return found; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: HasObjectInGroup - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Shows whether this is or carries a specifically grouped object in its - // inventory. Also looks through the inventories of potential passengers, - // as applicable. - bool AHuman::HasObjectInGroup(std::string groupName) const { bool found = Actor::HasObjectInGroup(groupName); @@ -473,11 +407,6 @@ namespace RTE { return found; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: GetCPUPos - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the absoltue position of this' brain, or equivalent. - Vector AHuman::GetCPUPos() const { if (m_pHead && m_pHead->IsAttached()) return m_Pos + ((m_pHead->GetParentOffset().GetXFlipped(m_HFlipped) * m_Rotation) * 1.5); @@ -485,12 +414,6 @@ namespace RTE { return m_Pos; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: GetEyePos - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the absoltue position of this' eye, or equivalent, where look - // vector starts from. - Vector AHuman::GetEyePos() const { if (m_pHead && m_pHead->IsAttached()) { return m_Pos + m_pHead->GetParentOffset() * 1.2F; @@ -499,8 +422,6 @@ namespace RTE { return m_Pos; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void AHuman::SetHead(Attachable* newHead) { if (m_pHead && m_pHead->IsAttached()) { RemoveAndDeleteAttachable(m_pHead); @@ -525,8 +446,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void AHuman::SetJetpack(AEJetpack* newJetpack) { if (m_pJetpack && m_pJetpack->IsAttached()) { RemoveAndDeleteAttachable(m_pJetpack); @@ -550,8 +469,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void AHuman::SetFGArm(Arm* newArm) { if (m_pFGArm && m_pFGArm->IsAttached()) { RemoveAndDeleteAttachable(m_pFGArm); @@ -576,8 +493,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void AHuman::SetBGArm(Arm* newArm) { if (m_pBGArm && m_pBGArm->IsAttached()) { RemoveAndDeleteAttachable(m_pBGArm); @@ -601,8 +516,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void AHuman::SetFGLeg(Leg* newLeg) { if (m_pFGLeg && m_pFGLeg->IsAttached()) { RemoveAndDeleteAttachable(m_pFGLeg); @@ -625,8 +538,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void AHuman::SetBGLeg(Leg* newLeg) { if (m_pBGLeg && m_pBGLeg->IsAttached()) { RemoveAndDeleteAttachable(m_pBGLeg); @@ -650,21 +561,10 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - BITMAP* AHuman::GetGraphicalIcon() const { return m_GraphicalIcon ? m_GraphicalIcon : (m_pHead ? m_pHead->GetSpriteFrame(0) : GetSpriteFrame(0)); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: CollideAtPoint - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Calculates the collision response when another MO's Atom collides with - // this MO's physical representation. The effects will be applied - // directly to this MO, and also represented in the passed in HitData. - bool AHuman::CollideAtPoint(HitData& hd) { return Actor::CollideAtPoint(hd); @@ -729,8 +629,6 @@ namespace RTE { } */ - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool AHuman::HandlePieCommand(PieSlice::SliceType pieSliceIndex) { if (pieSliceIndex != PieSlice::SliceType::NoType) { if (pieSliceIndex == PieSlice::SliceType::Pickup) { @@ -763,14 +661,6 @@ namespace RTE { return false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual Method: AddInventoryItem - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Adds an inventory item to this AHuman. This also puts that item - // directly in the hands of this if they are empty. - void AHuman::AddInventoryItem(MovableObject* pItemToAdd) { // If we have nothing in inventory, and nothing in our hands, just grab this first thing added to us. if (HeldDevice* itemToAddAsHeldDevice = dynamic_cast(pItemToAdd); itemToAddAsHeldDevice && m_Inventory.empty() && m_pFGArm && m_pFGArm->IsAttached() && !m_pFGArm->GetHeldDevice()) { @@ -783,8 +673,6 @@ namespace RTE { EquipShieldInBGArm(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - MovableObject* AHuman::SwapNextInventory(MovableObject* inventoryItemToSwapIn, bool muteSound) { MovableObject* swappedInventoryItem = Actor::SwapNextInventory(inventoryItemToSwapIn, muteSound); while (!dynamic_cast(swappedInventoryItem) && !m_Inventory.empty()) { @@ -795,8 +683,6 @@ namespace RTE { return swappedInventoryItem; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - MovableObject* AHuman::SwapPrevInventory(MovableObject* inventoryItemToSwapIn) { MovableObject* swappedInventoryItem = Actor::SwapPrevInventory(inventoryItemToSwapIn); while (!dynamic_cast(swappedInventoryItem) && !m_Inventory.empty()) { @@ -807,15 +693,6 @@ namespace RTE { return swappedInventoryItem; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual Method: EquipFirearm - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Switches the currently held device (if any) to the first found firearm - // in the inventory. If the held device already is a firearm, or no - // firearm is in inventory, nothing happens. - bool AHuman::EquipFirearm(bool doEquip) { if (!(m_pFGArm && m_pFGArm->IsAttached())) { return false; @@ -864,13 +741,6 @@ namespace RTE { return false; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual Method: EquipDeviceInGroup - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Switches the currently held device (if any) to the first found device - // of the specified group in the inventory. If the held device already - // is of that group, or no device is in inventory, nothing happens. - bool AHuman::EquipDeviceInGroup(std::string group, bool doEquip) { if (!(m_pFGArm && m_pFGArm->IsAttached())) { return false; @@ -929,13 +799,6 @@ namespace RTE { return false; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual Method: EquipLoadedFirearmInGroup - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Switches the currently held device (if any) to the first loaded HDFirearm - // of the specified group in the inventory. If no such weapon is in the - // inventory, nothing happens. - bool AHuman::EquipLoadedFirearmInGroup(std::string group, std::string excludeGroup, bool doEquip) { if (!(m_pFGArm && m_pFGArm->IsAttached())) { return false; @@ -982,13 +845,6 @@ namespace RTE { return false; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual Method: EquipNamedDevice - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Switches the currently held device (if any) to the first found device - // of with the specified preset name in the inventory. If the held device already - // is of that preset name, or no device is in inventory, nothing happens. - bool AHuman::EquipNamedDevice(const std::string& moduleName, const std::string& presetName, bool doEquip) { if (!(m_pFGArm && m_pFGArm->IsAttached())) { return false; @@ -1036,13 +892,6 @@ namespace RTE { return false; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual Method: EquipThrowable - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Switches the currently held device (if any) to the first found ThrownDevice - // in the inventory. If the held device already is a ThrownDevice, or no - // ThrownDevice is in inventory, nothing happens. - bool AHuman::EquipThrowable(bool doEquip) { if (!(m_pFGArm && m_pFGArm->IsAttached())) { return false; @@ -1091,8 +940,6 @@ namespace RTE { return false; } - ////////////////////////////////////////////////////////////////////////////////////////// - bool AHuman::EquipDiggingTool(bool doEquip) { if (!(m_pFGArm && m_pFGArm->IsAttached())) { return false; @@ -1124,8 +971,6 @@ namespace RTE { return strongestDigger != nullptr; } - ////////////////////////////////////////////////////////////////////////////////////////// - float AHuman::EstimateDigStrength() const { float maxPenetration = Actor::EstimateDigStrength(); @@ -1146,15 +991,6 @@ namespace RTE { return maxPenetration; } - ////////////////////////////////////////////////////////////////////////////////////////// - - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual Method: EquipShield - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Switches the currently held device (if any) to the first found shield - // in the inventory. If the held device already is a shield, or no - // shield is in inventory, nothing happens. - bool AHuman::EquipShield() { if (!(m_pFGArm && m_pFGArm->IsAttached())) { return false; @@ -1199,13 +1035,6 @@ namespace RTE { return false; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual Method: EquipShieldInBGArm - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Tries to equip the first shield in inventory to the background arm; - // this only works if nothing is held at all, or the FG arm holds a - // one-handed device, or we're in inventory mode. - bool AHuman::EquipShieldInBGArm() { if (!(m_pBGArm && m_pBGArm->IsAttached())) { return false; @@ -1257,8 +1086,6 @@ namespace RTE { return false; } - ////////////////////////////////////////////////////////////////////////////////////////// - bool AHuman::UnequipFGArm() { if (m_pFGArm) { if (HeldDevice* heldDevice = m_pFGArm->GetHeldDevice()) { @@ -1271,8 +1098,6 @@ namespace RTE { return false; } - ////////////////////////////////////////////////////////////////////////////////////////// - bool AHuman::UnequipBGArm() { if (m_pBGArm) { if (HeldDevice* heldDevice = m_pBGArm->GetHeldDevice()) { @@ -1285,8 +1110,6 @@ namespace RTE { return false; } - ////////////////////////////////////////////////////////////////////////////////////////// - float AHuman::GetEquippedMass() const { float equippedMass = 0; if (MovableObject* fgDevice = GetEquippedItem()) { @@ -1298,12 +1121,6 @@ namespace RTE { return equippedMass; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual Method: FirearmIsReady - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Indicates whether the currently held device's current mag is empty on - // ammo or not. - bool AHuman::FirearmIsReady() const { // Check if the currently held device is already the desired type if (m_pFGArm && m_pFGArm->IsAttached()) { @@ -1315,11 +1132,6 @@ namespace RTE { return false; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual Method: ThrowableIsReady - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Indicates whether the currently held ThrownDevice's is ready to go. - bool AHuman::ThrowableIsReady() const { // Check if the currently held thrown device is already the desired type if (m_pFGArm && m_pFGArm->IsAttached()) { @@ -1331,11 +1143,6 @@ namespace RTE { return false; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual Method: FirearmIsEmpty - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Indicates whether the currently held HDFirearm's is out of ammo. - bool AHuman::FirearmIsEmpty() const { if (m_pFGArm && m_pFGArm->IsAttached()) { const HDFirearm* pWeapon = dynamic_cast(m_pFGArm->GetHeldDevice()); @@ -1346,11 +1153,6 @@ namespace RTE { return false; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual Method: FirearmNeedsReload - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Indicates whether the currently held HDFirearm's is almost out of ammo. - bool AHuman::FirearmNeedsReload() const { if (const HDFirearm* fgWeapon = dynamic_cast(GetEquippedItem()); fgWeapon && fgWeapon->NeedsReloading()) { return true; @@ -1361,8 +1163,6 @@ namespace RTE { return false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool AHuman::FirearmsAreReloading(bool onlyIfAllFirearmsAreReloading) const { int reloadingFirearmCount = 0; int totalFirearmCount = 0; @@ -1387,13 +1187,6 @@ namespace RTE { return onlyIfAllFirearmsAreReloading ? reloadingFirearmCount == totalFirearmCount : reloadingFirearmCount > 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual Method: FirearmIsSemiAuto - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Indicates whether the currently held HDFirearm's is semi or full auto. - bool AHuman::FirearmIsSemiAuto() const { if (m_pFGArm && m_pFGArm->IsAttached()) { const HDFirearm* pWeapon = dynamic_cast(m_pFGArm->GetHeldDevice()); @@ -1402,13 +1195,6 @@ namespace RTE { return false; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual Method: ReloadFirearm - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Reloads the currently held firearm, if any. - // Arguments: None. - // Return value: None. - void AHuman::ReloadFirearms(bool onlyReloadEmptyFirearms) { for (Arm* arm: {m_pFGArm, m_pBGArm}) { if (arm) { @@ -1463,12 +1249,6 @@ namespace RTE { } } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual Method: FirearmActivationDelay - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns the currently held device's delay between pulling the trigger - // and activating. - int AHuman::FirearmActivationDelay() const { // Check if the currently held device is already the desired type if (m_pFGArm && m_pFGArm->IsAttached()) { @@ -1480,12 +1260,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: IsWithinRange - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Tells whether a point on the scene is within range of the currently - // used device and aiming status, if applicable. - bool AHuman::IsWithinRange(Vector& point) const { if (m_SharpAimMaxedOut) return true; @@ -1515,13 +1289,6 @@ namespace RTE { return sqrDistance <= (range * range); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Look - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Casts an unseen-revealing ray in the direction of where this is facing. - // Arguments: The degree angle to deviate from the current view point in the ray - // casting. A random ray will be chosen out of this +-range. - bool AHuman::Look(float FOVSpread, float range) { if (!g_SceneMan.AnythingUnseen(m_Team) || m_CanRevealUnseen == false) return false; @@ -1556,11 +1323,6 @@ namespace RTE { return g_SceneMan.CastSeeRay(m_Team, aimPos, lookVector, ignored, 25, (int)g_SceneMan.GetUnseenResolution(m_Team).GetSmallest() / 2); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: LookForGold - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Casts a material detecting ray in the direction of where this is facing. - bool AHuman::LookForGold(float FOVSpread, float range, Vector& foundLocation) const { Vector ray(m_HFlipped ? -range : range, 0); ray.DegRotate(FOVSpread * RandomNormalNum()); @@ -1568,13 +1330,6 @@ namespace RTE { return g_SceneMan.CastMaterialRay(m_Pos, ray, g_MaterialGold, foundLocation, 4); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: LookForMOs - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Casts an MO detecting ray in the direction of where the head is looking - // at the time. Factors including head rotation, sharp aim mode, and - // other variables determine how this ray is cast. - MovableObject* AHuman::LookForMOs(float FOVSpread, unsigned char ignoreMaterial, bool ignoreAllTerrain) { MovableObject* pSeenMO = 0; Vector aimPos = m_Pos; @@ -1607,13 +1362,6 @@ namespace RTE { return pSeenMO; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: ResetAllTimers - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Resest all the timers used by this. Can be emitters, etc. This is to - // prevent backed up emissions to come out all at once while this has been - // held dormant in an inventory. - void AHuman::ResetAllTimers() { Actor::ResetAllTimers(); @@ -1622,8 +1370,6 @@ namespace RTE { } } - ////////////////////////////////////////////////////////////////////////////////////////// - void AHuman::OnNewMovePath() { Actor::OnNewMovePath(); @@ -1656,8 +1402,6 @@ namespace RTE { } } - ////////////////////////////////////////////////////////////////////////////////////////// - void AHuman::UpdateWalkAngle(AHuman::Layer whichLayer) { if (m_Controller.IsState(BODY_JUMP)) { m_WalkAngle[whichLayer] = Matrix(c_QuarterPI * GetFlipFactor()); @@ -1689,8 +1433,6 @@ namespace RTE { } } - ////////////////////////////////////////////////////////////////////////////////////////// - void AHuman::UpdateCrouching() { if (!m_Controller.IsState(BODY_JUMP) && m_pHead) { float desiredWalkPathYOffset = 0.0F; @@ -1737,8 +1479,6 @@ namespace RTE { } } - ////////////////////////////////////////////////////////////////////////////////////////// - void AHuman::PreControllerUpdate() { ZoneScoped; @@ -2611,8 +2351,6 @@ namespace RTE { } } - ////////////////////////////////////////////////////////////////////////////////////////// - void AHuman::Update() { ZoneScoped; @@ -2789,8 +2527,6 @@ namespace RTE { // m_DeepCheck = true/*m_Status == DEAD*/; } - ////////////////////////////////////////////////////////////////////////////////////////// - void AHuman::DrawThrowingReticle(BITMAP* targetBitmap, const Vector& targetPos, float progressScalar) const { const int pointCount = 9; Vector points[pointCount]; @@ -2816,12 +2552,6 @@ namespace RTE { release_bitmap(targetBitmap); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Draw - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws this AHuman's current graphical representation to a - // BITMAP of choice. - void AHuman::Draw(BITMAP* pTargetBitmap, const Vector& targetPos, DrawMode mode, bool onlyPhysical) const { Actor::Draw(pTargetBitmap, targetPos, mode, onlyPhysical); @@ -2856,12 +2586,6 @@ namespace RTE { } } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: DrawHUD - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws this Actor's current graphical HUD overlay representation to a - // BITMAP of choice. - void AHuman::DrawHUD(BITMAP* pTargetBitmap, const Vector& targetPos, int whichScreen, bool playerControlled) { m_HUDStack = -m_CharHeight / 2; @@ -3136,8 +2860,6 @@ namespace RTE { m_Paths[BGROUND][WALK].OverridePushForce(force); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int AHuman::WhilePieMenuOpenListener(const PieMenu* pieMenu) { int result = Actor::WhilePieMenuOpenListener(pieMenu); diff --git a/Source/Entities/AHuman.h b/Source/Entities/AHuman.h index 9af2ebf22a..c4b3cf1d9f 100644 --- a/Source/Entities/AHuman.h +++ b/Source/Entities/AHuman.h @@ -1,18 +1,11 @@ #ifndef _RTEAHUMAN_ #define _RTEAHUMAN_ -////////////////////////////////////////////////////////////////////////////////////////// -// File: AHuman.h -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Header file for the AHuman class. -// Project: Retro Terrain Engine -// Author(s): Daniel Tabar -// data@datarealms.com -// http://www.datarealms.com - -////////////////////////////////////////////////////////////////////////////////////////// -// Inclusions of header files - +/// Header file for the AHuman class. +/// @author Daniel Tabar +/// data@datarealms.com +/// http://www.datarealms.com +/// Inclusions of header files #include "Actor.h" #include "Arm.h" #include "Leg.h" @@ -24,13 +17,7 @@ namespace RTE { class AEJetpack; - ////////////////////////////////////////////////////////////////////////////////////////// - // Class: AHuman - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: A humanoid actor. - // Parent(s): Actor. - // Class history: 05/24/2001 AHuman created. - + /// A humanoid actor. class AHuman : public Actor { friend struct EntityLuaBindings; @@ -57,9 +44,7 @@ namespace RTE { BGROUND }; - ////////////////////////////////////////////////////////////////////////////////////////// - // Public member variable, method and friend function declarations - + /// Public member variable, method and friend function declarations public: // Concrete allocation and cloning definitions EntityAllocation(AHuman); @@ -68,219 +53,135 @@ namespace RTE { ClassInfoGetters; DefaultPieMenuNameGetter("Default Human Pie Menu"); - ////////////////////////////////////////////////////////////////////////////////////////// - // Constructor: AHuman - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Constructor method used to instantiate a AHuman object in system - // memory. Create() should be called before using the object. - // Arguments: None. - + /// Constructor method used to instantiate a AHuman object in system + /// memory. Create() should be called before using the object. AHuman() { Clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Destructor: ~AHuman - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destructor method used to clean up a AHuman object before deletion - // from system memory. - // Arguments: None. - + /// Destructor method used to clean up a AHuman object before deletion + /// from system memory. ~AHuman() override { Destroy(true); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes the AHuman object ready for use. - // Arguments: None. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Makes the AHuman object ready for use. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Create() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Creates a AHuman to be identical to another, by deep copy. - // Arguments: A reference to the AHuman to deep copy. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Creates a AHuman to be identical to another, by deep copy. + /// @param reference A reference to the AHuman to deep copy. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Create(const AHuman& reference); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Reset - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Resets the entire AHuman, including its inherited members, to their - // default settings or values. - // Arguments: None. - // Return value: None. - + /// Resets the entire AHuman, including its inherited members, to their + /// default settings or values. void Reset() override { Clear(); Actor::Reset(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destroys and resets (through Clear()) the SceneLayer object. - // Arguments: Whether to only destroy the members defined in this derived class, or - // to destroy all inherited members also. - // Return value: None. - + /// Destroys and resets (through Clear()) the SceneLayer object. + /// @param notInherited Whether to only destroy the members defined in this derived class, or (default: false) + /// to destroy all inherited members also. void Destroy(bool notInherited = false) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetTotalValue - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the total liquidation value of this Actor and all its carried - // gold and inventory. - // Arguments: If this is supposed to be adjusted for a specific Tech's subjective - // value, then pass in the native DataModule ID of that tech. 0 means - // no Tech is specified and the base value is returned. - // How much to multiply the value if this happens to be a foreign Tech. - // Return value: The current value of this Actor and all his carried assets. - + /// Gets the total liquidation value of this Actor and all its carried + /// gold and inventory. + /// @param nativeModule If this is supposed to be adjusted for a specific Tech's subjective (default: 0) + /// value, then pass in the native DataModule ID of that tech. 0 means + /// no Tech is specified and the base value is returned. + /// @param foreignMult How much to multiply the value if this happens to be a foreign Tech. (default: 1.0) + /// @return The current value of this Actor and all his carried assets. float GetTotalValue(int nativeModule = 0, float foreignMult = 1.0, float nativeMult = 1.0) const override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: HasObject - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Shows whether this is or carries a specifically named object in its - // inventory. Also looks through the inventories of potential passengers, - // as applicable. - // Arguments: The Preset name of the object to look for. - // Return value: Whetehr the object was found carried by this. - + /// Shows whether this is or carries a specifically named object in its + /// inventory. Also looks through the inventories of potential passengers, + /// as applicable. + /// @param objectName The Preset name of the object to look for. + /// @return Whetehr the object was found carried by this. bool HasObject(std::string objectName) const override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: HasObjectInGroup - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Shows whether this is or carries a specifically grouped object in its - // inventory. Also looks through the inventories of potential passengers, - // as applicable. - // Arguments: The name of the group to look for. - // Return value: Whetehr the object in the group was found carried by this. - + /// Shows whether this is or carries a specifically grouped object in its + /// inventory. Also looks through the inventories of potential passengers, + /// as applicable. + /// @param groupName The name of the group to look for. + /// @return Whetehr the object in the group was found carried by this. bool HasObjectInGroup(std::string groupName) const override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: GetCPUPos - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the absoltue position of this' brain, or equivalent. - // Arguments: None. - // Return value: A Vector with the absolute position of this' brain. - + /// Gets the absoltue position of this' brain, or equivalent. + /// @return A Vector with the absolute position of this' brain. Vector GetCPUPos() const override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: GetEyePos - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the absoltue position of this' eye, or equivalent, where look - // vector starts from. - // Arguments: None. - // Return value: A Vector with the absolute position of this' eye or view point. - + /// Gets the absoltue position of this' eye, or equivalent, where look + /// vector starts from. + /// @return A Vector with the absolute position of this' eye or view point. Vector GetEyePos() const override; - /// /// Gets the head of this AHuman. - /// - /// A pointer to the head of this AHuman. Ownership is NOT transferred. + /// @return A pointer to the head of this AHuman. Ownership is NOT transferred. Attachable* GetHead() const { return m_pHead; } - /// /// Sets the head for this AHuman. - /// - /// The new head to use. + /// @param newHead The new head to use. void SetHead(Attachable* newHead); - /// /// Gets the jetpack of this AHuman. - /// - /// A pointer to the jetpack of this AHuman. Ownership is NOT transferred. + /// @return A pointer to the jetpack of this AHuman. Ownership is NOT transferred. AEJetpack* GetJetpack() const { return m_pJetpack; } - /// /// Sets the jetpack for this AHuman. - /// - /// The new jetpack to use. + /// @param newJetpack The new jetpack to use. void SetJetpack(AEJetpack* newJetpack); - /// /// Gets the foreground Arm of this AHuman. - /// - /// A pointer to the foreground Arm of this AHuman. Ownership is NOT transferred. + /// @return A pointer to the foreground Arm of this AHuman. Ownership is NOT transferred. Arm* GetFGArm() const { return m_pFGArm; } - /// /// Sets the foreground Arm for this AHuman. - /// - /// The new Arm to use. + /// @param newArm The new Arm to use. void SetFGArm(Arm* newArm); - /// /// Gets the background arm of this AHuman. - /// - /// A pointer to the background arm of this AHuman. Ownership is NOT transferred. + /// @return A pointer to the background arm of this AHuman. Ownership is NOT transferred. Arm* GetBGArm() const { return m_pBGArm; } - /// /// Sets the background Arm for this AHuman. - /// - /// The new Arm to use. + /// @param newArm The new Arm to use. void SetBGArm(Arm* newArm); - /// /// Gets the foreground Leg of this AHuman. - /// - /// A pointer to the foreground Leg of this AHuman. Ownership is NOT transferred. + /// @return A pointer to the foreground Leg of this AHuman. Ownership is NOT transferred. Leg* GetFGLeg() const { return m_pFGLeg; } - /// /// Sets the foreground Leg for this AHuman. - /// - /// The new Leg to use. + /// @param newLeg The new Leg to use. void SetFGLeg(Leg* newLeg); - /// /// Gets the background Leg of this AHuman. - /// - /// A pointer to the background Leg of this AHuman. Ownership is NOT transferred. + /// @return A pointer to the background Leg of this AHuman. Ownership is NOT transferred. Leg* GetBGLeg() const { return m_pBGLeg; } - /// /// Sets the background Leg for this AHuman. - /// - /// The new Leg to use. + /// @param newLeg The new Leg to use. void SetBGLeg(Leg* newLeg); - /// /// Gets the foot Attachable of this AHuman's foreground Leg. - /// - /// A pointer to the foot Attachable of this AHuman's foreground Leg. Ownership is NOT transferred! + /// @return A pointer to the foot Attachable of this AHuman's foreground Leg. Ownership is NOT transferred! Attachable* GetFGFoot() const { return m_pFGLeg ? m_pFGLeg->GetFoot() : nullptr; } - /// /// Sets the foot Attachable of this AHuman's foreground Leg. - /// - /// The new foot for this AHuman's foreground Leg to use. + /// @param newFoot The new foot for this AHuman's foreground Leg to use. void SetFGFoot(Attachable* newFoot) { if (m_pFGLeg && m_pFGLeg->IsAttached()) { m_pFGLeg->SetFoot(newFoot); } } - /// /// Gets the foot Attachable of this AHuman's background Leg. - /// - /// A pointer to the foot Attachable of this AHuman's background Leg. Ownership is NOT transferred! + /// @return A pointer to the foot Attachable of this AHuman's background Leg. Ownership is NOT transferred! Attachable* GetBGFoot() const { return m_pBGLeg ? m_pBGLeg->GetFoot() : nullptr; } - /// /// Sets the foot Attachable of this AHuman's background Leg. - /// - /// The new foot for this AHuman's background Leg to use. + /// @param newFoot The new foot for this AHuman's background Leg to use. void SetBGFoot(Attachable* newFoot) { if (m_pBGLeg && m_pBGLeg->IsAttached()) { m_pBGLeg->SetFoot(newFoot); @@ -288,619 +189,389 @@ namespace RTE { } /// Gets this AHuman's UpperBodyState. - /// - /// This AHuman's UpperBodyState. + /// @return This AHuman's UpperBodyState. UpperBodyState GetUpperBodyState() const { return m_ArmsState; } - /// /// Sets this AHuman's UpperBodyState to the new state. - /// - /// This AHuman's new UpperBodyState. + /// @param newUpperBodyState This AHuman's new UpperBodyState. void SetUpperBodyState(UpperBodyState newUpperBodyState) { m_ArmsState = newUpperBodyState; } /// Gets this AHuman's ProneState. - /// - /// This AHuman's ProneState. + /// @return This AHuman's ProneState. ProneState GetProneState() const { return m_ProneState; } - /// /// Sets this AHuman's ProneState to the new state. - /// - /// This AHuman's new ProneState. + /// @param newProneState This AHuman's new ProneState. void SetProneState(ProneState newProneState) { m_ProneState = newProneState; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: CollideAtPoint - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Calculates the collision response when another MO's Atom collides with - // this MO's physical representation. The effects will be applied - // directly to this MO, and also represented in the passed in HitData. - // Arguments: Reference to the HitData struct which describes the collision. This - // will be modified to represent the results of the collision. - // Return value: Whether the collision has been deemed valid. If false, then disregard - // any impulses in the Hitdata. - + /// Calculates the collision response when another MO's Atom collides with + /// this MO's physical representation. The effects will be applied + /// directly to this MO, and also represented in the passed in HitData. + /// @param hitData Reference to the HitData struct which describes the collision. This + /// will be modified to represent the results of the collision. + /// @return Whether the collision has been deemed valid. If false, then disregard + /// any impulses in the Hitdata. bool CollideAtPoint(HitData& hitData) override; - /// /// Tries to handle the activated PieSlice in this object's PieMenu, if there is one, based on its SliceType. - /// - /// The SliceType of the PieSlice being handled. - /// Whether or not the activated PieSlice SliceType was able to be handled. + /// @param pieSliceType The SliceType of the PieSlice being handled. + /// @return Whether or not the activated PieSlice SliceType was able to be handled. bool HandlePieCommand(PieSlice::SliceType pieSliceType) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual Method: AddInventoryItem - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Adds an inventory item to this AHuman. This also puts that item - // directly in the hands of this if they are empty. - // Arguments: An pointer to the new item to add. Ownership IS TRANSFERRED! - // Return value: None. - + /// Adds an inventory item to this AHuman. This also puts that item + /// directly in the hands of this if they are empty. + /// @param pItemToAdd An pointer to the new item to add. Ownership IS TRANSFERRED! void AddInventoryItem(MovableObject* pItemToAdd) override; - /// /// Swaps the next MovableObject carried by this AHuman and puts one not currently carried into the back of the inventory of this. /// For safety reasons, this will dump any non-HeldDevice inventory items it finds into MovableMan, ensuring the returned item is a HeldDevice (but not casted to one, for overload purposes). - /// - /// A pointer to the external MovableObject to swap in. Ownership IS transferred. - /// Whether or not to mute the sound on this event. - /// The next HeldDevice in this AHuman's inventory, if there are any. + /// @param inventoryItemToSwapIn A pointer to the external MovableObject to swap in. Ownership IS transferred. + /// @param muteSound Whether or not to mute the sound on this event. + /// @return The next HeldDevice in this AHuman's inventory, if there are any. MovableObject* SwapNextInventory(MovableObject* inventoryItemToSwapIn = nullptr, bool muteSound = false) override; - /// /// Swaps the previous MovableObject carried by this AHuman and puts one not currently carried into the back of the inventory of this. /// For safety reasons, this will dump any non-HeldDevice inventory items it finds into MovableMan, ensuring the returned item is a HeldDevice (but not casted to one, for overload purposes). - /// - /// A pointer to the external MovableObject to swap in. Ownership IS transferred. - /// The previous HeldDevice in this AHuman's inventory, if there are any. + /// @param inventoryItemToSwapIn A pointer to the external MovableObject to swap in. Ownership IS transferred. + /// @return The previous HeldDevice in this AHuman's inventory, if there are any. MovableObject* SwapPrevInventory(MovableObject* inventoryItemToSwapIn = nullptr) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual Method: EquipFirearm - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Switches the currently held device (if any) to the first found firearm - // in the inventory. If the held device already is a firearm, or no - // firearm is in inventory, nothing happens. - // Arguments: Whether to actually equip any matching item found in the inventory, - // or just report that it's there or not. - // Return value: Whether a firearm was successfully switched to, or already held. - + /// Switches the currently held device (if any) to the first found firearm + /// in the inventory. If the held device already is a firearm, or no + /// firearm is in inventory, nothing happens. + /// @param doEquip Whether to actually equip any matching item found in the inventory, (default: true) + /// or just report that it's there or not. + /// @return Whether a firearm was successfully switched to, or already held. bool EquipFirearm(bool doEquip = true); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual Method: EquipDeviceInGroup - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Switches the currently held device (if any) to the first found device - // of the specified group in the inventory. If the held device already - // is of that group, or no device is in inventory, nothing happens. - // Arguments: The group the device must belong to. - // Whether to actually equip any matching item found in the inventory, - // or just report that it's there or not. - // Return value: Whether a firearm was successfully switched to, or already held. - + /// Switches the currently held device (if any) to the first found device + /// of the specified group in the inventory. If the held device already + /// is of that group, or no device is in inventory, nothing happens. + /// @param group The group the device must belong to. + /// @param doEquip Whether to actually equip any matching item found in the inventory, (default: true) + /// or just report that it's there or not. + /// @return Whether a firearm was successfully switched to, or already held. bool EquipDeviceInGroup(std::string group, bool doEquip = true); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual Method: EquipLoadedFirearmInGroup - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Switches the currently held device (if any) to the first loaded HDFirearm - // of the specified group in the inventory. If no such weapon is in the - // inventory, nothing happens. - // Arguments: The group the HDFirearm must belong to. "Any" for all groups. - // The group the HDFirearm must *not* belong to. "None" for no group. - // Whether to actually equip any matching item found in the inventory, - // or just report that it's there or not. - // Return value: Whether a firearm was successfully switched to, or already held. - + /// Switches the currently held device (if any) to the first loaded HDFirearm + /// of the specified group in the inventory. If no such weapon is in the + /// inventory, nothing happens. + /// @param group The group the HDFirearm must belong to. "Any" for all groups. + /// @param exludeGroup The group the HDFirearm must *not* belong to. "None" for no group. + /// @param doEquip Whether to actually equip any matching item found in the inventory, (default: true) + /// or just report that it's there or not. + /// @return Whether a firearm was successfully switched to, or already held. bool EquipLoadedFirearmInGroup(std::string group, std::string exludeGroup, bool doEquip = true); - /// /// Switches the equipped HeldDevice (if any) to the first found device with the specified preset name in the inventory. /// If the equipped HeldDevice is of that module and preset name, nothing happens. - /// - /// The preset name of the HeldDevice to equip. - /// Whether to actually equip any matching item found in the inventory, or just report whether or not it's there. - /// Whether a matching HeldDevice was successfully found/switched -o, or already held. + /// @param presetName The preset name of the HeldDevice to equip. + /// @param doEquip Whether to actually equip any matching item found in the inventory, or just report whether or not it's there. + /// @return Whether a matching HeldDevice was successfully found/switched -o, or already held. bool EquipNamedDevice(const std::string& presetName, bool doEquip) { return EquipNamedDevice("", presetName, doEquip); } - /// /// Switches the equipped HeldDevice (if any) to the first found device with the specified module and preset name in the inventory. /// If the equipped HeldDevice is of that module and preset name, nothing happens. - /// - /// The module name of the HeldDevice to equip. - /// The preset name of the HeldDevice to equip. - /// Whether to actually equip any matching item found in the inventory, or just report whether or not it's there. - /// Whether a matching HeldDevice was successfully found/switched -o, or already held. + /// @param moduleName The module name of the HeldDevice to equip. + /// @param presetName The preset name of the HeldDevice to equip. + /// @param doEquip Whether to actually equip any matching item found in the inventory, or just report whether or not it's there. + /// @return Whether a matching HeldDevice was successfully found/switched -o, or already held. bool EquipNamedDevice(const std::string& moduleName, const std::string& presetName, bool doEquip); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual Method: EquipThrowable - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Switches the currently held device (if any) to the first found ThrownDevice - // in the inventory. If the held device already is a ThrownDevice, or no - // ThrownDevice is in inventory, nothing happens. - // Arguments: Whether to actually equip any matching item found in the inventory, - // or just report that it's there or not. - // Return value: Whether a ThrownDevice was successfully switched to, or already held. - + /// Switches the currently held device (if any) to the first found ThrownDevice + /// in the inventory. If the held device already is a ThrownDevice, or no + /// ThrownDevice is in inventory, nothing happens. + /// @param doEquip Whether to actually equip any matching item found in the inventory, (default: true) + /// or just report that it's there or not. + /// @return Whether a ThrownDevice was successfully switched to, or already held. bool EquipThrowable(bool doEquip = true); - /// /// Switches the currently held device (if any) to the strongest digging tool in the inventory. - /// - /// Whether to actually equip the strongest digging tool, or just report whether a digging tool was found. - /// Whether or not the strongest digging tool was successfully equipped. + /// @param doEquip Whether to actually equip the strongest digging tool, or just report whether a digging tool was found. + /// @return Whether or not the strongest digging tool was successfully equipped. bool EquipDiggingTool(bool doEquip = true); - /// /// Estimates what material strength any digger this AHuman is carrying can penetrate. - /// - /// The maximum material strength this AHuman's digger can penetrate, or a default dig strength if they don't have a digger. + /// @return The maximum material strength this AHuman's digger can penetrate, or a default dig strength if they don't have a digger. float EstimateDigStrength() const override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual Method: EquipShield - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Switches the currently held device (if any) to the first found shield - // in the inventory. If the held device already is a shield, or no - // shield is in inventory, nothing happens. - // Arguments: None. - // Return value: Whether a shield was successfully switched to, or already held. - + /// Switches the currently held device (if any) to the first found shield + /// in the inventory. If the held device already is a shield, or no + /// shield is in inventory, nothing happens. + /// @return Whether a shield was successfully switched to, or already held. bool EquipShield(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual Method: EquipShieldInBGArm - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Tries to equip the first shield in inventory to the background arm; - // this only works if nothing is held at all, or the FG arm holds a - // one-handed device, or we're in inventory mode. - // Arguments: None. - // Return value: Whether a shield was successfully equipped in the background arm. - + /// Tries to equip the first shield in inventory to the background arm; + /// this only works if nothing is held at all, or the FG arm holds a + /// one-handed device, or we're in inventory mode. + /// @return Whether a shield was successfully equipped in the background arm. bool EquipShieldInBGArm(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual Method: EquipDualWieldableInBGArm - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Tries to equip the first dual-wieldable in inventory to the background arm; - // this only works if nothing is held at all, or the FG arm holds a - // one-handed device, or we're in inventory mode. - // Arguments: None. - // Return value: Whether a shield was successfully equipped in the background arm. - + /// Tries to equip the first dual-wieldable in inventory to the background arm; + /// this only works if nothing is held at all, or the FG arm holds a + /// one-handed device, or we're in inventory mode. + /// @return Whether a shield was successfully equipped in the background arm. // bool EquipDualWieldableInBGArm(); - /// /// Gets the throw chargeup progress of this AHuman. - /// - /// The throw chargeup progress, as a scalar from 0 to 1. + /// @return The throw chargeup progress, as a scalar from 0 to 1. float GetThrowProgress() const { return m_ThrowPrepTime > 0 ? static_cast(std::min(m_ThrowTmr.GetElapsedSimTimeMS() / static_cast(m_ThrowPrepTime), 1.0)) : 1.0F; } - /// /// Unequips whatever is in the FG arm and puts it into the inventory. - /// - /// Whether there was anything to unequip. + /// @return Whether there was anything to unequip. bool UnequipFGArm(); - /// /// Unequips whatever is in the BG arm and puts it into the inventory. - /// - /// Whether there was anything to unequip. + /// @return Whether there was anything to unequip. bool UnequipBGArm(); - /// /// Unequips whatever is in either of the arms and puts them into the inventory. - /// void UnequipArms() { UnequipBGArm(); UnequipFGArm(); } - /// /// Gets the FG Arm's HeldDevice. Ownership is NOT transferred. - /// - /// The FG Arm's HeldDevice. + /// @return The FG Arm's HeldDevice. HeldDevice* GetEquippedItem() const { return m_pFGArm ? m_pFGArm->GetHeldDevice() : nullptr; } - /// /// Gets the BG Arm's HeldDevice. Ownership is NOT transferred. - /// - /// The BG Arm's HeldDevice. + /// @return The BG Arm's HeldDevice. HeldDevice* GetEquippedBGItem() const { return m_pBGArm ? m_pBGArm->GetHeldDevice() : nullptr; } - /// /// Gets the total mass of this AHuman's currently equipped devices. - /// - /// The mass of this AHuman's equipped devices. + /// @return The mass of this AHuman's equipped devices. float GetEquippedMass() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual Method: FirearmIsReady - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Indicates whether the currently held HDFirearm's is ready for use, and has - // ammo etc. - // Arguments: None. - // Return value: Whether a currently HDFirearm (if any) is ready for use. - + /// Indicates whether the currently held HDFirearm's is ready for use, and has + /// ammo etc. + /// @return Whether a currently HDFirearm (if any) is ready for use. bool FirearmIsReady() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ThrowableIsReady - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Indicates whether the currently held ThrownDevice's is ready to go. - // Arguments: None. - // Return value: Whether a currently held ThrownDevice (if any) is ready for use. - + /// Indicates whether the currently held ThrownDevice's is ready to go. + /// @return Whether a currently held ThrownDevice (if any) is ready for use. bool ThrowableIsReady() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: FirearmIsEmpty - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Indicates whether the currently held HDFirearm's is out of ammo. - // Arguments: None. - // Return value: Whether a currently HDFirearm (if any) is out of ammo. - + /// Indicates whether the currently held HDFirearm's is out of ammo. + /// @return Whether a currently HDFirearm (if any) is out of ammo. bool FirearmIsEmpty() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: FirearmNeedsReload - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Indicates whether any currently held HDFirearms are almost out of ammo. - // Arguments: None. - // Return value: Whether a currently HDFirearm (if any) has less than half of ammo left. - + /// Indicates whether any currently held HDFirearms are almost out of ammo. + /// @return Whether a currently HDFirearm (if any) has less than half of ammo left. bool FirearmNeedsReload() const; - /// /// Indicates whether currently held HDFirearms are reloading. If the parameter is true, it will only return true if all firearms are reloading, otherwise it will return whether any firearm is reloading. - /// - /// Whether or not currently held HDFirearms are reloading. + /// @return Whether or not currently held HDFirearms are reloading. bool FirearmsAreReloading(bool onlyIfAllFirearmsAreReloading) const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: FirearmIsSemiAuto - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Indicates whether the currently held HDFirearm's is semi or full auto. - // Arguments: None. - // Return value: Whether a currently HDFirearm (if any) is a semi auto device. - + /// Indicates whether the currently held HDFirearm's is semi or full auto. + /// @return Whether a currently HDFirearm (if any) is a semi auto device. bool FirearmIsSemiAuto() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: FirearmActivationDelay - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns the currently held device's delay between pulling the trigger - // and activating. - // Arguments: None. - // Return value: Delay in ms or zero if not a HDFirearm. - + /// Returns the currently held device's delay between pulling the trigger + /// and activating. + /// @return Delay in ms or zero if not a HDFirearm. int FirearmActivationDelay() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ReloadFirearm - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Reloads the currently held firearm, if any. Will only reload the BG Firearm if the FG one is full already, to support reloading guns one at a time. - // Arguments: Whether or not to only reload empty fireams. - // Return value: None. - + /// Reloads the currently held firearm, if any. Will only reload the BG Firearm if the FG one is full already, to support reloading guns one at a time. + /// @param onlyReloadEmptyFirearms Whether or not to only reload empty fireams. (default: false) void ReloadFirearms(bool onlyReloadEmptyFirearms = false); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: IsWithinRange - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Tells whether a point on the scene is within close range of the currently - // used device and aiming status, if applicable. - // Arguments: A Vector with the aboslute coordinates of a point to check. - // Return value: Whether the point is within close range of this. - + /// Tells whether a point on the scene is within close range of the currently + /// used device and aiming status, if applicable. + /// @param point A Vector with the aboslute coordinates of a point to check. + /// @return Whether the point is within close range of this. bool IsWithinRange(Vector& point) const override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Look - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Casts an unseen-revealing ray in the direction of where this is facing. - // Arguments: The degree angle to deviate from the current view point in the ray - // casting. A random ray will be chosen out of this +-range. - // The range, in pixels, beyond the actors sharp aim that the ray will have. - // Return value: Whether any unseen pixels were revealed by this look. - + /// Casts an unseen-revealing ray in the direction of where this is facing. + /// @param FOVSpread The degree angle to deviate from the current view point in the ray + /// casting. A random ray will be chosen out of this +-range. + /// @param range The range, in pixels, beyond the actors sharp aim that the ray will have. + /// @return Whether any unseen pixels were revealed by this look. bool Look(float FOVSpread, float range) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: LookForGold - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Casts a material detecting ray in the direction of where this is facing. - // Arguments: The degree angle to deviate from the current view point in the ray - // casting. A random ray will be chosen out of this +-range. - // The range, in pixels, that the ray will have. - // A Vector which will be filled with the absolute coordinates of any - // found gold. It will be unaltered if false is returned. - // Return value: Whether gold was spotted by this ray cast. If so, foundLocation - // has been filled out with the absolute location of the gold. - + /// Casts a material detecting ray in the direction of where this is facing. + /// @param FOVSpread The degree angle to deviate from the current view point in the ray + /// casting. A random ray will be chosen out of this +-range. + /// @param range The range, in pixels, that the ray will have. + /// @param foundLocation A Vector which will be filled with the absolute coordinates of any + /// found gold. It will be unaltered if false is returned. + /// @return Whether gold was spotted by this ray cast. If so, foundLocation + /// has been filled out with the absolute location of the gold. bool LookForGold(float FOVSpread, float range, Vector& foundLocation) const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: LookForMOs - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Casts an MO detecting ray in the direction of where the head is looking - // at the time. Factors including head rotation, sharp aim mode, and - // other variables determine how this ray is cast. - // Arguments: The degree angle to deviate from the current view point in the ray - // casting. A random ray will be chosen out of this +-range. - // A specific material ID to ignore (see through) - // Whether to ignore all terrain or not (true means 'x-ray vision'). - // Return value: A pointer to the MO seen while looking. - + /// Casts an MO detecting ray in the direction of where the head is looking + /// at the time. Factors including head rotation, sharp aim mode, and + /// other variables determine how this ray is cast. + /// @param FOVSpread The degree angle to deviate from the current view point in the ray (default: 45) + /// casting. A random ray will be chosen out of this +-range. + /// @param ignoreMaterial A specific material ID to ignore (see through) (default: 0) + /// @param ignoreAllTerrain Whether to ignore all terrain or not (true means 'x-ray vision'). (default: false) + /// @return A pointer to the MO seen while looking. MovableObject* LookForMOs(float FOVSpread = 45, unsigned char ignoreMaterial = 0, bool ignoreAllTerrain = false); - /// /// Gets the GUI representation of this AHuman, only defaulting to its Head or body if no GraphicalIcon has been defined. - /// - /// The graphical representation of this AHuman as a BITMAP. + /// @return The graphical representation of this AHuman as a BITMAP. BITMAP* GetGraphicalIcon() const override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: ResetAllTimers - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Resest all the timers used by this. Can be emitters, etc. This is to - // prevent backed up emissions to come out all at once while this has been - // held dormant in an inventory. - // Arguments: None. - // Return value: None. - + /// Resest all the timers used by this. Can be emitters, etc. This is to + /// prevent backed up emissions to come out all at once while this has been + /// held dormant in an inventory. void ResetAllTimers() override; - /// /// Detects slopes in terrain and updates the walk path rotation for the corresponding Layer accordingly. - /// - /// The Layer in question. + /// @param whichLayer The Layer in question. void UpdateWalkAngle(AHuman::Layer whichLayer); - /// /// Detects overhead ceilings and crouches for them. - /// void UpdateCrouching(); - /// /// Gets the walk path rotation for the specified Layer. - /// - /// The Layer in question. - /// The walk angle in radians. + /// @param whichLayer The Layer in question. + /// @return The walk angle in radians. float GetWalkAngle(AHuman::Layer whichLayer) const { return m_WalkAngle[whichLayer].GetRadAngle(); } - /// /// Sets the walk path rotation for the specified Layer. - /// - /// The Layer in question. - /// The angle to set. + /// @param whichLayer The Layer in question. + /// @param angle The angle to set. void SetWalkAngle(AHuman::Layer whichLayer, float angle) { m_WalkAngle[whichLayer] = Matrix(angle); } - /// /// Gets whether this AHuman has just taken a stride this frame. - /// - /// Whether this AHuman has taken a stride this frame or not. + /// @return Whether this AHuman has taken a stride this frame or not. bool StrideFrame() const { return m_StrideFrame; } - /// /// Gets whether this AHuman is currently attempting to climb something, using arms. - /// - /// Whether this AHuman is currently climbing or not. + /// @return Whether this AHuman is currently climbing or not. bool IsClimbing() const { return m_ArmClimbing[FGROUND] || m_ArmClimbing[BGROUND]; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: PreControllerUpdate - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Update called prior to controller update. Ugly hack. Supposed to be done every frame. - // Arguments: None. - // Return value: None. - + /// Update called prior to controller update. Ugly hack. Supposed to be done every frame. void PreControllerUpdate() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Update - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates this MovableObject. Supposed to be done every frame. - // Arguments: None. - // Return value: None. - + /// Updates this MovableObject. Supposed to be done every frame. void Update() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Draw - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws this AHuman's current graphical representation to a - // BITMAP of choice. - // Arguments: A pointer to a BITMAP to draw on. - // The absolute position of the target bitmap's upper left corner in the Scene. - // In which mode to draw in. See the DrawMode enumeration for the modes. - // Whether to not draw any extra 'ghost' items of this MovableObject, - // indicator arrows or hovering HUD text and so on. - // Return value: None. - + /// Draws this AHuman's current graphical representation to a + /// BITMAP of choice. + /// @param pTargetBitmap A pointer to a BITMAP to draw on. + /// @param targetPos The absolute position of the target bitmap's upper left corner in the Scene. (default: Vector()) + /// @param mode In which mode to draw in. See the DrawMode enumeration for the modes. (default: g_DrawColor) + /// @param onlyPhysical Whether to not draw any extra 'ghost' items of this MovableObject, (default: false) + /// indicator arrows or hovering HUD text and so on. void Draw(BITMAP* pTargetBitmap, const Vector& targetPos = Vector(), DrawMode mode = g_DrawColor, bool onlyPhysical = false) const override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: DrawHUD - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws this Actor's current graphical HUD overlay representation to a - // BITMAP of choice. - // Arguments: A pointer to a BITMAP to draw on. - // The absolute position of the target bitmap's upper left corner in the Scene. - // Which player's screen this is being drawn to. May affect what HUD elements - // get drawn etc. - // Return value: None. - + /// Draws this Actor's current graphical HUD overlay representation to a + /// BITMAP of choice. + /// @param pTargetBitmap A pointer to a BITMAP to draw on. + /// @param targetPos The absolute position of the target bitmap's upper left corner in the Scene. (default: Vector()) + /// @param whichScreen Which player's screen this is being drawn to. May affect what HUD elements (default: 0) + /// get drawn etc. void DrawHUD(BITMAP* pTargetBitmap, const Vector& targetPos = Vector(), int whichScreen = 0, bool playerControlled = false) override; - /// /// Gets the LimbPath corresponding to the passed in Layer and MovementState values. - /// - /// Whether to get foreground or background LimbPath. - /// Which movement state to get the LimbPath for. - /// The LimbPath corresponding to the passed in Layer and MovementState values. + /// @param layer Whether to get foreground or background LimbPath. + /// @param movementState Which movement state to get the LimbPath for. + /// @return The LimbPath corresponding to the passed in Layer and MovementState values. LimbPath* GetLimbPath(Layer layer, MovementState movementState) { return &m_Paths[layer][movementState]; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetLimbPathSpeed - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Get walking limb path speed for the specified preset. - // Arguments: Speed preset to set 0 = LimbPath::SLOW, 1 = Limbpath::NORMAL, 2 = LimbPath::FAST - // Return value: Limb path speed for the specified preset in m/s. - + /// Get walking limb path speed for the specified preset. + /// @param speedPreset Speed preset to set 0 = LimbPath::SLOW, 1 = Limbpath::NORMAL, 2 = LimbPath::FAST + /// @return Limb path speed for the specified preset in m/s. float GetLimbPathSpeed(int speedPreset) const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetLimbPathSpeed - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Set walking limb path speed for the specified preset. - // Arguments: Speed preset to set 0 = LimbPath::SLOW, 1 = Limbpath::NORMAL, 2 = LimbPath::FAST. New speed value in m/s. - // Return value: None. - + /// Set walking limb path speed for the specified preset. + /// @param speedPreset Speed preset to set 0 = LimbPath::SLOW, 1 = Limbpath::NORMAL, 2 = LimbPath::FAST. New speed value in m/s. void SetLimbPathSpeed(int speedPreset, float speed); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetLimbPathPushForce - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the default force that a limb traveling walking LimbPath can push against - // stuff in the scene with. - // Arguments: None. - // Return value: The default set force maximum, in kg * m/s^2. - + /// Gets the default force that a limb traveling walking LimbPath can push against + /// stuff in the scene with. + /// @return The default set force maximum, in kg * m/s^2. float GetLimbPathPushForce() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetLimbPathPushForce - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the default force that a limb traveling walking LimbPath can push against - // stuff in the scene with. - // Arguments: The default set force maximum, in kg * m/s^2. - // Return value: None - + /// Sets the default force that a limb traveling walking LimbPath can push against + /// stuff in the scene with. + /// @param force The default set force maximum, in kg * m/s^2. void SetLimbPathPushForce(float force); - /// /// Gets the target rot angle for the given MovementState. - /// - /// The MovementState to get the rot angle target for. - /// The target rot angle for the given MovementState. + /// @param movementState The MovementState to get the rot angle target for. + /// @return The target rot angle for the given MovementState. float GetRotAngleTarget(MovementState movementState) { return m_RotAngleTargets[movementState]; } - /// /// Sets the target rot angle for the given MovementState. - /// - /// The MovementState to get the rot angle target for. - /// The new rot angle target to use. + /// @param movementState The MovementState to get the rot angle target for. + /// @param newRotAngleTarget The new rot angle target to use. void SetRotAngleTarget(MovementState movementState, float newRotAngleTarget) { m_RotAngleTargets[movementState] = newRotAngleTarget; } - /// /// Gets the duration it takes this AHuman to fully charge a throw. - /// - /// The duration it takes to fully charge a throw in MS. + /// @return The duration it takes to fully charge a throw in MS. long GetThrowPrepTime() const { return m_ThrowPrepTime; } - /// /// Sets the duration it takes this AHuman to fully charge a throw. - /// - /// New duration to fully charge a throw in MS. + /// @param newPrepTime New duration to fully charge a throw in MS. void SetThrowPrepTime(long newPrepTime) { m_ThrowPrepTime = newPrepTime; } - /// /// Gets the rate at which this AHuman's Arms will swing with Leg movement, if they're not holding or supporting a HeldDevice. - /// - /// The arm swing rate of this AHuman. + /// @return The arm swing rate of this AHuman. float GetArmSwingRate() const { return m_ArmSwingRate; } - /// /// Sets the rate at which this AHuman's Arms will swing with Leg movement, if they're not holding or supporting a HeldDevice. - /// - /// The new arm swing rate for this AHuman. + /// @param newValue The new arm swing rate for this AHuman. void SetArmSwingRate(float newValue) { m_ArmSwingRate = newValue; } - /// /// Gets the rate at which this AHuman's Arms will sway with Leg movement, if they're holding or supporting a HeldDevice. - /// - /// The device arm sway rate of this AHuman. + /// @return The device arm sway rate of this AHuman. float GetDeviceArmSwayRate() const { return m_DeviceArmSwayRate; } - /// /// Sets the rate at which this AHuman's Arms will sway with Leg movement, if they're holding or supporting a HeldDevice. - /// - /// The new device arm sway rate for this AHuman. + /// @param newValue The new device arm sway rate for this AHuman. void SetDeviceArmSwayRate(float newValue) { m_DeviceArmSwayRate = newValue; } - /// /// Gets this AHuman's max walkpath adjustment upwards to crouch below low ceilings. - /// - /// This AHuman's max walkpath adjustment. + /// @return This AHuman's max walkpath adjustment. float GetMaxWalkPathCrouchShift() const { return m_MaxWalkPathCrouchShift; } - /// /// Sets this AHuman's max walkpath adjustment upwards to crouch below low ceilings. - /// - /// The new value for this AHuman's max walkpath adjustment. + /// @param newValue The new value for this AHuman's max walkpath adjustment. void SetMaxWalkPathCrouchShift(float newValue) { m_MaxWalkPathCrouchShift = newValue; } - /// /// Gets this AHuman's max crouch rotation to duck below low ceilings. - /// - /// This AHuman's max crouch rotation adjustment. + /// @return This AHuman's max crouch rotation adjustment. float GetMaxCrouchRotation() const { return m_MaxCrouchRotation; } - /// /// Sets this AHuman's max crouch rotation to duck below low ceilings. - /// - /// The new value for this AHuman's max crouch rotation adjustment. + /// @param newValue The new value for this AHuman's max crouch rotation adjustment. void SetMaxCrouchRotation(float newValue) { m_MaxCrouchRotation = newValue; } - /// /// Gets this AHuman's current crouch amount. 0.0 == fully standing, 1.0 == fully crouched. - /// - /// This AHuman's current crouch amount. + /// @return This AHuman's current crouch amount. float GetCrouchAmount() const { return (m_WalkPathOffset.m_Y * -1.0F) / m_MaxWalkPathCrouchShift; } - /// /// Gets this AHuman's current crouch amount override. 0.0 == fully standing, 1.0 == fully crouched, -1 == no override. - /// - /// This AHuman's current crouch amount override. + /// @return This AHuman's current crouch amount override. float GetCrouchAmountOverride() const { return m_CrouchAmountOverride; } - /// /// Sets this AHuman's current crouch amount override. - /// - /// The new value for this AHuman's current crouch amount override. + /// @param newValue The new value for this AHuman's current crouch amount override. void SetCrouchAmountOverride(float newValue) { m_CrouchAmountOverride = newValue; } - /// /// Gets this AHuman's stride sound. Ownership is NOT transferred! - /// - /// The SoundContainer for this AHuman's stride sound. + /// @return The SoundContainer for this AHuman's stride sound. SoundContainer* GetStrideSound() const { return m_StrideSound; } - /// /// Sets this AHuman's stride sound. Ownership IS transferred! - /// - /// The new SoundContainer for this AHuman's stride sound. + /// @param newSound The new SoundContainer for this AHuman's stride sound. void SetStrideSound(SoundContainer* newSound) { m_StrideSound = newSound; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Protected member variable and method declarations - + /// Protected member variable and method declarations protected: - /// /// Function that is called when we get a new movepath. /// This processes and cleans up the movepath. - /// void OnNewMovePath() override; - /// /// Draws an aiming aid in front of this AHuman for throwing. - /// - /// A pointer to a BITMAP to draw on. - /// The absolute position of the target bitmap's upper left corner in the Scene. - /// A normalized scalar that determines the magnitude of the reticle, to indicate force in the throw. + /// @param targetBitmap A pointer to a BITMAP to draw on. + /// @param targetPos The absolute position of the target bitmap's upper left corner in the Scene. + /// @param progressScalar A normalized scalar that determines the magnitude of the reticle, to indicate force in the throw. void DrawThrowingReticle(BITMAP* targetBitmap, const Vector& targetPos = Vector(), float progressScalar = 1.0F) const; // Member variables @@ -1047,26 +718,16 @@ namespace RTE { Timer m_JumpTimer; #pragma region Event Handling - /// /// Event listener to be run while this AHuman's PieMenu is opened. - /// - /// The PieMenu this event listener needs to listen to. This will always be this' m_PieMenu and only exists for std::bind. - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @param pieMenu The PieMenu this event listener needs to listen to. This will always be this' m_PieMenu and only exists for std::bind. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int WhilePieMenuOpenListener(const PieMenu* pieMenu) override; #pragma endregion - ////////////////////////////////////////////////////////////////////////////////////////// - // Private member variable and method declarations - + /// Private member variable and method declarations private: - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Clear - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears all the member variables of this AHuman, effectively - // resetting the members of this abstraction level only. - // Arguments: None. - // Return value: None. - + /// Clears all the member variables of this AHuman, effectively + /// resetting the members of this abstraction level only. void Clear(); // Disallow the use of some implicit methods. diff --git a/Source/Entities/Activity.cpp b/Source/Entities/Activity.cpp index 4166e47a37..aa1c491d54 100644 --- a/Source/Entities/Activity.cpp +++ b/Source/Entities/Activity.cpp @@ -22,8 +22,6 @@ namespace RTE { AbstractClassInfo(Activity, Entity); - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void Activity::Clear() { m_ActivityState = ActivityState::NotStarted; m_Paused = false; @@ -70,8 +68,6 @@ namespace RTE { m_SavedValues.Reset(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int Activity::Create() { if (Entity::Create() < 0) { return -1; @@ -83,8 +79,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int Activity::Create(const Activity& reference) { Entity::Create(reference); @@ -132,8 +126,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int Activity::ReadProperty(const std::string_view& propName, Reader& reader) { StartPropertyList(return Entity::ReadProperty(propName, reader)); @@ -229,8 +221,6 @@ namespace RTE { EndPropertyList; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int Activity::Save(Writer& writer) const { Entity::Save(writer); @@ -288,8 +278,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int Activity::Start() { // Reseed the RNG for determinism SeedRNG(); @@ -346,8 +334,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void Activity::End() { g_AudioMan.FinishIngameLoopingSounds(); // Actor control is automatically disabled when players are set to observation mode, so no need to do anything directly. @@ -357,8 +343,6 @@ namespace RTE { m_ActivityState = ActivityState::Over; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void Activity::SetupPlayers() { m_TeamCount = 0; m_PlayerCount = 0; @@ -389,8 +373,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool Activity::DeactivatePlayer(int playerToDeactivate) { if (playerToDeactivate < Players::PlayerOne || playerToDeactivate >= Players::MaxPlayerCount || !m_IsActive[playerToDeactivate] || !m_TeamActive[m_Team[playerToDeactivate]]) { return false; @@ -415,8 +397,6 @@ namespace RTE { return true; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int Activity::AddPlayer(int playerToAdd, bool isHuman, int team, float funds, const Icon* teamIcon) { if (playerToAdd < Players::PlayerOne || playerToAdd >= Players::MaxPlayerCount || team < Teams::TeamOne || team >= Teams::MaxTeamCount) { return m_PlayerCount; @@ -455,8 +435,6 @@ namespace RTE { return m_PlayerCount; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void Activity::ClearPlayers(bool resetFunds) { for (int player = Players::PlayerOne; player < Players::MaxPlayerCount; ++player) { m_IsActive[player] = false; @@ -478,8 +456,6 @@ namespace RTE { m_PlayerCount = m_TeamCount = 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int Activity::GetHumanCount() const { int humans = 0; for (int player = Players::PlayerOne; player < Players::MaxPlayerCount; ++player) { @@ -490,8 +466,6 @@ namespace RTE { return humans; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void Activity::SetTeamOfPlayer(int player, int team) { if (team < Teams::TeamOne || team >= Teams::MaxTeamCount || player < Players::PlayerOne || player >= Players::MaxPlayerCount) { return; @@ -502,8 +476,6 @@ namespace RTE { m_IsActive[player] = true; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int Activity::PlayerOfScreen(int screen) const { for (int player = Players::PlayerOne; player < Players::MaxPlayerCount; ++player) { if (m_PlayerScreen[player] == screen) { @@ -513,8 +485,6 @@ namespace RTE { return Players::NoPlayer; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - std::string Activity::GetTeamName(int whichTeam) const { if (whichTeam >= Teams::TeamOne && whichTeam < Teams::MaxTeamCount) { return m_TeamActive[whichTeam] ? m_TeamNames[whichTeam] : "Inactive Team"; @@ -522,8 +492,6 @@ namespace RTE { return ""; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool Activity::IsHumanTeam(int whichTeam) const { if (whichTeam >= Teams::TeamOne && whichTeam < Teams::MaxTeamCount) { for (int player = Players::PlayerOne; player < Players::MaxPlayerCount; ++player) { @@ -535,8 +503,6 @@ namespace RTE { return false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int Activity::PlayersInTeamCount(int team) const { int count = 0; for (int player = Players::PlayerOne; player < Players::MaxPlayerCount; ++player) { @@ -547,8 +513,6 @@ namespace RTE { return count; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void Activity::ChangeTeamFunds(float howMuch, int whichTeam) { if (whichTeam >= Teams::TeamOne && whichTeam < Teams::MaxTeamCount) { m_TeamFunds[whichTeam] += howMuch; @@ -563,8 +527,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool Activity::TeamFundsChanged(int whichTeam) { if (whichTeam >= Teams::TeamOne && whichTeam < Teams::MaxTeamCount) { bool changed = m_FundsChanged[whichTeam]; @@ -574,8 +536,6 @@ namespace RTE { return false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool Activity::UpdatePlayerFundsContribution(int player, float newFunds) { if (player < Players::PlayerOne || player >= Players::MaxPlayerCount || !m_IsActive[player] || !m_TeamActive[m_Team[player]]) { return false; @@ -604,8 +564,6 @@ namespace RTE { return true; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - float Activity::GetPlayerFundsShare(int player) const { if (player >= Players::PlayerOne && player < Players::MaxPlayerCount) { return (m_FundsContribution[player] > 0.0F) ? (m_TeamFunds[m_Team[player]] * m_TeamFundsShare[player]) : 0.0F; @@ -613,8 +571,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void Activity::SetPlayerBrain(Actor* newBrain, int player) { if ((player >= Players::PlayerOne || player < Players::MaxPlayerCount) && newBrain) { if (newBrain->GetTeam() != m_Team[player]) { @@ -625,8 +581,6 @@ namespace RTE { m_Brain[player] = newBrain; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool Activity::AnyBrainWasEvacuated() const { for (int player = Players::PlayerOne; player < Players::MaxPlayerCount; ++player) { if (m_BrainEvacuated[player]) { @@ -636,8 +590,6 @@ namespace RTE { return false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool Activity::IsAssignedBrain(Actor* actor) const { for (int player = Players::PlayerOne; player < Players::MaxPlayerCount; ++player) { if (actor == m_Brain[player]) { @@ -647,8 +599,6 @@ namespace RTE { return false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int Activity::IsBrainOfWhichPlayer(Actor* actor) const { for (int player = Players::PlayerOne; player < Players::MaxPlayerCount; ++player) { if (actor == m_Brain[player]) { @@ -658,8 +608,6 @@ namespace RTE { return Players::NoPlayer; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool Activity::IsOtherPlayerBrain(Actor* actor, int player) const { for (int playerToCheck = Players::PlayerOne; playerToCheck < Players::MaxPlayerCount; ++playerToCheck) { if (m_IsActive[playerToCheck] && playerToCheck != player && actor == m_Brain[playerToCheck]) { @@ -669,8 +617,6 @@ namespace RTE { return false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - std::string Activity::GetDifficultyString(int difficulty) { if (difficulty <= DifficultySetting::CakeDifficulty) { return "Cake"; @@ -687,8 +633,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - std::string Activity::GetAISkillString(int skill) { if (skill < AISkillSetting::InferiorSkill) { return "Inferior"; @@ -701,8 +645,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int Activity::GetTeamAISkill(int team) const { if (team >= Teams::TeamOne && team < Teams::MaxTeamCount) { return m_TeamAISkillLevels[team]; @@ -720,8 +662,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void Activity::ReassignSquadLeader(const int player, const int team) { if (m_ControlledActor[player]->GetAIMode() == Actor::AIMODE_SQUAD) { MOID leaderID = m_ControlledActor[player]->GetAIMOWaypointID(); @@ -764,8 +704,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool Activity::SwitchToActor(Actor* actor, int player, int team) { if (team < Teams::TeamOne || team >= Teams::MaxTeamCount || player < Players::PlayerOne || player >= Players::MaxPlayerCount || !m_IsHuman[player]) { return false; @@ -806,8 +744,6 @@ namespace RTE { return true; } - ////////////////////////////////////////////////////////////////////////////////////////// - void Activity::LoseControlOfActor(int player) { if (player >= Players::PlayerOne && player < Players::MaxPlayerCount) { if (Actor* actor = m_ControlledActor[player]; actor && g_MovableMan.IsActor(actor)) { @@ -820,8 +756,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void Activity::HandleCraftEnteringOrbit(ACraft* orbitedCraft) { if (!orbitedCraft) { return; @@ -876,8 +810,6 @@ namespace RTE { m_TeamDeaths[orbitedCraftTeam]--; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int Activity::GetBrainCount(bool getForHuman) const { int brainCount = 0; @@ -895,8 +827,6 @@ namespace RTE { return brainCount; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void Activity::SwitchToPrevOrNextActor(bool nextActor, int player, int team, const Actor* actorToSkip) { if (team < Teams::TeamOne || team >= Teams::MaxTeamCount || player < Players::PlayerOne || player >= Players::MaxPlayerCount || !m_IsHuman[player]) { return; @@ -928,8 +858,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void Activity::Update() { for (int player = Players::PlayerOne; player < Players::MaxPlayerCount; ++player) { if (m_MessageTimer[player].IsPastSimMS(5000)) { @@ -941,8 +869,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool Activity::CanBeUserSaved() const { if (const Scene* scene = g_SceneMan.GetScene(); (scene && scene->IsMetagameInternal()) || g_MetaMan.GameInProgress()) { return false; diff --git a/Source/Entities/Activity.h b/Source/Entities/Activity.h index 8d58759c9a..f9ad75e07b 100644 --- a/Source/Entities/Activity.h +++ b/Source/Entities/Activity.h @@ -10,18 +10,14 @@ namespace RTE { class Scene; class ACraft; - /// /// Base class for all Activities, including game modes and editors. - /// class Activity : public Entity { public: SerializableOverrideMethods; ClassInfoGetters; - /// /// Enumeration for the different states the Activity can be in. - /// enum ActivityState { NoActivity = -1, NotStarted = 0, @@ -33,9 +29,7 @@ namespace RTE { Over }; - /// /// Enumeration for the different teams in an activity. - /// enum Teams { NoTeam = -1, TeamOne = 0, @@ -45,9 +39,7 @@ namespace RTE { MaxTeamCount }; - /// /// Enumeration for the different observations states (camera viewpoint). - /// enum ViewState { Normal = 0, Observe, @@ -61,9 +53,7 @@ namespace RTE { UnitSelectCircle, }; - /// /// Enumeration for the different difficulty settings. - /// enum DifficultySetting { MinDifficulty = 0, CakeDifficulty = 20, @@ -74,9 +64,7 @@ namespace RTE { MaxDifficulty = 100, }; - /// /// Enumeration for the different AI skill settings. - /// enum AISkillSetting { MinSkill = 1, InferiorSkill = 35, @@ -87,35 +75,25 @@ namespace RTE { }; #pragma region Creation - /// /// Constructor method used to instantiate an Activity object in system memory. Create() should be called before using the object. - /// Activity() { Clear(); } - /// /// Makes the Activity object ready for use. - /// - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create() override; - /// /// Creates an Activity to be identical to another, by deep copy. - /// - /// A reference to the Activity to deep copy. - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @param reference A reference to the Activity to deep copy. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create(const Activity& reference); #pragma endregion #pragma region Destruction - /// /// Destructor method used to clean up an Activity object before deletion from system memory. - /// ~Activity() override { Destroy(true); } - /// /// Destroys and resets (through Clear()) the Activity object. - /// - /// Whether to only destroy the members defined in this derived class, or to destroy all inherited members also. + /// @param notInherited Whether to only destroy the members defined in this derived class, or to destroy all inherited members also. void Destroy(bool notInherited = false) override { if (!notInherited) { Entity::Destroy(); @@ -125,534 +103,388 @@ namespace RTE { #pragma endregion #pragma region Getters and Setters - /// /// Gets the current Activity state code. See the ActivityState enumeration for values. - /// - /// The current state of this Activity. See ActivityState enumeration. + /// @return The current state of this Activity. See ActivityState enumeration. ActivityState GetActivityState() const { return m_ActivityState; } - /// /// Overrides the current Activity state. Should not be used much, use dedicated state setting functions instead. - /// - /// The new state to set. + /// @param newState The new state to set. void SetActivityState(ActivityState newState) { m_ActivityState = newState; } - /// /// Indicates whether the Activity is currently running or not (not editing, over or paused) - /// - /// Whether the Activity is running or not. + /// @return Whether the Activity is running or not. bool IsRunning() const { return (m_ActivityState == ActivityState::Running || m_ActivityState == ActivityState::Editing) && !m_Paused; } - /// /// Indicates whether the Activity is currently paused or not. - /// - /// Whether the Activity is paused or not. + /// @return Whether the Activity is paused or not. bool IsPaused() const { return m_Paused; } - /// /// Pauses and unpauses the Activity. - /// - /// Whether to pause the Activity or not. + /// @param pause Whether to pause the Activity or not. virtual void SetPaused(bool pause = true) { m_Paused = pause; } - /// /// Indicates whether the Activity is over or not. - /// - /// Whether the Activity is over or not. + /// @return Whether the Activity is over or not. bool IsOver() const { return m_ActivityState == ActivityState::Over; } - /// /// Gets the user-friendly description of this Activity. - /// - /// A string with the user-friendly description of this Activity. + /// @return A string with the user-friendly description of this Activity. std::string GetDescription() const { return m_Description; } - /// /// Gets the max number of players supported by this Activity. - /// - /// The max number of players supported by this Activity. + /// @return The max number of players supported by this Activity. int GetMaxPlayerSupport() const { return m_MaxPlayerSupport; } - /// /// Gets the minimum number of teams with players that this Activity requires. - /// - /// The minimum number of Teams this Activity requires to run. + /// @return The minimum number of Teams this Activity requires to run. int GetMinTeamsRequired() const { return m_MinTeamsRequired; } - /// /// Tells if a particular Scene supports this specific Activity on it. Usually that means certain Areas need to be defined in the Scene. - /// - /// The Scene to check if it supports this Activity. Ownership is NOT transferred! - /// How many teams we're checking for. Some scenes may support and Activity but only for a limited number of teams. If -1, not applicable. - /// Whether the Scene has the right stuff. + /// @param scene The Scene to check if it supports this Activity. Ownership is NOT transferred! + /// @param teams How many teams we're checking for. Some scenes may support and Activity but only for a limited number of teams. If -1, not applicable. + /// @return Whether the Scene has the right stuff. virtual bool SceneIsCompatible(Scene* scene, int teams = -1) { return scene && teams <= m_MinTeamsRequired; } - /// /// Shows in which stage of the Campaign this appears. - /// - /// The stage number in the campaign. -1 means it's not in the campaign. + /// @return The stage number in the campaign. -1 means it's not in the campaign. int GetInCampaignStage() const { return m_InCampaignStage; } - /// /// /// Sets in which stage of the Campaign this appears. - /// - /// The new stage to set. -1 means it doesn't appear in the campaign. + /// @param newStage The new stage to set. -1 means it doesn't appear in the campaign. void SetInCampaignStage(int newStage) { m_InCampaignStage = newStage; } - /// /// Gets the name of the current scene. - /// - /// A string with the instance name of the scene. + /// @return A string with the instance name of the scene. std::string GetSceneName() const { return m_SceneName; } - /// /// Sets the name of the scene this is associated with. - /// - /// The new name of the scene to load next game. + /// @param sceneName The new name of the scene to load next game. void SetSceneName(const std::string sceneName) { m_SceneName = sceneName; } - /// /// Gets whether craft must be considered orbited if they reach the map border on non-wrapped maps. - /// - /// Whether craft are considered orbited when at the border of a non-wrapping map. + /// @return Whether craft are considered orbited when at the border of a non-wrapping map. bool GetCraftOrbitAtTheEdge() const { return m_CraftOrbitAtTheEdge; } - /// /// Sets whether craft must be considered orbited if they reach the map border on non-wrapped maps. - /// - /// Whether to consider orbited or not. + /// @param value Whether to consider orbited or not. void SetCraftOrbitAtTheEdge(bool value) { m_CraftOrbitAtTheEdge = value; } #pragma endregion #pragma region Virtual Override Methods - /// /// Officially starts this Activity. Creates all the data necessary to start the Activity. - /// - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. virtual int Start(); - /// /// Forces this Activity to end. - /// virtual void End(); - /// /// Updates the state of this Activity. Supposed to be done every frame before drawing. - /// virtual void Update(); - /// /// Draws the currently active GUI of a screen to a BITMAP of choice. - /// - /// A pointer to a screen-sized BITMAP to draw on. - /// The absolute position of the target bitmap's upper left corner in the scene. - /// Which screen's GUI to draw onto the bitmap. + /// @param targetBitmap A pointer to a screen-sized BITMAP to draw on. + /// @param targetPos The absolute position of the target bitmap's upper left corner in the scene. + /// @param whichScreen Which screen's GUI to draw onto the bitmap. virtual void DrawGUI(BITMAP* targetBitmap, const Vector& targetPos = Vector(), int whichScreen = 0) {} - /// /// Draws this Activity's current graphical representation to a BITMAP of choice. This includes all game-related graphics. - /// - /// A pointer to a BITMAP to draw on. - /// The absolute position of the target bitmap's upper left corner in the scene. + /// @param targetBitmap A pointer to a BITMAP to draw on. + /// @param targetPos The absolute position of the target bitmap's upper left corner in the scene. virtual void Draw(BITMAP* targetBitmap, const Vector& targetPos = Vector()) {} #pragma endregion #pragma region Player Handling - /// /// Pre-calculates the player-to-screen index map, counts the number of active players etc. - /// virtual void SetupPlayers(); - /// /// Indicates whether a specific player is active in the current game. - /// - /// Which player index to check. - /// Whether the player is active in the current Activity. + /// @param player Which player index to check. + /// @return Whether the player is active in the current Activity. bool PlayerActive(int player) const { return m_IsActive[player]; } - /// /// Turns off a player if they were active. Should only be done if brain etc are already taken care of and disposed of properly. /// Will also deactivate the team this player is on, if there's no other active players still on it. - /// - /// Which player index to deactivate. - /// Whether the player was active before trying to deactivate. + /// @param playerToDeactivate Which player index to deactivate. + /// @return Whether the player was active before trying to deactivate. bool DeactivatePlayer(int playerToDeactivate); - /// /// Sets up a specific player for this Activity, AI or Human. - /// - /// Which player slot to set up - PlayerOne to PlayerFour. - /// Whether this player is Human. - /// Which Team this player belongs to. - /// How many funds this player contributes to its Team's total funds. - /// The team flag icon of this player. Ownership is NOT transferred! - /// The new total number of active players in the current game. + /// @param playerToAdd Which player slot to set up - PlayerOne to PlayerFour. + /// @param isHuman Whether this player is Human. + /// @param team Which Team this player belongs to. + /// @param funds How many funds this player contributes to its Team's total funds. + /// @param teamIcon The team flag icon of this player. Ownership is NOT transferred! + /// @return The new total number of active players in the current game. int AddPlayer(int playerToAdd, bool isHuman, int team, float funds, const Icon* teamIcon = 0); - /// /// Sets all players as not active in the current Activity. - /// - /// Whether to reset the team funds as well. + /// @param resetFunds Whether to reset the team funds as well. void ClearPlayers(bool resetFunds = true); - /// /// Gets the total number of active players in the current Activity, AI or Human. - /// - /// The total number of players in the current Activity. + /// @return The total number of players in the current Activity. int GetPlayerCount() const { return m_PlayerCount; } - /// /// Gets the total number of human players in the current Activity. - /// - /// The total number of players in the current Activity. + /// @return The total number of players in the current Activity. int GetHumanCount() const; - /// /// Indicates whether a specific player is human in the current game, ie not an AI player and has a screen etc. - /// - /// Which player index to check. - /// Whether the player is active as a Human in the current Activity. + /// @param player Which player index to check. + /// @return Whether the player is active as a Human in the current Activity. bool PlayerHuman(int player) const { return m_IsHuman[player]; } - /// /// Gets the current team a specific player belongs to. - /// - /// The player to get the team info on. - /// The team number of the specified player. + /// @param player The player to get the team info on. + /// @return The team number of the specified player. int GetTeamOfPlayer(int player) const { return m_Team[player]; } - /// /// Sets the current team a specific player belongs to. - /// - /// The player to set the team for. - /// The team number to set the player to. + /// @param player The player to set the team for. + /// @param team The team number to set the player to. void SetTeamOfPlayer(int player, int team); - /// /// Converts a player index into a screen index, and only if that player is human. - /// - /// Which player index to convert. - /// The screen index, or -1 if non-human player or no players. + /// @param player Which player index to convert. + /// @return The screen index, or -1 if non-human player or no players. int ScreenOfPlayer(int player) const { return (player >= Players::PlayerOne && player < Players::MaxPlayerCount) ? m_PlayerScreen[player] : -1; } - /// /// Converts a screen index into a player index, if that screen exists. - /// - /// Which screen index to convert. - /// The player index, or -1 if that screen is not in use. + /// @param screen Which screen index to convert. + /// @return The player index, or -1 if that screen is not in use. int PlayerOfScreen(int screen) const; - /// /// Gets the current viewing state for a specific player. See the ViewState enumeration for values. - /// - /// Which player to get the view state for. - /// The current viewing state of the player. + /// @param whichPlayer Which player to get the view state for. + /// @return The current viewing state of the player. ViewState GetViewState(int whichPlayer = 0) const { return m_ViewState[whichPlayer]; } - /// /// Sets the current viewing state for a specific player. See the ViewState enumeration for values. - /// - /// The state to set to. - /// Which player to set the view state for. + /// @param whichViewState The state to set to. + /// @param whichPlayer Which player to set the view state for. void SetViewState(ViewState whichViewState, int whichPlayer = 0) { m_ViewState[whichPlayer] = whichViewState; } - /// /// Resets the message timer for one player. - /// - /// The player to reset the message timer for. + /// @param player The player to reset the message timer for. void ResetMessageTimer(int player = 0) { if (player >= Players::PlayerOne && player < Players::MaxPlayerCount) { m_MessageTimer[player].Reset(); } } - /// /// Gets a pointer to the GUI controller of the specified player. - /// - /// Which player to get the Controller of. - /// A pointer to the player's Controller. Ownership is NOT transferred! + /// @param player Which player to get the Controller of. + /// @return A pointer to the player's Controller. Ownership is NOT transferred! Controller* GetPlayerController(int player = 0) { return (player >= Players::PlayerOne && player < Players::MaxPlayerCount) ? &m_PlayerController[player] : nullptr; } #pragma endregion #pragma region Team Handling - /// /// Gets the total number of teams in the current Activity. - /// - /// The total number of teams in the current Activity. + /// @return The total number of teams in the current Activity. int GetTeamCount() const { return m_TeamCount; } - /// /// Gets the name of a specific team. - /// - /// Which team to get the name of. 0 = first team. - /// The current name of that team. + /// @param whichTeam Which team to get the name of. 0 = first team. + /// @return The current name of that team. std::string GetTeamName(int whichTeam = 0) const; - /// /// Sets the name of a specific team. - /// - /// Which team to set the name of. 0 = first team. - /// The name to set it to. + /// @param whichTeam Which team to set the name of. 0 = first team. + /// @param newName The name to set it to. void SetTeamName(int whichTeam, const std::string& newName) { if (whichTeam >= Teams::TeamOne && whichTeam < Teams::MaxTeamCount) { m_TeamNames[whichTeam] = newName; } } - /// /// Gets the Icon of a specific team. - /// - /// Which team to get the Icon of. 0 = first team. - /// The current Icon of that team. + /// @param whichTeam Which team to get the Icon of. 0 = first team. + /// @return The current Icon of that team. const Icon* GetTeamIcon(int whichTeam = 0) const { return (whichTeam >= Teams::TeamOne && whichTeam < Teams::MaxTeamCount) ? &m_TeamIcons[whichTeam] : nullptr; } - /// /// Sets the Icon of a specific team. - /// - /// Which team to set the Icon of. 0 = first team. - /// The Icon to set it to. + /// @param whichTeam Which team to set the Icon of. 0 = first team. + /// @param newIcon The Icon to set it to. void SetTeamIcon(int whichTeam, const Icon& newIcon) { if (whichTeam >= Teams::TeamOne && whichTeam < Teams::MaxTeamCount) { m_TeamIcons[whichTeam] = newIcon; } } - /// /// Indicates whether a specific team is active in the current game. - /// - /// Which team index to check. - /// Whether the team is active in the current Activity. + /// @param team Which team index to check. + /// @return Whether the team is active in the current Activity. bool TeamActive(int team) const { return (team >= Teams::TeamOne && team < Teams::MaxTeamCount) ? m_TeamActive[team] : false; } - /// /// Sets the given team as active, even if it shouldn't be considered as such normally. Useful for Activities that don't want to define/show all used teams. - /// - /// The team to force as active. + /// @param team The team to force as active. void ForceSetTeamAsActive(int team) { if (team >= Teams::TeamOne && team < Teams::MaxTeamCount) { m_TeamActive[team] = true; } } - /// /// Indicates whether a team is player controlled or not. - /// - /// The team number to check. - /// Whether team is player controlled or not. + /// @param team The team number to check. + /// @return Whether team is player controlled or not. bool IsHumanTeam(int team) const; - /// /// Gets the current number of players in a specific team. - /// - /// Which team to get the player count for. - /// The player count in the specified team. + /// @param team Which team to get the player count for. + /// @return The player count in the specified team. int PlayersInTeamCount(int team) const; - /// /// Gets the number of deaths on a specific team so far on the current Activity. - /// - /// Which team to get the death tally of. 0 = first team. - /// The current death count. + /// @param whichTeam Which team to get the death tally of. 0 = first team. + /// @return The current death count. int GetTeamDeathCount(int whichTeam = 0) const { return (whichTeam >= Teams::TeamOne && whichTeam < Teams::MaxTeamCount) ? m_TeamDeaths[whichTeam] : 0; } - /// /// Increments the tally of a death of an actor on a specific team. - /// - /// Which team to increase the death count of. 0 = first team. - /// The new death count. - /// The updated death count of the team. + /// @param whichTeam Which team to increase the death count of. 0 = first team. + /// @param howMany The new death count. + /// @return The updated death count of the team. int ReportDeath(int whichTeam = 0, int howMany = 1) { return (whichTeam >= Teams::TeamOne && whichTeam < Teams::MaxTeamCount) ? m_TeamDeaths[whichTeam] += howMany : 0; } #pragma endregion #pragma region Funds Handling - /// /// Gets the amount of funds a specific team currently has in the Activity. - /// - /// Which team to get the fund count from. 0 = first team. - /// A float with the funds tally for the requested team. + /// @param whichTeam Which team to get the fund count from. 0 = first team. + /// @return A float with the funds tally for the requested team. float GetTeamFunds(int whichTeam = 0) const { return (whichTeam >= Teams::TeamOne && whichTeam < Teams::MaxTeamCount) ? m_TeamFunds[whichTeam] : 0; } - /// /// Sets the amount of funds a specific team currently has in the Activity. - /// - /// Which team to set the fund count for. 0 = first team. - /// A float with the funds tally for the requested team. + /// @param newFunds Which team to set the fund count for. 0 = first team. + /// @param which A float with the funds tally for the requested team. void SetTeamFunds(float newFunds, int whichTeam = 0) { if (whichTeam >= Teams::TeamOne && whichTeam < Teams::MaxTeamCount) { m_TeamFunds[whichTeam] = newFunds; } } - /// /// Changes a team's funds level by a certain amount. - /// - /// The amount with which to change the funds balance. - /// Which team to alter the funds of. 0 = first team. + /// @param howMuch The amount with which to change the funds balance. + /// @param whichTeam Which team to alter the funds of. 0 = first team. void ChangeTeamFunds(float howMuch, int whichTeam = 0); - /// /// Checks whether the team funds changed since last time this was called. This also resets the state, so calling this again on the same team will yield false unless it's been changed again. - /// - /// Which team's funds to check. - /// Whether funds amount changed for this team since last time this was called. + /// @param whichTeam Which team's funds to check. + /// @return Whether funds amount changed for this team since last time this was called. bool TeamFundsChanged(int whichTeam = 0); - /// /// Gets the amount of funds a specific player originally added to his team's collective stash. - /// - /// Which player to check for. - /// A float with the funds originally deposited by this player. + /// @param player Which player to check for. + /// @return A float with the funds originally deposited by this player. float GetPlayerFundsContribution(int player) const { return (player >= Players::PlayerOne && player < Players::MaxPlayerCount) ? m_FundsContribution[player] : 0; } - /// /// Sets a new amount of starting funds for a player, after he has already been added. - /// - /// Which player slot to update - has to already be active. - /// Updated value of how many funds this player contributes to its Team's total funds. - /// Whether the update was successful. + /// @param player Which player slot to update - has to already be active. + /// @param newFunds Updated value of how many funds this player contributes to its Team's total funds. + /// @return Whether the update was successful. bool UpdatePlayerFundsContribution(int player, float newFunds); - /// /// Gets the share of funds a specific PLAYER currently has in the game, calculated from his original contribution to his team's collective funds. - /// - /// Which player to get the fund count from. - /// A float with the funds tally for the requested player. + /// @param player Which player to get the fund count from. + /// @return A float with the funds tally for the requested player. float GetPlayerFundsShare(int player = 0) const; #pragma endregion #pragma region Brain Handling - /// /// Shows how many human controlled brains are left in this Activity. - /// - /// How many human controlled brains are left in this Activity. + /// @return How many human controlled brains are left in this Activity. int HumanBrainCount() const { return GetBrainCount(true); } - /// /// Shows how many AI controlled brains are left in this Activity. - /// - /// how many AI controlled brains are left in this Activity. + /// @return how many AI controlled brains are left in this Activity. int AIBrainCount() const { return GetBrainCount(false); } - /// /// Gets the current Brain actor for a specific player. - /// - /// Which player to get the brain actor for. - /// A pointer to the Brain Actor. Ownership is NOT transferred! + /// @param player Which player to get the brain actor for. + /// @return A pointer to the Brain Actor. Ownership is NOT transferred! Actor* GetPlayerBrain(int player = 0) const { return (player >= Players::PlayerOne && player < Players::MaxPlayerCount) ? m_Brain[player] : nullptr; } - /// /// Sets the current Brain actor for a specific player. - /// - /// A pointer to the new brain Actor. Ownership is NOT transferred! - /// Which team to set the brain actor for. + /// @param newBrain A pointer to the new brain Actor. Ownership is NOT transferred! + /// @param player Which team to set the brain actor for. void SetPlayerBrain(Actor* newBrain, int player = 0); - /// /// Shows whether a specific player ever had a Brain yet. - /// - /// Which player to check whether they ever had a Brain. - /// Whether this player ever had a Brain. + /// @param player Which player to check whether they ever had a Brain. + /// @return Whether this player ever had a Brain. bool PlayerHadBrain(int player = 0) const { return (player >= Players::PlayerOne && player < Players::MaxPlayerCount) ? m_HadBrain[player] : false; } - /// /// Sets to indicate that the player had a Brain at some point. This is to simulate that in automated battle cases. - /// - /// Which player to set whether he had a Brain or not. - /// Whether he should be flagged as having had a Brain. + /// @param player Which player to set whether he had a Brain or not. + /// @param hadBrain Whether he should be flagged as having had a Brain. void SetPlayerHadBrain(int player, bool hadBrain = true) { if (player >= Players::PlayerOne && player < Players::MaxPlayerCount) m_HadBrain[player] = hadBrain; } - /// /// Shows whether a specific player's Brain was evacuated into orbit so far. - /// - /// Which player to check whether their Brain was evacuated. - /// Whether this player had a Brain that was evacuated. + /// @param player Which player to check whether their Brain was evacuated. + /// @return Whether this player had a Brain that was evacuated. bool BrainWasEvacuated(int player = 0) const { return (player >= Players::PlayerOne && player < Players::MaxPlayerCount) ? m_BrainEvacuated[player] : false; } - /// /// Sets whether a player's Brain was evacuated during the Activity. - /// - /// Which player to check whether their Brain was evacuated. - /// Whether it was evacuated yet. + /// @param player Which player to check whether their Brain was evacuated. + /// @param evacuated Whether it was evacuated yet. void SetBrainEvacuated(int player = 0, bool evacuated = true) { if (player >= Players::PlayerOne && player < Players::MaxPlayerCount) { m_BrainEvacuated[player] = evacuated; } } - /// /// Shows whether ANY player evacuated their Brain. - /// - /// Whether any player evacuated their Brain yet. + /// @return Whether any player evacuated their Brain yet. bool AnyBrainWasEvacuated() const; - /// /// Shows whether the passed in actor is the Brain of any player. - /// - /// Which Actor to check for player braininess. - /// Whether any player's Brain or not. + /// @param actor Which Actor to check for player braininess. + /// @return Whether any player's Brain or not. bool IsAssignedBrain(Actor* actor) const; - /// /// Shows which player has a specific actor as a Brain, if any. - /// - /// Which Actor to check for player braininess. - /// Which player has this assigned as a Brain, if any. + /// @param actor Which Actor to check for player braininess. + /// @return Which player has this assigned as a Brain, if any. int IsBrainOfWhichPlayer(Actor* actor) const; - /// /// Shows whether the passed in actor is the Brain of any other player. - /// - /// Which Actor to check for other player braininess. - /// From which player's perspective to check. - /// Whether other player's Brain or not. + /// @param actor Which Actor to check for other player braininess. + /// @param player From which player's perspective to check. + /// @return Whether other player's Brain or not. bool IsOtherPlayerBrain(Actor* actor, int player) const; #pragma endregion #pragma region Difficulty Handling - /// /// Returns string representation of a given difficulty value. - /// - /// Difficulty setting - /// Corresponding difficulty string. + /// @param difficulty Difficulty setting + /// @return Corresponding difficulty string. static std::string GetDifficultyString(int difficulty); - /// /// Gets the current difficulty setting. - /// - /// The current setting. + /// @return The current setting. int GetDifficulty() const { return m_Difficulty; } - /// /// Sets the current difficulty setting. - /// - /// The new difficulty setting. + /// @param newDifficulty The new difficulty setting. void SetDifficulty(int newDifficulty) { m_Difficulty = Limit(newDifficulty, DifficultySetting::MaxDifficulty, DifficultySetting::MinDifficulty); } #pragma endregion #pragma region AI Handling - /// /// Returns string representation of a given AI skill value. - /// - /// AI skill setting. - /// Corresponding AI skill string. + /// @param skill AI skill setting. + /// @return Corresponding AI skill string. static std::string GetAISkillString(int skill); - /// /// Returns skill level for specified team. If team is less than 0 or greater than 3 an average of all teams is returned. - /// - /// Team to get skill level for. - /// Team skill level. + /// @param team Team to get skill level for. + /// @return Team skill level. int GetTeamAISkill(int team) const; - /// /// Sets AI skill level for specified team. - /// - /// The team to set for. - /// AI skill level, 1-100. + /// @param team The team to set for. + /// @param skill AI skill level, 1-100. void SetTeamAISkill(int team, int skill) { if (team >= Teams::TeamOne && team < Teams::MaxTeamCount) { m_TeamAISkillLevels[team] = Limit(skill, AISkillSetting::UnfairSkill, AISkillSetting::MinSkill); @@ -661,101 +493,73 @@ namespace RTE { #pragma endregion #pragma region Actor Handling - /// /// Gets the currently controlled actor of a specific player. - /// - /// Which player to get the controlled actor of. - /// A pointer to the controlled Actor. Ownership is NOT transferred! 0 If no actor is currently controlled by this player. + /// @param player Which player to get the controlled actor of. + /// @return A pointer to the controlled Actor. Ownership is NOT transferred! 0 If no actor is currently controlled by this player. Actor* GetControlledActor(int player = 0) { return (player >= Players::PlayerOne && player < Players::MaxPlayerCount) ? m_ControlledActor[player] : nullptr; } - /// /// Makes the player's ControlledActor the leader of any squad it is a member of. - /// - /// Player to reassign for. - /// Team of the player. + /// @param player Player to reassign for. + /// @param team Team of the player. void ReassignSquadLeader(const int player, const int team); - /// /// Forces the ActivityMan to focus player control to a specific Actor for a specific team. Ownership is NOT transferred! - /// - /// Which Actor to switch focus to. The team of this Actor will be set once it is passed in. The actor should have been added to MovableMan already. - /// Player to force for. - /// Which team to switch to next actor on. - /// Whether the focus switch was successful or not. + /// @param actor Which Actor to switch focus to. The team of this Actor will be set once it is passed in. The actor should have been added to MovableMan already. + /// @param player Player to force for. + /// @param team Which team to switch to next actor on. + /// @return Whether the focus switch was successful or not. virtual bool SwitchToActor(Actor* actor, int player = 0, int team = 0); - /// /// Forces the Activity to focus player control to the previous Actor of a specific team, other than the current one focused on. - /// - /// Player to force for. - /// Which team to switch to next Actor on. - /// An Actor pointer to skip in the sequence. + /// @param player Player to force for. + /// @param team Which team to switch to next Actor on. + /// @param actorToSkip An Actor pointer to skip in the sequence. virtual void SwitchToPrevActor(int player, int team, Actor* actorToSkip = 0) { SwitchToPrevOrNextActor(false, player, team, actorToSkip); } - /// /// Forces the Activity to focus player control to the next Actor of a specific team, other than the current one focused on. - /// - /// Player to force for. - /// Which team to switch to next Actor on. - /// An Actor pointer to skip in the sequence. + /// @param player Player to force for. + /// @param team Which team to switch to next Actor on. + /// @param actorToSkip An Actor pointer to skip in the sequence. virtual void SwitchToNextActor(int player, int team, Actor* actorToSkip = 0) { SwitchToPrevOrNextActor(true, player, team, actorToSkip); } - /// /// Forces player to lose control of the currently selected Actor, as if it had died. - /// - /// Which player to lose control of their selected Actor. + /// @param player Which player to lose control of their selected Actor. virtual void LoseControlOfActor(int player); - /// /// Handles when an ACraft has left the game scene and entered orbit, though does not delete it. Ownership is NOT transferred, as the ACraft's inventory is just 'unloaded'. - /// - /// The ACraft instance that entered orbit. Ownership is NOT transferred! + /// @param orbitedCraft The ACraft instance that entered orbit. Ownership is NOT transferred! virtual void HandleCraftEnteringOrbit(ACraft* orbitedCraft); #pragma endregion #pragma region Save and Load Handling - /// /// Gets whether or not this Activity can be saved by the user. For this to be true, the Scene must not be MetagameInternal, and the AllowsUserSaving flag must not be disabled. - /// - /// Whether or not this Activity can be saved. + /// @return Whether or not this Activity can be saved. bool CanBeUserSaved() const; - /// /// Gets whether or not this Activity allows the player to manually save. - /// - /// Whether or not this Activity allows the player to manually save. + /// @return Whether or not this Activity allows the player to manually save. bool GetAllowsUserSaving() const { return m_AllowsUserSaving; } - /// /// Sets whether or not this Activity can be manually saved be the player. - /// - /// Whether or not this Activity can be manually saved be the player. + /// @param allowsUserSaving Whether or not this Activity can be manually saved be the player. void SetAllowsUserSaving(bool allowsUserSaving) { m_AllowsUserSaving = allowsUserSaving; } - /// /// Saves a string which will be stored in our ini. - /// - /// The key of the saved string. - /// The string to save. + /// @param key The key of the saved string. + /// @param value The string to save. void SaveString(const std::string& key, const std::string& value) { m_SavedValues.SaveString(key, value); }; - /// /// Loads and returns a previously saved string. - /// - /// The key of the string to load. + /// @param key The key of the string to load. const std::string& LoadString(const std::string& key) { return m_SavedValues.LoadString(key); }; - /// /// Saves a number which will be stored in our ini. - /// - /// The key of the saved number. - /// The number to save. + /// @param key The key of the saved number. + /// @param value The number to save. void SaveNumber(const std::string& key, float value) { m_SavedValues.SaveNumber(key, value); }; - /// /// Loads and returns a previously saved number. - /// - /// The key of the string to load. + /// @param key The key of the string to load. float LoadNumber(const std::string& key) { return m_SavedValues.LoadNumber(key); }; #pragma endregion @@ -808,33 +612,25 @@ namespace RTE { Timer m_MessageTimer[Players::MaxPlayerCount]; //!< Message timer for each player. - /// /// Generic additional saved strings/numbers, which are used for scripts primarily. /// They live here in the base class because GAScripted doesn't have a lua interface although it's a little messy. /// On the bright side, this would allows other parts of the code to add some metadata to stamp extra information onto an activity if needed, that'll be ignored otherwise. - /// GenericSavedData m_SavedValues; private: - /// /// Shared method to get the amount of human or AI controlled brains that are left in this Activity. - /// - /// Whether to get brain count for Human or for AI. True for Human. - /// How many human or AI controlled brains are left in this Activity. + /// @param getForHuman Whether to get brain count for Human or for AI. True for Human. + /// @return How many human or AI controlled brains are left in this Activity. int GetBrainCount(bool getForHuman) const; - /// /// Shared method to force the Activity to focus player control to the previous or next Actor of a specific team, other than the current one focused on. - /// - /// Whether to switch to the previous or the next Actor. True for next Actor. - /// Player to force for. - /// Which team to switch to next Actor on. - /// An Actor pointer to skip in the sequence. + /// @param nextActor Whether to switch to the previous or the next Actor. True for next Actor. + /// @param player Player to force for. + /// @param team Which team to switch to next Actor on. + /// @param skip An Actor pointer to skip in the sequence. void SwitchToPrevOrNextActor(bool nextActor, int player, int team, const Actor* skip = 0); - /// /// Clears all the member variables of this Activity, effectively resetting the members of this abstraction level only. - /// void Clear(); // Disallow the use of some implicit methods. diff --git a/Source/Entities/Actor.cpp b/Source/Entities/Actor.cpp index 98cdc914b6..1b39b54bc5 100644 --- a/Source/Entities/Actor.cpp +++ b/Source/Entities/Actor.cpp @@ -1,15 +1,3 @@ -////////////////////////////////////////////////////////////////////////////////////////// -// File: Actor.cpp -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Source file for the Actor class. -// Project: Retro Terrain Engine -// Author(s): Daniel Tabar -// data@datarealms.com -// http://www.datarealms.com - -////////////////////////////////////////////////////////////////////////////////////////// -// Inclusions of header files - #include "Actor.h" #include "UInputMan.h" @@ -50,17 +38,6 @@ namespace RTE { #define ARROWTIME 1000 - ////////////////////////////////////////////////////////////////////////////////////////// - // Constructor: LuaBindRegister - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Registration function for exposing this' members to a LuaBind module. - - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Clear - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears all the member variables of this Actor, effectively - // resetting the members of this abstraction level only. - void Actor::Clear() { m_Controller.Reset(); m_PlayerControllable = true; @@ -137,11 +114,6 @@ namespace RTE { m_PieMenu.reset(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes the Actor object ready for use. - int Actor::Create() { if (MOSRotating::Create() < 0) { return -1; @@ -179,11 +151,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Creates a Actor to be identical to another, by deep copy. - int Actor::Create(const Actor& reference) { MOSRotating::Create(reference); @@ -306,14 +273,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: ReadProperty - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Reads a property value from a reader stream. If the name isn't - // recognized by this class, then ReadProperty of the parent class - // is called. If the property isn't recognized by any of the base classes, - // false is returned, and the reader's position is untouched. - int Actor::ReadProperty(const std::string_view& propName, Reader& reader) { StartPropertyList(return MOSRotating::ReadProperty(propName, reader)); @@ -403,12 +362,6 @@ namespace RTE { EndPropertyList; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Save - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Saves the complete state of this Actor with a Writer for - // later recreation with Create(Reader &reader); - int Actor::Save(Writer& writer) const { MOSRotating::Save(writer); @@ -486,11 +439,6 @@ namespace RTE { MOSRotating::DestroyScriptState(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destroys and resets (through Clear()) the Actor object. - void Actor::Destroy(bool notInherited) { delete m_DeviceSwitchSound; delete m_BodyHitSound; @@ -509,8 +457,6 @@ namespace RTE { Clear(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - float Actor::GetInventoryMass() const { float inventoryMass = 0.0F; for (const MovableObject* inventoryItem: m_Inventory) { @@ -519,8 +465,6 @@ namespace RTE { return inventoryMass; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - float Actor::GetBaseMass() { if (m_BaseMass == std::numeric_limits::infinity()) { if (const Actor* presetActor = static_cast(GetPreset())) { @@ -533,23 +477,10 @@ namespace RTE { return m_BaseMass; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: IsPlayerControlled - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Tells whether a player is currently controlling this. - bool Actor::IsPlayerControlled() const { return m_Controller.GetInputMode() == Controller::CIM_PLAYER && m_Controller.GetPlayer() >= 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetTotalValue - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the total liquidation value of this Actor and all its carried - // gold and inventory. - float Actor::GetTotalValue(int nativeModule, float foreignMult, float nativeMult) const { float totalValue = (GetGoldValue(nativeModule, foreignMult, nativeMult) / 2) + ((GetGoldValue(nativeModule, foreignMult, nativeMult) / 2) * (GetHealth() / GetMaxHealth())); totalValue += GetGoldCarried(); @@ -564,12 +495,6 @@ namespace RTE { return totalValue; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: HasObject - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Shows whether this carries a specifically named object in its inventory. - // Also looks through the inventories of potential passengers, as applicable. - bool Actor::HasObject(std::string objectName) const { if (MOSRotating::HasObject(objectName)) return true; @@ -582,13 +507,6 @@ namespace RTE { return false; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: HasObjectInGroup - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Shows whether this is or carries a specifically grouped object in its - // inventory. Also looks through the inventories of potential passengers, - // as applicable. - bool Actor::HasObjectInGroup(std::string groupName) const { if (MOSRotating::HasObjectInGroup(groupName)) return true; @@ -601,11 +519,6 @@ namespace RTE { return false; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: SetTeam - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets which team this Actor belongs to. - void Actor::SetTeam(int team) { MovableObject::SetTeam(team); @@ -623,11 +536,6 @@ namespace RTE { } } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetControllerMode - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets this Actor's new Controller input mode. - void Actor::SetControllerMode(Controller::InputMode newMode, int newPlayer) { Controller::InputMode previousControllerMode = m_Controller.GetInputMode(); @@ -641,22 +549,12 @@ namespace RTE { m_NewControlTmr.Reset(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SwapControllerModes - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets this Actor's Controller mode and gives back what it used to be. - Controller::InputMode Actor::SwapControllerModes(Controller::InputMode newMode, int newPlayer) { Controller::InputMode returnMode = m_Controller.GetInputMode(); SetControllerMode(newMode, newPlayer); return returnMode; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Look - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Casts an unseen-revealing ray in the direction of where this is facing. - bool Actor::Look(float FOVSpread, float range) { if (!g_SceneMan.AnythingUnseen(m_Team) || m_CanRevealUnseen == false) return false; @@ -693,8 +591,6 @@ namespace RTE { return g_SceneMan.CastSeeRay(m_Team, aimPos, lookVector, ignored, 25, g_SceneMan.GetUnseenResolution(m_Team).GetSmallest() / 2); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void Actor::AddGold(float goldOz) { bool isHumanTeam = g_ActivityMan.GetActivity()->IsHumanTeam(m_Team); if (g_SettingsMan.GetAutomaticGoldDeposit() || !isHumanTeam) { @@ -713,8 +609,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void Actor::RestDetection() { MOSRotating::RestDetection(); @@ -726,22 +620,11 @@ namespace RTE { } } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: AddAIMOWaypoint - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Adds an MO in the scene as the next waypoint for this to go to, in order - void Actor::AddAIMOWaypoint(const MovableObject* pMOWaypoint) { if (g_MovableMan.ValidMO(pMOWaypoint)) m_Waypoints.push_back(std::pair(pMOWaypoint->GetPos(), pMOWaypoint)); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SwapNextInventory - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Swaps the next MovableObject carried by this Actor and puts one not - // currently carried into the into the back of the inventory of this. - MovableObject* Actor::SwapNextInventory(MovableObject* pSwapIn, bool muteSound) { MovableObject* pRetDev = 0; bool playSound = false; @@ -764,8 +647,6 @@ namespace RTE { return pRetDev; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void Actor::RemoveInventoryItem(const std::string& moduleName, const std::string& presetName) { for (std::deque::iterator inventoryIterator = m_Inventory.begin(); inventoryIterator != m_Inventory.end(); ++inventoryIterator) { if ((moduleName.empty() || (*inventoryIterator)->GetModuleName() == moduleName) && (*inventoryIterator)->GetPresetName() == presetName) { @@ -777,8 +658,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - MovableObject* Actor::RemoveInventoryItemAtIndex(int inventoryIndex) { if (inventoryIndex >= 0 && inventoryIndex < m_Inventory.size()) { MovableObject* itemAtIndex = m_Inventory[inventoryIndex]; @@ -788,14 +667,6 @@ namespace RTE { return nullptr; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SwapPrevInventory - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Swaps the prev MovableObject carried by this Actor and puts one not - // currently carried into the into the back of the inventory of this. - MovableObject* Actor::SwapPrevInventory(MovableObject* pSwapIn) { MovableObject* pRetDev = 0; bool playSound = false; @@ -816,8 +687,6 @@ namespace RTE { return pRetDev; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool Actor::SwapInventoryItemsByIndex(int inventoryIndex1, int inventoryIndex2) { if (inventoryIndex1 < 0 || inventoryIndex2 < 0 || inventoryIndex1 >= m_Inventory.size() || inventoryIndex2 >= m_Inventory.size()) { return false; @@ -827,8 +696,6 @@ namespace RTE { return true; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - MovableObject* Actor::SetInventoryItemAtIndex(MovableObject* newInventoryItem, int inventoryIndex) { if (!newInventoryItem) { return RemoveInventoryItemAtIndex(inventoryIndex); @@ -844,14 +711,6 @@ namespace RTE { return currentInventoryItemAtIndex; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: DropAllInventory - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Ejects all inventory items that this is carrying. It may not happen - // instantaneously, so check for ejection being complete with InventoryEmpty(). - void Actor::DropAllInventory() { MovableObject* pObject = 0; Actor* pPassenger = 0; @@ -921,8 +780,6 @@ namespace RTE { m_Inventory.clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - void Actor::DropAllGold() { const Material* goldMaterial = g_SceneMan.GetMaterialFromID(g_MaterialGold); float velMin = 3.0F; @@ -944,8 +801,6 @@ namespace RTE { m_GoldCarried = 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - bool Actor::AddToInventoryFront(MovableObject* itemToAdd) { // This function is called often to add stuff we just removed from our hands, which may be set to delete so we need to guard against that lest we crash. if (!itemToAdd || itemToAdd->IsSetToDelete()) { @@ -956,8 +811,6 @@ namespace RTE { return true; } - ////////////////////////////////////////////////////////////////////////////////////////// - bool Actor::AddToInventoryBack(MovableObject* itemToAdd) { // This function is called often to add stuff we just removed from our hands, which may be set to delete so we need to guard against that lest we crash. if (!itemToAdd || itemToAdd->IsSetToDelete()) { @@ -968,12 +821,6 @@ namespace RTE { return true; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: GibThis - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gibs this, effectively destroying it and creating multiple gibs or - // pieces in its place. - void Actor::GibThis(const Vector& impactImpulse, MovableObject* movableObjectToIgnore) { // Play death sound // TODO: Don't attenuate since death is pretty important.. maybe only make this happen for teh brains @@ -1067,13 +914,6 @@ namespace RTE { } } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: CollideAtPoint - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Calculates the collision response when another MO's Atom collides with - // this MO's physical representation. The effects will be applied - // directly to this MO, and also represented in the passed in HitData. - bool Actor::CollideAtPoint(HitData& hd) { return MOSRotating::CollideAtPoint(hd); @@ -1088,14 +928,6 @@ namespace RTE { // if (Status != ACTIVE) } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: ParticlePenetration - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Determines whether a particle which has hit this MO will penetrate, - // and if so, whether it gets lodged or exits on the other side of this - // MO. Appropriate effects will be determined and applied ONLY IF there - // was penetration! If not, nothing will be affected. - bool Actor::ParticlePenetration(HitData& hd) { bool penetrated = MOSRotating::ParticlePenetration(hd); @@ -1123,22 +955,10 @@ namespace RTE { return penetrated; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: GetAIModeIcon - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the icon bitmap associated with this' current AI mode and team. - BITMAP* Actor::GetAIModeIcon() { return m_apAIIcons[m_AIMode]; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: GetLastMOWaypointID - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the ID of the last set AI MO waypoint of this. If none, g_NoMOID is returned. - // Arguments: None. - // Return value: The furthest set AI MO waypoint of this. - MOID Actor::GetAIMOWaypointID() const { if (g_MovableMan.ValidMO(m_pMOMoveTarget)) return m_pMOMoveTarget->GetID(); @@ -1146,11 +966,6 @@ namespace RTE { return g_NoMOID; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: UpdateMovePath - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the path to move along to the currently set movetarget. - void Actor::UpdateMovePath() { if (g_SceneMan.GetScene() == nullptr) { return; @@ -1194,17 +1009,10 @@ namespace RTE { m_UpdateMovePath = false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - float Actor::EstimateDigStrength() const { return m_AIBaseDigStrength; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: VerifyMOIDs - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Verifieis whether all actor's MO has correct IDs. Should be used in Debug mode only. - void Actor::VerifyMOIDs() { std::vector MOIDs; GetMOIDs(MOIDs); @@ -1214,8 +1022,6 @@ namespace RTE { } } - ////////////////////////////////////////////////////////////////////////////////////////// - void Actor::OnNewMovePath() { if (!m_MovePath.empty()) { // Remove the first one; it's our position @@ -1235,8 +1041,6 @@ namespace RTE { } } - ////////////////////////////////////////////////////////////////////////////////////////// - void Actor::PreControllerUpdate() { if (m_PathRequest && m_PathRequest->complete) { m_MovePath = const_cast&>(m_PathRequest->path); @@ -1251,8 +1055,6 @@ namespace RTE { } } - ////////////////////////////////////////////////////////////////////////////////////////// - void Actor::Update() { ZoneScoped; @@ -1468,12 +1270,6 @@ namespace RTE { Update(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: DrawHUD - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws this Actor's current graphical HUD overlay representation to a - // BITMAP of choice. - void Actor::DrawHUD(BITMAP* pTargetBitmap, const Vector& targetPos, int whichScreen, bool playerControlled) { // This should indeed be a local var and not alter a member one in a draw func! Can cause nasty jittering etc if multiple sim updates are done without a drawing in between etc m_HUDStack = -m_CharHeight / 2; diff --git a/Source/Entities/Actor.h b/Source/Entities/Actor.h index e12b276318..8394ea5056 100644 --- a/Source/Entities/Actor.h +++ b/Source/Entities/Actor.h @@ -1,18 +1,11 @@ #ifndef _RTEACTOR_ #define _RTEACTOR_ -////////////////////////////////////////////////////////////////////////////////////////// -// File: Actor.h -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Header file for the Actor class. -// Project: Retro Terrain Engine -// Author(s): Daniel Tabar -// data@datarealms.com -// http://www.datarealms.com - -////////////////////////////////////////////////////////////////////////////////////////// -// Inclusions of header files - +/// Header file for the Actor class. +/// @author Daniel Tabar +/// data@datarealms.com +/// http://www.datarealms.com +/// Inclusions of header files #include "MOSRotating.h" #include "PieMenu.h" #include "PathFinder.h" @@ -29,19 +22,11 @@ namespace RTE { #define AILINEDOTSPACING 16 - ////////////////////////////////////////////////////////////////////////////////////////// - // Class: Actor - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: A sprite movable object that is autonomous. - // Parent(s): MOSRotating. - // Class history: 04/13/2001 Actor created. - + /// A sprite movable object that is autonomous. class Actor : public MOSRotating { friend struct EntityLuaBindings; - ////////////////////////////////////////////////////////////////////////////////////////// - // Public member variable, method and friend function declarations - + /// Public member variable, method and friend function declarations public: enum Status { STABLE = 0, @@ -88,371 +73,203 @@ namespace RTE { SerializableOverrideMethods; ClassInfoGetters; - ////////////////////////////////////////////////////////////////////////////////////////// - // Constructor: Actor - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Constructor method used to instantiate a Actor object in system - // memory. Create() should be called before using the object. - // Arguments: None. - + /// Constructor method used to instantiate a Actor object in system + /// memory. Create() should be called before using the object. Actor() { Clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Destructor: ~Actor - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destructor method used to clean up a Actor object before deletion - // from system memory. - // Arguments: None. - + /// Destructor method used to clean up a Actor object before deletion + /// from system memory. ~Actor() override { Destroy(true); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes the Actor object ready for use. - // Arguments: None. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Makes the Actor object ready for use. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Create() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Creates a Actor to be identical to another, by deep copy. - // Arguments: A reference to the Actor to deep copy. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Creates a Actor to be identical to another, by deep copy. + /// @param reference A reference to the Actor to deep copy. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Create(const Actor& reference); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Reset - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Resets the entire Actor, including its inherited members, to their - // default settings or values. - // Arguments: None. - // Return value: None. - + /// Resets the entire Actor, including its inherited members, to their + /// default settings or values. void Reset() override { Clear(); MOSRotating::Reset(); m_MOType = MovableObject::TypeActor; } - /// /// Cleans up and destroys the script state of this object, calling the Destroy callback in lua - /// void DestroyScriptState(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destroys and resets (through Clear()) the SceneLayer object. - // Arguments: Whether to only destroy the members defined in this derived class, or - // to destroy all inherited members also. - // Return value: None. - + /// Destroys and resets (through Clear()) the SceneLayer object. + /// @param notInherited Whether to only destroy the members defined in this derived class, or (default: false) + /// to destroy all inherited members also. void Destroy(bool notInherited = false) override; - /// /// Gets the mass of this Actor's inventory. Does not include any equipped item (for actor subtypes that have that). - /// - /// The mass of this Actor's inventory. + /// @return The mass of this Actor's inventory. float GetInventoryMass() const; - /// /// Gets the mass of this Actor, including the mass of its Attachables, wounds and inventory. - /// - /// The mass of this Actor, its inventory and all its Attachables and wounds in Kilograms (kg). + /// @return The mass of this Actor, its inventory and all its Attachables and wounds in Kilograms (kg). float GetMass() const override { return MOSRotating::GetMass() + GetInventoryMass() + (m_GoldCarried * g_SceneMan.GetKgPerOz()); } - /// /// Gets the mass that this actor had upon spawning, i.e with ini-defined inventory, gold and holding no items - /// - /// The base mass of this Actor, in Kilograms (kg). + /// @return The base mass of this Actor, in Kilograms (kg). float GetBaseMass(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetController - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets this Actor's Controller. Ownership IS NOT transferred! - // Arguments: None. - // Return value: A const pointer to this Actor's Controller. - + /// Gets this Actor's Controller. Ownership IS NOT transferred! + /// @return A const pointer to this Actor's Controller. Controller* GetController() { return &m_Controller; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: IsPlayerControlled - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Tells whether a player is currently controlling this. - // Arguments: None. - // Return value: Whether a player is controlling this. - + /// Tells whether a player is currently controlling this. + /// @return Whether a player is controlling this. bool IsPlayerControlled() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: IsControllable - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Tells wheter the player can switch control to this at all - // Arguments: None. - // Return value: Whether a player can control this at all. - + /// Tells wheter the player can switch control to this at all + /// @return Whether a player can control this at all. virtual bool IsControllable() const { return true; } - /// /// Gets whether or not this Actor can be controlled by human players. Note that this does not protect the Actor's Controller from having its input mode forced to CIM_PLAYER (e.g. via Lua). - /// - /// Whether or not this Actor can be controlled by human players. + /// @return Whether or not this Actor can be controlled by human players. bool IsPlayerControllable() const { return m_PlayerControllable; } - /// /// Sets whether or not this Actor can be controlled by human players. - /// - /// Whether or not this Actor should be able to be controlled by human players. + /// @param playerControllable Whether or not this Actor should be able to be controlled by human players. void SetPlayerControllable(bool playerControllable) { m_PlayerControllable = playerControllable; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetStatus - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns the current Status of this. - // Arguments: None. - // Return value: The status. - + /// Returns the current Status of this. + /// @return The status. int GetStatus() const { return m_Status; } - /// /// Gets this Actor's health value. - /// - /// A float describing this Actor's health. + /// @return A float describing this Actor's health. float GetHealth() const { return m_Health; } - /// /// Gets this Actor's previous health value, prior to this frame. - /// - /// A float describing this Actor's previous health. + /// @return A float describing this Actor's previous health. float GetPrevHealth() const { return m_PrevHealth; } - /// /// Gets this Actor's maximum health value. - /// - /// A float describing this Actor's max health. + /// @return A float describing this Actor's max health. float GetMaxHealth() const { return m_MaxHealth; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetMaxHealth - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets this Actor's maximum health value. - // Arguments: New max health value. - // Return value: None. - + /// Gets this Actor's maximum health value. + /// @param newValue New max health value. void SetMaxHealth(int newValue) { m_MaxHealth = newValue; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetAimDistance - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the distance between the actor and the view point when not - // sharp aiming. - // Arguments: None. - // Return value: A const int describing how far this actor aims/looks by default. - + /// Gets the distance between the actor and the view point when not + /// sharp aiming. + /// @return A const int describing how far this actor aims/looks by default. int GetAimDistance() const { return m_AimDistance; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetAimDistance - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the distance between the actor and the view point when not - // sharp aiming. - // Arguments: None. - // Return value: A const int describing how far this actor aims/looks by default. - + /// Gets the distance between the actor and the view point when not + /// sharp aiming. + /// @return A const int describing how far this actor aims/looks by default. void SetAimDistance(int newValue) { m_AimDistance = newValue; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetGoldCarried - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets how many ounces of gold this Actor is carrying. - // Arguments: None. - // Return value: The current amount of carried gold, in Oz. - + /// Gets how many ounces of gold this Actor is carrying. + /// @return The current amount of carried gold, in Oz. float GetGoldCarried() const { return m_GoldCarried; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetTotalValue - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the total liquidation value of this Actor and all its carried - // gold and inventory. - // Arguments: If this is supposed to be adjusted for a specific Tech's subjective - // value, then pass in the native DataModule ID of that tech. 0 means - // no Tech is specified and the base value is returned. - // How much to multiply the value if this happens to be a foreign Tech. - // Return value: The current value of this Actor and all his carried assets. - + /// Gets the total liquidation value of this Actor and all its carried + /// gold and inventory. + /// @param nativeModule If this is supposed to be adjusted for a specific Tech's subjective (default: 0) + /// value, then pass in the native DataModule ID of that tech. 0 means + /// no Tech is specified and the base value is returned. + /// @param foreignMult How much to multiply the value if this happens to be a foreign Tech. (default: 1.0) + /// @return The current value of this Actor and all his carried assets. float GetTotalValue(int nativeModule = 0, float foreignMult = 1.0, float nativeMult = 1.0) const override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: HasObject - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Shows whether this is or carries a specifically named object in its - // inventory. Also looks through the inventories of potential passengers, - // as applicable. - // Arguments: The Preset name of the object to look for. - // Return value: Whetehr the object was found carried by this. - + /// Shows whether this is or carries a specifically named object in its + /// inventory. Also looks through the inventories of potential passengers, + /// as applicable. + /// @param objectName The Preset name of the object to look for. + /// @return Whetehr the object was found carried by this. bool HasObject(std::string objectName) const override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: HasObjectInGroup - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Shows whether this is or carries a specifically grouped object in its - // inventory. Also looks through the inventories of potential passengers, - // as applicable. - // Arguments: The name of the group to look for. - // Return value: Whetehr the object in the group was found carried by this. - + /// Shows whether this is or carries a specifically grouped object in its + /// inventory. Also looks through the inventories of potential passengers, + /// as applicable. + /// @param groupName The name of the group to look for. + /// @return Whetehr the object in the group was found carried by this. bool HasObjectInGroup(std::string groupName) const override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetAimAngle - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets this Actor's aim angle. - // Arguments: Whether to adjust the angle for flipping or not. - // Return value: The angle, in radians. - + /// Gets this Actor's aim angle. + /// @param adjustForFlipped Whether to adjust the angle for flipping or not. (default: true) + /// @return The angle, in radians. float GetAimAngle(bool adjustForFlipped = true) const { return adjustForFlipped ? FacingAngle(m_AimAngle) : m_AimAngle; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetPassengerSlots - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets this Actor's passenger slots. - // Arguments: None. - // Return value: The Actor's passenger plots - + /// Gets this Actor's passenger slots. + /// @return The Actor's passenger plots int GetPassengerSlots() const { return m_PassengerSlots; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: GetCPUPos - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the absoltue position of this' brain, or equivalent. - // Arguments: None. - // Return value: A Vector with the absolute position of this' brain. - + /// Gets the absoltue position of this' brain, or equivalent. + /// @return A Vector with the absolute position of this' brain. virtual Vector GetCPUPos() const { return m_Pos; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: GetEyePos - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the absoltue position of this' eye, or equivalent, where look - // vector starts from. - // Arguments: None. - // Return value: A Vector with the absolute position of this' eye or view point. - + /// Gets the absoltue position of this' eye, or equivalent, where look + /// vector starts from. + /// @return A Vector with the absolute position of this' eye or view point. virtual Vector GetEyePos() const { return m_Pos; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: GetAboveHUDPos - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the absoltue position of the top of this' HUD stack. - // Arguments: None. - // Return value: A Vector with the absolute position of this' HUD stack top point. - + /// Gets the absoltue position of the top of this' HUD stack. + /// @return A Vector with the absolute position of this' HUD stack top point. Vector GetAboveHUDPos() const override { return m_Pos + Vector(0, m_HUDStack + 6); } - /// /// Gets the offset position of the holster where this Actor draws his devices from. - /// - /// The offset position of the holster. + /// @return The offset position of the holster. Vector GetHolsterOffset() const { return m_HolsterOffset; } - /// /// Sets the offset position of the holster where this Actor draws his devices from. - /// - /// A new holster offset. + /// @param newOffset A new holster offset. void SetHolsterOffset(Vector newOffset) { m_HolsterOffset = newOffset; } - /// /// Gets the offset position of where this Actor reloads his devices from. - /// - /// The offset position of the where this Actor reloads his devices from. + /// @return The offset position of the where this Actor reloads his devices from. Vector GetReloadOffset() const { return m_ReloadOffset; } - /// /// Sets the offset position of the where this Actor reloads his devices from. - /// - /// The new offset position of where this Actor reloads his devices from. + /// @param newOffset The new offset position of where this Actor reloads his devices from. void SetReloadOffset(Vector newOffset) { m_ReloadOffset = newOffset; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetViewPoint - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the point at which this actor is viewing, or that the scene frame - // should be centered on if tracking this Actor's view. In absolute scene - // coordinates. - // Arguments: None. - // Return value: The point in absolute scene coordinates. - + /// Gets the point at which this actor is viewing, or that the scene frame + /// should be centered on if tracking this Actor's view. In absolute scene + /// coordinates. + /// @return The point in absolute scene coordinates. Vector GetViewPoint() const { return m_ViewPoint.IsZero() ? m_Pos : m_ViewPoint; } - /// /// Gets the item that is within reach of the Actor at this frame, ready to be be picked up. Ownership is NOT transferred! - /// - /// A pointer to the item that has been determined to be within reach of this Actor, if any. + /// @return A pointer to the item that has been determined to be within reach of this Actor, if any. HeldDevice* GetItemInReach() const { return m_pItemInReach; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: GetLookVector - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the direction where this is looking/aiming. - // Arguments: None. - // Return value: A Vector with the direction in which this is looking along. - + /// Gets the direction where this is looking/aiming. + /// @return A Vector with the direction in which this is looking along. Vector GetLookVector() const { return m_ViewPoint - GetEyePos(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetSharpAimProgress - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the normalized amount of sharp aim that has been achieved by this. - // Arguments: None. - // Return value: Sharp aim progress between 0 - 1.0. 1.0 is fully aimed. - + /// Gets the normalized amount of sharp aim that has been achieved by this. + /// @return Sharp aim progress between 0 - 1.0. 1.0 is fully aimed. float GetSharpAimProgress() const { return m_SharpAimProgress; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: GetHeight - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the approximate height of this Actor, standing up. - // Arguments: None. - // Return value: A float with the approximate height, in pixels. - + /// Gets the approximate height of this Actor, standing up. + /// @return A float with the approximate height, in pixels. float GetHeight() const { return m_CharHeight; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetControllerMode - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets this Actor's new Controller input mode. - // Arguments: The new input mode. - // The player which will control this if the input mode was set to player. - // Return value: None. - + /// Sets this Actor's new Controller input mode. + /// @param newMode The new input mode. + /// @param newPlayer The player which will control this if the input mode was set to player. (default: -1) void SetControllerMode(Controller::InputMode newMode, int newPlayer = -1); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SwapControllerModes - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets this Actor's Controller mode and gives back what it used to be. - // Arguments: The new mode to set to. - // The player which will control this if the input mode was set to player. - // Return value: The old mode that it had before. - + /// Sets this Actor's Controller mode and gives back what it used to be. + /// @param newMode The new mode to set to. + /// @param newPlayer The player which will control this if the input mode was set to player. (default: -1) + /// @return The old mode that it had before. Controller::InputMode SwapControllerModes(Controller::InputMode newMode, int newPlayer = -1); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetStatus - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets this Actor's status. - // Arguments: A Status enumeration. - // Return value: None. - + /// Sets this Actor's status. + /// @param newStatus A Status enumeration. void SetStatus(Actor::Status newStatus) { m_Status = newStatus; if (newStatus == Actor::Status::UNSTABLE) { @@ -461,206 +278,112 @@ namespace RTE { } /// Gets this Actor's MovementState. - /// - /// This Actor's MovementState. + /// @return This Actor's MovementState. MovementState GetMovementState() const { return m_MoveState; } - /// /// Sets this Actor's MovementState to the new state. - /// - /// This Actor's new MovementState. + /// @param newMovementState This Actor's new MovementState. void SetMovementState(MovementState newMovementState) { m_MoveState = newMovementState; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: SetTeam - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets which team this Actor belongs to. - // Arguments: The assigned team number. - // Return value: None. - + /// Sets which team this Actor belongs to. + /// @param team The assigned team number. void SetTeam(int team) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetGoldCarried - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets how many ounces of gold this Actor is carrying. - // Arguments: The new amount of carried gold, in Oz. - // Return value: None. - + /// Sets how many ounces of gold this Actor is carrying. + /// @param goldOz The new amount of carried gold, in Oz. void SetGoldCarried(float goldOz) { m_GoldCarried = goldOz; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetAimAngle - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets this Actor's aim angle. - // Arguments: A new angle, in radians. - // Return value: None. - + /// Sets this Actor's aim angle. + /// @param newAngle A new angle, in radians. void SetAimAngle(float newAngle) { m_AimAngle = newAngle; Clamp(m_AimAngle, m_AimRange, -m_AimRange); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetPassengerSlots - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets this Actor's passenger slots. - // Arguments: A new amount of passenger slots. - // Return value: None. - + /// Sets this Actor's passenger slots. + /// @param newPassengerSlots A new amount of passenger slots. void SetPassengerSlots(int newPassengerSlots) { m_PassengerSlots = newPassengerSlots; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetViewPoint - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the point at which this actor is viewing, or that the scene frame - // should be centered on if tracking this Actor's view. In absolute scene - // coordinates. - // Arguments: A new point in absolute scene coords. - // Return value: None. - + /// Sets the point at which this actor is viewing, or that the scene frame + /// should be centered on if tracking this Actor's view. In absolute scene + /// coordinates. + /// @param newPoint A new point in absolute scene coords. void SetViewPoint(Vector newPoint) { m_ViewPoint = newPoint; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetItemInReach - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the item that is within reach of the Actor at this frame, so that - // it may be picked up. Ownership is NOT transferred! - // Arguments: A pointer to the item that has been determined to be within reach of - // this Actor. Ownership is NOT transferred! - // Return value: None. - + /// Sets the item that is within reach of the Actor at this frame, so that + /// it may be picked up. Ownership is NOT transferred! + /// @param pItem A pointer to the item that has been determined to be within reach of + /// this Actor. Ownership is NOT transferred! void SetItemInReach(HeldDevice* pItem) { m_pItemInReach = pItem; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: IsWithinRange - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Tells whether a point on the scene is within range of the currently - // used device and aiming status, if applicable. - // Arguments: A Vector witht he aboslute coordinates of a point to check. - // Return value: Whether the point is within range of this. - + /// Tells whether a point on the scene is within range of the currently + /// used device and aiming status, if applicable. + /// @param point A Vector witht he aboslute coordinates of a point to check. + /// @return Whether the point is within range of this. virtual bool IsWithinRange(Vector& point) const { return false; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Look - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Casts an unseen-revealing ray in the direction of where this is facing. - // Arguments: The degree angle to deviate from the current view point in the ray - // casting. A random ray will be chosen out of this +-range. - // The range, in pixels, that the ray will have. - // Return value: Whether any unseen pixels were revealed by this look. - + /// Casts an unseen-revealing ray in the direction of where this is facing. + /// @param FOVSpread The degree angle to deviate from the current view point in the ray + /// casting. A random ray will be chosen out of this +-range. + /// @param range The range, in pixels, that the ray will have. + /// @return Whether any unseen pixels were revealed by this look. virtual bool Look(float FOVSpread, float range); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: AddGold - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Adds a certain amount of ounces of gold to this' team's total funds. - // Arguments: The amount in Oz with which to change this' team's gold tally. - // Return value: None. - + /// Adds a certain amount of ounces of gold to this' team's total funds. + /// @param goldOz The amount in Oz with which to change this' team's gold tally. void AddGold(float goldOz); - /// /// Does the calculations necessary to detect whether this Actor is at rest or not. IsAtRest() retrieves the answer. - /// void RestDetection() override; - /// /// Adds health points to this Actor's current health value. - /// - /// A float specifying the value to add. - /// The resulting total health of this Actor. + /// @param setHealth A float specifying the value to add. + /// @return The resulting total health of this Actor. const float AddHealth(const float addedHealth) { return m_Health += addedHealth; } - /// /// Sets this Actor's current health value. - /// - /// A float specifying the value to set to. + /// @param setHealth A float specifying the value to set to. void SetHealth(const float setHealth) { m_Health = setHealth; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: IsStatus - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Checks if this Actor is in a specific status. - // Arguments: Which status to check for. - // Return value: A bool with the answer. - + /// Checks if this Actor is in a specific status. + /// @param which Which status to check for. + /// @return A bool with the answer. bool IsStatus(Status which) const { return m_Status == which; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: IsDead - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Checks if this Actor is dead. - // Arguments: None. - // Return value: A const bool with the answer. - + /// Checks if this Actor is dead. + /// @return A const bool with the answer. bool IsDead() const { return m_Status == DEAD; } - /// /// Tries to handle the activated PieSlice in this object's PieMenu, if there is one, based on its SliceType. - /// - /// The SliceType of the PieSlice being handled. - /// Whether or not the activated PieSlice SliceType was able to be handled. + /// @param pieSliceType The SliceType of the PieSlice being handled. + /// @return Whether or not the activated PieSlice SliceType was able to be handled. virtual bool HandlePieCommand(PieSlice::SliceType pieSliceType) { return false; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: GetAIMode - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets this' AI mode. - // Arguments: None. - // Return value: The current AI mode. - + /// Gets this' AI mode. + /// @return The current AI mode. int GetAIMode() const { return m_AIMode; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: GetAIModeIcon - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the icon bitmap associated with this' current AI mode and team. - // Arguments: None. - // Return value: The current AI mode icon of this. Ownership is NOT transferred! - + /// Gets the icon bitmap associated with this' current AI mode and team. + /// @return The current AI mode icon of this. Ownership is NOT transferred! BITMAP* GetAIModeIcon(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: SetAIMode - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets this' AI mode. - // Arguments: The new AI mode. - // Return value: None. - + /// Sets this' AI mode. + /// @param newMode The new AI mode. (default: AIMODE_SENTRY) void SetAIMode(AIMode newMode = AIMODE_SENTRY) { m_AIMode = newMode; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: AddAISceneWaypoint - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Adds an absolute scene point to the list of waypoints this is going to - // go to, in order - // Arguments: The new scene point this should try to get to after all other waypoints - // are reached. - // Return value: None. - + /// Adds an absolute scene point to the list of waypoints this is going to + /// go to, in order + /// @param m_Waypoints.push_back(std::pair(waypoint, (MovableObject*)NULL)); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: AddAIMOWaypoint - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Adds an MO in the scene as the next waypoint for this to go to, in order - // Arguments: The new MO this should try to get to after all other waypoints are reached. - // OWNERSHIP IS NOT TRANSFERRED! - // Return value: None. - + /// Adds an MO in the scene as the next waypoint for this to go to, in order + /// @param pMOWaypoint The new MO this should try to get to after all other waypoints are reached. + /// OWNERSHIP IS NOT TRANSFERRED! void AddAIMOWaypoint(const MovableObject* pMOWaypoint); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: ClearAIWaypoints - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Removes all AI waypoints and clears the current path to the current - // waypoint. The AI Actor will stop in its tracks. - // Arguments: None. - // Return value: None. - + /// Removes all AI waypoints and clears the current path to the current + /// waypoint. The AI Actor will stop in its tracks. void ClearAIWaypoints() { m_pMOMoveTarget = 0; m_Waypoints.clear(); @@ -669,14 +392,9 @@ namespace RTE { m_MoveVector.Reset(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: GetLastAIWaypoint - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the last or furthest set AI waypoint of this. If none, this' pos - // is returned. - // Arguments: None. - // Return value: The furthest set AI waypoint of this. - + /// Gets the last or furthest set AI waypoint of this. If none, this' pos + /// is returned. + /// @return The furthest set AI waypoint of this. Vector GetLastAIWaypoint() const { if (!m_Waypoints.empty()) { return m_Waypoints.back().first; @@ -686,83 +404,48 @@ namespace RTE { return m_Pos; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: GetLastMOWaypointID - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the ID of the last set AI MO waypoint of this. If none, g_NoMOID is returned. - // Arguments: None. - // Return value: The furthest set AI MO waypoint of this. - + /// Gets the ID of the last set AI MO waypoint of this. If none, g_NoMOID is returned. + /// @return The furthest set AI MO waypoint of this. MOID GetAIMOWaypointID() const; - /// /// Gets the list of waypoints for this Actor. - /// - /// The list of waypoints for this Actor. + /// @return The list of waypoints for this Actor. const std::list>& GetWaypointList() const { return m_Waypoints; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: GetWaypointsSize - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets how many waypoints this actor have. - // Arguments: None. - // Return value: How many waypoints. - + /// Gets how many waypoints this actor have. + /// @return How many waypoints. int GetWaypointsSize() { return m_Waypoints.size(); }; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: ClearMovePath - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears the list of coordinates in this' current MovePath, ie the path - // to the next Waypoint. - // Arguments: None. - // Return value: None. - + /// Clears the list of coordinates in this' current MovePath, ie the path + /// to the next Waypoint. void ClearMovePath() { m_MovePath.clear(); m_MoveTarget = m_Pos; m_MoveVector.Reset(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: AddToMovePathBeginning - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Adds a coordinate to the beginning of the MovePath, meaning the one - // closest to this Actor. - // Arguments: The new coordinate to add to the front of the MovePath. - // Return value: None. - + /// Adds a coordinate to the beginning of the MovePath, meaning the one + /// closest to this Actor. + /// @param newCoordinate The new coordinate to add to the front of the MovePath. void AddToMovePathBeginning(Vector newCoordinate) { m_MovePath.push_front(newCoordinate); m_MoveTarget = newCoordinate; m_MoveVector.Reset(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: AddToMovePathEnd - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Adds a coordinate to the end of the MovePath, meaning the one - // closest to this Actor's next waypoint. - // Arguments: The new coordinate to add to the end of the MovePath. - // Return value: None. - + /// Adds a coordinate to the end of the MovePath, meaning the one + /// closest to this Actor's next waypoint. + /// @param m_MovePath.push_back(newCoordinate The new coordinate to add to the end of the MovePath. void AddToMovePathEnd(Vector newCoordinate) { m_MovePath.push_back(newCoordinate); } - /// /// Gets the last position in this Actor's move path. - /// - /// The last position in this Actor's move path. + /// @return The last position in this Actor's move path. Vector GetMovePathEnd() const { return m_MovePath.back(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: RemoveMovePathBeginning - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Removes a coordinate from the beginning of the MovePath, meaning the - // one closest to this Actor. - // Arguments: None. - // Return value: Whether there was any coordinate to remove. If false, the MovePath - // is empty. - + /// Removes a coordinate from the beginning of the MovePath, meaning the + /// one closest to this Actor. + /// @return Whether there was any coordinate to remove. If false, the MovePath + /// is empty. bool RemoveMovePathBeginning() { if (!m_MovePath.empty()) { m_MovePath.pop_front(); @@ -773,15 +456,10 @@ namespace RTE { return false; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: RemoveMovePathEnd - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Removes a coordinate from the end of the MovePath, meaning the - // one farthest from this Actor. - // Arguments: None. - // Return value: Whether there was any coordinate to remove. If false, the MovePath - // is empty. - + /// Removes a coordinate from the end of the MovePath, meaning the + /// one farthest from this Actor. + /// @return Whether there was any coordinate to remove. If false, the MovePath + /// is empty. bool RemoveMovePathEnd() { if (!m_MovePath.empty()) { m_MovePath.pop_back(); @@ -790,69 +468,38 @@ namespace RTE { return false; } - /// /// Gets a pointer to the MovableObject move target of this Actor. - /// - /// A pointer to the MovableObject move target of this Actor. + /// @return A pointer to the MovableObject move target of this Actor. const MovableObject* GetMOMoveTarget() const { return m_pMOMoveTarget; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetPerceptiveness - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets this' perceptiveness to alarming events going on around him. - // Arguments: The current perceptiveness, 0.0 - 1.0 - // Return value: None. - + /// Sets this' perceptiveness to alarming events going on around him. + /// @param newPerceptiveness The current perceptiveness, 0.0 - 1.0 void SetPerceptiveness(float newPerceptiveness) { m_Perceptiveness = newPerceptiveness; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetPerceptiveness - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets this' perceptiveness to alarming events going on around him. - // Arguments: None. - // Return value: The current perceptiveness, 0.0 - 1.0 - + /// Gets this' perceptiveness to alarming events going on around him. + /// @return The current perceptiveness, 0.0 - 1.0 float GetPerceptiveness() const { return m_Perceptiveness; } - /// /// Gets whether this actor is able to reveal unseen areas by looking. - /// - /// Whether this actor can reveal unseen areas. + /// @return Whether this actor can reveal unseen areas. bool GetCanRevealUnseen() const { return m_CanRevealUnseen; } - /// /// Sets whether this actor can reveal unseen areas by looking. - /// - /// Whether this actor can reveal unseen areas. + /// @param newCanRevealUnseen Whether this actor can reveal unseen areas. void SetCanRevealUnseen(bool newCanRevealUnseen) { m_CanRevealUnseen = newCanRevealUnseen; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetPainThreshold - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets this' PainThreshold value above which it will play PainSound - // Arguments: Desired PainThreshold value - // Return value: None. - + /// Sets this' PainThreshold value above which it will play PainSound + /// @param newPainThreshold Desired PainThreshold value void SetPainThreshold(float newPainThreshold) { m_PainThreshold = newPainThreshold; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetPainThreshold - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets this' PainThreshold value above which it will play PainSound - // Arguments: None. - // Return value: The current PainThreshold - + /// Gets this' PainThreshold value above which it will play PainSound + /// @return The current PainThreshold float GetPainThreshold() const { return m_PainThreshold; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: AlarmPoint - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes this alarmed about a certian point on in the scene, overriding - // the current AI mode until a certain time has passed. - // Arguments: The new scene point this should look at and see if anything dangerous - // is there. - // Return value: None. - + /// Makes this alarmed about a certian point on in the scene, overriding + /// the current AI mode until a certain time has passed. + /// @param alarmPoint The new scene point this should look at and see if anything dangerous + /// is there. void AlarmPoint(const Vector& alarmPoint) { if (m_AlarmSound && m_AlarmTimer.IsPastSimTimeLimit()) { m_AlarmSound->Play(alarmPoint); @@ -863,14 +510,9 @@ namespace RTE { } } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetAlarmPoint - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets any point on the scene this actor should be alarmed about this frame. - // Arguments: None. - // Return value: The new scene point this should look at and see if anything dangerous - // is there or (0,0) if nothing is alarming. - + /// Gets any point on the scene this actor should be alarmed about this frame. + /// @return The new scene point this should look at and see if anything dangerous + /// is there or (0,0) if nothing is alarming. Vector GetAlarmPoint() { if (m_AlarmTimer.GetElapsedSimTimeMS() > g_TimerMan.GetDeltaTimeMS()) { return Vector(); @@ -878,528 +520,311 @@ namespace RTE { return m_LastAlarmPos; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual Method: AddInventoryItem - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Adds an inventory item to this Actor. - // Arguments: An pointer to the new item to add. Ownership IS TRANSFERRED! - // Return value: None.. - + /// Adds an inventory item to this Actor. + /// @param AddToInventoryBack(pItemToAdd An pointer to the new item to add. Ownership IS TRANSFERRED! + /// @return None.. virtual void AddInventoryItem(MovableObject* pItemToAdd) { AddToInventoryBack(pItemToAdd); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: RemoveInventoryItem - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Removes a specified item from the actor's inventory. Only one item is removed at a time. - // Arguments: Preset name of an item to remove. - // Return value: None. - + /// Removes a specified item from the actor's inventory. Only one item is removed at a time. + /// @param RemoveInventoryItem("" Preset name of an item to remove. void RemoveInventoryItem(const std::string& presetName) { RemoveInventoryItem("", presetName); } - /// /// Removes the first inventory item with the given module name and preset name. - /// - /// The module name of the item to remove. - /// The preset name of the item to remove. + /// @param moduleName The module name of the item to remove. + /// @param presetName The preset name of the item to remove. void RemoveInventoryItem(const std::string& moduleName, const std::string& presetName); - /// /// Removes and returns the inventory item at the given index. Ownership IS transferred. - /// - /// The index of the inventory item to remove. - /// An owning pointer to the removed inventory item. + /// @param inventoryIndex The index of the inventory item to remove. + /// @return An owning pointer to the removed inventory item. MovableObject* RemoveInventoryItemAtIndex(int inventoryIndex); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SwapNextInventory - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Swaps the next MovableObject carried by this Actor and puts one not - // currently carried into the into the back of the inventory of this. - // Arguments: A pointer to the external MovableObject to trade in. Ownership IS xferred! - // If 0 is passed in, nothing will be added to the inventory. - // Whether to mute the sound on this event. Override for the loading screen hack. - // Return value: The next MovableObject in this Actor's inventory. Ownership IS xferred! - // If there are no MovableObject:s in inventory, 0 will be returned. - + /// Swaps the next MovableObject carried by this Actor and puts one not + /// currently carried into the into the back of the inventory of this. + /// @param pSwapIn A pointer to the external MovableObject to trade in. Ownership IS xferred! (default: nullptr) + /// @param muteSound If 0 is passed in, nothing will be added to the inventory. (default: false) + /// Whether to mute the sound on this event. Override for the loading screen hack. + /// @return The next MovableObject in this Actor's inventory. Ownership IS xferred! + /// If there are no MovableObject:s in inventory, 0 will be returned. virtual MovableObject* SwapNextInventory(MovableObject* pSwapIn = nullptr, bool muteSound = false); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SwapPrevInventory - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Swaps the prev MovableObject carried by this Actor and puts one not - // currently carried into the into the back of the inventory of this. - // Arguments: A pointer to the external MovableObject to trade in. Ownership IS xferred! - // If 0 is passed in, nothing will be added to the inventory. - // Return value: The prev MovableObject in this Actor's inventory. Ownership IS xferred! - // If there are no MovableObject:s in inventory, 0 will be returned. - + /// Swaps the prev MovableObject carried by this Actor and puts one not + /// currently carried into the into the back of the inventory of this. + /// @param pSwapIn A pointer to the external MovableObject to trade in. Ownership IS xferred! (default: nullptr) + /// If 0 is passed in, nothing will be added to the inventory. + /// @return The prev MovableObject in this Actor's inventory. Ownership IS xferred! + /// If there are no MovableObject:s in inventory, 0 will be returned. virtual MovableObject* SwapPrevInventory(MovableObject* pSwapIn = nullptr); - /// /// Swaps the inventory items at the given indices. Will return false if a given index is invalid. - /// - /// The index of one item. - /// The index of the other item. - /// Whether or not the swap was successful. + /// @param inventoryIndex1 The index of one item. + /// @param inventoryIndex2 The index of the other item. + /// @return Whether or not the swap was successful. bool SwapInventoryItemsByIndex(int inventoryIndex1, int inventoryIndex2); - /// /// Sets the inventory item at the given index as the new inventory item, and gives back the one that was originally there. /// If an invalid index is given, the new item will be put in the back of the inventory, and nullptr will be returned. - /// - /// The new item that should be at the given inventory index. Cannot be a nullptr. Ownership IS transferred. - /// The inventory index the new item should be placed at. - /// The inventory item that used to be at the inventory index. Ownership IS transferred. + /// @param newInventoryItem The new item that should be at the given inventory index. Cannot be a nullptr. Ownership IS transferred. + /// @param inventoryIndex The inventory index the new item should be placed at. + /// @return The inventory item that used to be at the inventory index. Ownership IS transferred. MovableObject* SetInventoryItemAtIndex(MovableObject* newInventoryItem, int inventoryIndex); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: DropAllInventory - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Ejects all inventory items that this is carrying. It may not happen - // instantaneously, so check for ejection being complete with - // IsInventoryEmpty(). - // Arguments: None. - // Return value: None. - + /// Ejects all inventory items that this is carrying. It may not happen + /// instantaneously, so check for ejection being complete with + /// IsInventoryEmpty(). virtual void DropAllInventory(); - /// /// Converts all of the Gold carried by this Actor into MovableObjects and ejects them into the Scene. - /// virtual void DropAllGold(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetInventorySize - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Tells how many things are in the invetory - // Arguments: None. - // Return value: The number of things in the inventory - + /// Tells how many things are in the invetory + /// @return The number of things in the inventory int GetInventorySize() const { return m_Inventory.size(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: IsInventoryEmpty - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Tells whether inventory is completely empty - // Arguments: None. - // Return value: Whether inventory is completely empty. - + /// Tells whether inventory is completely empty + /// @return Whether inventory is completely empty. bool IsInventoryEmpty() { return m_Inventory.empty(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetInventory - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the deque of inventory of this. Ownership is NOT transferred. - // Arguments: None. - // Return value: A const pointer to the inventory deque of this. OWNERSHIP IS NOT TRANSFERRED! - + /// Gets the deque of inventory of this. Ownership is NOT transferred. + /// @return A const pointer to the inventory deque of this. OWNERSHIP IS NOT TRANSFERRED! const std::deque* GetInventory() const { return &m_Inventory; } - /// /// Returns the maximum total mass this Actor can carry in its inventory. - /// - /// The maximum carriable mass of this Actor. + /// @return The maximum carriable mass of this Actor. float GetMaxInventoryMass() const { return m_MaxInventoryMass; } - /// /// Attempts to add an item to the front of our inventory. - /// - /// Whether we succeeded in adding the item. We may fail if the object doesn't exist or is set to delete. + /// @return Whether we succeeded in adding the item. We may fail if the object doesn't exist or is set to delete. bool AddToInventoryFront(MovableObject* itemToAdd); - /// /// Attempts to add an item to the back of our inventory. - /// - /// Whether we succeeded in adding the item. We may fail if the object doesn't exist or is set to delete. + /// @return Whether we succeeded in adding the item. We may fail if the object doesn't exist or is set to delete. bool AddToInventoryBack(MovableObject* itemToAdd); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetAimRange - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: The limit of this actors aiming angle, in each direction, in radians. - // Arguments: None. - // Return value: The arc range of the aiming angle in radians. - // Eg if HalfPI, it means full 180 degree range - + /// The limit of this actors aiming angle, in each direction, in radians. + /// @return The arc range of the aiming angle in radians. + /// Eg if HalfPI, it means full 180 degree range float GetAimRange() const { return m_AimRange; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: SetAimRange - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the limit of this actors aiming angle, in each direction, in radians. - // Arguments: The arc range of the aiming angle in radians. - // Eg if HalfPI, it means full 180 degree range - // Return value: None. - + /// Sets the limit of this actors aiming angle, in each direction, in radians. + /// @param range The arc range of the aiming angle in radians. + /// Eg if HalfPI, it means full 180 degree range void SetAimRange(float range) { m_AimRange = range; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: DrawWaypoints - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes this draw its current waypoints and related data on the scene in - // its HUD drawing stage. - // Arguments: Whether to enable or disable the drawing of the waypoints. - // Return value: None. - + /// Makes this draw its current waypoints and related data on the scene in + /// its HUD drawing stage. + /// @param drawWaypoints Whether to enable or disable the drawing of the waypoints. (default: true) void DrawWaypoints(bool drawWaypoints = true) { m_DrawWaypoints = drawWaypoints; } - /// /// Destroys this MOSRotating and creates its specified Gibs in its place with appropriate velocities. /// Any Attachables are removed and also given appropriate velocities. - /// - /// The impulse (kg * m/s) of the impact causing the gibbing to happen. - /// A pointer to an MO which the Gibs and Attachables should not be colliding with. + /// @param impactImpulse The impulse (kg * m/s) of the impact causing the gibbing to happen. + /// @param movableObjectToIgnore A pointer to an MO which the Gibs and Attachables should not be colliding with. void GibThis(const Vector& impactImpulse = Vector(), MovableObject* movableObjectToIgnore = nullptr) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: CollideAtPoint - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Calculates the collision response when another MO's Atom collides with - // this MO's physical representation. The effects will be applied - // directly to this MO, and also represented in the passed in HitData. - // Arguments: Reference to the HitData struct which describes the collision. This - // will be modified to represent the results of the collision. - // Return value: Whether the collision has been deemed valid. If false, then disregard - // any impulses in the Hitdata. - + /// Calculates the collision response when another MO's Atom collides with + /// this MO's physical representation. The effects will be applied + /// directly to this MO, and also represented in the passed in HitData. + /// @param hitData Reference to the HitData struct which describes the collision. This + /// will be modified to represent the results of the collision. + /// @return Whether the collision has been deemed valid. If false, then disregard + /// any impulses in the Hitdata. bool CollideAtPoint(HitData& hitData) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: ParticlePenetration - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Determines whether a particle which has hit this MO will penetrate, - // and if so, whether it gets lodged or exits on the other side of this - // MO. Appropriate effects will be determined and applied ONLY IF there - // was penetration! If not, nothing will be affected. - // Arguments: The HitData describing the collision in detail, the impulses have to - // have been filled out! - // Return value: Whether the particle managed to penetrate into this MO or not. If - // somehting but a MOPixel or MOSParticle is being passed in as hitor, - // false will trivially be returned here. - + /// Determines whether a particle which has hit this MO will penetrate, + /// and if so, whether it gets lodged or exits on the other side of this + /// MO. Appropriate effects will be determined and applied ONLY IF there + /// was penetration! If not, nothing will be affected. + /// @param hd The HitData describing the collision in detail, the impulses have to + /// have been filled out! + /// @return Whether the particle managed to penetrate into this MO or not. If + /// somehting but a MOPixel or MOSParticle is being passed in as hitor, + /// false will trivially be returned here. bool ParticlePenetration(HitData& hd) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: PreTravel - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Does stuff that needs to be done before Travel(). Always call before - // calling Travel. - // Arguments: None. - // Return value: None. - + /// Does stuff that needs to be done before Travel(). Always call before + /// calling Travel. void PreTravel() override { MOSRotating::PreTravel(); m_GoldPicked = false; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetMovePathToUpdate - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets this' AI's move path to be updated. Will update the path to the - // current waypoint, if any. - // Arguments: None. - // Return value: None. - + /// Sets this' AI's move path to be updated. Will update the path to the + /// current waypoint, if any. void SetMovePathToUpdate() { m_UpdateMovePath = true; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetMovePathSize - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets how many waypoints there are in the MovePath currently - // Arguments: None. - // Return value: The number of waypoints in the MovePath. - + /// Gets how many waypoints there are in the MovePath currently + /// @return The number of waypoints in the MovePath. int GetMovePathSize() const { return m_MovePath.size(); } - /// /// Starts updating this Actor's movepath. - /// virtual void UpdateMovePath(); - /// /// Returns whether we're waiting on a new pending movepath. - /// - /// Whether we're waiting on a new pending movepath. + /// @return Whether we're waiting on a new pending movepath. bool IsWaitingOnNewMovePath() const { return m_PathRequest != nullptr || m_UpdateMovePath; } - /// /// Estimates what material strength this actor can penetrate. - /// - /// The actor's dig strength. + /// @return The actor's dig strength. virtual float EstimateDigStrength() const; - /// /// Gets this Actor's base dig strength, or the strength of terrain they can expect to walk through without tools. - /// - /// The actors base dig strength. + /// @return The actors base dig strength. float GetAIBaseDigStrength() const { return m_AIBaseDigStrength; } - /// /// Sets this Actor's base dig strength, or the strength of terrain they can expect to walk through without tools. - /// - /// The new base dig strength for this Actor. + /// @param newAIBaseDigStrength The new base dig strength for this Actor. void SetAIBaseDigStrength(float newAIBaseDigStrength) { m_AIBaseDigStrength = newAIBaseDigStrength; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: PreControllerUpdate - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Update called prior to controller update. Ugly hack. Supposed to be done every frame. - // Arguments: None. - // Return value: None. - + /// Update called prior to controller update. Ugly hack. Supposed to be done every frame. virtual void PreControllerUpdate(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Update - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates this MovableObject. Supposed to be done every frame. - // Arguments: None. - // Return value: None. - + /// Updates this MovableObject. Supposed to be done every frame. void Update() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: FullUpdate - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the full state of this object in one call. (PreControllerUpdate(), Controller::Update(), and Update()) - // Arguments: None. - // Return value: None. - + /// Updates the full state of this object in one call. (PreControllerUpdate(), Controller::Update(), and Update()) virtual void FullUpdate() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: SetDeploymentID - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets deployment ID for this actor - // Arguments: New deployment id. - // Return value: None. - + /// Description: Sets deployment ID for this actor + /// @param newID New deployment id. void SetDeploymentID(unsigned int newID) { m_DeploymentID = newID; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetDeploymentID - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets deployment ID of this actor - // Arguments: None. - // Return value: Returns deployment id of this actor. - + /// Description: Gets deployment ID of this actor + /// @return Returns deployment id of this actor. unsigned int GetDeploymentID() const { return m_DeploymentID; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: GetSightDistance - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns actor's sight distance. - // Arguments: None. - // Return value: Returns actor's sight distance. - + /// Description: Returns actor's sight distance. + /// @return Returns actor's sight distance. float GetSightDistance() const { return m_SightDistance; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: SetSightDistance - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets actor's sight distance. - // Arguments: New sight distance value. - // Return value: None. - + /// Description: Sets actor's sight distance. + /// @param newValue New sight distance value. void SetSightDistance(float newValue) { m_SightDistance = newValue; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: DrawHUD - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws this Actor's current graphical HUD overlay representation to a - // BITMAP of choice. - // Arguments: A pointer to a BITMAP to draw on. - // The absolute position of the target bitmap's upper left corner in the Scene. - // Which player's screen this is being drawn to. May affect what HUD elements - // get drawn etc. - // Return value: None. - + /// Draws this Actor's current graphical HUD overlay representation to a + /// BITMAP of choice. + /// @param pTargetBitmap A pointer to a BITMAP to draw on. + /// @param targetPos The absolute position of the target bitmap's upper left corner in the Scene. (default: Vector()) + /// @param whichScreen Which player's screen this is being drawn to. May affect what HUD elements (default: 0) + /// get drawn etc. void DrawHUD(BITMAP* pTargetBitmap, const Vector& targetPos = Vector(), int whichScreen = 0, bool playerControlled = false) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: VerifyMOIDIndex - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Verifieis whether all actor's MO has correct IDs. Should be used in Debug mode only. - // Arguments: None. - // Return value: None. - + /// Verifieis whether all actor's MO has correct IDs. Should be used in Debug mode only. void VerifyMOIDs(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetTravelImpulseDamage - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns Threshold for taking damage from travel impulses, in kg * m/s - // Arguments: None. - // Return value: Threshold for taking damage from travel impulses, in kg * m/s - + /// Returns Threshold for taking damage from travel impulses, in kg * m/s + /// @return Threshold for taking damage from travel impulses, in kg * m/s float GetTravelImpulseDamage() const { return m_TravelImpulseDamage; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetTravelImpulseDamage - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets Threshold for taking damage from travel impulses, in kg * m/s - // Arguments: Threshold for taking damage from travel impulses, in kg * m/s - // Return value: None. - + /// Sets Threshold for taking damage from travel impulses, in kg * m/s + /// @param value Threshold for taking damage from travel impulses, in kg * m/s void SetTravelImpulseDamage(float value) { m_TravelImpulseDamage = value; } - /// /// Gets this Actor's body hit sound. Ownership is NOT transferred! - /// - /// The SoundContainer for this Actor's body hit sound. + /// @return The SoundContainer for this Actor's body hit sound. SoundContainer* GetBodyHitSound() const { return m_BodyHitSound; } - /// /// Sets this Actor's body hit sound. Ownership IS transferred! - /// - /// The new SoundContainer for this Actor's body hit sound. + /// @param newSound The new SoundContainer for this Actor's body hit sound. void SetBodyHitSound(SoundContainer* newSound) { m_BodyHitSound = newSound; } - /// /// Gets this Actor's alarm sound. Ownership is NOT transferred! - /// - /// The SoundContainer for this Actor's alarm sound. + /// @return The SoundContainer for this Actor's alarm sound. SoundContainer* GetAlarmSound() const { return m_AlarmSound; } - /// /// Sets this Actor's alarm sound. Ownership IS transferred! - /// - /// The new SoundContainer for this Actor's alarm sound. + /// @param newSound The new SoundContainer for this Actor's alarm sound. void SetAlarmSound(SoundContainer* newSound) { m_AlarmSound = newSound; } - /// /// Gets this Actor's pain sound. Ownership is NOT transferred! - /// - /// The SoundContainer for this Actor's pain sound. + /// @return The SoundContainer for this Actor's pain sound. SoundContainer* GetPainSound() const { return m_PainSound; } - /// /// Sets this Actor's pain sound. Ownership IS transferred! - /// - /// The new SoundContainer for this Actor's pain sound. + /// @param newSound The new SoundContainer for this Actor's pain sound. void SetPainSound(SoundContainer* newSound) { m_PainSound = newSound; } - /// /// Gets this Actor's death sound. Ownership is NOT transferred! - /// - /// The SoundContainer for this Actor's death sound. + /// @return The SoundContainer for this Actor's death sound. SoundContainer* GetDeathSound() const { return m_DeathSound; } - /// /// Sets this Actor's death sound. Ownership IS transferred! - /// - /// The new SoundContainer for this Actor's death sound. + /// @param newSound The new SoundContainer for this Actor's death sound. void SetDeathSound(SoundContainer* newSound) { m_DeathSound = newSound; } - /// /// Gets this Actor's device switch sound. Ownership is NOT transferred! - /// - /// The SoundContainer for this Actor's device switch sound. + /// @return The SoundContainer for this Actor's device switch sound. SoundContainer* GetDeviceSwitchSound() const { return m_DeviceSwitchSound; } - /// /// Sets this Actor's device switch sound. Ownership IS transferred! - /// - /// The new SoundContainer for this Actor's device switch sound. + /// @param newSound The new SoundContainer for this Actor's device switch sound. void SetDeviceSwitchSound(SoundContainer* newSound) { m_DeviceSwitchSound = newSound; } - /// /// Gets the X and Y thresholds for how fast the actor can travel before losing stability. - /// - /// A Vector with the X and Y thresholds for how fast the actor can travel before losing stability. + /// @return A Vector with the X and Y thresholds for how fast the actor can travel before losing stability. Vector GetStableVel() const { return m_StableVel; } - /// /// Sets the X and Y thresholds for how fast the actor can travel before losing stability. - /// - /// New value for how fast the actor can travel before losing stability on X axis. - /// New value for how fast the actor can travel before losing stability on Y axis. + /// @param newVelX New value for how fast the actor can travel before losing stability on X axis. + /// @param newVelY New value for how fast the actor can travel before losing stability on Y axis. void SetStableVel(float newVelX, float newVelY) { m_StableVel.SetXY(newVelX, newVelY); } - /// /// Sets the X and Y thresholds for how fast the actor can travel before losing stability. - /// - /// Vector with new values for how fast the actor can travel before losing stability on both axis. + /// @param newVelVector Vector with new values for how fast the actor can travel before losing stability on both axis. void SetStableVel(Vector newVelVector) { m_StableVel = newVelVector; } - /// /// Gets the recovery delay from UNSTABLE to STABLE, in MS. - /// - /// The recovery delay, in MS. + /// @return The recovery delay, in MS. int GetStableRecoverDelay() const { return m_StableRecoverDelay; } - /// /// Sets the recovery delay from UNSTABLE to STABLE, in MS. - /// - /// The recovery delay, in MS. + /// @param newRecoverDelay The recovery delay, in MS. void SetStableRecoverDelay(int newRecoverDelay) { m_StableRecoverDelay = newRecoverDelay; } - /// /// Gets the distance in which the Actor will have considered itself to have reached it's waypoint. - /// - /// The move proximity limit. + /// @return The move proximity limit. float GetMoveProximityLimit() const { return m_MoveProximityLimit; } - /// /// Sets the distance in which the Actor will have considered itself to have reached it's waypoint. - /// - /// The move proximity limit. + /// @param newProximityLimit The move proximity limit. void SetMoveProximityLimit(float newProximityLimit) { m_MoveProximityLimit = newProximityLimit; } - /// /// Gets whether or not this Actor has the organic flag set and should be considered as organic. - /// - /// Whether or not this Actor has the organic flag set and should be considered as organic. + /// @return Whether or not this Actor has the organic flag set and should be considered as organic. bool IsOrganic() const { return m_Organic; } - /// /// Gets whether or not this Actor has the mechanical flag set and should be considered as mechanical. - /// - /// Whether or not this Actor has the mechanical flag set and should be considered as mechanical. + /// @return Whether or not this Actor has the mechanical flag set and should be considered as mechanical. bool IsMechanical() const { return m_Mechanical; } - /// /// Gets whether or not this Actor's limb push forces have been disabled. - /// - /// Whether or not this Actor's limb push forces have been disabled. + /// @return Whether or not this Actor's limb push forces have been disabled. bool GetLimbPushForcesAndCollisionsDisabled() const { return m_LimbPushForcesAndCollisionsDisabled; } - /// /// Sets whether or not this Actor's limb push forces should be disabled. - /// - /// Whether or not this Actor's limb push forces should be disabled. + /// @param newLimbPushForcesAndCollisionsDisabled Whether or not this Actor's limb push forces should be disabled. void SetLimbPushForcesAndCollisionsDisabled(bool newLimbPushForcesAndCollisionsDisabled) { m_LimbPushForcesAndCollisionsDisabled = newLimbPushForcesAndCollisionsDisabled; } - /// /// Gets the default PieMenu name for this type. - /// - /// The default PieMenu name for this type. + /// @return The default PieMenu name for this type. virtual std::string GetDefaultPieMenuName() const { return "Default Actor Pie Menu"; } - /// /// Gets a pointer to the PieMenu for this Actor. Ownership is NOT transferred. - /// - /// The PieMenu for this Actor. + /// @return The PieMenu for this Actor. PieMenu* GetPieMenu() const { return m_PieMenu.get(); } - /// /// Sets the PieMenu for this Actor. Ownership IS transferred. - /// - /// The new PieMenu for this Actor. + /// @param newPieMenu The new PieMenu for this Actor. void SetPieMenu(PieMenu* newPieMenu) { m_PieMenu = std::unique_ptr(newPieMenu); m_PieMenu->Create(this); m_PieMenu->AddWhilePieMenuOpenListener(this, std::bind(&Actor::WhilePieMenuOpenListener, this, m_PieMenu.get())); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Protected member variable and method declarations - + /// Protected member variable and method declarations protected: - /// /// Function that is called when we get a new movepath. /// This processes and cleans up the movepath. - /// virtual void OnNewMovePath(); // Member variables @@ -1590,20 +1015,12 @@ namespace RTE { bool m_LimbPushForcesAndCollisionsDisabled; // m_PieMenu; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Clear - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears all the member variables of this Actor, effectively - // resetting the members of this abstraction level only. - // Arguments: None. - // Return value: None. - + /// Clears all the member variables of this Actor, effectively + /// resetting the members of this abstraction level only. void Clear(); // Disallow the use of some implicit methods. diff --git a/Source/Entities/Arm.cpp b/Source/Entities/Arm.cpp index c8170a1923..5216c6630b 100644 --- a/Source/Entities/Arm.cpp +++ b/Source/Entities/Arm.cpp @@ -9,8 +9,6 @@ namespace RTE { ConcreteClassInfo(Arm, Attachable, 50); - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void Arm::Clear() { m_MaxLength = 0; m_MoveSpeed = 0; @@ -35,8 +33,6 @@ namespace RTE { m_HeldDeviceThisArmIsTryingToSupport = nullptr; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int Arm::Create() { if (Attachable::Create() < 0) { return -1; @@ -51,8 +47,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int Arm::Create(const Arm& reference) { if (reference.m_HeldDevice) { m_ReferenceHardcodedAttachableUniqueIDs.insert(reference.m_HeldDevice->GetUniqueID()); @@ -86,8 +80,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int Arm::ReadProperty(const std::string_view& propName, Reader& reader) { StartPropertyList(return Attachable::ReadProperty(propName, reader)); @@ -105,8 +97,6 @@ namespace RTE { EndPropertyList; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int Arm::Save(Writer& writer) const { Attachable::Save(writer); @@ -121,14 +111,10 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void Arm::SetHandPos(const Vector& newHandPos) { SetHandCurrentOffset(g_SceneMan.ShortestDistance(m_JointPos, newHandPos, g_SceneMan.SceneWrapsX() || g_SceneMan.SceneWrapsY())); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void Arm::AddHandTarget(const std::string& description, const Vector& handTargetPositionToAdd, float delayAtTarget) { Vector handTargetOffsetToAdd = g_SceneMan.ShortestDistance(m_JointPos, handTargetPositionToAdd, g_SceneMan.SceneWrapsX() || g_SceneMan.SceneWrapsY()); if (!handTargetOffsetToAdd.IsZero()) { @@ -143,8 +129,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void Arm::SetHeldDevice(HeldDevice* newHeldDevice) { if (m_HeldDevice && m_HeldDevice->IsAttached()) { RemoveAndDeleteAttachable(m_HeldDevice); @@ -169,22 +153,16 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - HeldDevice* Arm::SwapHeldDevice(HeldDevice* newHeldDevice) { Attachable* previousHeldDevice = RemoveAttachable(m_HeldDevice, false, false); SetHeldDevice(newHeldDevice); return dynamic_cast(previousHeldDevice); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool Arm::HandIsCloseToTargetOffset(const Vector& targetOffset) const { return (m_HandCurrentOffset - targetOffset).MagnitudeIsLessThan(m_MaxLength / 10.0F); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void Arm::Update() { Attachable::PreUpdate(); @@ -232,8 +210,6 @@ namespace RTE { m_HandIdleRotation = 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void Arm::UpdateHandCurrentOffset(bool armHasParent, bool heldDeviceIsAThrownDevice) { if (armHasParent) { Vector targetOffset; @@ -303,8 +279,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void Arm::AccountForHeldDeviceRecoil(const HeldDevice* heldDevice, Vector& targetOffset) { if (!heldDevice->GetRecoilForce().IsZero()) { float totalGripStrength = m_GripStrength * heldDevice->GetGripStrengthMultiplier(); @@ -342,8 +316,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void Arm::AccountForHeldDeviceTerrainClipping(const HeldDevice* heldDevice, Vector& targetOffset) const { Vector newMuzzlePos = (m_JointPos + targetOffset) - RotateOffset(heldDevice->GetJointOffset()) + RotateOffset(heldDevice->GetMuzzleOffset()); Vector midToMuzzle = RotateOffset({heldDevice->GetIndividualRadius(), 0}); @@ -358,16 +330,12 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void Arm::UpdateArmFrame() { float halfMaxLength = m_MaxLength / 2.0F; float newFrame = std::floor(((m_HandCurrentOffset.GetMagnitude() - halfMaxLength) / halfMaxLength) * static_cast(m_FrameCount)); m_Frame = static_cast(std::clamp(newFrame, 0.0F, static_cast(m_FrameCount - 1))); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void Arm::Draw(BITMAP* targetBitmap, const Vector& targetPos, DrawMode mode, bool onlyPhysical) const { Attachable::Draw(targetBitmap, targetPos, mode, onlyPhysical); @@ -379,8 +347,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void Arm::DrawHand(BITMAP* targetBitmap, const Vector& targetPos, DrawMode mode) const { Vector handPos(m_JointPos + m_HandCurrentOffset + (m_Recoiled ? m_RecoilOffset : Vector()) - targetPos); handPos -= Vector(static_cast(m_HandSpriteBitmap->w / 2), static_cast(m_HandSpriteBitmap->h / 2)); diff --git a/Source/Entities/Arm.h b/Source/Entities/Arm.h index 033b6f6dff..024f55b1aa 100644 --- a/Source/Entities/Arm.h +++ b/Source/Entities/Arm.h @@ -7,9 +7,7 @@ namespace RTE { class HeldDevice; - /// /// A detachable arm that can hold HeldDevices. - /// class Arm : public Attachable { public: @@ -18,35 +16,25 @@ namespace RTE { ClassInfoGetters; #pragma region Creation - /// /// Constructor method used to instantiate an Arm object in system memory. Create() should be called before using the object. - /// Arm() { Clear(); } - /// /// Makes the Arm object ready for use. - /// - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create() override; - /// /// Creates an Arm to be identical to another, by deep copy. - /// - /// A reference to the Arm to deep copy. - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @param reference A reference to the Arm to deep copy. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create(const Arm& reference); #pragma endregion #pragma region Destruction - /// /// Destructor method used to clean up an Arm object before deletion from system memory. - /// ~Arm() override { Destroy(true); } - /// /// Destroys and resets (through Clear()) the Arm object. - /// - /// Whether to only destroy the members defined in this derived class, or to destroy all inherited members also. + /// @param notInherited Whether to only destroy the members defined in this derived class, or to destroy all inherited members also. void Destroy(bool notInherited = false) override { if (!notInherited) { Attachable::Destroy(); @@ -54,9 +42,7 @@ namespace RTE { Clear(); } - /// /// Resets the entire Arm, including its inherited members, to their default settings or values. - /// void Reset() override { Clear(); Attachable::Reset(); @@ -64,121 +50,85 @@ namespace RTE { #pragma endregion #pragma region Getters and Setters - /// /// Gets the max length of this Arm when fully extended, i.e. the farthest possible length from its joint position to the hand. - /// - /// The max length of this Arm. + /// @return The max length of this Arm. float GetMaxLength() const { return m_MaxLength; } - /// /// Gets the move speed of this Arm, where 1.0 is instant and 0.0 is none. - /// - /// The move speed of this Arm. + /// @return The move speed of this Arm. float GetMoveSpeed() const { return m_MoveSpeed; } - /// /// Sets the move speed of this Arm, where 1.0 is instant and 0.0 is none. - /// - /// The new move speed of this Arm. + /// @return The new move speed of this Arm. void SetMoveSpeed(float newMoveSpeed) { m_MoveSpeed = newMoveSpeed; } - /// /// Gets the default idle offset of this Arm's hand, i.e. the default offset from the joint position that this Arm will try to move to when not moving towards a position. - /// - /// The idle offset of this Arm's hand. + /// @return The idle offset of this Arm's hand. Vector GetHandIdleOffset() const { return m_HandIdleOffset; } - /// /// Sets the default idle offset of this Arm's hand, i.e. the default offset from the joint position that this Arm will try to move to when not moving towards a position. - /// - /// The new idle offset of this Arm's hand. + /// @param newDefaultIdleOffset The new idle offset of this Arm's hand. void SetHandIdleOffset(const Vector& newDefaultIdleOffset) { m_HandIdleOffset = newDefaultIdleOffset; } - /// /// Gets the rotation that is being applied to this Arm's hand, if it's using an idle offset. - /// - /// The idle rotation of this Arm's hand. + /// @return The idle rotation of this Arm's hand. float GetHandIdleRotation() const { return m_HandIdleRotation; } - /// /// Sets the rotation that is being applied to this Arm's hand, if it's using an idle offset. Note that this value is reset to 0 every update. - /// - /// The new idle rotation of this Arm's hand. + /// @param newHandIdleRotation The new idle rotation of this Arm's hand. void SetHandIdleRotation(float newHandIdleRotation) { m_HandIdleRotation = newHandIdleRotation; } - /// /// Gets the current offset of this Arm's hand, i.e. its distance from the joint position. - /// - /// This current offset of this Arm's hand. + /// @return This current offset of this Arm's hand. Vector GetHandCurrentOffset() const { return m_HandCurrentOffset; } - /// /// Sets the current offset of this Arm's hand, i.e. its distance from the joint position. The value is capped to the max length of the Arm. - /// - /// The new current offset of this Arm's hand. + /// @param newHandOffset The new current offset of this Arm's hand. // TODO maybe don't want this in favor of SetHandPos? void SetHandCurrentOffset(const Vector& newHandOffset) { m_HandCurrentOffset = newHandOffset; m_HandCurrentOffset.CapMagnitude(m_MaxLength); } - /// /// Gets the current position of this Arm's hand in absolute Scene coordinates. - /// - /// The current position of this Arm's hand in absolute Scene coordinates. + /// @return The current position of this Arm's hand in absolute Scene coordinates. Vector GetHandPos() const { return m_JointPos + m_HandCurrentOffset; } - /// /// Sets the current position of this Arm's hand to an absolute scene coordinate. If needed, the set position is modified so its distance from the joint position of the Arm is capped to the max length of the Arm. - /// - /// The new current position of this Arm's hand as absolute scene coordinate. + /// @param newHandPos The new current position of this Arm's hand as absolute scene coordinate. void SetHandPos(const Vector& newHandPos); - /// /// Gets the the strength with which this Arm will grip its HeldDevice. - /// - /// The grip strength of this Arm. + /// @return The grip strength of this Arm. float GetGripStrength() const { return m_GripStrength; } - /// /// Sets the strength with which this Arm will grip its HeldDevice. - /// - /// The new grip strength for this Arm to use. + /// @param newGripStrength The new grip strength for this Arm to use. void SetGripStrength(float newGripStrength) { m_GripStrength = newGripStrength; } - /// /// Gets the the strength with which this Arm will throw a ThrownDevice. - /// - /// The throw strength of this Arm. + /// @return The throw strength of this Arm. float GetThrowStrength() const { return m_ThrowStrength; } - /// /// Sets the strength with which this Arm will throw a ThrownDevice. - /// - /// The new throw strength for this Arm to use. + /// @param newThrowStrength The new throw strength for this Arm to use. void SetThrowStrength(float newThrowStrength) { m_ThrowStrength = newThrowStrength; } #pragma endregion #pragma region Hand Animation Handling - /// /// Adds a HandTarget position, in absolute scene coordinates, to the queue for the Arm to move its hand towards. Target positions are removed from the queue when they're reached (or as close to reached as is possible). - /// - /// The description of this HandTarget, for easy identification. - /// The position, in absolute scene coordinates, to add the queue of hand targets. + /// @param description The description of this HandTarget, for easy identification. + /// @param handTargetPositionToAdd The position, in absolute scene coordinates, to add the queue of hand targets. void AddHandTarget(const std::string& description, const Vector& handTargetPositionToAdd) { AddHandTarget(description, handTargetPositionToAdd, 0); } - /// /// Adds a HandTarget position, in absolute scene coordinates, to the queue for the Arm to move its hand towards. Target positions are removed from the queue when they're reached (or as close to reached as is possible). /// If the target position is very close to the last element in the queue, or has the same name as it, the last element in the queue is updated to avoid filling the queue with similar values. - /// - /// The description of this HandTarget, for easy identification. - /// The position, in absolute scene coordinates, to add the queue of hand targets. - /// The amount of time, in MS, that the hand should wait when it reaches the newly added HandTarget. + /// @param description The description of this HandTarget, for easy identification. + /// @param handTargetPositionToAdd The position, in absolute scene coordinates, to add the queue of hand targets. + /// @param delayAtTarget The amount of time, in MS, that the hand should wait when it reaches the newly added HandTarget. void AddHandTarget(const std::string& description, const Vector& handTargetPositionToAdd, float delayAtTarget); - /// /// Removes this Arm's next HandTarget, if there is one. - /// void RemoveNextHandTarget() { if (!m_HandTargets.empty()) { m_HandTargets.pop(); @@ -186,89 +136,63 @@ namespace RTE { } } - /// /// Gets whether or not this Arm has any HandTargets. - /// - /// Whether or not this Arm has any HandTargets. + /// @return Whether or not this Arm has any HandTargets. bool HasAnyHandTargets() const { return !m_HandTargets.empty(); } - /// /// Gets the number of HandTargets this Arm has. - /// - /// The number of HandTargets this Arm has. + /// @return The number of HandTargets this Arm has. int GetNumberOfHandTargets() const { return m_HandTargets.size(); } - /// /// Gets the name of this Arm's next HandTarget. - /// - /// The name of this Arm's next HandTarget. + /// @return The name of this Arm's next HandTarget. std::string GetNextHandTargetDescription() const { return m_HandTargets.empty() ? "" : m_HandTargets.front().Description; } - /// /// Gets the position, in absolute scene coordinates, of this Arm's next HandTarget. - /// - /// The position of this Arm's next HandTarget. + /// @return The position of this Arm's next HandTarget. Vector GetNextHandTargetPosition() const { return m_HandTargets.empty() ? Vector() : m_HandTargets.front().TargetOffset + m_JointPos; } - /// /// Gets whether or not the hand has reached its current target. This is either the front of the HandTarget queue, or the offset it's currently trying to move to to when it has no HandTargets specified. - /// - /// Whether or not the hand has reached its current target. + /// @return Whether or not the hand has reached its current target. bool GetHandHasReachedCurrentTarget() const { return m_HandHasReachedCurrentTarget; } - /// /// Empties the queue of HandTargets. With the queue empty, the hand will move to its appropriate idle offset. - /// void ClearHandTargets() { m_HandTargets = {}; } #pragma endregion #pragma region HeldDevice Management - /// /// Gets the HeldDevice currently held by this Arm. - /// - /// The HeldDevice currently held by this Arm. Ownership is NOT transferred. + /// @return The HeldDevice currently held by this Arm. Ownership is NOT transferred. HeldDevice* GetHeldDevice() const { return m_HeldDevice; } - /// /// Sets the HeldDevice held by this Arm. - /// - /// The new HeldDevice to be held by this Arm. Ownership IS transferred. + /// @param newHeldDevice The new HeldDevice to be held by this Arm. Ownership IS transferred. void SetHeldDevice(HeldDevice* newHeldDevice); - /// /// Gets the HeldDevice this Arm is trying to support. - /// - /// The HeldDevice this Arm is trying to support. Ownership is NOT transferred. + /// @return The HeldDevice this Arm is trying to support. Ownership is NOT transferred. HeldDevice* GetHeldDeviceThisArmIsTryingToSupport() const { return m_HeldDeviceThisArmIsTryingToSupport; } - /// /// Sets the HeldDevice being this Arm is trying to support. - /// - /// The new HeldDevice this Arm should try to support. Ownership is NOT transferred. + /// @param newHeldDeviceForThisArmToTryToSupport The new HeldDevice this Arm should try to support. Ownership is NOT transferred. void SetHeldDeviceThisArmIsTryingToSupport(HeldDevice* newHeldDeviceThisArmShouldTryToSupport) { m_HeldDeviceThisArmIsTryingToSupport = newHeldDeviceThisArmShouldTryToSupport; } - /// /// Replaces the HeldDevice currently held by this Arm with a new one, and returns the old one. Ownership IS transferred both ways. - /// - /// The new HeldDevice to be held by this Arm. Ownership IS transferred. - /// The HeldDevice that was held by this Arm. Ownership IS transferred. + /// @param newHeldDevice The new HeldDevice to be held by this Arm. Ownership IS transferred. + /// @return The HeldDevice that was held by this Arm. Ownership IS transferred. HeldDevice* SwapHeldDevice(HeldDevice* newHeldDevice); #pragma endregion #pragma region Concrete Methods - /// /// Draws this Arm's hand's graphical representation to a BITMAP of choice. - /// - /// A pointer to a BITMAP to draw on. - /// The absolute position of the target bitmap's upper left corner in the Scene. - /// Which mode to draw in. See the DrawMode enumeration for available modes. + /// @param targetBitmap A pointer to a BITMAP to draw on. + /// @param targetPos The absolute position of the target bitmap's upper left corner in the Scene. + /// @param mode Which mode to draw in. See the DrawMode enumeration for available modes. void DrawHand(BITMAP* targetBitmap, const Vector& targetPos = Vector(), DrawMode mode = g_DrawColor) const; #pragma endregion #pragma region Override Methods - /// /// Does stuff that needs to be done after Update(). - /// void PostTravel() override { if (IsAttached()) { m_AngularVel = 0; @@ -276,29 +200,21 @@ namespace RTE { MOSRotating::PostTravel(); } - /// /// Updates this Arm. Supposed to be done every frame. - /// void Update() override; - /// /// Draws this Arm's current graphical representation to a BITMAP of choice. - /// - /// A pointer to a BITMAP to draw on. - /// The absolute position of the target bitmap's upper left corner in the Scene. - /// Which mode to draw in. See the DrawMode enumeration for the modes. - /// Whether to not draw any extra 'ghost' items of this Arm. In this case, that means the hand sprite. + /// @param targetBitmap A pointer to a BITMAP to draw on. + /// @param targetPos The absolute position of the target bitmap's upper left corner in the Scene. + /// @param mode Which mode to draw in. See the DrawMode enumeration for the modes. + /// @param onlyPhysical Whether to not draw any extra 'ghost' items of this Arm. In this case, that means the hand sprite. void Draw(BITMAP* targetBitmap, const Vector& targetPos = Vector(), DrawMode mode = g_DrawColor, bool onlyPhysical = false) const override; #pragma endregion private: - /// /// Struct for storing data about each target in the Arm's queue of HandTargets. - /// struct HandTarget { - /// /// Constructor method used to instantiate a HandTarget object in system memory. - /// HandTarget(const std::string_view& description, const Vector& targetOffset, float delayAtTarget, bool hFlippedWhenTargetWasCreated) : Description(description), TargetOffset(targetOffset), DelayAtTarget(delayAtTarget), HFlippedWhenTargetWasCreated(hFlippedWhenTargetWasCreated) {} @@ -331,45 +247,33 @@ namespace RTE { HeldDevice* m_HeldDevice; //!< A pointer to the HeldDevice this Arm is currently holding. Owned in the MOSRotating Attachables list, kept here for convenience. HeldDevice* m_HeldDeviceThisArmIsTryingToSupport; //!< A pointer to the HeldDevice being supported by this Arm (i.e. this is the background Arm for another HeldDevice). - /// /// Gets whether or not the hand is close to the given offset. - /// - /// The offset to check for closeness to the hand. - /// Whether or not the hand is close to the given offset. + /// @param targetOffset The offset to check for closeness to the hand. + /// @return Whether or not the hand is close to the given offset. bool HandIsCloseToTargetOffset(const Vector& targetOffset) const; #pragma region Update Breakdown - /// /// Updates the current hand offset for this Arm. Should only be called from Update. /// If the Arm is attached, the current hand offset is based on the target offset and move speed, and whether the Arm should idle or not, otherwise it puts it in a reasonable position. - /// - /// Whether or not this Arm has a parent. Passed in for convenient reuse. - /// Whether or not this Arm's HeldDevice is a ThrownDevice. Passed in for convenient reuse. + /// @param hasParent Whether or not this Arm has a parent. Passed in for convenient reuse. + /// @param heldDeviceIsAThrownDevice Whether or not this Arm's HeldDevice is a ThrownDevice. Passed in for convenient reuse. void UpdateHandCurrentOffset(bool armHasParent, bool heldDeviceIsAThrownDevice); - /// /// To be used in UpdateHandCurrentOffset. Applies any recoil accumulated on the HeldDevice to the passed in target offset, so it can be used to affect the hand's target position. - /// - /// The held MO as a HeldDevice, for convenience. - /// The target offset to have recoil applied to it. + /// @param heldDevice The held MO as a HeldDevice, for convenience. + /// @param targetOffset The target offset to have recoil applied to it. void AccountForHeldDeviceRecoil(const HeldDevice* heldDevice, Vector& targetOffset); - /// /// To be used in UpdateHandCurrentOffset. Ensures the HeldDevice won't clip through terrain by modifying the passed in target offset. - /// - /// The held MO as a HeldDevice, for convenience. - /// The target offset to be modified to avoid any terrain clipping. + /// @param heldDevice The held MO as a HeldDevice, for convenience. + /// @param targetOffset The target offset to be modified to avoid any terrain clipping. void AccountForHeldDeviceTerrainClipping(const HeldDevice* heldDevice, Vector& targetOffset) const; - /// /// Updates the frame for this Arm. Should only be called from Update. - /// void UpdateArmFrame(); #pragma endregion - /// /// Clears all the member variables of this Arm, effectively resetting the members of this abstraction level only. - /// void Clear(); // Disallow the use of some implicit methods. diff --git a/Source/Entities/AtomGroup.cpp b/Source/Entities/AtomGroup.cpp index ea424a4fbf..5c5f66fad8 100644 --- a/Source/Entities/AtomGroup.cpp +++ b/Source/Entities/AtomGroup.cpp @@ -17,8 +17,6 @@ namespace RTE { {"Circle", AtomGroup::AreaDistributionType::Circle}, {"Square", AtomGroup::AreaDistributionType::Square}}; - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void AtomGroup::Clear() { m_Atoms.clear(); m_SubGroups.clear(); @@ -35,8 +33,6 @@ namespace RTE { m_IgnoreMOIDs.clear(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int AtomGroup::Create() { if (Entity::Create() < 0) { return -1; @@ -55,8 +51,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int AtomGroup::Create(const AtomGroup& reference, bool onlyCopyOwnerAtoms) { Entity::Create(reference); @@ -102,8 +96,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int AtomGroup::Create(MOSRotating* ownerMOSRotating, Material const* material, int resolution, int depth) { RTEAssert(ownerMOSRotating, "Trying to generate an AtomGroup for a MOSRotating without a sprite!"); @@ -118,8 +110,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int AtomGroup::ReadProperty(const std::string_view& propName, Reader& reader) { StartPropertyList(return Entity::ReadProperty(propName, reader)); @@ -162,8 +152,6 @@ namespace RTE { EndPropertyList; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int AtomGroup::Save(Writer& writer) const { Entity::Save(writer); @@ -195,8 +183,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void AtomGroup::Destroy(bool notInherited) { for (const Atom* atom: m_Atoms) { delete atom; @@ -207,8 +193,6 @@ namespace RTE { Clear(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void AtomGroup::SetAtomList(const std::vector& newAtoms) { for (const Atom* atom: m_Atoms) { delete atom; @@ -216,8 +200,6 @@ namespace RTE { m_Atoms = newAtoms; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - float AtomGroup::CalculateMaxRadius() const { float sqrMagnitude = 0.0F; float sqrLongest = 0.0F; @@ -231,8 +213,6 @@ namespace RTE { return std::sqrt(sqrLongest); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void AtomGroup::SetOwner(MOSRotating* newOwner) { m_OwnerMOSR = newOwner; for (Atom* atom: m_Atoms) { @@ -240,14 +220,10 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - Vector AtomGroup::GetAdjustedAtomOffset(const Atom* atom) const { return atom->GetOffset().GetXFlipped(m_OwnerMOSR->m_HFlipped) * m_OwnerMOSR->GetRotMatrix(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - float AtomGroup::GetMomentOfInertia() { float currentOwnerMass = (m_OwnerMOSR->GetMass() != 0 ? m_OwnerMOSR->GetMass() : 0.0001F); if (m_MomentOfInertia == 0.0F || std::abs(m_StoredOwnerMass - currentOwnerMass) >= (m_StoredOwnerMass / 10.0F)) { @@ -269,8 +245,6 @@ namespace RTE { return m_MomentOfInertia; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void AtomGroup::AddAtoms(const std::vector& atomList, long subgroupID, const Vector& offset, const Matrix& offsetRotation) { if (m_SubGroups.count(subgroupID) == 0) { m_SubGroups.insert({subgroupID, std::vector()}); @@ -294,8 +268,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool AtomGroup::RemoveAtoms(long removeID) { std::size_t oldSize = m_Atoms.size(); @@ -319,8 +291,6 @@ namespace RTE { return removedAny; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool AtomGroup::UpdateSubAtoms(long subgroupID, const Vector& newOffset, const Matrix& newOffsetRotation) { if (m_SubGroups.empty() || m_SubGroups.count(subgroupID) == 0) { return false; @@ -333,14 +303,10 @@ namespace RTE { return true; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - float AtomGroup::Travel(float travelTime, bool callOnBounce, bool callOnSink, bool scenePreLocked) { return Travel(m_OwnerMOSR->m_Pos, m_OwnerMOSR->m_Vel, m_OwnerMOSR->m_Rotation, m_OwnerMOSR->m_AngularVel, m_OwnerMOSR->m_DidWrap, m_OwnerMOSR->m_TravelImpulse, m_OwnerMOSR->GetMass(), travelTime, callOnBounce, callOnSink, scenePreLocked); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // TODO: Break down and rework this trainwreck. float AtomGroup::Travel(Vector& position, Vector& velocity, Matrix& rotation, float& angularVel, bool& didWrap, Vector& totalImpulse, float mass, float travelTime, bool callOnBounce, bool callOnSink, bool scenePreLocked) { ZoneScoped; @@ -785,8 +751,6 @@ namespace RTE { return timeLeft; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // TODO: Break down and rework this dumpsterfire. Vector AtomGroup::PushTravel(Vector& position, const Vector& velocity, float pushForce, bool& didWrap, float travelTime, bool callOnBounce, bool callOnSink, bool scenePreLocked) { ZoneScoped; @@ -1242,8 +1206,6 @@ namespace RTE { return returnPush; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool AtomGroup::PushAsLimb(const Vector& jointPos, const Vector& velocity, const Matrix& rotation, LimbPath& limbPath, const float travelTime, bool* restarted, bool affectRotation, Vector rotationOffset, Vector positionOffset) { RTEAssert(m_OwnerMOSR, "Tried to push-as-limb an AtomGroup that has no parent!"); @@ -1317,8 +1279,6 @@ namespace RTE { return true; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void AtomGroup::FlailAsLimb(const Vector& ownerPos, const Vector& jointOffset, const float limbRadius, const Vector& velocity, const float angularVel, const float mass, const float travelTime) { RTEAssert(m_OwnerMOSR, "Tried to flail an AtomGroup that has no parent!"); @@ -1339,8 +1299,6 @@ namespace RTE { return; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool AtomGroup::InTerrain() const { RTEAssert(m_OwnerMOSR, "Tried to check overlap with terrain for an AtomGroup that has no parent!"); @@ -1363,8 +1321,6 @@ namespace RTE { return penetrates; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - float AtomGroup::RatioInTerrain() const { RTEAssert(m_OwnerMOSR, "Tried to check ratio in terrain for an AtomGroup that has no parent!"); @@ -1386,8 +1342,6 @@ namespace RTE { return static_cast(inTerrain) / static_cast(m_Atoms.size()); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // TODO: Look into breaking this into smaller methods. bool AtomGroup::ResolveTerrainIntersection(Vector& position, unsigned char strongerThan) const { thread_local std::vector intersectingAtoms; @@ -1471,8 +1425,6 @@ namespace RTE { return true; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // TODO: Look into breaking this into smaller methods. bool AtomGroup::ResolveMOSIntersection(Vector& position) { if (!m_OwnerMOSR->m_HitsMOs) { @@ -1612,8 +1564,6 @@ namespace RTE { return intersectingAtoms.empty(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - float AtomGroup::GetSurfaceArea(int pixelWidth) const { float distributionAmount; @@ -1637,8 +1587,6 @@ namespace RTE { return distributionAmount * m_AreaDistributionSurfaceAreaMultiplier; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void AtomGroup::Draw(BITMAP* targetBitmap, const Vector& targetPos, bool useLimbPos, unsigned char color) const { Vector atomPos; Vector normal; @@ -1660,8 +1608,6 @@ namespace RTE { release_bitmap(targetBitmap); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // TODO: dan pls. void AtomGroup::GenerateAtomGroup(MOSRotating* ownerMOSRotating) { BITMAP* refSprite = ownerMOSRotating->GetSpriteFrame(); @@ -1867,8 +1813,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void AtomGroup::AddAtomToGroup(MOSRotating* ownerMOSRotating, const Vector& spriteOffset, int x, int y, bool calcNormal) { Atom* atomToAdd = new Atom(Vector(static_cast(x) + spriteOffset.GetFloorIntX(), static_cast(y) + spriteOffset.GetFloorIntY()), m_Material, ownerMOSRotating); if (calcNormal) { diff --git a/Source/Entities/AtomGroup.h b/Source/Entities/AtomGroup.h index 564d980fb1..48df80458e 100644 --- a/Source/Entities/AtomGroup.h +++ b/Source/Entities/AtomGroup.h @@ -8,9 +8,7 @@ namespace RTE { class MOSRotating; class LimbPath; - /// /// A group of Atoms that move and interact with the terrain in unison. - /// class AtomGroup : public Entity { public: @@ -19,76 +17,56 @@ namespace RTE { ClassInfoGetters; #pragma region Creation - /// /// Constructor method used to instantiate an AtomGroup object in system memory. Create() should be called before using the object. - /// AtomGroup() { Clear(); } - /// /// Copy constructor method used to instantiate an AtomGroup object identical to an already existing one. - /// - /// An AtomGroup object which is passed in by reference. + /// @param reference An AtomGroup object which is passed in by reference. AtomGroup(const AtomGroup& reference) { Clear(); Create(reference); } - /// /// Makes the AtomGroup object ready for use. - /// - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create() override; - /// /// Creates an AtomGroup to be identical to another, by deep copy. - /// - /// A reference to the AtomGroup to deep copy. - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @param reference A reference to the AtomGroup to deep copy. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create(const AtomGroup& reference) { return Create(reference, false); } - /// /// Creates an AtomGroup to be identical to another, by deep copy, with the option to only copy Atoms that belong to the reference AtomGroup's owner thereby excluding any Atom subgroups. - /// - /// A reference to the AtomGroup to deep copy. - /// Whether or not to only copy Atoms that belong to the reference AtomGroup's owner directly. - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @param reference A reference to the AtomGroup to deep copy. + /// @param onlyCopyOwnerAtoms Whether or not to only copy Atoms that belong to the reference AtomGroup's owner directly. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create(const AtomGroup& reference, bool onlyCopyOwnerAtoms); - /// /// Creates an AtomGroup after the silhouette shape of a passed in MOSRotating by dotting the outline of the sprite with Atoms. /// The passed in MOSRotating will also be made the owner of this AtomGroup! Ownership of the MOSRotating is NOT transferred! - /// - /// A pointer to a MOSRotating whose outline will be approximated by Atoms of this AtomGroup, and that will be set as the owner of this AtomGroup. - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @param ownerMOSRotating A pointer to a MOSRotating whose outline will be approximated by Atoms of this AtomGroup, and that will be set as the owner of this AtomGroup. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create(MOSRotating* ownerMOSRotating) { return Create(ownerMOSRotating, m_Material, m_Resolution, m_Depth); } - /// /// Creates an AtomGroup after the silhouette shape of a passed in MOSRotating by dotting the outline of the sprite with Atoms. /// The passed in MOSRotating will also be made the owner of this AtomGroup! Ownership of the MOSRotating is NOT transferred! - /// - /// A pointer to an MOSRotating whose outline will be approximated by Atoms of this AtomGroup, and that will be set as the owner of this AtomGroup. - /// The Material that the Atoms of this AtomGroup should be. - /// Resolution, or density of the Atoms in representing the MOSRotating's outline. Lower value equals higher density. - /// The depth into the sprite that the Atoms should be placed. - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @param ownerMOSRotating A pointer to an MOSRotating whose outline will be approximated by Atoms of this AtomGroup, and that will be set as the owner of this AtomGroup. + /// @param material The Material that the Atoms of this AtomGroup should be. + /// @param resolution Resolution, or density of the Atoms in representing the MOSRotating's outline. Lower value equals higher density. + /// @param depth The depth into the sprite that the Atoms should be placed. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create(MOSRotating* ownerMOSRotating, Material const* material, int resolution = 1, int depth = 0); #pragma endregion #pragma region Destruction - /// /// Destructor method used to clean up an AtomGroup object before deletion from system memory. - /// ~AtomGroup() override { Destroy(true); } - /// /// Destroys and resets (through Clear()) the AtomGroup object. - /// - /// Whether to only destroy the members defined in this derived class, or to destroy all inherited members also. + /// @param notInherited Whether to only destroy the members defined in this derived class, or to destroy all inherited members also. void Destroy(bool notInherited = false) override; - /// /// Resets the entire AtomGroup, including its inherited members, to their default settings or values. - /// void Reset() override { Clear(); Entity::Reset(); @@ -96,132 +74,94 @@ namespace RTE { #pragma endregion #pragma region Getters and Setters - /// /// Gets the current list of Atoms that make up the group. - /// - /// A const reference to the Atom list. + /// @return A const reference to the Atom list. const std::vector& GetAtomList() const { return m_Atoms; } - /// /// Sets the a new list of Atoms that make up the group. - /// - /// List of Atoms that make up the group. + /// @param newAtoms List of Atoms that make up the group. void SetAtomList(const std::vector& newAtoms); - /// /// Gets the current number of Atoms that make up the group. - /// - /// The number of Atoms that make up the group. + /// @return The number of Atoms that make up the group. int GetAtomCount() const { return m_Atoms.size(); } - /// /// Gets max radius of the AtomGroup through the longest magnitude of all the Atom's offsets. - /// - /// The largest magnitude of Atom's offsets, in pixels. + /// @return The largest magnitude of Atom's offsets, in pixels. float CalculateMaxRadius() const; - /// /// Gets the current owner MOSRotating of this AtomGroup. - /// - /// A pointer to the owner. + /// @return A pointer to the owner. MOSRotating* GetOwner() const { return m_OwnerMOSR; } - /// /// Sets the current owner MOSRotating of this AtomGroup. - /// - /// A pointer to the new owner. Ownership is NOT transferred! + /// @param newOwner A pointer to the new owner. Ownership is NOT transferred! void SetOwner(MOSRotating* newOwner); - /// /// Gets the Material of this AtomGroup. - /// - /// A const pointer to the Material. + /// @return A const pointer to the Material. const Material* GetMaterial() const { return (m_Material) ? m_Material : g_SceneMan.GetMaterialFromID(g_MaterialAir); } - /// /// Gets whether this AtomGroup's Atoms are to be automatically generated based on a bitmap, or manually specified. - /// - /// Whether this AtomGroup is auto generated from a bitmap or not. + /// @return Whether this AtomGroup is auto generated from a bitmap or not. bool AutoGenerate() const { return m_AutoGenerate; } - /// /// Gets the resolution (density of Atoms) of this AtomGroup. Higher values mean a less dense and less accurate physical representation of the owner MOSR's graphical representation. - /// - /// The resolution value of this AtomGroup. 0 means the Atoms in this AtomGroup were defined manually. + /// @return The resolution value of this AtomGroup. 0 means the Atoms in this AtomGroup were defined manually. int GetResolution() const { return m_Resolution; } - /// /// Gets the depth Atoms in this AtomGroup are placed off the edge of the owning MOSR's graphical representation outline towards it's center. - /// - /// The depth, in pixels. If 0, Atoms are placed right on the edge of the MOSR outline. + /// @return The depth, in pixels. If 0, Atoms are placed right on the edge of the MOSR outline. int GetDepth() const { return m_Depth; } - /// /// Gets the offset of an Atom in this AtomGroup adjusted to the Owner MOSRotating horizontal flip and rotation. - /// - /// The individual Atom to get the offset for. - /// The offset of an Atom in this AtomGroup adjusted to the Owner MOSRotating horizontal flip and rotation. + /// @param atom The individual Atom to get the offset for. + /// @return The offset of an Atom in this AtomGroup adjusted to the Owner MOSRotating horizontal flip and rotation. Vector GetAdjustedAtomOffset(const Atom* atom) const; - /// /// Gets the current position of this AtomGroup as a limb. - /// - /// Whether to adjust the position for horizontal flip or not. - /// The absolute limb position in the world. + /// @param hFlipped Whether to adjust the position for horizontal flip or not. + /// @return The absolute limb position in the world. Vector GetLimbPos(bool hFlipped = false) const { return m_LimbPos.GetFloored() + m_JointOffset.GetXFlipped(hFlipped); } - /// /// Sets the current position of this AtomGroup as a limb. - /// - /// The Vector with the new absolute position. - /// Whether to adjust the new position for horizontal flip or not. + /// @param newPos The Vector with the new absolute position. + /// @param hFlipped Whether to adjust the new position for horizontal flip or not. void SetLimbPos(const Vector& newPos, bool hFlipped = false) { m_LimbPos = newPos - m_JointOffset.GetXFlipped(hFlipped); } - /// /// Gets the current mass moment of inertia of this AtomGroup. - /// - /// A float with the moment of inertia, in Kg * meter^2. + /// @return A float with the moment of inertia, in Kg * meter^2. float GetMomentOfInertia(); - /// /// Sets the offset of the joint relative to this AtomGroup's origin when used as a limb. - /// - /// The new joint offset. + /// @param newOffset The new joint offset. void SetJointOffset(const Vector& newOffset) { m_JointOffset = newOffset; } #pragma endregion #pragma region Atom Management - /// /// Adds a new Atom into the internal list that makes up this AtomGroup. Ownership of the Atom IS transferred! /// Note, this resets the moment of inertia, which then has to be recalculated. - /// - /// A pointer to an Atom that will pushed onto the end of the list. Ownership IS transferred! - /// The subgroup ID that the new Atom will have within the group. + /// @param newAtom A pointer to an Atom that will pushed onto the end of the list. Ownership IS transferred! + /// @param subgroupID The subgroup ID that the new Atom will have within the group. void AddAtom(Atom* newAtom, long subgroupID = 0) { newAtom->SetSubID(subgroupID); m_Atoms.push_back(newAtom); m_MomentOfInertia = 0.0F; } - /// /// Adds a list of new Atoms to the internal list that makes up this AtomGroup. Ownership of all Atoms in the list IS NOT transferred! - /// - /// A list of pointers to Atoms whose copies will be pushed onto the end of this AtomGroup's list. Ownership IS NOT transferred! - /// The desired subgroup ID for the Atoms being added. - /// An offset that should be applied to all added Atoms. - /// The rotation of the placed Atoms around the specified offset. + /// @param atomList A list of pointers to Atoms whose copies will be pushed onto the end of this AtomGroup's list. Ownership IS NOT transferred! + /// @param subgroupID The desired subgroup ID for the Atoms being added. + /// @param offset An offset that should be applied to all added Atoms. + /// @param offsetRotation The rotation of the placed Atoms around the specified offset. void AddAtoms(const std::vector& atomList, long subgroupID = 0, const Vector& offset = Vector(), const Matrix& offsetRotation = Matrix()); - /// /// Removes all Atoms of a specific subgroup ID from this AtomGroup. - /// - /// The ID of the subgroup of Atoms to remove. - /// Whether any Atoms of that subgroup ID were found and removed. + /// @param removeID The ID of the subgroup of Atoms to remove. + /// @return Whether any Atoms of that subgroup ID were found and removed. bool RemoveAtoms(long removeID); - /// /// Removes all atoms in this AtomGroup, leaving it empty of Atoms. - /// void RemoveAllAtoms() { m_Atoms.clear(); m_SubGroups.clear(); @@ -229,166 +169,131 @@ namespace RTE { m_StoredOwnerMass = 0.0F; } - /// /// Gets whether the AtomGroup contains a subgroup with the given subgroupID. - /// - /// The subgroupID to check for. - /// Whether this AtomGroup contains a subgroup with the given subgroupID. + /// @param subgroupID The subgroupID to check for. + /// @return Whether this AtomGroup contains a subgroup with the given subgroupID. bool ContainsSubGroup(long subgroupID) const { return m_SubGroups.count(subgroupID) != 0; } - /// /// Updates the offsets of a subgroup of Atoms in this AtomGroup. This allows repositioning a subgroup to match the position and rotation of the graphical representation of it's owner MOSR. - /// - /// The desired subgroup ID of the Atoms to update offsets for. - /// The change in offset for the Atoms of the specified subgroup. - /// The rotation of the updated Atoms around the specified offset. - /// Whether any Atoms were found and updated for the specified subgroup. + /// @param subgroupID The desired subgroup ID of the Atoms to update offsets for. + /// @param newOffset The change in offset for the Atoms of the specified subgroup. + /// @param newOffsetRotation The rotation of the updated Atoms around the specified offset. + /// @return Whether any Atoms were found and updated for the specified subgroup. bool UpdateSubAtoms(long subgroupID = 0, const Vector& newOffset = Vector(), const Matrix& newOffsetRotation = Matrix()); #pragma endregion #pragma region Travel - /// /// Makes this AtomGroup travel and react when terrain is hit. Effects are directly applied to the owning MOSRotating. - /// - /// The amount of time in seconds that this AtomGroup is supposed to travel. - /// Whether to call the parent MOSR's OnBounce function upon bouncing against anything or not. - /// Whether to call the parent MOSR's OnSink function upon sinking into anything or not. - /// Whether the Scene has been pre-locked or not. - /// The amount of time remaining of the travelTime passed in, in seconds. This may only possibly be a non-zero if callOnBounce or callOnSink are true. + /// @param travelTime The amount of time in seconds that this AtomGroup is supposed to travel. + /// @param callOnBounce Whether to call the parent MOSR's OnBounce function upon bouncing against anything or not. + /// @param callOnSink Whether to call the parent MOSR's OnSink function upon sinking into anything or not. + /// @param scenePreLocked Whether the Scene has been pre-locked or not. + /// @return The amount of time remaining of the travelTime passed in, in seconds. This may only possibly be a non-zero if callOnBounce or callOnSink are true. float Travel(float travelTime, bool callOnBounce = false, bool callOnSink = false, bool scenePreLocked = false); - /// /// Makes this AtomGroup travel and react when terrain is hit. Effects are applied to the passed in variables. - /// - /// A reference to a Vector with the starting position of the AtomGroup origin. Will be altered according to where the AtomGroup ends up after it's done traveling. - /// A Vector with the total desired velocity of the AtomGroup. Will also be altered according to any collision response. - /// The current rotation Matrix of the AtomGroup. Will be altered accordingly as travel happens. - /// The current desired angular velocity of the owner MOSR, in rad/sec. Will be altered. - /// A bool that will be set to whether the position change involved a wrapping of the scene or not. - /// A float to be filled out with the total magnitudes of all the forces exerted on this through collisions during this frame. - /// The designated mass of the AtomGroup at this time. - /// The amount of time in seconds that this AtomGroup is supposed to travel. - /// Whether to call the parent MOSR's OnBounce function upon bouncing against anything or not. - /// Whether to call the parent MOSR's OnSink function upon sinking into anything or not. - /// Whether the Scene has been pre-locked or not. - /// The amount of time remaining of the travelTime passed in, in seconds. This may only possibly be a non-zero if callOnBounce or callOnSink are true. - /// + /// @param position A reference to a Vector with the starting position of the AtomGroup origin. Will be altered according to where the AtomGroup ends up after it's done traveling. + /// @param velocity A Vector with the total desired velocity of the AtomGroup. Will also be altered according to any collision response. + /// @param rotation The current rotation Matrix of the AtomGroup. Will be altered accordingly as travel happens. + /// @param angularVel The current desired angular velocity of the owner MOSR, in rad/sec. Will be altered. + /// @param didWrap A bool that will be set to whether the position change involved a wrapping of the scene or not. + /// @param totalImpulse A float to be filled out with the total magnitudes of all the forces exerted on this through collisions during this frame. + /// @param mass The designated mass of the AtomGroup at this time. + /// @param travelTime The amount of time in seconds that this AtomGroup is supposed to travel. + /// @param callOnBounce Whether to call the parent MOSR's OnBounce function upon bouncing against anything or not. + /// @param callOnSink Whether to call the parent MOSR's OnSink function upon sinking into anything or not. + /// @param scenePreLocked Whether the Scene has been pre-locked or not. + /// @return The amount of time remaining of the travelTime passed in, in seconds. This may only possibly be a non-zero if callOnBounce or callOnSink are true. + /// @remark /// Pseudocode explaining how this works can be found at: https://github.com/cortex-command-community/Cortex-Command-Community-Project-Source/wiki/Notes-on-AtomGroup::Travel. - /// float Travel(Vector& position, Vector& velocity, Matrix& rotation, float& angularVel, bool& didWrap, Vector& totalImpulse, float mass, float travelTime, bool callOnBounce = false, bool callOnSink = false, bool scenePreLocked = false); - /// /// Makes this AtomGroup travel without rotation and react with the scene by pushing against it. - /// - /// A reference to a Vector with the starting position of the AtomGroup origin. Will be altered according to where the AtomGroup ends up after done traveling. - /// A Vector with the total desired velocity of the AtomGroup. - /// The maximum force that the push against other stuff in the scene can have, in Newtons (N). - /// A bool that will be set to whether the position change involved a wrapping of the scene or not. - /// The amount of time in seconds that this AtomGroup is supposed to travel. - /// Whether to call the parent MOSR's OnBounce function upon bouncing against anything or not. - /// Whether to call the parent MOSR's OnSink function upon sinking into anything or not. - /// Whether the Scene has been pre-locked or not. - /// A Vector with the resulting push impulse force, in Newton-second (Ns). + /// @param position A reference to a Vector with the starting position of the AtomGroup origin. Will be altered according to where the AtomGroup ends up after done traveling. + /// @param velocity A Vector with the total desired velocity of the AtomGroup. + /// @param pushForce The maximum force that the push against other stuff in the scene can have, in Newtons (N). + /// @param didWrap A bool that will be set to whether the position change involved a wrapping of the scene or not. + /// @param travelTime The amount of time in seconds that this AtomGroup is supposed to travel. + /// @param callOnBounce Whether to call the parent MOSR's OnBounce function upon bouncing against anything or not. + /// @param callOnSink Whether to call the parent MOSR's OnSink function upon sinking into anything or not. + /// @param scenePreLocked Whether the Scene has been pre-locked or not. + /// @return A Vector with the resulting push impulse force, in Newton-second (Ns). Vector PushTravel(Vector& position, const Vector& velocity, float pushForce, bool& didWrap, float travelTime, bool callOnBounce = false, bool callOnSink = false, bool scenePreLocked = false); - /// /// Makes this AtomGroup travel as a pushing entity relative to the position of the owning MOSRotating. /// If stuff in the scene is hit, resulting forces are be added to the owning MOSRotating's impulse forces. - /// - /// A reference to a Vector with the world position of the limb joint which this AtomGroup is being pushed along. - /// A Vector with the velocity of the owning MOSRotating. - /// A Matrix with the rotation of the owning MOSRotating. - /// A LimbPath which this AtomGroup should travel along. - /// The amount of time in seconds that this AtomGroup is supposed to travel. - /// Pointer to a bool which gets set to true if the LimbPath got restarted during this push. It does NOT get initialized to false! - /// Whether the forces created by this should have rotational leverage on the owner or only have translational effect. - /// The position, relative to the owning actor's position, that we should rotate around. - /// The positional offset to apply to our limb path. - /// Whether the LimbPath passed in could start free of terrain or not. + /// @param jointPos A reference to a Vector with the world position of the limb joint which this AtomGroup is being pushed along. + /// @param velocity A Vector with the velocity of the owning MOSRotating. + /// @param rotation A Matrix with the rotation of the owning MOSRotating. + /// @param limbPath A LimbPath which this AtomGroup should travel along. + /// @param travelTime The amount of time in seconds that this AtomGroup is supposed to travel. + /// @param restarted Pointer to a bool which gets set to true if the LimbPath got restarted during this push. It does NOT get initialized to false! + /// @param affectRotation Whether the forces created by this should have rotational leverage on the owner or only have translational effect. + /// @param rotationOffset The position, relative to the owning actor's position, that we should rotate around. + /// @param rotationOffset The positional offset to apply to our limb path. + /// @return Whether the LimbPath passed in could start free of terrain or not. bool PushAsLimb(const Vector& jointPos, const Vector& velocity, const Matrix& rotation, LimbPath& limbPath, const float travelTime, bool* restarted = nullptr, bool affectRotation = true, Vector rotationOffset = Vector(), Vector positionOffset = Vector()); - /// /// Makes this AtomGroup travel as a lifeless limb, constrained to a radius around the joint pin in the center. - /// - /// A Vector with the world position of the owner MOSRotating. - /// A Vector with the rotated offset of the joint that this should flail around in a radius. - /// The radius/range of the limb this is to simulate. - /// A Vector with the velocity of the owning MOSRotating. - /// A float with the angular velocity in rad/sec of the owning MOSRotating. - /// The mass of this dead weight limb. - /// The amount of time in seconds that this AtomGroup is supposed to travel. + /// @param ownerPos A Vector with the world position of the owner MOSRotating. + /// @param jointOffset A Vector with the rotated offset of the joint that this should flail around in a radius. + /// @param limbRadius The radius/range of the limb this is to simulate. + /// @param velocity A Vector with the velocity of the owning MOSRotating. + /// @param angularVel A float with the angular velocity in rad/sec of the owning MOSRotating. + /// @param mass The mass of this dead weight limb. + /// @param travelTime The amount of time in seconds that this AtomGroup is supposed to travel. void FlailAsLimb(const Vector& ownerPos, const Vector& jointOffset, const float limbRadius, const Vector& velocity, const float angularVel, const float mass, const float travelTime); #pragma endregion #pragma region Collision - /// /// Adds a MOID that this AtomGroup should ignore collisions with during its next Travel sequence. - /// - /// The MOID to add to the ignore list. + /// @param moidToIgnore The MOID to add to the ignore list. void AddMOIDToIgnore(MOID moidToIgnore) { m_IgnoreMOIDs.push_back(moidToIgnore); } - /// /// Checks whether this AtomGroup is set to ignore collisions with a MOSR of a specific MOID. - /// - /// The MOID to check if it is ignored. - /// Whether or not this MOID is being ignored. + /// @param whichMOID The MOID to check if it is ignored. + /// @return Whether or not this MOID is being ignored. bool IsIgnoringMOID(MOID whichMOID) { return (*(m_Atoms.begin()))->IsIgnoringMOID(whichMOID); } - /// /// Clears the list of MOIDs that this AtomGroup is set to ignore collisions with during its next Travel sequence. /// This should be done each frame so that fresh MOIDs can be re-added. (MOIDs are only valid during a frame). - /// void ClearMOIDIgnoreList() { m_IgnoreMOIDs.clear(); } - /// /// Gets whether any of the Atoms in this AtomGroup are on top of terrain pixels. - /// - /// Whether any Atom of this AtomGroup is on top of a terrain pixel. + /// @return Whether any Atom of this AtomGroup is on top of a terrain pixel. bool InTerrain() const; - /// /// Gets the ratio of how many Atoms of this AtomGroup are on top of intact terrain pixels. - /// - /// The ratio of Atoms on top of terrain pixels, from 0 to 1.0. + /// @return The ratio of Atoms on top of terrain pixels, from 0 to 1.0. float RatioInTerrain() const; - /// /// Checks whether any of the Atoms in this AtomGroup are on top of terrain pixels, and if so, attempt to move the OwnerMO out so none of the Atoms are inside any terrain pixels anymore. - /// - /// Current position of the owner MOSR. - /// Only attempt to move out of materials stronger than this specific ID. - /// Whether any intersection was successfully resolved. Will return true even if there wasn't any intersections to begin with. + /// @param position Current position of the owner MOSR. + /// @param strongerThan Only attempt to move out of materials stronger than this specific ID. + /// @return Whether any intersection was successfully resolved. Will return true even if there wasn't any intersections to begin with. bool ResolveTerrainIntersection(Vector& position, unsigned char strongerThan = 0) const; - /// /// Checks whether any of the Atoms in this AtomGroup are on top of MOSprites, and if so, attempt to move the OwnerMO out so none of the Atoms are inside the other MOSprite's silhouette anymore. - /// - /// Current position of the owner MOSR.> - /// Whether all intersections were successfully resolved. + /// @param position Current position of the owner MOSR. + /// @return Whether all intersections were successfully resolved. bool ResolveMOSIntersection(Vector& position); - /// /// Returns the surface area for a given pixel width. - /// - /// Our surface area. + /// @return Our surface area. float GetSurfaceArea(int pixelWidth) const; #pragma endregion #pragma region Debug - /// /// Draws this AtomGroup's current graphical debug representation to a BITMAP of choice. - /// - /// A pointer to a BITMAP to draw on. - /// The absolute position of the target bitmap's upper left corner in the Scene. - /// Whether to use the limb position of this AtomGroup, or the owner's position. - /// The color to draw the Atoms' pixels as. + /// @param targetBitmap A pointer to a BITMAP to draw on. + /// @param targetPos The absolute position of the target bitmap's upper left corner in the Scene. + /// @param useLimbPos Whether to use the limb position of this AtomGroup, or the owner's position. + /// @param color The color to draw the Atoms' pixels as. void Draw(BITMAP* targetBitmap, const Vector& targetPos, bool useLimbPos = false, unsigned char color = 34) const; #pragma endregion protected: - /// /// Enumeration for how the AtomGroup's area is distributed. Linear means it acts a 2D line whereas Circle/Square acts as a pseudo-3d circle/square. - /// enum class AreaDistributionType { Linear, Circle, @@ -410,12 +315,10 @@ namespace RTE { bool m_AutoGenerate; //!< Whether the Atoms in this AtomGroup were automatically generated based on a sprite, or manually defined. - /// /// The density of Atoms in this AtomGroup along the outline of the owning MOSR's graphical representation. Higher values mean more pixels are skipped along the outline when placing Atoms. /// For example: a box that is 20x20px will have an outline of 80px, with a resolution value of 10 an Atom will be placed every 10 pixels on this outline, resulting in an AtomGroup that /// consists of 8 Atoms total with 2 Atoms on each plane. Note that the outline isn't actually "unwrapped" and higher values may result in slightly less accurate Atom placement on complex sprites. /// 0 means the Atoms in this AtomGroup were defined manually. 1 means the whole outline will be populated with Atoms, resulting in the most accurate physical representation. - /// int m_Resolution; int m_Depth; //!< The depth Atoms in this AtomGroup are placed off the edge of the owning MOSR's graphical representation outline towards it's center, in pixels. @@ -433,26 +336,20 @@ namespace RTE { private: #pragma region Create Breakdown - /// /// Generates an AtomGroup using the owner MOSRotating's sprite outline. - /// - /// MOSRotating whose outline will be approximated by Atoms of this AtomGroup. + /// @param ownerMOSRotating MOSRotating whose outline will be approximated by Atoms of this AtomGroup. void GenerateAtomGroup(MOSRotating* ownerMOSRotating); - /// /// Create and add an Atom to this AtomGroup's list of Atoms. This is called during GenerateAtomGroup(). - /// - /// MOSRotating whose outline will be approximated by Atoms of this AtomGroup. - /// Sprite offset relative to the owner MOSRotating. - /// X coordinate in the sprite frame. - /// Y coordinate in the sprite frame. - /// Whether to set a normal for the Atom. Should be true for surface Atoms. + /// @param ownerMOSRotating MOSRotating whose outline will be approximated by Atoms of this AtomGroup. + /// @param spriteOffset Sprite offset relative to the owner MOSRotating. + /// @param x X coordinate in the sprite frame. + /// @param y Y coordinate in the sprite frame. + /// @param calcNormal Whether to set a normal for the Atom. Should be true for surface Atoms. void AddAtomToGroup(MOSRotating* ownerMOSRotating, const Vector& spriteOffset, int x, int y, bool calcNormal); #pragma endregion - /// /// Clears all the member variables of this AtomGroup, effectively resetting the members of this abstraction level only. - /// void Clear(); }; } // namespace RTE diff --git a/Source/Entities/Attachable.cpp b/Source/Entities/Attachable.cpp index c86309246b..1029c615cb 100644 --- a/Source/Entities/Attachable.cpp +++ b/Source/Entities/Attachable.cpp @@ -11,8 +11,6 @@ namespace RTE { ConcreteClassInfo(Attachable, MOSRotating, 0); - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void Attachable::Clear() { m_Parent = nullptr; m_ParentOffset.Reset(); @@ -53,8 +51,6 @@ namespace RTE { m_PreUpdateHasRunThisFrame = false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int Attachable::Create() { MOSRotating::Create(); @@ -63,8 +59,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int Attachable::Create(const Attachable& reference) { MOSRotating::Create(reference); @@ -107,8 +101,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int Attachable::ReadProperty(const std::string_view& propName, Reader& reader) { StartPropertyList(return MOSRotating::ReadProperty(propName, reader)); @@ -150,8 +142,6 @@ namespace RTE { EndPropertyList; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int Attachable::Save(Writer& writer) const { MOSRotating::Save(writer); @@ -182,8 +172,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool Attachable::TransferJointForces(Vector& jointForces) { if (!m_Parent) { return false; @@ -197,8 +185,6 @@ namespace RTE { return true; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool Attachable::TransferJointImpulses(Vector& jointImpulses, float jointStiffnessValueToUse, float jointStrengthValueToUse, float gibImpulseLimitValueToUse) { if (!m_Parent) { return false; @@ -250,8 +236,6 @@ namespace RTE { return true; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - float Attachable::CollectDamage() { if (m_DamageMultiplier != 0) { float totalDamage = m_DamageCount; @@ -268,8 +252,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void Attachable::SetCollidesWithTerrainWhileAttached(bool collidesWithTerrainWhileAttached) { if (m_CollidesWithTerrainWhileAttached != collidesWithTerrainWhileAttached) { bool previousTerrainCollisionValue = CanCollideWithTerrain(); @@ -281,8 +263,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool Attachable::CanCollideWithTerrain() const { if (m_CollidesWithTerrainWhileAttached && IsAttached() && GetParent() != GetRootParent()) { if (const Attachable* parentAsAttachable = dynamic_cast(GetParent())) { @@ -292,8 +272,6 @@ namespace RTE { return m_CollidesWithTerrainWhileAttached; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool Attachable::CollideAtPoint(HitData& hd) { if (m_IgnoresParticlesWhileAttached && m_Parent && !m_Parent->ToDelete() && !dynamic_cast(hd.Body[HITOR])) { return false; @@ -301,8 +279,6 @@ namespace RTE { return MOSRotating::CollideAtPoint(hd); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool Attachable::ParticlePenetration(HitData& hd) { bool penetrated = MOSRotating::ParticlePenetration(hd); @@ -334,8 +310,6 @@ namespace RTE { return penetrated; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void Attachable::GibThis(const Vector& impactImpulse, MovableObject* movableObjectToIgnore) { if (m_Parent) { m_Parent->RemoveAttachable(this, true, true); @@ -343,8 +317,6 @@ namespace RTE { MOSRotating::GibThis(impactImpulse, movableObjectToIgnore); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool Attachable::HandlePotentialRadiusAffectingAttachable(const Attachable* attachable) { if (MOSRotating::HandlePotentialRadiusAffectingAttachable(attachable)) { if (IsAttached()) { @@ -355,8 +327,6 @@ namespace RTE { return false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int Attachable::UpdateScripts() { if (m_Parent && !m_AllLoadedScripts.empty() && !ObjectScriptsInitialized()) { RunScriptedFunctionInAppropriateScripts("OnAttach", false, false, {m_Parent}, {}, {}); @@ -365,8 +335,6 @@ namespace RTE { return MOSRotating::UpdateScripts(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void Attachable::Update() { if (!m_PreUpdateHasRunThisFrame) { PreUpdate(); @@ -425,8 +393,6 @@ namespace RTE { m_PreUpdateHasRunThisFrame = false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void Attachable::PreUpdate() { if (!m_PreUpdateHasRunThisFrame) { if (m_Parent) { @@ -442,8 +408,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void Attachable::SetMass(const float newMass) { float currentMass = GetMass(); if (newMass != currentMass) { @@ -455,8 +419,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void Attachable::UpdateAttachableAndWoundMass(float oldAttachableOrWoundMass, float newAttachableOrWoundMass) { float previousMassForUpdatingParent = m_Parent ? GetMass() : 0.0F; MOSRotating::UpdateAttachableAndWoundMass(oldAttachableOrWoundMass, newAttachableOrWoundMass); @@ -465,8 +427,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void Attachable::AddAttachable(Attachable* attachable, const Vector& parentOffsetToSet) { float previousMassForUpdatingParent = m_Parent ? GetMass() : 0.0F; MOSRotating::AddAttachable(attachable, parentOffsetToSet); @@ -475,8 +435,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - Attachable* Attachable::RemoveAttachable(Attachable* attachable, bool addToMovableMan, bool addBreakWounds) { float previousMassForUpdatingParent = m_Parent ? GetMass() : 0.0F; Attachable* removedAttachable = MOSRotating::RemoveAttachable(attachable, addToMovableMan, addBreakWounds); @@ -486,8 +444,6 @@ namespace RTE { return removedAttachable; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void Attachable::AddWound(AEmitter* woundToAdd, const Vector& parentOffsetToSet, bool checkGibWoundLimit) { float previousMassForUpdatingParent = m_Parent ? GetMass() : 0.0F; MOSRotating::AddWound(woundToAdd, parentOffsetToSet, checkGibWoundLimit); @@ -496,8 +452,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - float Attachable::RemoveWounds(int numberOfWoundsToRemove, bool includeAttachablesWithAPositiveDamageMultiplier, bool includeAttachablesWithANegativeDamageMultiplier, bool includeAttachablesWithNoDamageMultiplier) { float previousMassForUpdatingParent = m_Parent ? GetMass() : 0.0F; float result = MOSRotating::RemoveWounds(numberOfWoundsToRemove, includeAttachablesWithAPositiveDamageMultiplier, includeAttachablesWithANegativeDamageMultiplier, includeAttachablesWithNoDamageMultiplier); @@ -507,8 +461,6 @@ namespace RTE { return result; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void Attachable::SetParent(MOSRotating* newParent) { if (newParent == m_Parent) { return; @@ -580,8 +532,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void Attachable::UpdatePositionAndJointPositionBasedOnOffsets() { if (m_Parent) { m_JointPos = m_Parent->GetPos() + m_Parent->RotateOffset(GetParentOffset()); @@ -592,8 +542,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void Attachable::AddOrRemoveAtomsFromRootParentAtomGroup(bool addAtoms, bool propagateToChildAttachables) { if (IsAttached()) { MOSRotating* rootParentAsMOSR = dynamic_cast(GetRootParent()); @@ -619,8 +567,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void Attachable::AddOrRemovePieSlicesAndListenersFromPieMenu(PieMenu* pieMenuToModify, bool addToPieMenu) { RTEAssert(pieMenuToModify, "Cannot add or remove Attachable PieSlices and listeners from a non-existant PieMenu."); if (addToPieMenu) { diff --git a/Source/Entities/Attachable.h b/Source/Entities/Attachable.h index 141265e425..a254782352 100644 --- a/Source/Entities/Attachable.h +++ b/Source/Entities/Attachable.h @@ -8,9 +8,7 @@ namespace RTE { class AEmitter; - /// /// An articulated, detachable part of an Actor's body. - /// class Attachable : public MOSRotating { friend class MOSRotating; @@ -21,35 +19,25 @@ namespace RTE { ClassInfoGetters; #pragma region Creation - /// /// Constructor method used to instantiate a Attachable object in system memory. Create() should be called before using the object. - /// Attachable() { Clear(); } - /// /// Makes the Attachable object ready for use. - /// - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create() override; - /// /// Creates an Attachable to be identical to another, by deep copy. - /// - /// A reference to the Attachable to deep copy. - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @param reference A reference to the Attachable to deep copy. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create(const Attachable& reference); #pragma endregion #pragma region Destruction - /// /// Destructor method used to clean up an Attachable object before deletion from system memory. - /// ~Attachable() override { Destroy(true); } - /// /// Destroys and resets (through Clear()) the Attachable object. - /// - /// Whether to only destroy the members defined in this derived class, or to destroy all inherited members also. + /// @param notInherited Whether to only destroy the members defined in this derived class, or to destroy all inherited members also. void Destroy(bool notInherited = false) override { if (!notInherited) { MOSRotating::Destroy(); @@ -57,9 +45,7 @@ namespace RTE { Clear(); } - /// /// Resets the entire Attachable, including its inherited members, to their default settings or values. - /// void Reset() override { Clear(); MOSRotating::Reset(); @@ -67,502 +53,357 @@ namespace RTE { #pragma endregion #pragma region Parent Getters and Setters - /// /// Gets the MOSRotating which is the parent of this Attachable. - /// - /// A pointer to the parent of this Attachable. + /// @return A pointer to the parent of this Attachable. MOSRotating* GetParent() override { return m_Parent; } - /// /// Gets the MOSRotating which is the parent of this Attachable. - /// - /// A pointer to the parent of this Attachable. + /// @return A pointer to the parent of this Attachable. const MOSRotating* GetParent() const override { return m_Parent; } - /// /// Indicates whether this Attachable is attached to an MOSRotating parent or not. - /// - /// Whether it's attached or not. + /// @return Whether it's attached or not. bool IsAttached() const { return m_Parent != nullptr; } - /// /// Indicates whether this Attachable is attached to the specified MOSRotating or not. - /// - /// A pointer to which MOSRotating you want to check for. - /// Whether it's attached or not. + /// @param parentToCheck A pointer to which MOSRotating you want to check for. + /// @return Whether it's attached or not. bool IsAttachedTo(const MOSRotating* parentToCheck) const { return m_Parent == parentToCheck; } - /// /// Gets the MO which is the ultimate root parent of this Attachable and its parent. - /// - /// A pointer to the highest root parent of this Attachable. + /// @return A pointer to the highest root parent of this Attachable. MovableObject* GetRootParent() override { return m_Parent ? m_Parent->GetRootParent() : this; } - /// /// Gets the MO which is the ultimate root parent of this Attachable and its parent. - /// - /// A pointer to the highest root parent of this Attachable. + /// @return A pointer to the highest root parent of this Attachable. const MovableObject* GetRootParent() const override { return m_Parent ? m_Parent->GetRootParent() : this; } - /// /// Gets the stored offset between this Attachable's parent's position and the joint position. This should be maintained by the parent. - /// - /// A const reference Vector describing the offset from the parent's position to the joint position. + /// @return A const reference Vector describing the offset from the parent's position to the joint position. const Vector& GetParentOffset() const { return m_ParentOffset; } - /// /// Sets the stored offset between this Attachable's parent's Pos and the joint position. This should be maintained by the parent. - /// - /// A const reference to the new parent offset. + /// @param newParentOffset A const reference to the new parent offset. void SetParentOffset(const Vector& newParentOffset) { m_ParentOffset = newParentOffset; } - /// /// Gets whether this Attachable is to be drawn after (in front of) or before (behind) its parent. - /// - /// Whether this Attachable is to be drawn after its parent or not. + /// @return Whether this Attachable is to be drawn after its parent or not. bool IsDrawnAfterParent() const override { return m_DrawAfterParent; } - /// /// Sets whether this Attachable is to be drawn after (in front of) or before (behind) its parent. - /// - /// Whether this Attachable is to be drawn after its parent. + /// @param drawAfterParent Whether this Attachable is to be drawn after its parent. void SetDrawnAfterParent(bool drawAfterParent) { m_DrawAfterParent = drawAfterParent; } - /// /// Gets whether this Attachable should be drawn normally by its parent. /// Some attachables (e.g. AEmitter flashes) require custom handling for when they should or shouldn't draw, to be done by the specific parent class. - /// - /// Whether this Attachable should be drawn normally by its parent. + /// @return Whether this Attachable should be drawn normally by its parent. bool IsDrawnNormallyByParent() const { return m_DrawnNormallyByParent; } - /// /// Sets whether this Attachable should be drawn normally by its parent. /// Some attachables (e.g. AEmitter flashes) require custom handling for when they should or shouldn't draw, to be done by the specific parent class. - /// - /// Whether this Attachable should be drawn normally by its parent. + /// @param drawnNormallyByParent Whether this Attachable should be drawn normally by its parent. void SetDrawnNormallyByParent(bool drawnNormallyByParent) { m_DrawnNormallyByParent = drawnNormallyByParent; } - /// /// Gets whether this Attachable will be deleted when removed from its parent. Has no effect until the Attachable has been added to a parent. - /// - /// Whether this Attachable is marked to be deleted when removed from its parent or not. + /// @return Whether this Attachable is marked to be deleted when removed from its parent or not. bool GetDeleteWhenRemovedFromParent() const { return m_DeleteWhenRemovedFromParent; } - /// /// Sets whether this Attachable will be deleted when removed from its parent. - /// - /// Whether this Attachable should be deleted when removed from its parent. + /// @param deleteWhenRemovedFromParent Whether this Attachable should be deleted when removed from its parent. void SetDeleteWhenRemovedFromParent(bool deleteWhenRemovedFromParent) { m_DeleteWhenRemovedFromParent = deleteWhenRemovedFromParent; } - /// /// Gets whether this Attachable will gib when removed from its parent. Has no effect until the Attachable has been added to a parent. - /// - /// Whether this Attachable is marked to gib when removed from its parent or not. + /// @return Whether this Attachable is marked to gib when removed from its parent or not. bool GetGibWhenRemovedFromParent() const { return m_GibWhenRemovedFromParent; } - /// /// Sets whether this Attachable will gib when removed from its parent. - /// - /// Whether this Attachable should gib when removed from its parent. + /// @param gibWhenRemovedFromParent Whether this Attachable should gib when removed from its parent. void SetGibWhenRemovedFromParent(bool gibWhenRemovedFromParent) { m_GibWhenRemovedFromParent = gibWhenRemovedFromParent; } - /// /// Gets whether forces transferred from this Attachable should be applied at its parent's offset (rotated to match the parent) where they will produce torque, or directly at its parent's position. - /// - /// Whether forces transferred from this Attachable should be applied at an offset. + /// @return Whether forces transferred from this Attachable should be applied at an offset. bool GetApplyTransferredForcesAtOffset() const { return m_ApplyTransferredForcesAtOffset; } - /// /// Sets whether forces transferred from this Attachable should be applied at its parent's offset (rotated to match the parent) where they will produce torque, or directly at its parent's position. - /// - /// Whether forces transferred from this Attachable should be applied at an offset. + /// @param appliesTransferredForcesAtOffset Whether forces transferred from this Attachable should be applied at an offset. void SetApplyTransferredForcesAtOffset(bool appliesTransferredForcesAtOffset) { m_ApplyTransferredForcesAtOffset = appliesTransferredForcesAtOffset; } #pragma endregion #pragma region Parent Gib Handling Getters and Setters - /// /// Gets the percentage chance that this Attachable will gib when its parent does. 0 means never, 1 means always. - /// - /// A float with the percentage chance this Attachable will gib when its parent gibs. + /// @return A float with the percentage chance this Attachable will gib when its parent gibs. float GetGibWithParentChance() const { return m_GibWithParentChance; } - /// /// Sets the percentage chance that this Attachable will gib when its parent does. 0 means never, 1 means always. - /// - /// A float describing the percentage chance this Attachable will gib when its parent gibs. + /// @param gibWithParentChance A float describing the percentage chance this Attachable will gib when its parent gibs. void SetGibWithParentChance(float gibWithParentChance) { m_GibWithParentChance = gibWithParentChance; } - /// /// Gets the multiplier for how strongly this Attachable's parent's gib blast strength will be applied to it when its parent's gibs - /// - /// A float with the parent gib blast strength multiplier of this Attachable. + /// @return A float with the parent gib blast strength multiplier of this Attachable. float GetParentGibBlastStrengthMultiplier() const { return m_ParentGibBlastStrengthMultiplier; } - /// /// Sets the multiplier for how strongly this Attachable's parent's gib blast strength will be applied to it when its parent's gibs - /// - /// A float describing the parent gib blast strength multiplier of this Attachable. + /// @param parentGibBlastStrengthMultiplier A float describing the parent gib blast strength multiplier of this Attachable. void SetParentGibBlastStrengthMultiplier(float parentGibBlastStrengthMultiplier) { m_ParentGibBlastStrengthMultiplier = parentGibBlastStrengthMultiplier; } #pragma endregion #pragma region Temporary Handling for Wounds, to be Replaced by a Wound Object in Future - /// /// Gets whether or not this Attachable is a wound, as determined by its parent MOSR. - /// - /// Whether or not this Attachable is a wound. + /// @return Whether or not this Attachable is a wound. bool IsWound() const { return m_IsWound; } - /// /// Sets whether or not this Attachable is a wound, to be done by its parent MOSR. - /// - /// Whether or not this Attachable should be a wound. + /// @param isWound Whether or not this Attachable should be a wound. void SetIsWound(bool isWound) { m_IsWound = isWound; } #pragma endregion #pragma region Joint Getters and Setters - /// /// Gets the amount of impulse force the joint of this Attachable can handle before breaking. - /// - /// A float with the max tolerated impulse force in kg * m/s. + /// @return A float with the max tolerated impulse force in kg * m/s. float GetJointStrength() const { return m_JointStrength; } - /// /// Sets the amount of impulse force the joint of this Attachable can handle before breaking. - /// - /// A float describing the max tolerated impulse force in Newtons (kg * m/s). + /// @param jointStrength A float describing the max tolerated impulse force in Newtons (kg * m/s). void SetJointStrength(float jointStrength) { m_JointStrength = jointStrength; } - /// /// Gets the stiffness scalar of the joint of this Attachable, normalized between 0 and 1.0. /// 1.0 means impulse forces on this attachable will be transferred to the parent with 100% strength, 0 means they will not transfer at all. - /// - /// The normalized stiffness scalar of this Attachable's joint. + /// @return The normalized stiffness scalar of this Attachable's joint. float GetJointStiffness() const { return m_JointStiffness; } - /// /// Sets the stiffness scalar of the joint of this Attachable, limited between 0 and 1.0. /// 1.0 means impulse forces on this attachable will be transferred to the parent with 100% strength, 0 means they will not transfer at all. - /// - /// A float describing the normalized stiffness scalar of this Attachable's joint. It will automatically be limited between 0 and 1.0. + /// @param jointStiffness A float describing the normalized stiffness scalar of this Attachable's joint. It will automatically be limited between 0 and 1.0. virtual void SetJointStiffness(float jointStiffness) { m_JointStiffness = std::clamp(jointStiffness, 0.0F, 1.0F); } - /// /// Gets the offset of the joint (the point around which this Attachable and its parent hinge) from this Attachable's center of mass/origin. - /// - /// A const reference Vector describing the offset of the joint relative to this Attachable's origin/center of mass position. + /// @return A const reference Vector describing the offset of the joint relative to this Attachable's origin/center of mass position. const Vector& GetJointOffset() const { return m_JointOffset; } - /// /// Sets the offset of the joint (the point around which this Attachable and its parent hinge) from this Attachable's center of mass/origin. - /// - /// A Vector describing the offset of the joint relative to the this Attachable's origin/center of mass position. + /// @param newJointOffset A Vector describing the offset of the joint relative to the this Attachable's origin/center of mass position. void SetJointOffset(const Vector& newJointOffset) { m_JointOffset = newJointOffset; } - /// /// Gets the absolute position of the joint that the parent of this Attachable sets upon Update(). - /// - /// A Vector describing the current absolute position of the joint. + /// @return A Vector describing the current absolute position of the joint. const Vector& GetJointPos() const { return m_JointPos; } #pragma endregion #pragma region Force Transferral - /// /// Bundles up all the accumulated forces of this Attachable and calculates how they transfer to the joint, and therefore to the parent. /// If the accumulated forces exceed the joint strength of this Attachable, the jointForces Vector will be filled to the limit and false will be returned. /// Additionally, in this case, the Attachable will remove itself from its parent. - /// - /// A vector that will have the forces affecting the joint ADDED to it. - /// False if the Attachable has no parent or its accumulated forces are greater than its joint strength, otherwise true. + /// @param jointForces A vector that will have the forces affecting the joint ADDED to it. + /// @return False if the Attachable has no parent or its accumulated forces are greater than its joint strength, otherwise true. bool TransferJointForces(Vector& jointForces); - /// /// Bundles up all the accumulated impulse forces of this Attachable and calculates how they transfer to the joint, and therefore to the parent. /// If the accumulated impulse forces exceed the joint strength or gib impulse limit of this Attachable, the jointImpulses Vector will be filled up to that limit and false will be returned. /// Additionally, in this case, the Attachable will remove itself from its parent and gib itself if appropriate. - /// - /// A vector that will have the impulse forces affecting the joint ADDED to it. - /// An optional override for the Attachable's joint stiffness for this function call. Primarily used to allow subclasses to perform special behavior. - /// An optional override for the Attachable's joint strength for this function call. Primarily used to allow subclasses to perform special behavior. - /// An optional override for the Attachable's gib impulse limit for this function call. Primarily used to allow subclasses to perform special behavior. - /// False if the Attachable has no parent or its accumulated forces are greater than its joint strength or gib impulse limit, otherwise true. + /// @param jointImpulses A vector that will have the impulse forces affecting the joint ADDED to it. + /// @param jointStiffnessValueToUse An optional override for the Attachable's joint stiffness for this function call. Primarily used to allow subclasses to perform special behavior. + /// @param jointStrengthValueToUse An optional override for the Attachable's joint strength for this function call. Primarily used to allow subclasses to perform special behavior. + /// @param gibImpulseLimitValueToUse An optional override for the Attachable's gib impulse limit for this function call. Primarily used to allow subclasses to perform special behavior. + /// @return False if the Attachable has no parent or its accumulated forces are greater than its joint strength or gib impulse limit, otherwise true. virtual bool TransferJointImpulses(Vector& jointImpulses, float jointStiffnessValueToUse = -1, float jointStrengthValueToUse = -1, float gibImpulseLimitValueToUse = -1); #pragma endregion #pragma region Damage and Wound Management - /// /// Adds the specified number of damage points to this attachable. - /// - /// The amount of damage to add. + /// @param damageAmount The amount of damage to add. void AddDamage(float damageAmount) { m_DamageCount += damageAmount; } - /// /// Calculates the amount of damage this Attachable has sustained since the last time this method was called and returns it, modified by the Attachable's damage multiplier. /// This should normally be called AFTER updating this Attachable in order to get the correct damage for a given frame. - /// - /// A float with the damage accumulated, multiplied by the Attachable's damage multiplier, since the last time this method was called. + /// @return A float with the damage accumulated, multiplied by the Attachable's damage multiplier, since the last time this method was called. float CollectDamage(); - /// /// Gets the AEmitter that represents the wound added to this Attachable when it gets detached from its parent. OWNERSHIP IS NOT TRANSFERRED! - /// - /// A const pointer to the break wound AEmitter. + /// @return A const pointer to the break wound AEmitter. const AEmitter* GetBreakWound() const { return m_BreakWound; } - /// /// Sets the AEmitter that represents the wound added to this Attachable when it gets detached from its parent. OWNERSHIP IS NOT TRANSFERRED! - /// - /// The AEmitter to use for this Attachable's breakwound. + /// @param breakWound The AEmitter to use for this Attachable's breakwound. void SetBreakWound(AEmitter* breakWound) { m_BreakWound = breakWound; } - /// /// Gets the AEmitter that represents the wound added to this Attachable's parent when this Attachable gets detached from its parent. OWNERSHIP IS NOT TRANSFERRED! - /// - /// A const pointer to the parent break wound AEmitter. + /// @return A const pointer to the parent break wound AEmitter. const AEmitter* GetParentBreakWound() const { return m_ParentBreakWound; } - /// /// Sets the AEmitter that represents the wound added to this Attachable's parent when this Attachable gets detached from its parent. OWNERSHIP IS NOT TRANSFERRED! - /// - /// The AEmitter to use for the parent's breakwound. + /// @param breakWound The AEmitter to use for the parent's breakwound. void SetParentBreakWound(AEmitter* breakWound) { m_ParentBreakWound = breakWound; } #pragma endregion #pragma region Inherited Value Getters and Setters - /// /// Gets whether or not this Attachable inherits its parent's HFlipped value, i.e. whether it has its HFlipped value reset to match/reverse its parent's every frame, if attached. /// 0 means no inheritance, 1 means normal inheritance, anything else means reversed inheritance (i.e. if the parent's HFlipped value is true, this Attachable's HFlipped value will be false). - /// - /// Whether or not this Attachable inherits its parent's HFlipped value. + /// @return Whether or not this Attachable inherits its parent's HFlipped value. int InheritsHFlipped() const { return m_InheritsHFlipped; } - /// /// Sets whether or not this Attachable inherits its parent's HFlipped value, i.e. whether it has its HFlipped value reset to match/reverse its parent's every frame, if attached. /// 0 means no inheritance, 1 means normal inheritance, anything else means reversed inheritance (i.e. if the parent's HFlipped value is true, this Attachable's HFlipped value will be false). - /// - /// Whether or not to inherit its parent's HFlipped value. + /// @param inheritsRotAngle Whether or not to inherit its parent's HFlipped value. void SetInheritsHFlipped(int inheritsHFlipped) { m_InheritsHFlipped = inheritsHFlipped; } - /// /// Gets whether or not this Attachable inherits its RotAngle from its parent, i.e. whether it has its RotAngle reset to match its parent every frame, if attached. - /// - /// Whether or not this Attachable inherits its parent's RotAngle. + /// @return Whether or not this Attachable inherits its parent's RotAngle. bool InheritsRotAngle() const { return m_InheritsRotAngle; } - /// /// Sets whether or not this Attachable inherits its RotAngle from its parent, i.e. whether it has its RotAngle reset to match its parent every frame, if attached. - /// - /// Whether or not to inherit its parent's RotAngle. + /// @param inheritsRotAngle Whether or not to inherit its parent's RotAngle. void SetInheritsRotAngle(bool inheritsRotAngle) { m_InheritsRotAngle = inheritsRotAngle; } - /// /// Gets the offset of this Attachable's rotation angle from its parent. Only actually applied if the Attachable is set to inherit its parent's rotation angle. - /// - /// This Attachable's inherited rotation angle offset. + /// @return This Attachable's inherited rotation angle offset. float GetInheritedRotAngleOffset() const { return m_InheritedRotAngleOffset; } - /// /// Sets the offset of this Attachable's rotation angle from its parent. Only actually applied if the Attachable is set to inherit its parent's rotation angle. - /// - /// Thee new rotation angle offset for this Attachable. + /// @param inheritedRotAngleOffset Thee new rotation angle offset for this Attachable. void SetInheritedRotAngleOffset(float inheritedRotAngleOffset) { m_InheritedRotAngleOffset = inheritedRotAngleOffset; } - /// /// Gets whether or not this Attachable inherits its Frame from its parent, if attached. - /// - /// Whether or not this Attachable inherits its parent's Frame. + /// @return Whether or not this Attachable inherits its parent's Frame. bool InheritsFrame() const { return m_InheritsFrame; } - /// /// Sets whether or not this Attachable inherits its Frame from its parent, if attached. - /// - /// Whether or not to inherit its parent's Frame. + /// @param inheritsFrame Whether or not to inherit its parent's Frame. void SetInheritsFrame(bool inheritsFrame) { m_InheritsFrame = inheritsFrame; } #pragma endregion #pragma region Collision Management - /// /// Gets the subgroup ID of this' Atoms. - /// - /// The subgroup ID of this' Atoms. + /// @return The subgroup ID of this' Atoms. long GetAtomSubgroupID() const { return m_AtomSubgroupID; } - /// /// Sets the subgroup ID of this' Atoms - /// - /// A long describing the new subgroup id of this' Atoms. + /// @param newID A long describing the new subgroup id of this' Atoms. void SetAtomSubgroupID(long subgroupID = 0) { m_AtomSubgroupID = subgroupID; } - /// /// Gets whether this Attachable currently has terrain collisions enabled and it's atoms are present in the parent AtomGroup. /// Attachables with Attachable parents that don't collide with terrain will not collide with terrain. This chains up to the root parent. - /// - /// If true, terrain collisions while attached are enabled and atoms are present in parent AtomGroup. + /// @return If true, terrain collisions while attached are enabled and atoms are present in parent AtomGroup. bool GetCollidesWithTerrainWhileAttached() const { return m_CollidesWithTerrainWhileAttached; } - /// /// Sets whether this Attachable currently has terrain collisions enabled and it's atoms are present in the parent AtomGroup. - /// - /// Whether this attachable currently has terrain collisions enabled and it's atoms are present in the parent AtomGroup. + /// @param collidesWithTerrainWhileAttached Whether this attachable currently has terrain collisions enabled and it's atoms are present in the parent AtomGroup. void SetCollidesWithTerrainWhileAttached(bool collidesWithTerrainWhileAttached); - /// /// Gets whether this Attachable is currently able to collide with terrain, taking into account its terrain collision settings and those of its parent and so on. - /// - /// Whether this Attachable is currently able to collide with terrain, taking into account its terrain collision settings and those of its parent and so on. + /// @return Whether this Attachable is currently able to collide with terrain, taking into account its terrain collision settings and those of its parent and so on. bool CanCollideWithTerrain() const; - /// /// Gets whether this Attachable currently ignores collisions with single-atom particles. - /// - /// >Whether this attachable ignores collisions with single-atom particles. + /// @return >Whether this attachable ignores collisions with single-atom particles. bool GetIgnoresParticlesWhileAttached() const { return m_IgnoresParticlesWhileAttached; } - /// /// Sets whether this Attachable currently ignores collisions with single-atom particles. - /// - /// Whether this attachable ignores collisions with single-atom particles. + /// @param collidesWithTerrainWhileAttached Whether this attachable ignores collisions with single-atom particles. void SetIgnoresParticlesWhileAttached(bool ignoresParticlesWhileAttached) { m_IgnoresParticlesWhileAttached = ignoresParticlesWhileAttached; } #pragma endregion #pragma region Override Methods - /// /// Calculates the collision response when another MO's Atom collides with this MO's physical representation. /// The effects will be applied directly to this MO, and also represented in the passed in HitData. - /// - /// Reference to the HitData struct which describes the collision. This will be modified to represent the results of the collision. - /// Whether the collision has been deemed valid. If false, then disregard any impulses in the HitData. + /// @param hitData Reference to the HitData struct which describes the collision. This will be modified to represent the results of the collision. + /// @return Whether the collision has been deemed valid. If false, then disregard any impulses in the HitData. bool CollideAtPoint(HitData& hitData) override; - /// /// Determines whether a particle which has hit this MO will penetrate, and if so, whether it gets lodged or exits on the other side of this MO. /// Appropriate effects will be determined and applied ONLY IF there was penetration! If not, nothing will be affected. - /// - /// The HitData describing the collision in detail, the impulses have to have been filled out! - /// + /// @param hitData The HitData describing the collision in detail, the impulses have to have been filled out! + /// @return /// Whether the particle managed to penetrate into this MO or not. /// If something other than an MOPixel or MOSParticle is being passed in as the hitor, false will trivially be returned here. - /// bool ParticlePenetration(HitData& hitData) override; - /// /// Destroys this Attachable and creates its specified Gibs in its place with appropriate velocities. /// Any Attachables are removed and also given appropriate velocities. - /// - /// The impulse (kg * m/s) of the impact causing the gibbing to happen. - /// A pointer to an MO which the Gibs and Attachables should not be colliding with. + /// @param impactImpulse The impulse (kg * m/s) of the impact causing the gibbing to happen. + /// @param movableObjectToIgnore A pointer to an MO which the Gibs and Attachables should not be colliding with. void GibThis(const Vector& impactImpulse = Vector(), MovableObject* movableObjectToIgnore = nullptr) override; - /// /// Checks if the given Attachable should affect radius, and handles it if it should. - /// - /// The Attachable to check. - /// Whether the radius affecting Attachable changed as a result of this call. + /// @param attachable The Attachable to check. + /// @return Whether the radius affecting Attachable changed as a result of this call. bool HandlePotentialRadiusAffectingAttachable(const Attachable* attachable) override; - /// /// Updates this Attachable's Lua scripts. - /// - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int UpdateScripts() override; - /// /// Updates this Attachable. Supposed to be done every frame. /// NOTE - Attachable subclasses that do things before calling Attachable::Update should make sure to call Attachable::PreUpdate. - /// void Update() override; #pragma endregion - /// /// Pre-update method that should be run by all Attachable sub-classes that do things before calling Attachable::Update. - /// void PreUpdate(); #pragma region Override Methods for Handling Mass - /// /// Sets the mass of this Attachable. - /// - /// A float specifying the new mass value in Kilograms (kg). + /// @param newMass A float specifying the new mass value in Kilograms (kg). void SetMass(const float newMass) final; - /// /// Updates the total mass of Attachables and wounds for this Attachable, intended to be used when Attachables' masses get modified. Simply subtracts the old mass and adds the new one. - /// - /// The mass the Attachable or wound had before its mass was modified. - /// The up-to-date mass of the Attachable or wound after its mass was modified. + /// @param oldAttachableOrWoundMass The mass the Attachable or wound had before its mass was modified. + /// @param newAttachableOrWoundMass The up-to-date mass of the Attachable or wound after its mass was modified. void UpdateAttachableAndWoundMass(float oldAttachableOrWoundMass, float newAttachableOrWoundMass) final; - /// /// Adds the passed in Attachable the list of Attachables and sets its parent to this Attachable. - /// - /// The Attachable to add. + /// @param attachable The Attachable to add. void AddAttachable(Attachable* attachable) final { MOSRotating::AddAttachable(attachable); } - /// /// Adds the passed in Attachable the list of Attachables, changes its parent offset to the passed in Vector, and sets its parent to this Attachable. - /// - /// The Attachable to add. - /// The Vector to set as the Attachable's parent offset. + /// @param attachable The Attachable to add. + /// @param parentOffsetToSet The Vector to set as the Attachable's parent offset. void AddAttachable(Attachable* attachable, const Vector& parentOffsetToSet) final; - /// /// Removes the Attachable corresponding to the passed in UniqueID and sets its parent to nullptr. Does not add it to MovableMan or add break wounds. - /// - /// The UniqueID of the Attachable to remove. - /// A pointer to the removed Attachable. Ownership IS transferred! + /// @param attachableUniqueID The UniqueID of the Attachable to remove. + /// @return A pointer to the removed Attachable. Ownership IS transferred! Attachable* RemoveAttachable(long attachableUniqueID) final { return MOSRotating::RemoveAttachable(attachableUniqueID); } - /// /// Removes the Attachable corresponding to the passed in UniqueID and sets its parent to nullptr. Optionally adds it to MovableMan and/or adds break wounds. /// If the Attachable is not set to delete or delete when removed from its parent, and addToMovableMan is false, the caller must hang onto a pointer to the Attachable ahead of time to avoid memory leaks. - /// - /// The UniqueID of the Attachable to remove. - /// Whether or not to add the Attachable to MovableMan once it has been removed. - /// Whether or not to add break wounds to the removed Attachable and this Attachable. - /// A pointer to the removed Attachable, if it wasn't added to MovableMan or nullptr if it was. Ownership IS transferred! + /// @param attachableUniqueID The UniqueID of the Attachable to remove. + /// @param addToMovableMan Whether or not to add the Attachable to MovableMan once it has been removed. + /// @param addBreakWounds Whether or not to add break wounds to the removed Attachable and this Attachable. + /// @return A pointer to the removed Attachable, if it wasn't added to MovableMan or nullptr if it was. Ownership IS transferred! Attachable* RemoveAttachable(long attachableUniqueID, bool addToMovableMan, bool addBreakWounds) final { return MOSRotating::RemoveAttachable(attachableUniqueID, addToMovableMan, addBreakWounds); } - /// /// Removes the passed in Attachable and sets its parent to nullptr. Does not add it to MovableMan or add break wounds. - /// - /// The Attachable to remove. - /// A pointer to the removed Attachable. Ownership IS transferred! + /// @param attachable The Attachable to remove. + /// @return A pointer to the removed Attachable. Ownership IS transferred! Attachable* RemoveAttachable(Attachable* attachable) final { return MOSRotating::RemoveAttachable(attachable); } - /// /// Removes the passed in Attachable and sets its parent to nullptr. Optionally adds it to MovableMan and/or adds break wounds. /// If the Attachable is not set to delete or delete when removed from its parent, and addToMovableMan is false, the caller must hang onto a pointer to the Attachable ahead of time to avoid memory leaks. - /// - /// The Attachable to remove. - /// Whether or not to add the Attachable to MovableMan once it has been removed. - /// Whether or not to add break wounds to the removed Attachable and this Attachable. - /// A pointer to the removed Attachable, if it wasn't added to MovableMan or nullptr if it was. Ownership IS transferred! + /// @param attachable The Attachable to remove. + /// @param addToMovableMan Whether or not to add the Attachable to MovableMan once it has been removed. + /// @param addBreakWounds Whether or not to add break wounds to the removed Attachable and this Attachable. + /// @return A pointer to the removed Attachable, if it wasn't added to MovableMan or nullptr if it was. Ownership IS transferred! Attachable* RemoveAttachable(Attachable* attachable, bool addToMovableMan, bool addBreakWounds) final; - /// /// Adds the passed in wound AEmitter to the list of wounds and changes its parent offset to the passed in Vector. - /// - /// The wound AEmitter to add. - /// The vector to set as the wound AEmitter's parent offset. - /// Whether to gib this Attachable if adding this wound raises its wound count past its gib wound limit. Defaults to true. + /// @param woundToAdd The wound AEmitter to add. + /// @param parentOffsetToSet The vector to set as the wound AEmitter's parent offset. + /// @param checkGibWoundLimit Whether to gib this Attachable if adding this wound raises its wound count past its gib wound limit. Defaults to true. void AddWound(AEmitter* woundToAdd, const Vector& parentOffsetToSet, bool checkGibWoundLimit = true) final; - /// /// Removes the specified number of wounds from this Attachable, and returns damage caused by these removed wounds. /// Includes any Attachables (and their Attachables, etc.) that have a positive damage multiplier. - /// - /// The number of wounds that should be removed. - /// The amount of damage caused by these wounds, taking damage multipliers into account. + /// @param numberOfWoundsToRemove The number of wounds that should be removed. + /// @return The amount of damage caused by these wounds, taking damage multipliers into account. float RemoveWounds(int numberOfWoundsToRemove) final { return MOSRotating::RemoveWounds(numberOfWoundsToRemove); } - /// /// Removes the specified number of wounds from this Attachable, and returns damage caused by these removed wounds. /// Optionally removes wounds from Attachables (and their Attachables, etc.) that match the conditions set by the provided inclusion parameters. - /// - /// The number of wounds that should be removed. - /// Whether to count wounds from Attachables that have a positive damage multiplier, i.e. those that damage their parent (this Attachable) when wounded. - /// Whether to count wounds from Attachables that have a negative damage multiplier, i.e. those that heal their parent (this Attachable) when wounded. - /// Whether to count wounds from Attachables that a zero damage multiplier, i.e. those that do not affect their parent (this Attachable) when wounded. - /// The amount of damage caused by these wounds, taking damage multipliers into account. + /// @param numberOfWoundsToRemove The number of wounds that should be removed. + /// @param includePositiveDamageAttachables Whether to count wounds from Attachables that have a positive damage multiplier, i.e. those that damage their parent (this Attachable) when wounded. + /// @param includeNegativeDamageAttachables Whether to count wounds from Attachables that have a negative damage multiplier, i.e. those that heal their parent (this Attachable) when wounded. + /// @param includeNoDamageAttachables Whether to count wounds from Attachables that a zero damage multiplier, i.e. those that do not affect their parent (this Attachable) when wounded. + /// @return The amount of damage caused by these wounds, taking damage multipliers into account. float RemoveWounds(int numberOfWoundsToRemove, bool includeAttachablesWithAPositiveDamageMultiplier, bool includeAttachablesWithANegativeDamageMultiplier, bool includeAttachablesWithNoDamageMultiplier) override; #pragma endregion @@ -608,36 +449,26 @@ namespace RTE { float m_PrevRotAngleOffset; //!< The previous frame's difference between this Attachable's RotAngle and it's root parent's RotAngle. bool m_PreUpdateHasRunThisFrame; //!< Whether or not PreUpdate has run this frame. PreUpdate, like Update, should only run once per frame. - /// /// Sets this Attachable's parent MOSRotating, and also sets its Team based on its parent and, if the Attachable is set to collide, adds/removes Atoms to its new/old parent. - /// - /// A pointer to the MOSRotating to set as the new parent. Ownership is NOT transferred! + /// @param newParent A pointer to the MOSRotating to set as the new parent. Ownership is NOT transferred! virtual void SetParent(MOSRotating* newParent); private: - /// /// Updates the position of this Attachable based on its parent offset and joint offset. Used during update and when something sets these offsets through setters. - /// void UpdatePositionAndJointPositionBasedOnOffsets(); - /// /// Turns on/off this Attachable's terrain collisions while it is attached by adding/removing its Atoms to/from its root parent's AtomGroup. - /// - /// Whether to add this Attachable's Atoms to the root parent's AtomGroup or remove them. - /// Whether this Atom addition or removal should be propagated to any child Attachables (as appropriate). + /// @param addAtoms Whether to add this Attachable's Atoms to the root parent's AtomGroup or remove them. + /// @param propagateToChildAttachables Whether this Atom addition or removal should be propagated to any child Attachables (as appropriate). void AddOrRemoveAtomsFromRootParentAtomGroup(bool addAtoms, bool propagateToChildAttachables); - /// /// Add or removes this Attachable's PieSlices and PieMenu listeners, as well as those of any of its child Attachables, from the given PieMenu (should be the root parent's PieMenu). /// Note that listeners are only added for Attachables that have at least one script file with the appropriate Lua function. - /// - /// The PieMenu to modify, passed in to keep the recursion simple and clean. - /// Whether to add this Attachable's PieSlices and listeners to, or remove them from, the root parent's PieMenu. + /// @param pieMenuToModify The PieMenu to modify, passed in to keep the recursion simple and clean. + /// @param addToPieMenu Whether to add this Attachable's PieSlices and listeners to, or remove them from, the root parent's PieMenu. void AddOrRemovePieSlicesAndListenersFromPieMenu(PieMenu* pieMenuToModify, bool addToPieMenu); - /// /// Clears all the member variables of this Attachable, effectively resetting the members of this abstraction level only. - /// void Clear(); // Disallow the use of some implicit methods. diff --git a/Source/Entities/BunkerAssembly.cpp b/Source/Entities/BunkerAssembly.cpp index 6e8c4fbd67..cf4580d36f 100644 --- a/Source/Entities/BunkerAssembly.cpp +++ b/Source/Entities/BunkerAssembly.cpp @@ -1,15 +1,3 @@ -////////////////////////////////////////////////////////////////////////////////////////// -// File: BunkerAssembly.cpp -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Source file for the BunkerAssembly class. -// Project: Retro Terrain Engine -// Author(s): Daniel Tabar -// data@datarealms.com -// http://www.datarealms.com - -////////////////////////////////////////////////////////////////////////////////////////// -// Inclusions of header files - #include "BunkerAssembly.h" #include "PresetMan.h" #include "ADoor.h" @@ -21,12 +9,6 @@ namespace RTE { ConcreteClassInfo(BunkerAssembly, SceneObject, 0); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Clear - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears all the member variables of this BunkerAssembly, effectively - // resetting the members of this abstraction level only. - void BunkerAssembly::Clear() { m_FGColorFile.Reset(); m_MaterialFile.Reset(); @@ -44,11 +26,6 @@ namespace RTE { m_ParentSchemeGroup.clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes the BunkerAssembly object ready for use. - int BunkerAssembly::Create() { if (TerrainObject::Create() < 0) return -1; @@ -56,13 +33,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: AddPlacedObject - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Adds placed object to the internallist of placed objects for this assembly, - // applies it's image to presentation bitmap and sets assembly price accordingly. - // Added scene object MUST have coordinates relative to this assembly. - void BunkerAssembly::AddPlacedObject(SceneObject* pSO) { m_PlacedObjects.push_back(pSO); @@ -103,11 +73,6 @@ namespace RTE { } } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes the BunkerAssembly object ready for use. - int BunkerAssembly::Create(BunkerAssemblyScheme* pScheme) { if (TerrainObject::Create() < 0) return -1; @@ -138,11 +103,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Creates a MOPixel to be identical to another, by deep copy. - int BunkerAssembly::Create(const BunkerAssembly& reference) { TerrainObject::Create(reference); @@ -157,14 +117,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: ReadProperty - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Reads a property value from a reader stream. If the name isn't - // recognized by this class, then ReadProperty of the parent class - // is called. If the property isn't recognized by any of the base classes, - // false is returned, and the reader's position is untouched. - int BunkerAssembly::ReadProperty(const std::string_view& propName, Reader& reader) { StartPropertyList(return SceneObject::ReadProperty(propName, reader)); @@ -241,12 +193,6 @@ namespace RTE { EndPropertyList; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Save - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Saves the complete state of this BunkerAssembly with a Writer for - // later recreation with Create(Reader &reader); - int BunkerAssembly::Save(Writer& writer) const { SceneObject::Save(writer); @@ -309,11 +255,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destroys and resets (through Clear()) the BunkerAssembly object. - void BunkerAssembly::Destroy(bool notInherited) { for (std::list::iterator oItr = m_PlacedObjects.begin(); oItr != m_PlacedObjects.end(); ++oItr) { delete (*oItr); @@ -339,13 +280,6 @@ namespace RTE { Clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: GetDeployments - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Retrieves the list of random deployemtns selected to be deployed by this assembly - // based on it's parent scheme MaxDeployments value. This list will always include all - // brain deployments so it can be longer that MaxDeployments. OWNERSHIP NOT TRANSFERRED. - std::vector BunkerAssembly::GetDeployments() { std::vector deploymentsList; std::vector candidatesList; @@ -381,12 +315,6 @@ namespace RTE { return deploymentsList; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: IsOnScenePoint - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Indicates whether this' current graphical representation overlaps - // a point in absolute scene coordinates. - bool BunkerAssembly::IsOnScenePoint(Vector& scenePoint) const { if (!m_pPresentationBitmap) return false; @@ -402,11 +330,6 @@ namespace RTE { return false; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: SetTeam - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets which team this Actor belongs to. - void BunkerAssembly::SetTeam(int team) { TerrainObject::SetTeam(team); @@ -415,12 +338,6 @@ namespace RTE { (*itr)->SetTeam(team); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Draw - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws this TerrainObject's current graphical representation to a - // BITMAP of choice. - void BunkerAssembly::Draw(BITMAP* pTargetBitmap, const Vector& targetPos, DrawMode mode, bool onlyPhysical) const { if (!m_FGColorBitmap) RTEAbort("TerrainObject's bitmaps are null when drawing!"); diff --git a/Source/Entities/BunkerAssembly.h b/Source/Entities/BunkerAssembly.h index cf47b9340a..e967ce7e34 100644 --- a/Source/Entities/BunkerAssembly.h +++ b/Source/Entities/BunkerAssembly.h @@ -1,18 +1,11 @@ #ifndef _RTEBUNKERASSEMBLY_ #define _RTEBUNKERASSEMBLY_ -////////////////////////////////////////////////////////////////////////////////////////// -// File: BunkerAssembly.h -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Header file for the BunkerAssembly class. -// Project: Retro Terrain Engine -// Author(s): Daniel Tabar -// data@datarealms.com -// http://www.datarealms.com - -////////////////////////////////////////////////////////////////////////////////////////// -// Inclusions of header files - +/// Header file for the BunkerAssembly class. +/// @author Daniel Tabar +/// data@datarealms.com +/// http://www.datarealms.com +/// Inclusions of header files #include "TerrainObject.h" namespace RTE { @@ -20,203 +13,107 @@ namespace RTE { class BunkerAssemblyScheme; class Deployment; - ////////////////////////////////////////////////////////////////////////////////////////// - // Class: BunkerAssembly - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: An assembly of a few terrain objects. - // material layer and optional background layer. - // Parent(s): SceneObject. - // Class history: 08/23/2002 BunkerAssembly created. - + /// An assembly of a few terrain objects. + /// material layer and optional background layer. class BunkerAssembly : public TerrainObject { - ////////////////////////////////////////////////////////////////////////////////////////// - // Public member variable, method and friend function declarations - + /// Public member variable, method and friend function declarations public: // Concrete allocation and cloning definitions EntityAllocation(BunkerAssembly); SerializableOverrideMethods; ClassInfoGetters; - ////////////////////////////////////////////////////////////////////////////////////////// - // Constructor: BunkerAssembly - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Constructor method used to instantiate a BunkerAssembly object in system - // memory. Create() should be called before using the object. - // Arguments: None. - + /// Constructor method used to instantiate a BunkerAssembly object in system + /// memory. Create() should be called before using the object. BunkerAssembly() { Clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Destructor: ~BunkerAssembly - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destructor method used to clean up a BunkerAssembly object before deletion - // from system memory. - // Arguments: None. - + /// Destructor method used to clean up a BunkerAssembly object before deletion + /// from system memory. ~BunkerAssembly() override { Destroy(true); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Pure V. method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes the BunkerAssembly object ready for use. - // Arguments: None. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Makes the BunkerAssembly object ready for use. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Create() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes the BunkerAssembly object ready for use. - // Arguments: None. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Makes the BunkerAssembly object ready for use. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Create(BunkerAssemblyScheme* scheme); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Creates a BunkerAssembly to be identical to another, by deep copy. - // Arguments: A reference to the BunkerAssembly to deep copy. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Creates a BunkerAssembly to be identical to another, by deep copy. + /// @param reference A reference to the BunkerAssembly to deep copy. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Create(const BunkerAssembly& reference); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Reset - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Resets the entire BunkerAssembly, including its inherited members, to - // their default settings or values. - // Arguments: None. - // Return value: None. - + /// Resets the entire BunkerAssembly, including its inherited members, to + /// their default settings or values. void Reset() override { Clear(); SceneObject::Reset(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Pure V. method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destroys and resets (through Clear()) the BunkerAssembly object. - // Arguments: Whether to only destroy the members defined in this derived class, or - // to destroy all inherited members also. - // Return value: None. - + /// Destroys and resets (through Clear()) the BunkerAssembly object. + /// @param notInherited Whether to only destroy the members defined in this derived class, or (default: false) + /// to destroy all inherited members also. void Destroy(bool notInherited = false) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetParentAssemblySchemeName - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: - // - // Arguments: None. - // Return value: - // - + /// Description: + /// Return value: std::string GetParentAssemblySchemeName() const { return m_ParentAssemblyScheme; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: IsOnScenePoint - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Indicates whether this' current graphical representation overlaps - // a point in absolute scene coordinates. - // Arguments: The point in absolute scene coordinates. - // Return value: Whether this' graphical rep overlaps the scene point. - + /// Indicates whether this' current graphical representation overlaps + /// a point in absolute scene coordinates. + /// @param scenePoint The point in absolute scene coordinates. + /// @return Whether this' graphical rep overlaps the scene point. bool IsOnScenePoint(Vector& scenePoint) const override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetDeployments - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Retrieves the list of random deployemtns selected to be deployed by this assembly - // based on it's parent scheme MaxDeployments value. This list will always include all - // brain deployments so it can be longer that MaxDeployments. - // Arguments: None. - // Return value: List of deployments. - + /// Retrieves the list of random deployemtns selected to be deployed by this assembly + /// based on it's parent scheme MaxDeployments value. This list will always include all + /// brain deployments so it can be longer that MaxDeployments. + /// @return List of deployments. std::vector GetDeployments(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: SetTeam - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets which team this belongs to. - // Arguments: The assigned team number. - // Return value: None. - + /// Sets which team this belongs to. + /// @param team The assigned team number. void SetTeam(int team) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetPlacedObjects - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the list of SceneObject:s which are placed in this assembly on loading. - // Arguments: None. - // Return value: The list of of placed objects. Ownership is NOT transferred! - + /// Gets the list of SceneObject:s which are placed in this assembly on loading. + /// @return The list of of placed objects. Ownership is NOT transferred! const std::list* GetPlacedObjects() const { return &m_PlacedObjects; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: AddPlacedObject - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Adds placed object to the internallist of placed objects for this assembly, - // applies it's image to presentation bitmap and sets assembly price accordingly. - // Added scene object MUST have coordinates relative to this assembly. - // Arguments: Object to add. - // Return value: None. - + /// Adds placed object to the internallist of placed objects for this assembly, + /// applies it's image to presentation bitmap and sets assembly price accordingly. + /// Added scene object MUST have coordinates relative to this assembly. + /// @param pSO Object to add. void AddPlacedObject(SceneObject* pSO); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetGraphicalIcon - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets a bitmap showing a good identifyable icon of this, for use in - // GUI lists etc. - // Arguments: None. - // Return value: A good identifyable graphical representation of this in a BITMAP, if - // available. If not, 0 is returned. Ownership is NOT TRANSFERRED! - + /// Gets a bitmap showing a good identifyable icon of this, for use in + /// GUI lists etc. + /// @return A good identifyable graphical representation of this in a BITMAP, if + /// available. If not, 0 is returned. Ownership is NOT TRANSFERRED! BITMAP* GetGraphicalIcon() const override { return m_pPresentationBitmap; }; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetSymmetricAssemblyName - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the name of an assembly symmetric to this one. - // Arguments: None. - // Return value: Symmetric assembly name. - + /// Gets the name of an assembly symmetric to this one. + /// @return Symmetric assembly name. std::string GetSymmetricAssemblyName() const { return m_SymmetricAssembly; }; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetSymmetricAssemblyName - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the name of an assembly symmetric to this one. - // Arguments: Symmetric assembly name. - // Return value: None. - + /// Sets the name of an assembly symmetric to this one. + /// @param newSymmetricAssembly Symmetric assembly name. void SetSymmetricAssemblyName(std::string newSymmetricAssembly) { m_SymmetricAssembly = newSymmetricAssembly; }; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Draw - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws this TerrainObject's current graphical representation to a - // BITMAP of choice. - // Arguments: A pointer to a BITMAP to draw on. - // The absolute position of the target bitmap's upper left corner in the Scene. - // In which mode to draw in. See the DrawMode enumeration for the modes. - // Whether to not draw any extra 'ghost' items of this MovableObject, - // like indicator arrows or hovering HUD text and so on. - // Return value: None. - + /// Draws this TerrainObject's current graphical representation to a + /// BITMAP of choice. + /// @param pTargetBitmap A pointer to a BITMAP to draw on. + /// @param targetPos The absolute position of the target bitmap's upper left corner in the Scene. (default: Vector()) + /// @param mode In which mode to draw in. See the DrawMode enumeration for the modes. (default: g_DrawColor) + /// @param onlyPhysical Whether to not draw any extra 'ghost' items of this MovableObject, (default: false) + /// like indicator arrows or hovering HUD text and so on. void Draw(BITMAP* pTargetBitmap, const Vector& targetPos = Vector(), DrawMode mode = g_DrawColor, bool onlyPhysical = false) const override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Protected member variable and method declarations - + /// Protected member variable and method declarations protected: // Member variables static Entity::ClassInfo m_sClass; @@ -231,18 +128,10 @@ namespace RTE { // Assembly symmetric to this one std::string m_SymmetricAssembly; - ////////////////////////////////////////////////////////////////////////////////////////// - // Private member variable and method declarations - + /// Private member variable and method declarations private: - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Clear - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears all the member variables of this BunkerAssembly, effectively - // resetting the members of this abstraction level only. - // Arguments: None. - // Return value: None. - + /// Clears all the member variables of this BunkerAssembly, effectively + /// resetting the members of this abstraction level only. void Clear(); // Disallow the use of some implicit methods. diff --git a/Source/Entities/BunkerAssemblyScheme.cpp b/Source/Entities/BunkerAssemblyScheme.cpp index 0252f7163b..edabc68f92 100644 --- a/Source/Entities/BunkerAssemblyScheme.cpp +++ b/Source/Entities/BunkerAssemblyScheme.cpp @@ -1,15 +1,3 @@ -////////////////////////////////////////////////////////////////////////////////////////// -// File: BunkerAssemblyScheme.cpp -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Source file for the BunkerAssemblyScheme class. -// Project: Retro Terrain Engine -// Author(s): Daniel Tabar -// data@datarealms.com -// http://www.datarealms.com - -////////////////////////////////////////////////////////////////////////////////////////// -// Inclusions of header files - #include "BunkerAssemblyScheme.h" #include "PresetMan.h" #include "FrameMan.h" @@ -21,12 +9,6 @@ namespace RTE { ConcreteClassInfo(BunkerAssemblyScheme, SceneObject, 0); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Clear - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears all the member variables of this BunkerAssemblyScheme, effectively - // resetting the members of this abstraction level only. - void BunkerAssemblyScheme::Clear() { m_pPresentationBitmap = 0; m_ChildObjects.clear(); @@ -38,11 +20,6 @@ namespace RTE { m_AssemblyGroup.clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes the BunkerAssemblyScheme object ready for use. - int BunkerAssemblyScheme::Create() { if (SceneObject::Create() < 0) return -1; @@ -50,11 +27,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Creates a MOPixel to be identical to another, by deep copy. - int BunkerAssemblyScheme::Create(const BunkerAssemblyScheme& reference) { SceneObject::Create(reference); @@ -76,14 +48,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: ReadProperty - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Reads a property value from a reader stream. If the name isn't - // recognized by this class, then ReadProperty of the parent class - // is called. If the property isn't recognized by any of the base classes, - // false is returned, and the reader's position is untouched. - int BunkerAssemblyScheme::ReadProperty(const std::string_view& propName, Reader& reader) { StartPropertyList(return SceneObject::ReadProperty(propName, reader)); @@ -223,12 +187,6 @@ namespace RTE { EndPropertyList; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Save - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Saves the complete state of this BunkerAssemblyScheme with a Writer for - // later recreation with Create(Reader &reader); - int BunkerAssemblyScheme::Save(Writer& writer) const { SceneObject::Save(writer); @@ -242,11 +200,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destroys and resets (through Clear()) the BunkerAssemblyScheme object. - void BunkerAssemblyScheme::Destroy(bool notInherited) { // Probably no need to delete those, as bitmaps are only created when preset is read from file // and then they just copy pointers in via Clone() @@ -258,22 +211,10 @@ namespace RTE { Clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetGraphicalIcon - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets a bitmap showing a good identifyable icon of this, for use in - // GUI lists etc. - BITMAP* BunkerAssemblyScheme::GetGraphicalIcon() const { return m_pIconBitmap; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: IsOnScenePoint - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Indicates whether this' current graphical representation overlaps - // a point in absolute scene coordinates. - bool BunkerAssemblyScheme::IsOnScenePoint(Vector& scenePoint) const { if (!m_pBitmap) return false; @@ -293,11 +234,6 @@ namespace RTE { return false; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: SetTeam - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets which team this Actor belongs to. - void BunkerAssemblyScheme::SetTeam(int team) { SceneObject::SetTeam(team); @@ -306,12 +242,6 @@ namespace RTE { (*itr).SetTeam(team); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Draw - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws this BunkerAssemblyScheme's current graphical representation to a - // BITMAP of choice. - void BunkerAssemblyScheme::Draw(BITMAP* pTargetBitmap, const Vector& targetPos, DrawMode mode, bool onlyPhysical) const { if (!m_pPresentationBitmap) RTEAbort("BunkerAssemblyScheme's bitmaps are null when drawing!"); diff --git a/Source/Entities/BunkerAssemblyScheme.h b/Source/Entities/BunkerAssemblyScheme.h index ff0cbbed4d..cf9645a708 100644 --- a/Source/Entities/BunkerAssemblyScheme.h +++ b/Source/Entities/BunkerAssemblyScheme.h @@ -1,18 +1,11 @@ #ifndef _RTEBUNKERASSEMBLYSCHEME_ #define _RTEBUNKERASSEMBLYSCHEME_ -////////////////////////////////////////////////////////////////////////////////////////// -// File: BunkerAssemblyScheme.h -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Header file for the BunkerAssemblyScheme class. -// Project: Retro Terrain Engine -// Author(s): Daniel Tabar -// data@datarealms.com -// http://www.datarealms.com - -////////////////////////////////////////////////////////////////////////////////////////// -// Inclusions of header files - +/// Header file for the BunkerAssemblyScheme class. +/// @author Daniel Tabar +/// data@datarealms.com +/// http://www.datarealms.com +/// Inclusions of header files #include "SceneObject.h" #include "SceneMan.h" @@ -23,19 +16,11 @@ namespace RTE { class ContentFile; - ////////////////////////////////////////////////////////////////////////////////////////// - // Class: BunkerAssemblyScheme - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: A feature of the terrain, which includes foreground color layer, - // material layer and optional background layer. - // Parent(s): SceneObject. - // Class history: 08/23/2002 BunkerAssemblyScheme created. - + /// A feature of the terrain, which includes foreground color layer, + /// material layer and optional background layer. class BunkerAssemblyScheme : public SceneObject { - ////////////////////////////////////////////////////////////////////////////////////////// - // Public member variable, method and friend function declarations - + /// Public member variable, method and friend function declarations public: // Different scheme properties are encoded on colors of scheme bitmap enum SchemeColor { @@ -61,207 +46,108 @@ namespace RTE { SerializableOverrideMethods; ClassInfoGetters; - ////////////////////////////////////////////////////////////////////////////////////////// - // Constructor: BunkerAssemblyScheme - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Constructor method used to instantiate a BunkerAssemblyScheme object in system - // memory. Create() should be called before using the object. - // Arguments: None. - + /// Constructor method used to instantiate a BunkerAssemblyScheme object in system + /// memory. Create() should be called before using the object. BunkerAssemblyScheme() { Clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Destructor: ~BunkerAssemblyScheme - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destructor method used to clean up a BunkerAssemblyScheme object before deletion - // from system memory. - // Arguments: None. - + /// Destructor method used to clean up a BunkerAssemblyScheme object before deletion + /// from system memory. ~BunkerAssemblyScheme() override { Destroy(true); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Pure V. method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes the BunkerAssemblyScheme object ready for use. - // Arguments: None. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Makes the BunkerAssemblyScheme object ready for use. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Create() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Creates a BunkerAssemblyScheme to be identical to another, by deep copy. - // Arguments: A reference to the BunkerAssemblyScheme to deep copy. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Creates a BunkerAssemblyScheme to be identical to another, by deep copy. + /// @param reference A reference to the BunkerAssemblyScheme to deep copy. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Create(const BunkerAssemblyScheme& reference); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Reset - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Resets the entire BunkerAssemblyScheme, including its inherited members, to - // their default settings or values. - // Arguments: None. - // Return value: None. - + /// Resets the entire BunkerAssemblyScheme, including its inherited members, to + /// their default settings or values. void Reset() override { Clear(); SceneObject::Reset(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Pure V. method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destroys and resets (through Clear()) the BunkerAssemblyScheme object. - // Arguments: Whether to only destroy the members defined in this derived class, or - // to destroy all inherited members also. - // Return value: None. - + /// Destroys and resets (through Clear()) the BunkerAssemblyScheme object. + /// @param notInherited Whether to only destroy the members defined in this derived class, or (default: false) + /// to destroy all inherited members also. void Destroy(bool notInherited = false) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetBitmapWidth - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the width this' bitmap. - // Arguments: None. - // Return value: Width of bitmap. - + /// Method: GetBitmapWidth + /// Gets the width this' bitmap. + /// @return Width of bitmap. const int GetBitmapWidth() const { return m_pPresentationBitmap->w; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetBitmapHeight - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the height this' material bitmap. - // Arguments: None. - // Return value: Height of 'material' bitmap. - + /// Method: GetBitmapHeight + /// Gets the height this' material bitmap. + /// @return Height of 'material' bitmap. const int GetBitmapHeight() const { return m_pPresentationBitmap->h; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetBitmapOffset - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the offset of presentation bitmap - // Arguments: None. - // Return value: Offset of bitmap - + /// Method: GetBitmapOffset + /// Gets the offset of presentation bitmap + /// @return Offset of bitmap const Vector GetBitmapOffset() const { return m_BitmapOffset; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetBitmap - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the BITMAP object that this BunkerAssemblyScheme uses for its fore- - // ground color representation. - // Arguments: None. - // Return value: A pointer to the foreground color BITMAP object. Ownership is not - // transferred. - + /// Gets the BITMAP object that this BunkerAssemblyScheme uses for its fore- + /// ground color representation. + /// @return A pointer to the foreground color BITMAP object. Ownership is not + /// transferred. BITMAP* GetBitmap() const { return m_pPresentationBitmap; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetArea - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the area of the structure bitmap. - // Arguments: None. - // Return value: None. - + /// Gets the area of the structure bitmap. int GetArea() const { return m_pBitmap->h * m_pBitmap->w; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetGraphicalIcon - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets a bitmap showing a good identifyable icon of this, for use in - // GUI lists etc. - // Arguments: None. - // Return value: A good identifyable graphical representation of this in a BITMAP, if - // available. If not, 0 is returned. Ownership is NOT TRANSFERRED! - + /// Gets a bitmap showing a good identifyable icon of this, for use in + /// GUI lists etc. + /// @return A good identifyable graphical representation of this in a BITMAP, if + /// available. If not, 0 is returned. Ownership is NOT TRANSFERRED! BITMAP* GetGraphicalIcon() const override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: SetTeam - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets which team this belongs to. - // Arguments: The assigned team number. - // Return value: None. - + /// Sets which team this belongs to. + /// @param team The assigned team number. void SetTeam(int team) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: IsOnScenePoint - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Indicates whether this' current graphical representation overlaps - // a point in absolute scene coordinates. - // Arguments: The point in absolute scene coordinates. - // Return value: Whether this' graphical rep overlaps the scene point. - + /// Indicates whether this' current graphical representation overlaps + /// a point in absolute scene coordinates. + /// @param scenePoint The point in absolute scene coordinates. + /// @return Whether this' graphical rep overlaps the scene point. bool IsOnScenePoint(Vector& scenePoint) const override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Draw - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws this BunkerAssemblyScheme's current graphical representation to a - // BITMAP of choice. - // Arguments: A pointer to a BITMAP to draw on. - // The absolute position of the target bitmap's upper left corner in the Scene. - // In which mode to draw in. See the DrawMode enumeration for the modes. - // Whether to not draw any extra 'ghost' items of this MovableObject, - // like indicator arrows or hovering HUD text and so on. - // Return value: None. - + /// Draws this BunkerAssemblyScheme's current graphical representation to a + /// BITMAP of choice. + /// @param pTargetBitmap A pointer to a BITMAP to draw on. + /// @param targetPos The absolute position of the target bitmap's upper left corner in the Scene. (default: Vector()) + /// @param mode In which mode to draw in. See the DrawMode enumeration for the modes. (default: g_DrawColor) + /// @param onlyPhysical Whether to not draw any extra 'ghost' items of this MovableObject, (default: false) + /// like indicator arrows or hovering HUD text and so on. void Draw(BITMAP* pTargetBitmap, const Vector& targetPos = Vector(), DrawMode mode = g_DrawColor, bool onlyPhysical = false) const override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetOneTypePerScene - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns whether sceneman should select just a single assembly for this scheme - // and use it everywhere on the scene. - // Arguments: None. - // Return value: Whether we allowed to use just one type of assembly for this scheme - + /// Returns whether sceneman should select just a single assembly for this scheme + /// and use it everywhere on the scene. + /// @return Whether we allowed to use just one type of assembly for this scheme bool IsOneTypePerScene() { return m_IsOneTypePerScene; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetSymmetricSchemeName - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the name of the scheme symmetric to this one. - // Arguments: None. - // Return value: Symmetric scheme name. - + /// Gets the name of the scheme symmetric to this one. + /// @return Symmetric scheme name. std::string GetSymmetricSchemeName() const { return m_SymmetricScheme; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetAssemblyGroup - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the name of group to which assemblies linked with this scheme must be added. - // Arguments: None. - // Return value: Assembly group name. - + /// Gets the name of group to which assemblies linked with this scheme must be added. + /// @return Assembly group name. std::string GetAssemblyGroup() const { return m_AssemblyGroup; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetLimit - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns the limit of these schemes per scene. 0 - no limit. - // Arguments: None. - // Return value: Scheme limit. - + /// Returns the limit of these schemes per scene. 0 - no limit. + /// @return Scheme limit. int GetLimit() { return m_Limit; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetMaxDeployments - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns the number of deployments this scheme is allowed to place. - // Arguments: None. - // Return value: Deployments limit. - + /// Returns the number of deployments this scheme is allowed to place. + /// @return Deployments limit. int GetMaxDeployments() const { return m_MaxDeployments; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Protected member variable and method declarations - + /// Protected member variable and method declarations protected: // Member variables static Entity::ClassInfo m_sClass; @@ -289,18 +175,10 @@ namespace RTE { // To which group we should add assemblies linked to this scheme std::string m_AssemblyGroup; - ////////////////////////////////////////////////////////////////////////////////////////// - // Private member variable and method declarations - + /// Private member variable and method declarations private: - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Clear - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears all the member variables of this BunkerAssemblyScheme, effectively - // resetting the members of this abstraction level only. - // Arguments: None. - // Return value: None. - + /// Clears all the member variables of this BunkerAssemblyScheme, effectively + /// resetting the members of this abstraction level only. void Clear(); // Disallow the use of some implicit methods. diff --git a/Source/Entities/Deployment.cpp b/Source/Entities/Deployment.cpp index a9710c3fb0..f06d43ad03 100644 --- a/Source/Entities/Deployment.cpp +++ b/Source/Entities/Deployment.cpp @@ -1,15 +1,3 @@ -////////////////////////////////////////////////////////////////////////////////////////// -// File: Deployment.cpp -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Source file for the Deployment class. -// Project: Retro Terrain Engine -// Author(s): Daniel Tabar -// data@datarealms.com -// http://www.datarealms.com - -////////////////////////////////////////////////////////////////////////////////////////// -// Inclusions of header files - #include "Deployment.h" #include "PresetMan.h" #include "MetaMan.h" @@ -28,12 +16,6 @@ namespace RTE { std::vector Deployment::m_apArrowLeftBitmap; std::vector Deployment::m_apArrowRightBitmap; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Clear - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears all the member variables of this Deployment, effectively - // resetting the members of this abstraction level only. - void Deployment::Clear() { m_LoadoutName = "Default"; m_Icon.Reset(); @@ -43,11 +25,6 @@ namespace RTE { m_HFlipped = false; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes the Deployment object ready for use. - int Deployment::Create() { if (SceneObject::Create() < 0) return -1; @@ -62,11 +39,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes the Deployment object ready for use. - int Deployment::Create(std::string loadoutName, const Icon& icon, float spawnRadius) { m_LoadoutName = loadoutName; m_Icon = icon; @@ -85,11 +57,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Creates a MOPixel to be identical to another, by deep copy. - int Deployment::Create(const Deployment& reference) { SceneObject::Create(reference); @@ -103,14 +70,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: ReadProperty - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Reads a property value from a reader stream. If the name isn't - // recognized by this class, then ReadProperty of the parent class - // is called. If the property isn't recognized by any of the base classes, - // false is returned, and the reader's position is untouched. - int Deployment::ReadProperty(const std::string_view& propName, Reader& reader) { StartPropertyList(return SceneObject::ReadProperty(propName, reader)); @@ -124,12 +83,6 @@ namespace RTE { EndPropertyList; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Save - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Saves the complete state of this Deployment with a Writer for - // later recreation with Create(Reader &reader); - int Deployment::Save(Writer& writer) const { SceneObject::Save(writer); @@ -147,11 +100,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destroys and resets (through Clear()) the Deployment object. - void Deployment::Destroy(bool notInherited) { if (!notInherited) @@ -159,27 +107,11 @@ namespace RTE { Clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: CreateDeployedActor - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Creates and returns the Actor that this Deployment dictates should - // spawn here. Ownership IS transferred!! All items of the Loadout of - // this Deployment will be added to the Actor's inventory as well (and - // also owned by it) - Actor* Deployment::CreateDeployedActor() { float cost; return CreateDeployedActor(-1, cost); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: CreateDeployedActor - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Creates and returns the Actor that this Deployment dictates should - // spawn here. Ownership IS transferred!! All items of the Loadout of - // this Deployment will be added to the Actor's inventory as well (and - // also owned by it) - Actor* Deployment::CreateDeployedActor(int player, float& costTally) { // The Actor instance we return and pass ownership of Actor* pReturnActor = 0; @@ -238,23 +170,11 @@ namespace RTE { return pReturnActor; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: CreateDeployedObject - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Creates and returns the first Device that Deployment dictates should - // spawn here. Ownership IS transferred!! Only the first Device is created. - SceneObject* Deployment::CreateDeployedObject() { float cost; return CreateDeployedObject(-1, cost); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: CreateDeployedObject - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Creates and returns the first Device that Deployment dictates should - // spawn here. Ownership IS transferred!! Only the first Device is created. - SceneObject* Deployment::CreateDeployedObject(int player, float& costTally) { // The Actor instance we return and pass ownership of SceneObject* pReturnObject = 0; @@ -310,13 +230,6 @@ namespace RTE { return pReturnObject; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: DeploymentBlocked - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Tests whether the Object this is supposed to spawn/deploy is blocked - // by an already exiting object in the a list being positioned within the - // spawn radius of this. - bool Deployment::DeploymentBlocked(int player, const std::list& existingObjects) { bool blocked = false; @@ -426,12 +339,6 @@ namespace RTE { return blocked; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetTotalValue - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the total liquidation value of a spawn of this, including - // everything carried by it. - float Deployment::GetTotalValue(int nativeModule, float foreignMult, float nativeMult) const { float totalValue = 0; const Actor* pFirstActor = 0; @@ -524,12 +431,6 @@ namespace RTE { return totalValue; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: IsOnScenePoint - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Indicates whether this' current graphical representation overlaps - // a point in absolute scene coordinates. - bool Deployment::IsOnScenePoint(Vector& scenePoint) const { if (m_Icon.GetBitmaps8().empty() || !(m_Icon.GetBitmaps8().at(0))) return false; @@ -590,12 +491,6 @@ namespace RTE { return false; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Draw - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws this Deployment's current graphical representation to a - // BITMAP of choice. - void Deployment::Draw(BITMAP* pTargetBitmap, const Vector& targetPos, DrawMode mode, bool onlyPhysical) const { if (m_Icon.GetBitmaps8().empty() || !(m_Icon.GetBitmaps8().at(0))) RTEAbort("Deployment's Icon bitmaps are null when drawing!"); diff --git a/Source/Entities/Deployment.h b/Source/Entities/Deployment.h index 3919254a1b..91d6e1cf8f 100644 --- a/Source/Entities/Deployment.h +++ b/Source/Entities/Deployment.h @@ -1,336 +1,198 @@ #ifndef _RTEDEPLOYMENT_ #define _RTEDEPLOYMENT_ -////////////////////////////////////////////////////////////////////////////////////////// -// File: Deployment.h -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Header file for the Deployment class. -// Project: Retro Terrain Engine -// Author(s): Daniel Tabar -// data@datarealms.com -// http://www.datarealms.com - -////////////////////////////////////////////////////////////////////////////////////////// -// Inclusions of header files - +/// Header file for the Deployment class. +/// @author Daniel Tabar +/// data@datarealms.com +/// http://www.datarealms.com +/// Inclusions of header files #include "RTETools.h" #include "SceneObject.h" #include "Vector.h" #include "SceneMan.h" -//#include "MovableMan.h" +// #include "MovableMan.h" namespace RTE { class ContentFile; - ////////////////////////////////////////////////////////////////////////////////////////// - // Class: Deployment - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: A special SceneObject that specifies a Loadout of whatever Tech is - // relevant to be placed in a specific location in a Scene. - // Parent(s): SceneObject. - // Class history: 02/27/2012 Deployment created. - + /// A special SceneObject that specifies a Loadout of whatever Tech is + /// relevant to be placed in a specific location in a Scene. class Deployment : public SceneObject { - ////////////////////////////////////////////////////////////////////////////////////////// - // Public member variable, method and friend function declarations - + /// Public member variable, method and friend function declarations public: // Concrete allocation and cloning definitions EntityAllocation(Deployment); SerializableOverrideMethods; ClassInfoGetters; - ////////////////////////////////////////////////////////////////////////////////////////// - // Constructor: Deployment - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Constructor method used to instantiate a Deployment object in system - // memory. Create() should be called before using the object. - // Arguments: None. - + /// Constructor method used to instantiate a Deployment object in system + /// memory. Create() should be called before using the object. Deployment() { Clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Destructor: ~Deployment - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destructor method used to clean up a Deployment object before deletion - // from system memory. - // Arguments: None. - + /// Destructor method used to clean up a Deployment object before deletion + /// from system memory. ~Deployment() override { Destroy(true); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Pure V. method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes the Deployment object ready for use. - // Arguments: None. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Makes the Deployment object ready for use. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Create() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes the Deployment object ready for use. - // Arguments: The name of the Loadout that this should invoke at this' position. - // Icon that represents this graphically. - // The radius around this deployment that gets checked if another - // actor/item of the same type and name already exists and will block - // re-spawning a new one by this. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Makes the Deployment object ready for use. + /// @param loadoutName The name of the Loadout that this should invoke at this' position. + /// @param icon Icon that represents this graphically. + /// @param spawnRadius The radius around this deployment that gets checked if another + /// actor/item of the same type and name already exists and will block + /// re-spawning a new one by this. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Create(std::string loadoutName, const Icon& icon, float spawnRadius); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Creates a Deployment to be identical to another, by deep copy. - // Arguments: A reference to the Deployment to deep copy. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Creates a Deployment to be identical to another, by deep copy. + /// @param reference A reference to the Deployment to deep copy. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Create(const Deployment& reference); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Reset - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Resets the entire Deployment, including its inherited members, to - // their default settings or values. - // Arguments: None. - // Return value: None. - + /// Resets the entire Deployment, including its inherited members, to + /// their default settings or values. void Reset() override { Clear(); SceneObject::Reset(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Pure V. method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destroys and resets (through Clear()) the Deployment object. - // Arguments: Whether to only destroy the members defined in this derived class, or - // to destroy all inherited members also. - // Return value: None. - + /// Destroys and resets (through Clear()) the Deployment object. + /// @param notInherited Whether to only destroy the members defined in this derived class, or (default: false) + /// to destroy all inherited members also. void Destroy(bool notInherited = false) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetGraphicalIcon - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets a bitmap showing a good identifyable icon of this, for use in - // GUI lists etc. - // Arguments: None. - // Return value: A good identifyable graphical representation of this in a BITMAP, if - // available. If not, 0 is returned. Ownership is NOT TRANSFERRED! - + /// Gets a bitmap showing a good identifyable icon of this, for use in + /// GUI lists etc. + /// @return A good identifyable graphical representation of this in a BITMAP, if + /// available. If not, 0 is returned. Ownership is NOT TRANSFERRED! BITMAP* GetGraphicalIcon() const override { return !m_Icon.GetBitmaps8().empty() ? m_Icon.GetBitmaps8()[0] : nullptr; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetLoadoutName - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the name of the Loadout that this Deployment spawns. - // Arguments: None. - // Return value: The name of the Loadout preset that this Deployment spawns. - + /// Gets the name of the Loadout that this Deployment spawns. + /// @return The name of the Loadout preset that this Deployment spawns. const std::string& GetLoadoutName() { return m_LoadoutName; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetGraphicalIcon - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets a bitmap showing a good identifyable icon of this. - // Arguments: None. - // Return value: The Icon that represents this graphically. - + /// Gets a bitmap showing a good identifyable icon of this. + /// @return The Icon that represents this graphically. Icon GetIcon() { return m_Icon; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetSpawnRadius - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the radius around this deployment that gets checked if another - // actor/item of the same type and name already exists and will block - // re-spawning a new one by this - // Arguments: None. - // Return value: The radius this Deployment will be checking within. - + /// Gets the radius around this deployment that gets checked if another + /// actor/item of the same type and name already exists and will block + /// re-spawning a new one by this + /// @return The radius this Deployment will be checking within. float GetSpawnRadius() const { return m_SpawnRadius; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: IsOnScenePoint - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Indicates whether this' current graphical representation overlaps - // a point in absolute scene coordinates. - // Arguments: The point in absolute scene coordinates. - // Return value: Whether this' graphical rep overlaps the scene point. - + /// Indicates whether this' current graphical representation overlaps + /// a point in absolute scene coordinates. + /// @param scenePoint The point in absolute scene coordinates. + /// @return Whether this' graphical rep overlaps the scene point. bool IsOnScenePoint(Vector& scenePoint) const override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: CreateDeployedActor - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Creates and returns the Actor that this Deployment dictates should - // spawn here. Ownership IS transferred!! All items of the Loadout of - // this Deployment will be added to the Actor's inventory as well (and - // also owned by it) - // Arguments: Which in-game player to create the delivery for. - // A float which will be added to with the cost of the stuff returned here. - // Return value: The Actor instance, if any, that this Deployment is supposed to spawn. - // OWNERSHIP IS TRANSFERRED! - + /// Creates and returns the Actor that this Deployment dictates should + /// spawn here. Ownership IS transferred!! All items of the Loadout of + /// this Deployment will be added to the Actor's inventory as well (and + /// also owned by it) + /// @param player Which in-game player to create the delivery for. + /// @param costTally A float which will be added to with the cost of the stuff returned here. + /// @return The Actor instance, if any, that this Deployment is supposed to spawn. + /// OWNERSHIP IS TRANSFERRED! Actor* CreateDeployedActor(int player, float& costTally); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: CreateDeployedActor - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Creates and returns the Actor that this Deployment dictates should - // spawn here. Ownership IS transferred!! All items of the Loadout of - // this Deployment will be added to the Actor's inventory as well (and - // also owned by it) - // Arguments: Which in-game player to create the delivery for. - // Return value: The Actor instance, if any, that this Deployment is supposed to spawn. - // OWNERSHIP IS TRANSFERRED! - + /// Creates and returns the Actor that this Deployment dictates should + /// spawn here. Ownership IS transferred!! All items of the Loadout of + /// this Deployment will be added to the Actor's inventory as well (and + /// also owned by it) + /// @param Which in-game player to create the delivery for. + /// @return The Actor instance, if any, that this Deployment is supposed to spawn. + /// OWNERSHIP IS TRANSFERRED! Actor* CreateDeployedActor(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: CreateDeployedObject - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Creates and returns the first Device that Deployment dictates should - // spawn here. Ownership IS transferred!! Only the first Device is created. - // Arguments: Which in-game player to create the delivery for. - // A float which will be added to with the cost of the stuff returned here. - // Return value: The Actor instance, if any, that this Deployment is supposed to spawn. - // OWNERSHIP IS TRANSFERRED! - + /// Creates and returns the first Device that Deployment dictates should + /// spawn here. Ownership IS transferred!! Only the first Device is created. + /// @param player Which in-game player to create the delivery for. + /// @param costTally A float which will be added to with the cost of the stuff returned here. + /// @return The Actor instance, if any, that this Deployment is supposed to spawn. + /// OWNERSHIP IS TRANSFERRED! SceneObject* CreateDeployedObject(int player, float& costTally); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: CreateDeployedObject - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Creates and returns the first Device that Deployment dictates should - // spawn here. Ownership IS transferred!! Only the first Device is created. - // Arguments: Which in-game player to create the delivery for. - // Return value: The Actor instance, if any, that this Deployment is supposed to spawn. - // OWNERSHIP IS TRANSFERRED! - + /// Creates and returns the first Device that Deployment dictates should + /// spawn here. Ownership IS transferred!! Only the first Device is created. + /// @param Which in-game player to create the delivery for. + /// @return The Actor instance, if any, that this Deployment is supposed to spawn. + /// OWNERSHIP IS TRANSFERRED! SceneObject* CreateDeployedObject(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: DeploymentBlocked - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Tests whether the Object this is supposed to spawn/deploy is blocked - // by an already exiting object in the a list being positioned within the - // spawn radius of this. - // Arguments: Which in-game player to create the delivery for. - // A list of SceneObject:s that will be tested against to see if any - // sufficiently similar Object is positioned within the spawn radius of - // this. - // Return value: Whether the deployment spawning is blocked by one of the Objects in - // the list. - + /// Tests whether the Object this is supposed to spawn/deploy is blocked + /// by an already exiting object in the a list being positioned within the + /// spawn radius of this. + /// @param player Which in-game player to create the delivery for. + /// @param existingObjects A list of SceneObject:s that will be tested against to see if any + /// sufficiently similar Object is positioned within the spawn radius of + /// this. + /// @return Whether the deployment spawning is blocked by one of the Objects in + /// the list. bool DeploymentBlocked(int player, const std::list& existingObjects); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetGoldValue - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the cost to purchase this item, in oz's of gold. - // Arguments: If this is supposed to be adjusted for a specific Tech's subjective - // value, then pass in the native DataModule ID of that tech. 0 means - // no Tech is specified and the base value is returned. - // How much to multiply the value if this happens to be a foreign Tech. - // Return value: The cost, in oz of gold. - + /// Gets the cost to purchase this item, in oz's of gold. + /// @param nativeModule If this is supposed to be adjusted for a specific Tech's subjective (default: 0) + /// value, then pass in the native DataModule ID of that tech. 0 means + /// no Tech is specified and the base value is returned. + /// @param foreignMult How much to multiply the value if this happens to be a foreign Tech. (default: 1.0) + /// @return The cost, in oz of gold. float GetGoldValue(int nativeModule = 0, float foreignMult = 1.0, float nativeMult = 1.0) const override { return GetTotalValue(nativeModule, foreignMult, nativeMult); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetGoldValueOld - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: DOES THE SAME THING AS GetGoldValue, USED ONLY TO PRESERVE LUA COMPATIBILITY - + /// DOES THE SAME THING AS GetGoldValue, USED ONLY TO PRESERVE LUA COMPATIBILITY float GetGoldValueOld(int nativeModule = 0, float foreignMult = 1.0) const override { return GetTotalValue(nativeModule, foreignMult, 1.0); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetTotalValue - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the total liquidation value of a spawn of this, including - // everything carried by it. - // Arguments: If this is supposed to be adjusted for a specific Tech's subjective - // value, then pass in the native DataModule ID of that tech. 0 means - // no Tech is specified and the base value is returned. - // How much to multiply the value if this happens to be a foreign Tech. - // Return value: The current value of this and all contained assets. - + /// Gets the total liquidation value of a spawn of this, including + /// everything carried by it. + /// @param nativeModule If this is supposed to be adjusted for a specific Tech's subjective (default: 0) + /// value, then pass in the native DataModule ID of that tech. 0 means + /// no Tech is specified and the base value is returned. + /// @param foreignMult How much to multiply the value if this happens to be a foreign Tech. (default: 1.0) + /// @return The current value of this and all contained assets. float GetTotalValue(int nativeModule = 0, float foreignMult = 1.0, float nativeMult = 1.0) const override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetID - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Return this deployment's unique ID - // Arguments: None. - // Return value: This deployment's ID - + /// Return this deployment's unique ID + /// @return This deployment's ID unsigned int GetID() const { return m_ID; }; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: CloneID - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clones id from the specified deployment - // Arguments: Deployment to clone Id from. - // Return value: None - + /// Clones id from the specified deployment + /// @param from Deployment to clone Id from. void CloneID(Deployment* from) { if (from) m_ID = from->GetID(); }; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: NewID - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Generates new random ID for this deployment. - // Arguments: None. - // Return value: None. - + /// Generates new random ID for this deployment. void NewID() { m_ID = RandomNum(1, 0xFFFF); }; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Draw - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws this Deployment's current graphical representation to a - // BITMAP of choice. - // Arguments: A pointer to a BITMAP to draw on. - // The absolute position of the target bitmap's upper left corner in the Scene. - // In which mode to draw in. See the DrawMode enumeration for the modes. - // Whether to not draw any extra 'ghost' items of this MovableObject, - // like indicator arrows or hovering HUD text and so on. - // Return value: None. - + /// Draws this Deployment's current graphical representation to a + /// BITMAP of choice. + /// @param pTargetBitmap A pointer to a BITMAP to draw on. + /// @param targetPos The absolute position of the target bitmap's upper left corner in the Scene. (default: Vector()) + /// @param mode In which mode to draw in. See the DrawMode enumeration for the modes. (default: g_DrawColor) + /// @param onlyPhysical Whether to not draw any extra 'ghost' items of this MovableObject, (default: false) + /// like indicator arrows or hovering HUD text and so on. void Draw(BITMAP* pTargetBitmap, const Vector& targetPos = Vector(), DrawMode mode = g_DrawColor, bool onlyPhysical = false) const override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: IsHFlipped - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns whether this MOSprite is being drawn flipped horizontally - // (along the vertical axis), or not. - // Arguments: None. - // Return value: Whether flipped or not. - + /// Returns whether this MOSprite is being drawn flipped horizontally + /// (along the vertical axis), or not. + /// @return Whether flipped or not. bool IsHFlipped() const override { return m_HFlipped; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virutal method: SetHFlipped - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets whether this should be drawn flipped horizontally (around the - // vertical axis). - // Arguments: A bool with the new value. - // Return value: None. - + /// Sets whether this should be drawn flipped horizontally (around the + /// vertical axis). + /// @param flipped A bool with the new value. void SetHFlipped(const bool flipped) override { m_HFlipped = flipped; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Protected member variable and method declarations - + /// Protected member variable and method declarations protected: // Member variables static Entity::ClassInfo m_sClass; @@ -351,18 +213,10 @@ namespace RTE { static std::vector m_apArrowLeftBitmap; static std::vector m_apArrowRightBitmap; - ////////////////////////////////////////////////////////////////////////////////////////// - // Private member variable and method declarations - + /// Private member variable and method declarations private: - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Clear - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears all the member variables of this Deployment, effectively - // resetting the members of this abstraction level only. - // Arguments: None. - // Return value: None. - + /// Clears all the member variables of this Deployment, effectively + /// resetting the members of this abstraction level only. void Clear(); // Disallow the use of some implicit methods. diff --git a/Source/Entities/Emission.cpp b/Source/Entities/Emission.cpp index 724bef4fe0..69c4b59177 100644 --- a/Source/Entities/Emission.cpp +++ b/Source/Entities/Emission.cpp @@ -1,12 +1,3 @@ -////////////////////////////////////////////////////////////////////////////////////////// -// File: Emission.cpp -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Source file for the Emission class. -// Project: Retro Terrain Engine -// Author(s): Daniel Tabar -// data@datarealms.com -// http://www.datarealms.com - #include "Emission.h" #include "PresetMan.h" @@ -16,12 +7,6 @@ namespace RTE { ConcreteClassInfo(Emission, Entity, 100); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Clear - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears all the member variables of this Emission, effectively - // resetting the members of this abstraction level only. - void Emission::Clear() { m_pEmission = 0; m_PPM = 0; @@ -55,11 +40,6 @@ namespace RTE { } */ - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Creates a Emission to be identical to another, by deep copy. - int Emission::Create(const Emission& reference) { m_pEmission = reference.m_pEmission; m_PPM = reference.m_PPM; @@ -78,14 +58,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: ReadProperty - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Reads a property value from a reader stream. If the name isn't - // recognized by this class, then ReadProperty of the parent class - // is called. If the property isn't recognized by any of the base classes, - // false is returned, and the reader's position is untouched. - int Emission::ReadProperty(const std::string_view& propName, Reader& reader) { StartPropertyList(return Serializable::ReadProperty(propName, reader)); @@ -123,12 +95,6 @@ namespace RTE { EndPropertyList; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Save - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Saves the complete state of this Emission with a Writer for - // later recreation with Create(Reader &reader); - int Emission::Save(Writer& writer) const { Serializable::Save(writer); diff --git a/Source/Entities/Emission.h b/Source/Entities/Emission.h index 52bc01f3c1..edbd483a4b 100644 --- a/Source/Entities/Emission.h +++ b/Source/Entities/Emission.h @@ -1,263 +1,133 @@ #ifndef _RTEEMISSION_ #define _RTEEMISSION_ -////////////////////////////////////////////////////////////////////////////////////////// -// File: Emission.h -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Something to bundle the properties of an emission together. -// Parent(s): Entity. -// Class history: 09/07/2004 Emission created as struct. -// 07/21/2006 Emission turned into 'Serializable' class. - +/// File: Emission.h +/// Something to bundle the properties of an emission together. +/// 07/21/2006 Emission turned into 'Serializable' class. #include "Serializable.h" #include "MovableObject.h" namespace RTE { - ////////////////////////////////////////////////////////////////////////////////////////// - // Class: Emission - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Something to bundle the properties of an emission together. - // Parent(s): Entity. - + /// Something to bundle the properties of an emission together. class Emission : public Entity { friend class AEmitter; friend class PEmitter; - ////////////////////////////////////////////////////////////////////////////////////////// - // Public member variable, method and friend function declarations - + /// Public member variable, method and friend function declarations public: // Concrete allocation and cloning definitions EntityAllocation(Emission); SerializableOverrideMethods; ClassInfoGetters; - ////////////////////////////////////////////////////////////////////////////////////////// - // Constructor: Emission - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Constructor method used to instantiate a Emission object in system - // memory. Create() should be called before using the object. - // Arguments: None. - + /// Constructor method used to instantiate a Emission object in system + /// memory. Create() should be called before using the object. Emission() { Clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Creates a Emission to be identical to another, by deep copy. - // Arguments: A reference to the Emission to deep copy. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Creates a Emission to be identical to another, by deep copy. + /// @param reference A reference to the Emission to deep copy. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Create(const Emission& reference); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Reset - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Resets the entire Serializable, including its inherited members, to their - // default settings or values. - // Arguments: None. - // Return value: None. - + /// Resets the entire Serializable, including its inherited members, to their + /// default settings or values. void Reset() override { Clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetEmissionParticlePreset - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the reference particle to be emitted. Owenership is NOT transferred! - // Arguments: None. - // Return value: A pointer to the particle to be emitted. Not transferred! - + /// Gets the reference particle to be emitted. Owenership is NOT transferred! + /// @return A pointer to the particle to be emitted. Not transferred! const MovableObject* GetEmissionParticlePreset() { return m_pEmission; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetRate - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the rate at which these emissions are made, in particles per minute. - // Arguments: None. - // Return value: The emission rate in PPM. - + /// Gets the rate at which these emissions are made, in particles per minute. + /// @return The emission rate in PPM. float GetRate() const { return m_PPM; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetRate - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the rate at which these emissions are made, in particles per minute. - // Arguments: The emission rate in PPM. - // Return value: None. - + /// Sets the rate at which these emissions are made, in particles per minute. + /// @param newPPM The emission rate in PPM. void SetRate(float newPPM) { m_PPM = newPPM; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetBurstSize - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the number of extra particles that are bursted at the beginning of - // emission. - // Arguments: None. - // Return value: The burst size. - + /// Gets the number of extra particles that are bursted at the beginning of + /// emission. + /// @return The burst size. int GetBurstSize() const { return m_BurstSize; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetBurstSize - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the number of extra particles that are bursted at the beginning of - // emission. - // Arguments: The burst size. - // Return value: None. - + /// Sets the number of extra particles that are bursted at the beginning of + /// emission. + /// @param newSize The burst size. void SetBurstSize(int newSize) { m_BurstSize = newSize; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetSpread - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the angle spread of velocity of the emitted MO's to each side of - // the m_EmitAngle angle. in radians. PI/2 would mean that MO's fly out to - // one side only, with the m_Rotation defining the middle of that half circle. - // Arguments: None. - // Return value: The emission spread in radians. - + /// Gets the angle spread of velocity of the emitted MO's to each side of + /// the m_EmitAngle angle. in radians. PI/2 would mean that MO's fly out to + /// one side only, with the m_Rotation defining the middle of that half circle. + /// @return The emission spread in radians. float GetSpread() const { return m_Spread; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetSpread - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the angle spread of velocity of the emitted MO's to each side of - // the m_EmitAngle angle. in radians. PI/2 would mean that MO's fly out to - // one side only, with the m_Rotation defining the middle of that half circle. - // Arguments: The emission spread in radians. - // Return value: None. - + /// Sets the angle spread of velocity of the emitted MO's to each side of + /// the m_EmitAngle angle. in radians. PI/2 would mean that MO's fly out to + /// one side only, with the m_Rotation defining the middle of that half circle. + /// @param newSpread The emission spread in radians. void SetSpread(float newSpread) { m_Spread = newSpread; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetMinVelocity - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the specified minimum velocity an emitted MO can have when emitted. - // Arguments: None. - // Return value: The min emission velocity in m/s. - + /// Gets the specified minimum velocity an emitted MO can have when emitted. + /// @return The min emission velocity in m/s. float GetMinVelocity() const { return m_MinVelocity; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetMinVelocity - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the specified minimum velocity an emitted MO can have when emitted. - // Arguments: The min emission velocity in m/s. - // Return value: None. - + /// Sets the specified minimum velocity an emitted MO can have when emitted. + /// @param newVel The min emission velocity in m/s. void SetMinVelocity(float newVel) { m_MinVelocity = newVel; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetMaxVelocity - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the specified maximum velocity an emitted MO can have when emitted. - // Arguments: None. - // Return value: The max emission velocity in m/s. - + /// Gets the specified maximum velocity an emitted MO can have when emitted. + /// @return The max emission velocity in m/s. float GetMaxVelocity() const { return m_MaxVelocity; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetMaxVelocity - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the specified maximum velocity an emitted MO can have when emitted. - // Arguments: The max emission velocity in m/s. - // Return value: None. - + /// Gets the specified maximum velocity an emitted MO can have when emitted. + /// @param newVel The max emission velocity in m/s. void SetMaxVelocity(float newVel) { m_MaxVelocity = newVel; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetLifeVariation - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the specified variation in lifetime of the emitted particles. - // Arguments: None. - // Return value: The life variation rationally expressed.. 0.1 = up to 10% varitaion. - + /// Gets the specified variation in lifetime of the emitted particles. + /// @return The life variation rationally expressed.. 0.1 = up to 10% varitaion. float GetLifeVariation() const { return m_LifeVariation; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetLifeVariation - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the specified variation in lifetime of the emitted particles. - // Arguments: The life variation rationally expressed.. 0.1 = up to 10% varitaion. - // Return value: None. - + /// Sets the specified variation in lifetime of the emitted particles. + /// @param newVariation The life variation rationally expressed.. 0.1 = up to 10% varitaion. void SetLifeVariation(float newVariation) { m_LifeVariation = newVariation; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: PushesEmitter - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Indicates whether this emission is supposed to push its emitter back - // because of recoil. - // Arguments: None. - // Return value: Whether recoil pushing is enabled or not for this emitter. - + /// Indicates whether this emission is supposed to push its emitter back + /// because of recoil. + /// @return Whether recoil pushing is enabled or not for this emitter. bool PushesEmitter() const { return m_PushesEmitter; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetPushesEmitter - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets whether this emission is supposed to push its emitter back - // because of recoil. - // Arguments: Whether recoil pushing is enabled or not for this emitter. - // Return value: None. - + /// Sets whether this emission is supposed to push its emitter back + /// because of recoil. + /// @param newValue Whether recoil pushing is enabled or not for this emitter. void SetPushesEmitter(bool newValue) { m_PushesEmitter = newValue; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: IsEmissionTime - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Shows whether this should be emitting now or not, based on what its - // start and end timers are set to. - // Arguments: None. - // Return value: Whether this should be emitting right now. - + /// Shows whether this should be emitting now or not, based on what its + /// start and end timers are set to. + /// @return Whether this should be emitting right now. bool IsEmissionTime() { return m_StartTimer.IsPastSimTimeLimit() && !m_StopTimer.IsPastSimTimeLimit(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ResetEmissionTimers - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Resets the emission timers so they start counting time as to wheter - // emissions are clearer. - // Arguments: None. - // Return value: None. - + /// Resets the emission timers so they start counting time as to wheter + /// emissions are clearer. void ResetEmissionTimers() { m_StartTimer.Reset(); m_StopTimer.Reset(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: InheritsVelocity - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: How much of the root parent's velocity this emission inherit - // Arguments: None. - // Return value: The proportion of the velocity inherited. 0.1 = 10% inheritance. - + /// How much of the root parent's velocity this emission inherit + /// @return The proportion of the velocity inherited. 0.1 = 10% inheritance. float InheritsVelocity() { return m_InheritsVel; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetOffset - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets offset of the emission point from Emitter's sprite center, which gets rotated with owner Emitter - // Arguments: None. - // Return value: Returns emission offset. - + /// Gets offset of the emission point from Emitter's sprite center, which gets rotated with owner Emitter + /// @return Returns emission offset. Vector GetOffset() const { return m_Offset; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetOffset - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets offset of the emission point from Emitter's sprite center, which gets rotated with owner Emitter - // Arguments: New offset value. - // Return value: None. - + /// Sets offset of the emission point from Emitter's sprite center, which gets rotated with owner Emitter + /// @param offset New offset value. void SetOffset(Vector offset) { m_Offset = offset; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Protected member variable and method declarations - + /// Protected member variable and method declarations protected: // Member variables // static const std::string m_sClassName; @@ -294,18 +164,10 @@ namespace RTE { // Offset of the emission point from Emitter's sprite center, which gets rotated with owner Emitter Vector m_Offset; - ////////////////////////////////////////////////////////////////////////////////////////// - // Private member variable and method declarations - + /// Private member variable and method declarations private: - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Clear - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears all the member variables of this Emission, effectively - // resetting the members of this abstraction level only. - // Arguments: None. - // Return value: None. - + /// Clears all the member variables of this Emission, effectively + /// resetting the members of this abstraction level only. void Clear(); }; diff --git a/Source/Entities/Gib.cpp b/Source/Entities/Gib.cpp index c136976780..763c006ade 100644 --- a/Source/Entities/Gib.cpp +++ b/Source/Entities/Gib.cpp @@ -6,8 +6,6 @@ namespace RTE { const std::string Gib::c_ClassName = "Gib"; - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void Gib::Clear() { m_GibParticle = nullptr; m_Offset.Reset(); @@ -21,8 +19,6 @@ namespace RTE { m_SpreadMode = SpreadMode::SpreadRandom; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int Gib::Create(const Gib& reference) { m_GibParticle = reference.m_GibParticle; m_Offset = reference.m_Offset; @@ -38,8 +34,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int Gib::ReadProperty(const std::string_view& propName, Reader& reader) { StartPropertyList(return Serializable::ReadProperty(propName, reader)); @@ -60,8 +54,6 @@ namespace RTE { EndPropertyList; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int Gib::Save(Writer& writer) const { Serializable::Save(writer); diff --git a/Source/Entities/Gib.h b/Source/Entities/Gib.h index 5051479235..635315295c 100644 --- a/Source/Entities/Gib.h +++ b/Source/Entities/Gib.h @@ -7,9 +7,7 @@ namespace RTE { class MovableObject; - /// /// Something to bundle the properties of Gib piece together. - /// class Gib : public Serializable { friend class GibEditor; friend struct EntityLuaBindings; @@ -18,9 +16,7 @@ namespace RTE { SerializableClassNameGetter; SerializableOverrideMethods; - /// /// Different types of logic for the Gib to use when applying velocity to its GibParticles. - /// enum SpreadMode { SpreadRandom, SpreadEven, @@ -28,115 +24,79 @@ namespace RTE { }; #pragma region Creation - /// /// Constructor method used to instantiate a Gib object in system memory. Create() should be called before using the object. - /// Gib() { Clear(); } - /// /// Creates a Gib to be identical to another, by deep copy. - /// - /// A reference to the Gib to deep copy. - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @param reference A reference to the Gib to deep copy. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create(const Gib& reference); #pragma endregion #pragma region Destruction - /// /// Destructor method used to clean up a Gib object before deletion from system memory. - /// ~Gib() override { Destroy(); } - /// /// Destroys and resets (through Clear()) the Gib object. - /// void Destroy() { Clear(); } #pragma endregion #pragma region Getters and Setters - /// /// Gets the reference particle to be used as a Gib. Ownership is NOT transferred! - /// - /// A pointer to the particle to be used as a Gib. + /// @return A pointer to the particle to be used as a Gib. const MovableObject* GetParticlePreset() const { return m_GibParticle; } - /// /// Sets the reference particle to be used as a Gib. Ownership is NOT transferred! - /// - /// A pointer to the new particle to be used as a Gib. + /// @param newParticlePreset A pointer to the new particle to be used as a Gib. void SetParticlePreset(const MovableObject* newParticlePreset) { m_GibParticle = newParticlePreset; } - /// /// Gets the spawn offset of this Gib from the parent's position. - /// - /// The offset in pixels from the parent's position where this Gib gets spawned. + /// @return The offset in pixels from the parent's position where this Gib gets spawned. Vector GetOffset() const { return m_Offset; } - /// /// Gets the number of copies of the GibParticle object that will be spawned in this Gib. - /// - /// The number of copies of the GibParticle object that will be spawned in this Gib. + /// @return The number of copies of the GibParticle object that will be spawned in this Gib. unsigned int GetCount() const { return m_Count; } - /// /// Gets the angle spread of the spawned GibParticle objects to each side of the parent's angle in radians. /// PI/2 would mean that GibParticles fly out to one side only, with the m_Rotation of the parent defining the middle of that half circle. - /// - /// The GibParticle spread in radians. + /// @return The GibParticle spread in radians. float GetSpread() const { return m_Spread; } - /// /// Gets the specified minimum velocity a GibParticle object can have when spawned. - /// - /// The minimum velocity a GibParticle can have when spawned in m/s. + /// @return The minimum velocity a GibParticle can have when spawned in m/s. float GetMinVelocity() const { return std::min(m_MinVelocity, m_MaxVelocity); } - /// /// Sets the specified minimum velocity a GibParticle object can have when spawned. - /// - /// The new minimum velocity in m/s. + /// @param newMinVelocity The new minimum velocity in m/s. void SetMinVelocity(float newMinVelocity) { m_MinVelocity = newMinVelocity; } - /// /// Gets the specified maximum velocity a GibParticle object can have when spawned. - /// - /// The maximum velocity a GibParticle can have when spawned in m/s. + /// @return The maximum velocity a GibParticle can have when spawned in m/s. float GetMaxVelocity() const { return std::max(m_MinVelocity, m_MaxVelocity); } - /// /// Sets the specified maximum velocity a GibParticle object can have when spawned. - /// - /// The new maximum velocity in m/s. + /// @param newMaxVelocity The new maximum velocity in m/s. void SetMaxVelocity(float newMaxVelocity) { m_MaxVelocity = newMaxVelocity; } - /// /// Gets the specified variation in Lifetime of the GibParticle objects. - /// - /// The life variation rationally expressed. 0.1 = up to 10% variation. + /// @return The life variation rationally expressed. 0.1 = up to 10% variation. float GetLifeVariation() const { return m_LifeVariation; } - /// /// Gets how much of the gibbing parent's velocity this Gib's GibParticles should inherit. - /// - /// The proportion of inherited velocity as a scalar from 0 to 1. + /// @return The proportion of inherited velocity as a scalar from 0 to 1. float InheritsVelocity() const { return m_InheritsVel; } - /// /// Gets whether this Gib's GibParticles should ignore hits with the team of the gibbing parent. - /// - /// Whether this Gib's GibParticles should ignore hits with the team of the gibbing parent. + /// @return Whether this Gib's GibParticles should ignore hits with the team of the gibbing parent. bool IgnoresTeamHits() const { return m_IgnoresTeamHits; } - /// /// Gets this Gib's spread mode, which determines how velocity angles are applied to the GibParticles. - /// - /// The spread mode of this Gib. + /// @return The spread mode of this Gib. SpreadMode GetSpreadMode() const { return m_SpreadMode; } - /// /// Sets this Gib's spread mode, which determines how velocity angles are applied to the GibParticles. - /// - /// The new spread mode of this Gib. See the SpreadMode enumeration. + /// @param newSpreadMode The new spread mode of this Gib. See the SpreadMode enumeration. void SetSpreadMode(SpreadMode newSpreadMode) { m_SpreadMode = (newSpreadMode < SpreadMode::SpreadRandom || newSpreadMode > SpreadMode::SpreadSpiral) ? SpreadMode::SpreadRandom : newSpreadMode; } #pragma endregion @@ -155,9 +115,7 @@ namespace RTE { private: static const std::string c_ClassName; //!< A string with the friendly-formatted type name of this object. - /// /// Clears all the member variables of this Gib, effectively resetting the members of this abstraction level only. - /// void Clear(); }; } // namespace RTE diff --git a/Source/Entities/GlobalScript.cpp b/Source/Entities/GlobalScript.cpp index d2c9175ea7..0d02e32a3d 100644 --- a/Source/Entities/GlobalScript.cpp +++ b/Source/Entities/GlobalScript.cpp @@ -14,8 +14,6 @@ namespace RTE { ConcreteClassInfo(GlobalScript, Entity, 10); - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GlobalScript::Clear() { m_ScriptPath.clear(); m_LuaClassName.clear(); @@ -25,8 +23,6 @@ namespace RTE { m_PieSlicesToAdd.clear(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int GlobalScript::Create(const GlobalScript& reference) { Entity::Create(reference); @@ -43,8 +39,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int GlobalScript::ReadProperty(const std::string_view& propName, Reader& reader) { StartPropertyList(return Entity::ReadProperty(propName, reader)); @@ -56,8 +50,6 @@ namespace RTE { EndPropertyList; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int GlobalScript::Save(Writer& writer) const { Entity::Save(writer); @@ -72,8 +64,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - const std::vector>& GlobalScript::GetPieSlicesToAdd() const { static const std::vector> emptyVector; if (!m_HasStarted || !m_IsActive || !g_SettingsMan.IsGlobalScriptEnabled(GetModuleAndPresetName())) { @@ -83,8 +73,6 @@ namespace RTE { return m_PieSlicesToAdd; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int GlobalScript::ReloadScripts() { int error = 0; @@ -101,8 +89,6 @@ namespace RTE { return error; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int GlobalScript::Start() { if (!g_SettingsMan.IsGlobalScriptEnabled(GetModuleAndPresetName())) { return 0; @@ -122,8 +108,6 @@ namespace RTE { return error; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int GlobalScript::Pause(bool pause) const { if (!m_IsActive || !m_HasStarted || !g_SettingsMan.IsGlobalScriptEnabled(GetModuleAndPresetName())) { return 0; @@ -132,8 +116,6 @@ namespace RTE { return g_LuaMan.GetMasterScriptState().RunScriptString("if " + m_LuaClassName + ".PauseScript then " + m_LuaClassName + ":PauseScript(" + (pause ? "true" : "false") + "); end"); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int GlobalScript::End() const { if (!m_HasStarted) { return 0; @@ -146,8 +128,6 @@ namespace RTE { return g_LuaMan.GetMasterScriptState().RunScriptString("if " + m_LuaClassName + ".EndScript then " + m_LuaClassName + ":EndScript(); end"); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GlobalScript::HandleCraftEnteringOrbit(const ACraft* orbitedCraft) { if (!m_IsActive || !!m_HasStarted || orbitedCraft == nullptr || !g_MovableMan.IsActor(orbitedCraft) || !g_SettingsMan.IsGlobalScriptEnabled(GetModuleAndPresetName())) { return; @@ -159,8 +139,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GlobalScript::Update() { if (!m_IsActive) { return; diff --git a/Source/Entities/GlobalScript.h b/Source/Entities/GlobalScript.h index d3a43db7c5..e1cd37de65 100644 --- a/Source/Entities/GlobalScript.h +++ b/Source/Entities/GlobalScript.h @@ -7,9 +7,7 @@ namespace RTE { class ACraft; - /// /// The supporting object for a lua script that can be turned on and off by the player, and run independent of Activities. - /// class GlobalScript : public Entity { friend struct EntityLuaBindings; @@ -19,35 +17,25 @@ namespace RTE { ClassInfoGetters; #pragma region Creation - /// /// Constructor method used to instantiate a GlobalScript object in system memory. Create() should be called before using the object. - /// GlobalScript() { Clear(); } - /// /// Makes the GlobalScript object ready for use. - /// - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create() override { return 0; } - /// /// Creates an GlobalScript to be identical to another, by deep copy. - /// - /// A reference to the GlobalScript to deep copy. - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @param reference A reference to the GlobalScript to deep copy. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create(const GlobalScript& reference); #pragma endregion #pragma region Destruction - /// /// Destructor method used to clean up a GlobalScript object before deletion from system memory. - /// ~GlobalScript() override { Destroy(true); } - /// /// Destroys and resets (through Clear()) the GlobalScript object. - /// - /// Whether to only destroy the members defined in this derived class, or to destroy all inherited members also. + /// @param notInherited Whether to only destroy the members defined in this derived class, or to destroy all inherited members also. void Destroy(bool notInherited = false) override { if (!notInherited) { Entity::Destroy(); @@ -55,9 +43,7 @@ namespace RTE { Clear(); } - /// /// Resets the entire GlobalScript, including its inherited members, to their default settings or values. - /// void Reset() override { Clear(); Entity::Reset(); @@ -65,66 +51,46 @@ namespace RTE { #pragma endregion #pragma region Getters and Setters - /// /// Gets whether or not this GlobalScript is active. Active scripts can be deactivated automatically if it fails to execute it's Update function without errors to avoid filling the console with error messages. - /// - /// Whether or not this GlobalScript is active. + /// @return Whether or not this GlobalScript is active. bool IsActive() const { return m_IsActive; } - /// /// Sets whether or not this GlobalScript should be active. - /// - /// Whether or not this GlobalScript should be active. + /// @param active Whether or not this GlobalScript should be active. void SetActive(bool active) { m_IsActive = active; } - /// /// Gets whether or not this GlobalScript should be updated late, i.e. after the standard MovableMan update. - /// - /// Whether or not this GlobalScript should be updated late. + /// @return Whether or not this GlobalScript should be updated late. bool ShouldLateUpdate() const { return m_LateUpdate; } - /// /// Gets the list of PieSlices this GlobalScript adds to any active Actor PieMenus. - /// - /// The list of PieSilces this GlobalScript adds to any active Actor PieMenus + /// @return The list of PieSilces this GlobalScript adds to any active Actor PieMenus const std::vector>& GetPieSlicesToAdd() const; #pragma endregion #pragma region Concrete Methods - /// /// Reloads the Lua script specified by this GlobalScript. This will also update the original preset in the PresetMan with the update scripts so future objects spawned will use the new scripts. - /// - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int ReloadScripts() override; - /// /// Starts this GlobalScript by running the appropriate Lua function. - /// - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Start(); - /// /// Pauses and unpauses this GlobalScript by running the appropriate Lua function. - /// - /// Whether or not this GlobalScript should be paused. - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @param pause Whether or not this GlobalScript should be paused. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Pause(bool pause = true) const; - /// /// Ends this GlobalScript by running the appropriate Lua function - /// - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int End() const; - /// /// Handles when an ACraft has left the game scene and entered orbit by running the appropriate Lua function. Ownership is NOT transferred! - /// - /// The ACraft instance that entered orbit. Ownership is NOT transferred! + /// @param orbitedCraft The ACraft instance that entered orbit. Ownership is NOT transferred! void HandleCraftEnteringOrbit(const ACraft* orbitedCraft); - /// /// Updates the state of this GlobalScript every frame. - /// void Update(); #pragma endregion @@ -139,9 +105,7 @@ namespace RTE { std::vector> m_PieSlicesToAdd; //!< A vector of PieSlices that should be added to any PieMenus opened while this GlobalScript is active. - /// /// Clears all the member variables of this GlobalScript, effectively resetting the members of this abstraction level only. - /// void Clear(); // Disallow the use of some implicit methods. diff --git a/Source/Entities/HDFirearm.cpp b/Source/Entities/HDFirearm.cpp index 72c11dda37..804435a3b0 100644 --- a/Source/Entities/HDFirearm.cpp +++ b/Source/Entities/HDFirearm.cpp @@ -1,15 +1,3 @@ -////////////////////////////////////////////////////////////////////////////////////////// -// File: HDFirearm.cpp -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Source file for the HDFirearm class. -// Project: Retro Terrain Engine -// Author(s): Daniel Tabar -// data@datarealms.com -// http://www.datarealms.com - -////////////////////////////////////////////////////////////////////////////////////////// -// Inclusions of header files - #include "HDFirearm.h" #include "ActivityMan.h" @@ -27,12 +15,6 @@ namespace RTE { ConcreteClassInfo(HDFirearm, HeldDevice, 50); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Clear - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears all the member variables of this HDFirearm, effectively - // resetting the members of this abstraction level only. - void HDFirearm::Clear() { m_pMagazineReference = 0; m_pMagazine = 0; @@ -88,11 +70,6 @@ namespace RTE { m_LegacyCompatibilityRoundsAlwaysFireUnflipped = false; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes the Round object ready for use. - int HDFirearm::Create() { if (HeldDevice::Create() < 0) return -1; @@ -103,11 +80,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Creates a HDFirearm to be identical to another, by deep copy. - int HDFirearm::Create(const HDFirearm& reference) { if (reference.m_pMagazine) { m_ReferenceHardcodedAttachableUniqueIDs.insert(reference.m_pMagazine->GetUniqueID()); @@ -186,14 +158,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: ReadProperty - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Reads a property value from a reader stream. If the name isn't - // recognized by this class, then ReadProperty of the parent class - // is called. If the property isn't recognized by any of the base classes, - // false is returned, and the reader's position is untouched. - int HDFirearm::ReadProperty(const std::string_view& propName, Reader& reader) { StartPropertyList(return HeldDevice::ReadProperty(propName, reader)); @@ -277,12 +241,6 @@ namespace RTE { EndPropertyList; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Save - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Saves the complete state of this HDFirearm with a Writer for - // later recreation with Create(Reader &reader); - int HDFirearm::Save(Writer& writer) const { HeldDevice::Save(writer); @@ -357,11 +315,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destroys and resets (through Clear()) the HDFirearm object. - void HDFirearm::Destroy(bool notInherited) { if (m_PreFireSound) { m_PreFireSound->Stop(); @@ -402,8 +355,6 @@ namespace RTE { Clear(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void HDFirearm::SetMagazine(Magazine* newMagazine) { if (m_pMagazine && m_pMagazine->IsAttached()) { RemoveAndDeleteAttachable(m_pMagazine); @@ -427,8 +378,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void HDFirearm::SetFlash(Attachable* newFlash) { if (m_pFlash && m_pFlash->IsAttached()) { RemoveAndDeleteAttachable(m_pFlash); @@ -452,14 +401,10 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - std::string HDFirearm::GetNextMagazineName() const { return m_pMagazineReference->GetPresetName(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool HDFirearm::SetNextMagazineName(std::string magName) { const Magazine* pNewMag = dynamic_cast(g_PresetMan.GetEntityPreset("Magazine", magName)); if (pNewMag) { @@ -473,17 +418,10 @@ namespace RTE { return false; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: GetRoundInMagCount - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the number of rounds still in the loaded magazine. - int HDFirearm::GetRoundInMagCount() const { return m_pMagazine ? m_pMagazine->GetRoundCount() : 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int HDFirearm::GetRoundInMagCapacity() const { if (m_pMagazine) { return m_pMagazine->GetCapacity(); @@ -493,11 +431,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetAIFireVel - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the velocity the AI use when aiming this weapon - float HDFirearm::GetAIFireVel() { if (m_AIFireVel < 0 && m_pMagazine) m_AIFireVel = m_pMagazine->GetAIAimVel(); @@ -505,11 +438,6 @@ namespace RTE { return m_AIFireVel; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetAIBulletLifeTime - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the bullet life time the AI use when aiming this weapon. - unsigned long HDFirearm::GetAIBulletLifeTime() { if (m_AIBulletLifeTime == 0 && m_pMagazine) { const Round* pRound = m_pMagazine->GetNextRound(); @@ -525,11 +453,6 @@ namespace RTE { return m_AIBulletLifeTime; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetBulletAccScalar - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the bullet acceleration scalar the AI use when aiming this weapon. - float HDFirearm::GetBulletAccScalar() { if (m_AIBulletAccScalar < 0 && m_pMagazine) m_AIBulletAccScalar = m_pMagazine->GetBulletAccScalar(); @@ -537,11 +460,6 @@ namespace RTE { return m_AIBulletAccScalar; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetAIBlastRadius - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the blast radius the AI use when aiming this weapon - float HDFirearm::GetAIBlastRadius() const { int radius = -1; if (m_pMagazine) @@ -558,11 +476,6 @@ namespace RTE { return radius; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetAIPenetration - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets how much material the projectiles from this weapon can destory. - float HDFirearm::GetAIPenetration() const { if (m_pMagazine) return m_pMagazine->GetAIAimPenetration(); @@ -570,11 +483,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: CompareTrajectories - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Estimates how close the projectiles from two weapons will land. - float HDFirearm::CompareTrajectories(HDFirearm* pWeapon) { if (pWeapon) { // Get AI aim data and cap life time to one second @@ -606,28 +514,14 @@ namespace RTE { return 100000; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: GetMagazinePos - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the absolute position of the magazine or other equivalent point of - // this. - Vector HDFirearm::GetMagazinePos() const { return m_Pos + RotateOffset(m_MagOff); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virutal method: GetMuzzlePos - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the absolute position of the muzzle or other equivalent point of - // this. - Vector HDFirearm::GetMuzzlePos() const { return m_Pos + RotateOffset(m_MuzzleOff); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void HDFirearm::RestDetection() { HeldDevice::RestDetection(); @@ -636,12 +530,6 @@ namespace RTE { } } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Activate - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Activates one of this HDFirearm's features. Analogous to 'pulling - // the trigger'. - void HDFirearm::Activate() { bool wasActivated = m_Activated; HeldDevice::Activate(); @@ -659,12 +547,6 @@ namespace RTE { } } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Deactivate - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Deactivates one of this HDFirearm's features. Analogous to 'releasing - // the trigger'. - void HDFirearm::Deactivate() { bool wasActivated = m_Activated; HeldDevice::Deactivate(); @@ -681,12 +563,6 @@ namespace RTE { } } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: StopActivationSound - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Aborts playing of active sound no matter what. Used to silence spinning - // weapons when weapons swapped - void HDFirearm::StopActivationSound() { if (m_ActiveSound && m_ActiveSound->IsBeingPlayed()) m_ActiveSound->Stop(); @@ -698,8 +574,6 @@ namespace RTE { // m_LastFireTmr.SetElapsedSimTimeMS(m_DeactivationDelay + 1); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void HDFirearm::Reload() { if (!m_Reloading && m_Reloadable) { bool hadMagazineBeforeReloading = m_pMagazine != nullptr; @@ -730,13 +604,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: NeedsReloading - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Tells whether the device is curtrently in need of being reloaded. - bool HDFirearm::NeedsReloading() const { if (!m_Reloading && m_Reloadable) { if (m_pMagazine) { @@ -749,12 +616,6 @@ namespace RTE { return false; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: IsFull - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Tells whether the device is curtrently full and reloading won't have - // any effect. - bool HDFirearm::IsFull() const { if (!m_Reloading && m_Reloadable) { if (m_pMagazine) { @@ -767,8 +628,6 @@ namespace RTE { return true; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool HDFirearm::IsEmpty() const { if (m_pMagazine) { return m_pMagazine->IsEmpty(); @@ -776,13 +635,6 @@ namespace RTE { return true; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Update - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates this HDFirearm. Supposed to be done every frame. - void HDFirearm::Update() { HeldDevice::Update(); @@ -1146,21 +998,10 @@ namespace RTE { } } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: EstimateDigStrength - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Estimates what material strength the rounds in the magazine can destroy. - float HDFirearm::EstimateDigStrength() const { return m_pMagazine ? m_pMagazine->EstimateDigStrength() : m_pMagazineReference->EstimateDigStrength(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Draw - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws this HDFirearm's current graphical representation to a - // BITMAP of choice. - void HDFirearm::Draw(BITMAP* pTargetBitmap, const Vector& targetPos, DrawMode mode, bool onlyPhysical) const { if (m_pFlash && m_FireFrame && !m_pFlash->IsDrawnAfterParent() && mode == g_DrawColor && !onlyPhysical) { m_pFlash->Draw(pTargetBitmap, targetPos, mode, onlyPhysical); @@ -1173,11 +1014,6 @@ namespace RTE { } } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: DrawHUD - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws an aiming aid in front of this HeldDevice. - void HDFirearm::DrawHUD(BITMAP* pTargetBitmap, const Vector& targetPos, int whichScreen, bool playerControlled) { if (!m_HUDVisible) return; diff --git a/Source/Entities/HDFirearm.h b/Source/Entities/HDFirearm.h index 127a60b288..1c411f316e 100644 --- a/Source/Entities/HDFirearm.h +++ b/Source/Entities/HDFirearm.h @@ -1,36 +1,21 @@ #ifndef _RTEHDFIREARM_ #define _RTEHDFIREARM_ -////////////////////////////////////////////////////////////////////////////////////////// -// File: HDFirearm.h -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Header file for the HDFirearm class. -// Project: Retro Terrain Engine -// Author(s): Daniel Tabar -// data@datarealms.com -// http://www.datarealms.com - -////////////////////////////////////////////////////////////////////////////////////////// -// Inclusions of header files - +/// Header file for the HDFirearm class. +/// @author Daniel Tabar +/// data@datarealms.com +/// http://www.datarealms.com +/// Inclusions of header files #include "HeldDevice.h" namespace RTE { class Magazine; - ////////////////////////////////////////////////////////////////////////////////////////// - // Class: HDFirearm - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: A firearm device that fires projectile MO's and discharges shell MO's. - // Parent(s): HeldDevice. - // Class history: 07/1/2002 HDFirearm created. - + /// A firearm device that fires projectile MO's and discharges shell MO's. class HDFirearm : public HeldDevice { - ////////////////////////////////////////////////////////////////////////////////////////// - // Public member variable, method and friend function declarations - + /// Public member variable, method and friend function declarations public: // Concrete allocation and cloning definitions EntityAllocation(HDFirearm); @@ -38,816 +23,451 @@ namespace RTE { ClassInfoGetters; AddScriptFunctionNames(HeldDevice, "OnFire", "OnReload"); - ////////////////////////////////////////////////////////////////////////////////////////// - // Constructor: HDFirearm - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Constructor method used to instantiate a HDFirearm object in system - // memory. Create() should be called before using the object. - // Arguments: None. - + /// Constructor method used to instantiate a HDFirearm object in system + /// memory. Create() should be called before using the object. HDFirearm() { Clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Destructor: ~HDFirearm - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destructor method used to clean up a HDFirearm object before deletion - // from system memory. - // Arguments: None. - + /// Destructor method used to clean up a HDFirearm object before deletion + /// from system memory. ~HDFirearm() override { Destroy(true); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes the HDFirearm object ready for use. - // Arguments: None. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Makes the HDFirearm object ready for use. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Create() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Creates a HDFirearm to be identical to another, by deep copy. - // Arguments: A reference to the HDFirearm to deep copy. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Creates a HDFirearm to be identical to another, by deep copy. + /// @param reference A reference to the HDFirearm to deep copy. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Create(const HDFirearm& reference); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Reset - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Resets the entire HDFirearm, including its inherited members, to their - // default settings or values. - // Arguments: None. - // Return value: None. - + /// Resets the entire HDFirearm, including its inherited members, to their + /// default settings or values. void Reset() override { Clear(); HeldDevice::Reset(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destroys and resets (through Clear()) the SceneLayer object. - // Arguments: Whether to only destroy the members defined in this derived class, or - // to destroy all inherited members also. - // Return value: None. - + /// Destroys and resets (through Clear()) the SceneLayer object. + /// @param notInherited Whether to only destroy the members defined in this derived class, or (default: false) + /// to destroy all inherited members also. void Destroy(bool notInherited = false) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetReloadEndOffset - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets reload end offset, in ms. This is how early the ReloadEnd - // sound is played compared to actual end of reload. - // Arguments: None. - // Return value: The reload end offset, in ms. - + /// Gets reload end offset, in ms. This is how early the ReloadEnd + /// sound is played compared to actual end of reload. + /// @return The reload end offset, in ms. int GetReloadEndOffset() const { return m_ReloadEndOffset; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetReloadEndOffset - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets reload end offset, in ms. This is how early the ReloadEnd - // sound is played compared to actual end of reload. - // Arguments: The new reload end offset, in ms. - // Return value: None. - + /// Sets reload end offset, in ms. This is how early the ReloadEnd + /// sound is played compared to actual end of reload. + /// @param newRate The new reload end offset, in ms. void SetReloadEndOffset(int newRate) { m_ReloadEndOffset = newRate; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetRateOfFire - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the rate of fire of this. This applies even if semi-auto. it - // limits how quickly a new round can be fired after the last. - // Arguments: None. - // Return value: The rate of fire, in rounds per min. - + /// Gets the rate of fire of this. This applies even if semi-auto. it + /// limits how quickly a new round can be fired after the last. + /// @return The rate of fire, in rounds per min. int GetRateOfFire() const { return m_RateOfFire; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetRateOfFire - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the rate of fire of this. This applies even if semi-auto. it - // limits how quickly a new round can be fired after the last. - // Arguments: The new rate of fire, in rounds per min. - // Return value: None. - + /// Sets the rate of fire of this. This applies even if semi-auto. it + /// limits how quickly a new round can be fired after the last. + /// @param newRate The new rate of fire, in rounds per min. void SetRateOfFire(int newRate) { m_RateOfFire = newRate; } - /// /// Gets the minimum time in between shots, in MS. - /// - /// The minimum time in between shots, in MS. + /// @return The minimum time in between shots, in MS. double GetMSPerRound() const { return 60000.0 / static_cast(m_RateOfFire); } - /// /// Gets the Magazine of this HDFirearm. - /// - /// A pointer to Magazine of this HDFirearm. Ownership is NOT transferred! + /// @return A pointer to Magazine of this HDFirearm. Ownership is NOT transferred! Magazine* GetMagazine() const { return m_pMagazine; } - /// /// Sets the Magazine for this HDFirearm. Ownership IS transferred! - /// - /// The new Magazine to use. + /// @param newMagazine The new Magazine to use. void SetMagazine(Magazine* newMagazine); - /// /// Gets the flash of this HDFirearm. - /// - /// A pointer to flash of this HDFirearm. Ownership is NOT transferred! + /// @return A pointer to flash of this HDFirearm. Ownership is NOT transferred! Attachable* GetFlash() const { return m_pFlash; } - /// /// Sets the flash for this HDFirearm. Ownership IS transferred! - /// - /// The new flash to use. + /// @param newTurret The new flash to use. void SetFlash(Attachable* newFlash); - /// /// Gets the preset name of the next Magazine that will be loaded into this gun. - /// - /// The preset name of the next Magazine that will be loaded into this gun. + /// @return The preset name of the next Magazine that will be loaded into this gun. std::string GetNextMagazineName() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetNextMagazineName - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the Preset name of the next Magazine that will be loaded into - // this gun. This changes all future mags that will be reloaded. - // Arguments: The preset name of the new Magazine to load into this from now on. - // Return value: Whether the specified magazine was found and successfully prepared. - + /// Sets the Preset name of the next Magazine that will be loaded into + /// this gun. This changes all future mags that will be reloaded. + /// @param magName The preset name of the new Magazine to load into this from now on. + /// @return Whether the specified magazine was found and successfully prepared. bool SetNextMagazineName(std::string magName); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetRoundInMagCount - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the number of rounds still in the loaded magazine. Negative value - // means infinite ammo. - // Arguments: None. - // Return value: An int with the number of rounds in the magazine currently in this - // HDFirearm. Negative means infinite ammo. - + /// Gets the number of rounds still in the loaded magazine. Negative value + /// means infinite ammo. + /// @return An int with the number of rounds in the magazine currently in this + /// HDFirearm. Negative means infinite ammo. int GetRoundInMagCount() const; - /// /// Gets the maximum RoundCount a Magazine of this HDFirearm can hold. /// If there is no Magazine, it gets the RoundCount of the reference Magazine. - /// - /// An int with the maximum RoundCount the magazine or magazine reference of this HDFirearm can hold. + /// @return An int with the maximum RoundCount the magazine or magazine reference of this HDFirearm can hold. int GetRoundInMagCapacity() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetActivationDelay - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the delay before firing. - // Arguments: None. - // Return value: An int with the activation delay in ms. - + /// Gets the delay before firing. + /// @return An int with the activation delay in ms. int GetActivationDelay() const { return m_ActivationDelay; }; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetActivationDelay - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the delay before firing. - // Arguments: An int with the activation delay in ms. - // Return value: None. - + /// Sets the delay before firing. + /// @param delay An int with the activation delay in ms. void SetActivationDelay(int delay) { m_ActivationDelay = delay; }; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetDeactivationDelay - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the delay between release of activation and another can be started. - // Arguments: None. - // Return value: An int with the delay in ms. - + /// Gets the delay between release of activation and another can be started. + /// @return An int with the delay in ms. int GetDeactivationDelay() const { return m_DeactivationDelay; }; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetDeactivationDelay - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the delay between release of activation and another can be started. - // Arguments: An int with the delay in ms. - // Return value: None. - + /// Sets the delay between release of activation and another can be started. + /// @param delay An int with the delay in ms. void SetDeactivationDelay(int delay) { m_DeactivationDelay = delay; }; - /// /// Gets the base time this HDFirearm takes to reload, in milliseconds. - /// - /// The base time this HeldDevice takes to reload, in milliseconds. + /// @return The base time this HeldDevice takes to reload, in milliseconds. int GetBaseReloadTime() const { return m_BaseReloadTime; }; - /// /// Sets the base time this HDFirearm takes to reload, in milliseconds. - /// - /// The base time this HDFirearm should take to reload, in milliseconds. + /// @param delay The base time this HDFirearm should take to reload, in milliseconds. void SetBaseReloadTime(int newReloadTime) { m_BaseReloadTime = newReloadTime; CorrectReloadTimerForSupportAvailable(); }; - /// /// Gets how long this HDFirearm currently takes to reload, in milliseconds. - /// - /// How long this HDFirearm currently takes to reload, in milliseconds. + /// @return How long this HDFirearm currently takes to reload, in milliseconds. int GetReloadTime() const { return m_ReloadTmr.GetSimTimeLimitMS() <= 0 ? m_BaseReloadTime : static_cast(std::floor(m_ReloadTmr.GetSimTimeLimitMS())); }; - /// /// Gets whether or not this HDFirearm allows dual-reload, i.e. if it's one-handed and dual-wieldable, it can reload at the same time as another weapon that also allows dual-reload. - /// - /// Whether or not this HDFirearm allows dual-reload. + /// @return Whether or not this HDFirearm allows dual-reload. bool IsDualReloadable() const { return m_DualReloadable; } - /// /// Sets whether or not this HDFirearm allows dual-reloading. - /// - /// The new value for whether or not this HDFirearm should allow dual-reloading. + /// @param newDualReloadable The new value for whether or not this HDFirearm should allow dual-reloading. void SetDualReloadable(bool newDualReloadable) { m_DualReloadable = newDualReloadable; } - /// /// Gets the multiplier to be applied to reload time when this HDFirearm is being reloaded one-handed. - /// - /// The multiplier to be applied to reload time when this HDFirearm is being reloaded one-handed. + /// @return The multiplier to be applied to reload time when this HDFirearm is being reloaded one-handed. float GetOneHandedReloadTimeMultiplier() const { return m_OneHandedReloadTimeMultiplier; } - /// /// Sets the multiplier to be applied to reload time when this HDFirearm is being reloaded one-handed. - /// - /// The new multiplier to be applied to reload time when this HDFirearm is being reloaded one-handed. + /// @param newDualReloadTimeMultiplier The new multiplier to be applied to reload time when this HDFirearm is being reloaded one-handed. void SetOneHandedReloadTimeMultiplier(float newOneHandedReloadTimeMultiplier) { m_OneHandedReloadTimeMultiplier = newOneHandedReloadTimeMultiplier; } - /// /// Gets the reload angle this HDFirearm will use when support is available. - /// - /// The reload angle this HDFirearm will use when support is available, in radians. + /// @return The reload angle this HDFirearm will use when support is available, in radians. float GetReloadAngle() const { return m_ReloadAngle; } - /// /// Sets the reload angle this HDFirearm should use when support is available. - /// - /// The new reload angle this HDFirearm should use when support is available. + /// @param newReloadAngle The new reload angle this HDFirearm should use when support is available. void SetReloadAngle(float newReloadAngle) { m_ReloadAngle = newReloadAngle; } - /// /// Gets the reload angle this HDFirearm will use when support is not available. - /// - /// The reload angle this HDFirearm will use when support is not available, in radians. + /// @return The reload angle this HDFirearm will use when support is not available, in radians. float GetOneHandedReloadAngle() const { return m_OneHandedReloadAngle; } - /// /// Sets the reload angle this HDFirearm should use when support is not available. - /// - /// The new reload angle this HDFirearm should use when support is not available. + /// @param newOneHandedReloadAngle The new reload angle this HDFirearm should use when support is not available. void SetOneHandedReloadAngle(float newOneHandedReloadAngle) { m_OneHandedReloadAngle = newOneHandedReloadAngle; } - /// /// Gets the reload angle this HDFirearm is currently using, based on whether or not support is available. - /// - /// The current reload angle of this HDFirearm, in radians. + /// @return The current reload angle of this HDFirearm, in radians. float GetCurrentReloadAngle() const { return m_SupportAvailable ? m_ReloadAngle : m_OneHandedReloadAngle; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetShakeRange - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the range of normal shaking of entire weapon. - // Arguments: None. - // Return value: A float with the range in degrees. - + /// Gets the range of normal shaking of entire weapon. + /// @return A float with the range in degrees. float GetShakeRange() const { return m_ShakeRange; }; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetShakeRange - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the range of normal shaking of entire weapon. - // Arguments: A float with the range in degrees. - // Return value: None. - + /// Sets the range of normal shaking of entire weapon. + /// @param range A float with the range in degrees. void SetShakeRange(float range) { m_ShakeRange = range; }; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetSharpShakeRange - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the range of shaking of entire weapon during sharp aiming. - // Arguments: None. - // Return value: A float with the range in degrees. - + /// Gets the range of shaking of entire weapon during sharp aiming. + /// @return A float with the range in degrees. float GetSharpShakeRange() const { return m_SharpShakeRange; }; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetSharpShakeRange - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the range of shaking of entire weapon during sharp aiming. - // Arguments: A float with the range in degrees. - // Return value: None. - + /// Sets the range of shaking of entire weapon during sharp aiming. + /// @param range A float with the range in degrees. void SetSharpShakeRange(float range) { m_SharpShakeRange = range; }; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetNoSupportFactor - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the factor for how much more weapon shakes if it isn't supported - // by a second hand. - // Arguments: None. - // Return value: A float with the factor. - + /// Gets the factor for how much more weapon shakes if it isn't supported + /// by a second hand. + /// @return A float with the factor. float GetNoSupportFactor() const { return m_NoSupportFactor; }; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetNoSupportFactor - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the factor for how much more weapon shakes if it isn't supported - // by a second hand. - // Arguments: A float with the factor. - // Return value: None. - + /// Sets the factor for how much more weapon shakes if it isn't supported + /// by a second hand. + /// @param factor A float with the factor. void SetNoSupportFactor(float factor) { m_NoSupportFactor = factor; }; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetParticleSpreadRange - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the range of spread angle of fired particles, in one direction. - // Arguments: None. - // Return value: A float with the range in degrees. - + /// Gets the range of spread angle of fired particles, in one direction. + /// @return A float with the range in degrees. float GetParticleSpreadRange() const { return m_ParticleSpreadRange; }; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetParticleSpreadRange - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the range of spread angle of fired particles, in one direction. - // Arguments: A float with the range in degrees. - // Return value: None. - + /// Sets the range of spread angle of fired particles, in one direction. + /// @param range A float with the range in degrees. void SetParticleSpreadRange(float range) { m_ParticleSpreadRange = range; }; - /// /// Gets the random velocity variation scalar at which this HDFirearm's shell is to be ejected. - /// - /// A float with the scalar value. + /// @return A float with the scalar value. float GetShellVelVariation() const { return m_ShellVelVariation; } - /// /// Sets the random velocity variation scalar at which this HDFirearm's shell is to be ejected. - /// - /// The new velocity variation scalar. + /// @param newVariation The new velocity variation scalar. void SetShellVelVariation(float newVariation) { m_ShellVelVariation = newVariation; } - /// /// Sets the stiffness scalar of the joint of this HDFirearm. Unlike Attachable::SetJointStiffness, there are no limitations on this value. /// 1.0 means impulse forces on this attachable will be transferred to the parent with 100% strength, 0 means they will not transfer at all, negative values will apply negative force, which may behave oddly. - /// - /// A float describing the normalized stiffness scalar of this Attachable's joint. + /// @param jointStiffness A float describing the normalized stiffness scalar of this Attachable's joint. void SetJointStiffness(float jointStiffness) override { m_JointStiffness = jointStiffness; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetAIFireVel - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the velocity the AI use when aiming this weapon. - // Arguments: None. - // Return value: A float with the velocity in m/s. - + /// Gets the velocity the AI use when aiming this weapon. + /// @return A float with the velocity in m/s. float GetAIFireVel(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetAIBulletLifeTime - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the bullet life time the AI use when aiming this weapon. - // Arguments: None. - // Return value: A float with the life time in ms. - + /// Gets the bullet life time the AI use when aiming this weapon. + /// @return A float with the life time in ms. unsigned long GetAIBulletLifeTime(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetBulletAccScalar - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the bullet acceleration scalar the AI use when aiming this weapon. - // Arguments: None. - // Return value: A float with the scalar. - + /// Gets the bullet acceleration scalar the AI use when aiming this weapon. + /// @return A float with the scalar. float GetBulletAccScalar(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetAIBlastRadius - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the blast radius the AI use when aiming this weapon. - // Arguments: None. - // Return value: A float with the blast radius in pixels. - + /// Gets the blast radius the AI use when aiming this weapon. + /// @return A float with the blast radius in pixels. float GetAIBlastRadius() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetAIPenetration - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets how much material the projectiles from this weapon can destory. - // Arguments: None. - // Return value: A float with the material strength. - + /// Gets how much material the projectiles from this weapon can destory. + /// @return A float with the material strength. float GetAIPenetration() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: CompareTrajectories - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Estimates how close the projectiles from two weapons will land. - // Arguments: A HDFirearm pointer to compare with. - // Return value: A float with the distance in pixels. - + /// Estimates how close the projectiles from two weapons will land. + /// @param pWeapon A HDFirearm pointer to compare with. + /// @return A float with the distance in pixels. float CompareTrajectories(HDFirearm* pWeapon); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: GetMagazinePos - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the absolute position of the magazine or other equivalent point of - // this. - // Arguments: None. - // Return value: A vector describing the absolute world coordinates for the magazine - // attachment point of this - + /// Gets the absolute position of the magazine or other equivalent point of + /// this. + /// @return A vector describing the absolute world coordinates for the magazine + /// attachment point of this Vector GetMagazinePos() const override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: GetMuzzlePos - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the absolute position of the muzzle or other equivalent point of - // this. - // Arguments: None. - // Return value: A vector describing the absolute world coordinates for the muzzle point - // of this - + /// Gets the absolute position of the muzzle or other equivalent point of + /// this. + /// @return A vector describing the absolute world coordinates for the muzzle point + /// of this Vector GetMuzzlePos() const override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: GetMuzzleOffset - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the unrotated relative offset from the position to the muzzle or - // other equivalent point of this. - // Arguments: None. - // Return value: A unrotated vector describing the relative for the muzzle point of - // this from this' position. - + /// Gets the unrotated relative offset from the position to the muzzle or + /// other equivalent point of this. + /// @return A unrotated vector describing the relative for the muzzle point of + /// this from this' position. Vector GetMuzzleOffset() const override { return m_MuzzleOff; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: SetMuzzleOffset - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the unrotated relative offset from the position to the muzzle or - // other equivalent point of this. - // Arguments: Bew ofsset value. - // Return value: None. - + /// Sets the unrotated relative offset from the position to the muzzle or + /// other equivalent point of this. + /// @param newOffset Bew ofsset value. void SetMuzzleOffset(Vector newOffset) override { m_MuzzleOff = newOffset; } - /// /// Gets this HDFirearm's pre fire sound. Ownership is NOT transferred! - /// - /// The SoundContainer for this HDFirearm's pre fire sound. + /// @return The SoundContainer for this HDFirearm's pre fire sound. SoundContainer* GetPreFireSound() const { return m_PreFireSound; } - /// /// Sets this HDFirearm's pre fire sound. Ownership IS transferred! - /// - /// The new SoundContainer for this HDFirearm's pre fire sound. + /// @param newSound The new SoundContainer for this HDFirearm's pre fire sound. void SetPreFireSound(SoundContainer* newSound) { m_PreFireSound = newSound; } - /// /// Gets this HDFirearm's fire sound. Ownership is NOT transferred! - /// - /// The SoundContainer for this HDFirearm's fire sound. + /// @return The SoundContainer for this HDFirearm's fire sound. SoundContainer* GetFireSound() const { return m_FireSound; } - /// /// Sets this HDFirearm's fire sound. Ownership IS transferred! - /// - /// The new SoundContainer for this HDFirearm's fire sound. + /// @param newSound The new SoundContainer for this HDFirearm's fire sound. void SetFireSound(SoundContainer* newSound) { m_FireSound = newSound; } - /// /// Gets this HDFirearm's fire echo sound. Ownership is NOT transferred! - /// - /// The SoundContainer for this HDFirearm's fire echo sound. + /// @return The SoundContainer for this HDFirearm's fire echo sound. SoundContainer* GetFireEchoSound() const { return m_FireEchoSound; } - /// /// Sets this HDFirearm's fire echo sound. Ownership IS transferred! - /// - /// The new SoundContainer for this HDFirearm's fire echo sound. + /// @param newSound The new SoundContainer for this HDFirearm's fire echo sound. void SetFireEchoSound(SoundContainer* newSound) { m_FireEchoSound = newSound; } - /// /// Gets this HDFirearm's active sound. Ownership is NOT transferred! - /// - /// The SoundContainer for this HDFirearm's active sound. + /// @return The SoundContainer for this HDFirearm's active sound. SoundContainer* GetActiveSound() const { return m_ActiveSound; } - /// /// Sets this HDFirearm's active sound. Ownership IS transferred! - /// - /// The new SoundContainer for this HDFirearm's active sound. + /// @param newSound The new SoundContainer for this HDFirearm's active sound. void SetActiveSound(SoundContainer* newSound) { m_ActiveSound = newSound; } - /// /// Gets this HDFirearm's deactivation sound. Ownership is NOT transferred! - /// - /// The SoundContainer for this HDFirearm's deactivation sound. + /// @return The SoundContainer for this HDFirearm's deactivation sound. SoundContainer* GetDeactivationSound() const { return m_DeactivationSound; } - /// /// Sets this HDFirearm's deactivation sound. Ownership IS transferred! - /// - /// The new SoundContainer for this HDFirearm's deactivation sound. + /// @param newSound The new SoundContainer for this HDFirearm's deactivation sound. void SetDeactivationSound(SoundContainer* newSound) { m_DeactivationSound = newSound; } - /// /// Gets this HDFirearm's empty sound. Ownership is NOT transferred! - /// - /// The SoundContainer for this HDFirearm's empty sound. + /// @return The SoundContainer for this HDFirearm's empty sound. SoundContainer* GetEmptySound() const { return m_EmptySound; } - /// /// Sets this HDFirearm's empty sound. Ownership IS transferred! - /// - /// The new SoundContainer for this HDFirearm's empty sound. + /// @param newSound The new SoundContainer for this HDFirearm's empty sound. void SetEmptySound(SoundContainer* newSound) { m_EmptySound = newSound; } - /// /// Gets this HDFirearm's reload start sound. Ownership is NOT transferred! - /// - /// The SoundContainer for this HDFirearm's reload start sound. + /// @return The SoundContainer for this HDFirearm's reload start sound. SoundContainer* GetReloadStartSound() const { return m_ReloadStartSound; } - /// /// Sets this HDFirearm's reload start sound. Ownership IS transferred! - /// - /// The new SoundContainer for this HDFirearm's reload start sound. + /// @param newSound The new SoundContainer for this HDFirearm's reload start sound. void SetReloadStartSound(SoundContainer* newSound) { m_ReloadStartSound = newSound; } - /// /// Gets this HDFirearm's reload end sound. Ownership is NOT transferred! - /// - /// The SoundContainer for this HDFirearm's reload end sound. + /// @return The SoundContainer for this HDFirearm's reload end sound. SoundContainer* GetReloadEndSound() const { return m_ReloadEndSound; } - /// /// Sets this HDFirearm's reload end sound. Ownership IS transferred! - /// - /// The new SoundContainer for this HDFirearm's reload end sound. + /// @param newSound The new SoundContainer for this HDFirearm's reload end sound. void SetReloadEndSound(SoundContainer* newSound) { m_ReloadEndSound = newSound; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: ResetAllTimers - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Resest all the timers used by this. Can be emitters, etc. This is to - // prevent backed up emissions to come out all at once while this has been - // held dormant in an inventory. - // Arguments: None. - // Return value: None. - + /// Resest all the timers used by this. Can be emitters, etc. This is to + /// prevent backed up emissions to come out all at once while this has been + /// held dormant in an inventory. void ResetAllTimers() override { HeldDevice::ResetAllTimers(); m_LastFireTmr.Reset(); m_ReloadTmr.Reset(); } - /// /// Gets this HDFirearm's reload progress as a scalar from 0 to 1. - /// - /// The reload progress as a scalar from 0 to 1. + /// @return The reload progress as a scalar from 0 to 1. float GetReloadProgress() const { return IsReloading() && m_BaseReloadTime > 0 ? static_cast(m_ReloadTmr.SimTimeLimitProgress()) : 1.0F; } - /// /// Does the calculations necessary to detect whether this HDFirearm is at rest or not. IsAtRest() retrieves the answer. - /// void RestDetection() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Activate - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Activates one of this HDFirearm's features. Analogous to 'pulling - // the trigger'. - // Arguments: None. - // Return value: None. - + /// Activates one of this HDFirearm's features. Analogous to 'pulling + /// the trigger'. void Activate() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Deactivate - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Deactivates one of this HDFirearm's features. Analogous to 'releasing - // the trigger'. - // Arguments: None. - // Return value: None. - + /// Deactivates one of this HDFirearm's features. Analogous to 'releasing + /// the trigger'. void Deactivate() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: StopActivationSound - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Aborts playing of active sound no matter what. Used to silence spinning - // weapons when weapons swapped - // Arguments: None. - // Return value: None. - + /// Method: StopActivationSound + /// Aborts playing of active sound no matter what. Used to silence spinning + /// weapons when weapons swapped void StopActivationSound(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Reload - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Throws out the currently used Magazine, if any, and puts in a new one - // after the reload delay is up. - // Arguments: None. - // Return value: None. - + /// Throws out the currently used Magazine, if any, and puts in a new one + /// after the reload delay is up. void Reload() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: IsReloading - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Tells whether the device is curtrently being reloaded. - // Arguments: None. - // Return value: Whetehr being reloaded. - + /// Tells whether the device is curtrently being reloaded. + /// @return Whetehr being reloaded. bool IsReloading() const override { return m_Reloading; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: DoneReloading - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Tells whether the device just finished reloading this frame. - // Arguments: None. - // Return value: Whether just done reloading this frame. - + /// Tells whether the device just finished reloading this frame. + /// @return Whether just done reloading this frame. bool DoneReloading() const override { return m_DoneReloading; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: NeedsReloading - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Tells whether the device is curtrently in need of being reloaded. - // Arguments: None. - // Return value: Whetehr in need of reloading (ie not full). - + /// Tells whether the device is curtrently in need of being reloaded. + /// @return Whetehr in need of reloading (ie not full). bool NeedsReloading() const override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: IsFull - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Tells whether the device is curtrently full and reloading won't have - // any effect. - // Arguments: None. - // Return value: Whetehr magazine is full or not. - + /// Tells whether the device is curtrently full and reloading won't have + /// any effect. + /// @return Whetehr magazine is full or not. bool IsFull() const override; bool IsEmpty() const override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: IsFullAuto - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Tells whether the device is fully automatic or not. - // Arguments: None. - // Return value: Whether the player can hold down fire and this will fire repeatedly. - + /// Tells whether the device is fully automatic or not. + /// @return Whether the player can hold down fire and this will fire repeatedly. bool IsFullAuto() const { return m_FullAuto; } - /// /// Gets whether this HDFirearm is set to be reloadable or not. - /// - /// Whether this HDFirearm is reloadable. + /// @return Whether this HDFirearm is reloadable. bool IsReloadable() const { return m_Reloadable; } - /// /// Sets whether this HDFirearm is reloadable or not and halts the reloading process. - /// - /// Whether this HDFirearm is reloadable. + /// @param isReloadable Whether this HDFirearm is reloadable. void SetReloadable(bool isReloadable) { m_Reloadable = isReloadable; m_Reloading = m_Reloading && m_Reloadable; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetFullAuto - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets whether the device is fully automatic or not. - // Arguments: New value. - // Return value: None. - + /// Sets whether the device is fully automatic or not. + /// @param newValue New value. void SetFullAuto(bool newValue) { m_FullAuto = newValue; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Update - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates this MovableObject. Supposed to be done every frame. - // Arguments: None. - // Return value: None. - + /// Updates this MovableObject. Supposed to be done every frame. void Update() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Draw - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws this HDFirearm's current graphical representation to a - // BITMAP of choice. - // Arguments: A pointer to a BITMAP to draw on. - // The absolute position of the target bitmap's upper left corner in the Scene. - // In which mode to draw in. See the DrawMode enumeration for the modes. - // Whether to not draw any extra 'ghost' items of this MovableObject, - // indicator arrows or hovering HUD text and so on. - // Return value: None. - + /// Draws this HDFirearm's current graphical representation to a + /// BITMAP of choice. + /// @param pTargetBitmap A pointer to a BITMAP to draw on. + /// @param targetPos The absolute position of the target bitmap's upper left corner in the Scene. (default: Vector()) + /// @param mode In which mode to draw in. See the DrawMode enumeration for the modes. (default: g_DrawColor) + /// @param onlyPhysical Whether to not draw any extra 'ghost' items of this MovableObject, (default: false) + /// indicator arrows or hovering HUD text and so on. void Draw(BITMAP* pTargetBitmap, const Vector& targetPos = Vector(), DrawMode mode = g_DrawColor, bool onlyPhysical = false) const override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: DrawHUD - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws an aiming aid in front of this HeldDevice. - // Arguments: A pointer to a BITMAP to draw on. - // The absolute position of the target bitmap's upper left corner in the Scene. - // Which player's screen this is being drawn to. May affect what HUD elements - // get drawn etc. - // Return value: None. - + /// Draws an aiming aid in front of this HeldDevice. + /// @param pTargetBitmap A pointer to a BITMAP to draw on. + /// @param targetPos The absolute position of the target bitmap's upper left corner in the Scene. (default: Vector()) + /// @param whichScreen Which player's screen this is being drawn to. May affect what HUD elements (default: 0) + /// get drawn etc. void DrawHUD(BITMAP* pTargetBitmap, const Vector& targetPos = Vector(), int whichScreen = 0, bool playerControlled = false) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: EstimateDigStrength - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Estimates what material strength one round in the magazine can destroy. - // Arguments: None. - // Return value: The maximum material strength the regular or the tracer round can destroy. - + /// Estimates what material strength one round in the magazine can destroy. + /// @return The maximum material strength the regular or the tracer round can destroy. float EstimateDigStrength() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: FiredOnce - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Whether at least one round has already been fired during the current activation. - // Arguments: None. - // Return value: Returns true if at least one round has already been fired during the current activation. - + /// Whether at least one round has already been fired during the current activation. + /// @return Returns true if at least one round has already been fired during the current activation. bool FiredOnce() const { return m_FiredOnce; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: FiredFrame - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Whether at least one round has already been fired during the current frame. - // Arguments: None. - // Return value: Returns true at least one round has already been fired during the current frame. - + /// Whether at least one round has already been fired during the current frame. + /// @return Returns true at least one round has already been fired during the current frame. bool FiredFrame() const { return m_FireFrame; } - /// /// Gets whether this HDFirearm is ready to be fired. - /// - /// Whether this HDFirearm is ready to pop another Round. + /// @return Whether this HDFirearm is ready to pop another Round. bool CanFire() const { return m_LastFireTmr.IsPastSimMS(GetMSPerRound()); } - /// /// Gets whether this HDFirearm is halfway to be fired. Used for evenly spacing out dual-wielded fire. - /// - /// Whether this HDFirearm is halfway to pop another Round. + /// @return Whether this HDFirearm is halfway to pop another Round. bool HalfwayToNextRound() const { return m_LastFireTmr.IsPastSimMS(GetMSPerRound() / 2.0); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: RoundsFired - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: How many rounds were fired during this frame. - // Arguments: None. - // Return value: Returns the number of rounds fired during this frame. - + /// How many rounds were fired during this frame. + /// @return Returns the number of rounds fired during this frame. int RoundsFired() const { return m_RoundsFired; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: IsAnimatedManually - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: If true then the m_Frame property is not changed bye the Update function - // Arguments: None. - // Return value: Whether this HDFirearm is animated manually. - + /// If true then the m_Frame property is not changed bye the Update function + /// @return Whether this HDFirearm is animated manually. bool IsAnimatedManually() const { return m_IsAnimatedManually; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetAnimatedManually - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets Whether this HDFirearm is animated manually. - // Arguments: Manual animation flag value. - // Return value: None. - + /// Sets Whether this HDFirearm is animated manually. + /// @param newValue Manual animation flag value. void SetAnimatedManually(bool newValue) { m_IsAnimatedManually = newValue; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Protected member variable and method declarations - + /// Protected member variable and method declarations protected: - /// /// Sets this Attachable's parent MOSRotating, and also sets its Team based on its parent and, if the Attachable is set to collide, adds/removes Atoms to its new/old parent. /// Additionally, sets this HDFirearm as not firing or reloading, and resets its reload timer. - /// - /// A pointer to the MOSRotating to set as the new parent. Ownership is NOT transferred! + /// @param newParent A pointer to the MOSRotating to set as the new parent. Ownership is NOT transferred! void SetParent(MOSRotating* newParent) override { HeldDevice::SetParent(newParent); Deactivate(); @@ -969,23 +589,13 @@ namespace RTE { std::string m_BallisticScriptFunction; */ - ////////////////////////////////////////////////////////////////////////////////////////// - // Private member variable and method declarations - + /// Private member variable and method declarations private: - /// /// Ensures the reload Timer's time limit is set accordingly, based on whether the HDFirearm has support available. - /// void CorrectReloadTimerForSupportAvailable() { m_ReloadTmr.SetSimTimeLimitMS(static_cast(static_cast(m_BaseReloadTime) * (m_SupportAvailable ? 1.0F : m_OneHandedReloadTimeMultiplier))); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Clear - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears all the member variables of this HDFirearm, effectively - // resetting the members of this abstraction level only. - // Arguments: None. - // Return value: None. - + /// Clears all the member variables of this HDFirearm, effectively + /// resetting the members of this abstraction level only. void Clear(); // Disallow the use of some implicit methods. diff --git a/Source/Entities/HeldDevice.cpp b/Source/Entities/HeldDevice.cpp index ce460701cf..9873639a24 100644 --- a/Source/Entities/HeldDevice.cpp +++ b/Source/Entities/HeldDevice.cpp @@ -1,15 +1,3 @@ -////////////////////////////////////////////////////////////////////////////////////////// -// File: HeldDevice.cpp -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Source file for the HeldDevice class. -// Project: Retro Terrain Engine -// Author(s): Daniel Tabar -// data@datarealms.com -// http://www.datarealms.com - -////////////////////////////////////////////////////////////////////////////////////////// -// Inclusions of header files - #include "HeldDevice.h" #include "CameraMan.h" @@ -30,12 +18,6 @@ namespace RTE { ConcreteClassInfo(HeldDevice, Attachable, 50); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Clear - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears all the member variables of this HeldDevice, effectively - // resetting the members of this abstraction level only. - void HeldDevice::Clear() { m_HeldDeviceType = WEAPON; m_Activated = false; @@ -66,11 +48,6 @@ namespace RTE { m_CollidesWithTerrainWhileAttached = false; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes the Round object ready for use. - int HeldDevice::Create() { if (Attachable::Create() < 0) return -1; @@ -122,11 +99,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Creates a HeldDevice to be identical to another, by deep copy. - int HeldDevice::Create(const HeldDevice& reference) { Attachable::Create(reference); @@ -164,14 +136,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: ReadProperty - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Reads a property value from a reader stream. If the name isn't - // recognized by this class, then ReadProperty of the parent class - // is called. If the property isn't recognized by any of the base classes, - // false is returned, and the reader's position is untouched. - int HeldDevice::ReadProperty(const std::string_view& propName, Reader& reader) { StartPropertyList(return Attachable::ReadProperty(propName, reader)); @@ -219,12 +183,6 @@ namespace RTE { EndPropertyList; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Save - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Saves the complete state of this HeldDevice with a Writer for - // later recreation with Create(Reader &reader); - int HeldDevice::Save(Writer& writer) const { Attachable::Save(writer); /* @@ -257,11 +215,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destroys and resets (through Clear()) the HeldDevice object. - void HeldDevice::Destroy(bool notInherited) { if (!notInherited) @@ -269,14 +222,6 @@ namespace RTE { Clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: GetStanceOffset - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the current position offset of this HeldDevice's joint relative - // from the parent Actor's position, if attached. - // Arguments: None. - // Return value: A const reference to the current stance parent offset. - Vector HeldDevice::GetStanceOffset() const { if (m_SharpAim > 0) { float rotAngleScalar = std::abs(std::sin(GetRootParent()->GetRotAngle())); @@ -286,12 +231,6 @@ namespace RTE { return m_StanceOffset.GetXFlipped(m_HFlipped); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetSupportPos - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the absolute position of the support handhold that this HeldDevice - // offers. - Vector HeldDevice::GetSupportPos() const { /* Vector rotOff(m_SupportOffset.GetYFlipped(m_HFlipped)); @@ -301,24 +240,14 @@ namespace RTE { return m_Pos + RotateOffset(m_SupportOffset); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: GetMagazinePos - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the absolute position of the magazine or other equivalent point of - // this. - Vector HeldDevice::GetMagazinePos() const { return m_Pos; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool HeldDevice::IsBeingHeld() const { return dynamic_cast(m_Parent); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void HeldDevice::RemovePickupableByPresetName(const std::string& actorPresetName) { std::unordered_set::iterator pickupableByPresetNameEntry = m_PickupableByPresetNames.find(actorPresetName); if (pickupableByPresetNameEntry != m_PickupableByPresetNames.end()) { @@ -326,15 +255,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: CollideAtPoint - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Calculates the collision response when another MO's Atom collides with - // this MO's physical representation. The effects will be applied - // directly to this MO, and also represented in the passed in HitData. - bool HeldDevice::CollideAtPoint(HitData& hd) { if (!m_GetsHitByMOsWhenHeld && IsBeingHeld()) { return false; @@ -343,11 +263,6 @@ namespace RTE { return Attachable::CollideAtPoint(hd); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Activate - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Activates this HDFirearm. Analogous to 'pulling the trigger'. - void HeldDevice::Activate() { if (!m_Activated) { m_ActivationTimer.Reset(); @@ -355,18 +270,10 @@ namespace RTE { m_Activated = true; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Deactivate - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Deactivates one of this HDFirearm's features. Analogous to 'releasing - // the trigger'. - void HeldDevice::Deactivate() { m_Activated = false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool HeldDevice::TransferJointImpulses(Vector& jointImpulses, float jointStiffnessValueToUse, float jointStrengthValueToUse, float gibImpulseLimitValueToUse) { MovableObject* parent = m_Parent; if (!parent) { @@ -394,8 +301,6 @@ namespace RTE { return intact; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - /* ////////////////////////////////////////////////////////////////////////////////////////// // Virtual method: Travel @@ -410,11 +315,6 @@ namespace RTE { } */ - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Update - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates this HeldDevice. Supposed to be done every frame. - void HeldDevice::Update() { Attachable::Update(); @@ -453,12 +353,6 @@ namespace RTE { } } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Draw - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws this HeldDevice's current graphical representation to a - // BITMAP of choice. - void HeldDevice::Draw(BITMAP* pTargetBitmap, const Vector& targetPos, DrawMode mode, @@ -490,12 +384,6 @@ namespace RTE { */ } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: DrawHUD - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws this Actor's current graphical HUD overlay representation to a - // BITMAP of choice. - void HeldDevice::DrawHUD(BITMAP* pTargetBitmap, const Vector& targetPos, int whichScreen, bool playerControlled) { if (!m_HUDVisible) { return; diff --git a/Source/Entities/HeldDevice.h b/Source/Entities/HeldDevice.h index 4312b9f812..062a4a788b 100644 --- a/Source/Entities/HeldDevice.h +++ b/Source/Entities/HeldDevice.h @@ -1,18 +1,11 @@ #ifndef _RTEHELDDEVICE_ #define _RTEHELDDEVICE_ -////////////////////////////////////////////////////////////////////////////////////////// -// File: HeldDevice.h -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Header file for the HeldDevice class. -// Project: Retro Terrain Engine -// Author(s): Daniel Tabar -// data@datarealms.com -// http://www.datarealms.com - -////////////////////////////////////////////////////////////////////////////////////////// -// Inclusions of header files - +/// Header file for the HeldDevice class. +/// @author Daniel Tabar +/// data@datarealms.com +/// http://www.datarealms.com +/// Inclusions of header files #include "Attachable.h" #include "Actor.h" @@ -25,597 +18,334 @@ namespace RTE { BOMB, }; - ////////////////////////////////////////////////////////////////////////////////////////// - // Class: HeldDevice - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: An articulated device that can be weilded by an Actor. - // Parent(s): Attachable. - // Class history: 06/2/2002 HeldDevice created. - // 01/31/2007 Made concrete so Shields can be jsut HeldDevice:s - + /// An articulated device that can be weilded by an Actor. + /// 01/31/2007 Made concrete so Shields can be jsut HeldDevice:s class HeldDevice : public Attachable { - ////////////////////////////////////////////////////////////////////////////////////////// - // Public member variable, method and friend function declarations - + /// Public member variable, method and friend function declarations public: // Concrete allocation and cloning definitions EntityAllocation(HeldDevice); SerializableOverrideMethods; ClassInfoGetters; - ////////////////////////////////////////////////////////////////////////////////////////// - // Constructor: HeldDevice - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Constructor method used to instantiate a HeldDevice object in system - // memory. Create() should be called before using the object. - // Arguments: None. - + /// Constructor method used to instantiate a HeldDevice object in system + /// memory. Create() should be called before using the object. HeldDevice() { Clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Destructor: ~HeldDevice - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destructor method used to clean up a HeldDevice object before deletion - // from system memory. - // Arguments: None. - + /// Destructor method used to clean up a HeldDevice object before deletion + /// from system memory. ~HeldDevice() override { Destroy(true); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes the HeldDevice object ready for use. - // Arguments: None. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Makes the HeldDevice object ready for use. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Create() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Creates a HeldDevice to be identical to another, by deep copy. - // Arguments: A reference to the HeldDevice to deep copy. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Creates a HeldDevice to be identical to another, by deep copy. + /// @param reference A reference to the HeldDevice to deep copy. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Create(const HeldDevice& reference); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Reset - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Resets the entire HeldDevice, including its inherited members, to their - // default settings or values. - // Arguments: None. - // Return value: None. - + /// Resets the entire HeldDevice, including its inherited members, to their + /// default settings or values. void Reset() override { Clear(); Attachable::Reset(); m_MOType = MovableObject::TypeHeldDevice; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destroys and resets (through Clear()) the SceneLayer object. - // Arguments: Whether to only destroy the members defined in this derived class, or - // to destroy all inherited members also. - // Return value: None. - + /// Destroys and resets (through Clear()) the SceneLayer object. + /// @param notInherited Whether to only destroy the members defined in this derived class, or (default: false) + /// to destroy all inherited members also. void Destroy(bool notInherited = false) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: GetAboveHUDPos - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the absoltue position of the top of this' HUD stack. - // Arguments: None. - // Return value: A Vector with the absolute position of this' HUD stack top point. - + /// Gets the absoltue position of the top of this' HUD stack. + /// @return A Vector with the absolute position of this' HUD stack top point. Vector GetAboveHUDPos() const override { return m_Pos + Vector(0, -32); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetSupportPos - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the absolute position of the support handhold that this HeldDevice - // offers. - // Arguments: None. - // Return value: A vector describing the absolute world coordinates for the support - // position of this HeldDevice. - + /// Gets the absolute position of the support handhold that this HeldDevice + /// offers. + /// @return A vector describing the absolute world coordinates for the support + /// position of this HeldDevice. Vector GetSupportPos() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: GetMagazinePos - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the absolute position of the magazine or other equivalent point of - // this. - // Arguments: None. - // Return value: A vector describing the absolute world coordinates for the magazine - // attachment point of this - + /// Gets the absolute position of the magazine or other equivalent point of + /// this. + /// @return A vector describing the absolute world coordinates for the magazine + /// attachment point of this virtual Vector GetMagazinePos() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: GetMuzzlePos - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the absolute position of the muzzle or other equivalent point of - // this. - // Arguments: None. - // Return value: A vector describing the absolute world coordinates for the muzzle point - // of this - + /// Gets the absolute position of the muzzle or other equivalent point of + /// this. + /// @return A vector describing the absolute world coordinates for the muzzle point + /// of this virtual Vector GetMuzzlePos() const { return m_Pos; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: GetMuzzleOffset - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the unrotated relative offset from the position to the muzzle or - // other equivalent point of this. - // Arguments: None. - // Return value: A unrotated vector describing the relative for the muzzle point of - // this from this' position. - + /// Gets the unrotated relative offset from the position to the muzzle or + /// other equivalent point of this. + /// @return A unrotated vector describing the relative for the muzzle point of + /// this from this' position. virtual Vector GetMuzzleOffset() const { return Vector(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: SetMuzzleOffset - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the unrotated relative offset from the position to the muzzle or - // other equivalent point of this. - // Arguments: Bew ofsset value. - // Return value: None. - + /// Sets the unrotated relative offset from the position to the muzzle or + /// other equivalent point of this. + /// @param newOffset Bew ofsset value. virtual void SetMuzzleOffset(Vector newOffset) { /* Actually does something in inherited classes */ } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: GetStanceOffset - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the current position offset of this HeldDevice's joint relative - // from the parent Actor's position, if attached. - // Arguments: None. - // Return value: A const reference to the current stance parent offset. - + /// Gets the current position offset of this HeldDevice's joint relative + /// from the parent Actor's position, if attached. + /// @return A const reference to the current stance parent offset. virtual Vector GetStanceOffset() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: SetStanceOffset - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the current position offset of this HeldDevice's joint relative - // from the parent Actor's position, if attached. - // Arguments: New value. - // Return value: None. - + /// Sets the current position offset of this HeldDevice's joint relative + /// from the parent Actor's position, if attached. + /// @param newValue New value. void SetStanceOffset(Vector newValue) { m_StanceOffset = newValue; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: SetSharpStanceOffset - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the current position offset of this HeldDevice's joint relative - // from the parent Actor's position, if attached. - // Arguments: New value. - // Return value: None. - + /// Sets the current position offset of this HeldDevice's joint relative + /// from the parent Actor's position, if attached. + /// @param New value. Vector GetSharpStanceOffset() const { return m_SharpStanceOffset; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: SetSharpStanceOffset - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the current position offset of this HeldDevice's joint relative - // from the parent Actor's position, if attached. - // Arguments: New value. - // Return value: None. - + /// Sets the current position offset of this HeldDevice's joint relative + /// from the parent Actor's position, if attached. + /// @param newValue New value. void SetSharpStanceOffset(Vector newValue) { m_SharpStanceOffset = newValue; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: GetSharpLength - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets how much farther an Actor which holds this device can see when - // aiming this HeldDevice sharply. - // Arguments: None. - // Return value: The length in world pixel units. - + /// Gets how much farther an Actor which holds this device can see when + /// aiming this HeldDevice sharply. + /// @return The length in world pixel units. float GetSharpLength() const { return m_MaxSharpLength; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: SetSharpLength - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets how much farther an Actor which holds this device can see when - // aiming this HeldDevice sharply. - // Arguments: The length in world pixel units. - // Return value: None. - + /// Sets how much farther an Actor which holds this device can see when + /// aiming this HeldDevice sharply. + /// @param newLength The length in world pixel units. void SetSharpLength(float newLength) { m_MaxSharpLength = newLength; } - /// /// Gets whether this HeldDevice can be supported when held. - /// - /// Whether this HeldDevice can be supported when held. + /// @return Whether this HeldDevice can be supported when held. bool IsSupportable() const { return m_Supportable; } - /// /// Sets whether this HeldDevice can be supported when held. - /// - /// Whether this HeldDevice can be supported when held. + /// @param shouldBeSupportable Whether this HeldDevice can be supported when held. void SetSupportable(bool shouldBeSupportable) { m_Supportable = shouldBeSupportable; } - /// /// Gets whether this HeldDevice is currently supported by a second Arm. - /// - /// Whether this HeldDevice is supported or not. + /// @return Whether this HeldDevice is supported or not. bool GetSupported() const { return m_Supportable && m_Supported; } - /// /// Sets whether this HeldDevice is currently supported by a second Arm. - /// - /// Whether this HeldDevice is being supported. + /// @param supported Whether this HeldDevice is being supported. void SetSupported(bool supported) { m_Supported = m_Supportable && supported; } - /// /// Gets whether this HeldDevice's parent has a second Arm available to provide support (or this is on a Turret). - /// - /// Whether this HeldDevice's parent has a second Arm available to provide support (or this is on a Turret). + /// @return Whether this HeldDevice's parent has a second Arm available to provide support (or this is on a Turret). bool GetSupportAvailable() const { return m_Supportable && m_SupportAvailable; } - /// /// Sets whether this HeldDevice's parent has a second Arm available to provide support (or this is on a Turret). - /// - /// Whether this HeldDevice's parent has a second Arm available to provide support (or this is on a Turret). + /// @param supported Whether this HeldDevice's parent has a second Arm available to provide support (or this is on a Turret). void SetSupportAvailable(bool supportAvailable) { m_SupportAvailable = m_Supportable && supportAvailable; } - /// /// Gets whether this HeldDevice while be held at the support offset with the off-hand when reloading. - /// - /// Whether this HeldDevice while be held at the support offset with the off-hand when reloading. + /// @return Whether this HeldDevice while be held at the support offset with the off-hand when reloading. bool GetUseSupportOffsetWhileReloading() const { return m_UseSupportOffsetWhileReloading; } - /// /// Sets whether this HeldDevice while be held at the support offset with the off-hand when reloading. - /// - /// Whether this HeldDevice while be held at the support offset with the off-hand when reloading. + /// @param value Whether this HeldDevice while be held at the support offset with the off-hand when reloading. void SetUseSupportOffsetWhileReloading(bool value) { m_UseSupportOffsetWhileReloading = value; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: GetSupportOffset - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns support offset. - // Arguments: None. - // Return value: Support offset value. - + /// Returns support offset. + /// @return Support offset value. Vector GetSupportOffset() const { return m_SupportOffset; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: SetSupportOffset - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets support offset. - // Arguments: New support offset value. - // Return value: None. - + /// Sets support offset. + /// @param newOffset New support offset value. void SetSupportOffset(Vector newOffset) { m_SupportOffset = newOffset; } - /// /// Gets whether this HeldDevice has any limitations on what can pick it up. - /// - /// Whether this HeldDevice has any limitations on what can pick it up. + /// @return Whether this HeldDevice has any limitations on what can pick it up. bool HasPickupLimitations() const { return IsUnPickupable() || !m_PickupableByPresetNames.empty(); } - /// /// Gets whether this HeldDevice cannot be picked up at all. - /// - /// Whether this HeldDevice cannot be picked up at all. + /// @return Whether this HeldDevice cannot be picked up at all. bool IsUnPickupable() const { return m_IsUnPickupable; } - /// /// Sets whether this HeldDevice cannot be picked up at all. - /// - /// Whether this HeldDevice cannot be picked up at all. True means it cannot, false means any other limitations will apply normally. + /// @param shouldBeUnPickupable Whether this HeldDevice cannot be picked up at all. True means it cannot, false means any other limitations will apply normally. void SetUnPickupable(bool shouldBeUnPickupable) { m_IsUnPickupable = shouldBeUnPickupable; } - /// /// Checks whether the given Actor can pick up this HeldDevice. - /// - /// The Actor to check. Ownership is NOT transferred. - /// Whether the given Actor can pick up this HeldDevice. + /// @param actor The Actor to check. Ownership is NOT transferred. + /// @return Whether the given Actor can pick up this HeldDevice. bool IsPickupableBy(const Actor* actor) const { return !HasPickupLimitations() || m_PickupableByPresetNames.find(actor->GetPresetName()) != m_PickupableByPresetNames.end(); } - /// /// Specify that objects with the given PresetName can pick up this HeldDevice. - /// - /// The PresetName of an object that should be able to pick up this HeldDevice. + /// @param presetName The PresetName of an object that should be able to pick up this HeldDevice. void AddPickupableByPresetName(const std::string& presetName) { SetUnPickupable(false); m_PickupableByPresetNames.insert(presetName); } - /// /// Remove allowance for objects with the given PresetName to pick up this HeldDevice. /// Note that if the last allowance is removed, the HeldDevice will no longer have pickup limitations, rather than setting itself as unpickupable. - /// - /// The PresetName of an object that should no longer be able to pick up this HeldDevice. + /// @param actorPresetName The PresetName of an object that should no longer be able to pick up this HeldDevice. void RemovePickupableByPresetName(const std::string& actorPresetName); - /// /// Gets the multiplier for how well this HeldDevice can be gripped by Arms. - /// - /// The grip strength multiplier for this HeldDevice. + /// @return The grip strength multiplier for this HeldDevice. float GetGripStrengthMultiplier() const { return m_GripStrengthMultiplier; } - /// /// Sets the multiplier for how well this HeldDevice can be gripped by Arms. - /// - /// The new grip strength multiplier for this HeldDevice. + /// @param gripStrengthMultiplier The new grip strength multiplier for this HeldDevice. void SetGripStrengthMultiplier(float gripStrengthMultiplier) { m_GripStrengthMultiplier = gripStrengthMultiplier; } - /// /// Gets whether this can get hit by MOs when held. - /// - /// Whether this can get hit by MOs when held. + /// @return Whether this can get hit by MOs when held. bool GetsHitByMOsWhenHeld() const { return m_GetsHitByMOsWhenHeld; } - /// /// Sets whether this can get hit by MOs when held. - /// - /// Whether this can get hit by MOs when held. + /// @param value Whether this can get hit by MOs when held. void SetGetsHitByMOsWhenHeld(bool value) { m_GetsHitByMOsWhenHeld = value; } - /// /// Gets whether this HeldDevice is currently being held or not. - /// - /// Whether this HeldDevice is currently being held or not. + /// @return Whether this HeldDevice is currently being held or not. bool IsBeingHeld() const; - /// /// Gets the visual recoil multiplier. - /// - /// A float with the scalar value. + /// @return A float with the scalar value. float GetVisualRecoilMultiplier() const { return m_VisualRecoilMultiplier; } - /// /// Sets the visual recoil multiplier. - /// - /// The new recoil multiplier scalar. + /// @param value The new recoil multiplier scalar. void SetVisualRecoilMultiplier(float value) { m_VisualRecoilMultiplier = value; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetSharpAim - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the degree to which this is being aimed sharp. This will - // affect the accuracy and what GetParentOffset returns. - // Arguments: A normalized scalar between 0 (no sharp aim) to 1.0 (best aim). - // Return value: None. - + /// Sets the degree to which this is being aimed sharp. This will + /// affect the accuracy and what GetParentOffset returns. + /// @param sharpAim A normalized scalar between 0 (no sharp aim) to 1.0 (best aim). void SetSharpAim(float sharpAim) { m_SharpAim = sharpAim; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: IsWeapon - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Indicates whether this is an offensive weapon or not. - // Arguments: None. - // Return value: Offensive weapon or not. - + /// Indicates whether this is an offensive weapon or not. + /// @return Offensive weapon or not. bool IsWeapon() { return m_HeldDeviceType == WEAPON; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: IsTool - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Indicates whether this is a tool or not. - // Arguments: None. - // Return value: Tool or not. - + /// Indicates whether this is a tool or not. + /// @return Tool or not. bool IsTool() { return m_HeldDeviceType == TOOL; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: IsShield - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Indicates whether this is a shield or not. - // Arguments: None. - // Return value: Shield or not. - + /// Indicates whether this is a shield or not. + /// @return Shield or not. bool IsShield() { return m_HeldDeviceType == SHIELD; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: IsDualWieldable - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Indicates whether this is a dual wieldable weapon or not. - // Arguments: None. - // Return value: Dual wieldable or not. - + /// Indicates whether this is a dual wieldable weapon or not. + /// @return Dual wieldable or not. bool IsDualWieldable() const { return m_DualWieldable; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetDualWieldable - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets whether this is a dual wieldable weapon or not. - // Arguments: Dual wieldable or not. - // Return value: None. - + /// Sets whether this is a dual wieldable weapon or not. + /// @param isDualWieldable Dual wieldable or not. void SetDualWieldable(bool isDualWieldable) { m_DualWieldable = isDualWieldable; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: IsOneHanded - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Indicates whether this can be held and operated effectively with one - // hand or not. - // Arguments: None. - // Return value: One handed device or not. - + /// Indicates whether this can be held and operated effectively with one + /// hand or not. + /// @return One handed device or not. bool IsOneHanded() const { return m_OneHanded; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetOneHanded - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets whether this can be held and operated effectively with one - // hand or not. - // Arguments: New value. - // Return value: None. - + /// Sets whether this can be held and operated effectively with one + /// hand or not. + /// @param newValue New value. void SetOneHanded(bool newValue) { m_OneHanded = newValue; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: CollideAtPoint - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Calculates the collision response when another MO's Atom collides with - // this MO's physical representation. The effects will be applied - // directly to this MO, and also represented in the passed in HitData. - // Arguments: Reference to the HitData struct which describes the collision. This - // will be modified to represent the results of the collision. - // Return value: Whether the collision has been deemed valid. If false, then disregard - // any impulses in the Hitdata. - + /// Calculates the collision response when another MO's Atom collides with + /// this MO's physical representation. The effects will be applied + /// directly to this MO, and also represented in the passed in HitData. + /// @param hitData Reference to the HitData struct which describes the collision. This + /// will be modified to represent the results of the collision. + /// @return Whether the collision has been deemed valid. If false, then disregard + /// any impulses in the Hitdata. bool CollideAtPoint(HitData& hitData) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Activate - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Activates one of this HDFirearm's features. Analogous to 'pulling - // the trigger'. - // Arguments: None. - // Return value: None. - + /// Activates one of this HDFirearm's features. Analogous to 'pulling + /// the trigger'. virtual void Activate(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Deactivate - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Deactivates one of this HDFirearm's features. Analogous to 'releasing - // the trigger'. - // Arguments: None. - // Return value: None. - + /// Deactivates one of this HDFirearm's features. Analogous to 'releasing + /// the trigger'. virtual void Deactivate(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Reload - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Throws out the currently used Magazine, if any, and puts in a new one - // after the reload delay is up. - // Arguments: None. - // Return value: None. - + /// Throws out the currently used Magazine, if any, and puts in a new one + /// after the reload delay is up. virtual void Reload() {} - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: IsActivated - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Tells whether the device is curtrently being activated. - // Arguments: None. - // Return value: Whether being activated. - + /// Tells whether the device is curtrently being activated. + /// @return Whether being activated. virtual bool IsActivated() const { return m_Activated; } - /// /// Gets the activation Timer for this HeldDevice. - /// - /// The activation Timer for this HeldDevice. + /// @return The activation Timer for this HeldDevice. const Timer& GetActivationTimer() const { return m_ActivationTimer; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: IsReloading - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Tells whether the device is curtrently being reloaded. - // Arguments: None. - // Return value: Whetehr being reloaded. - + /// Tells whether the device is curtrently being reloaded. + /// @return Whetehr being reloaded. virtual bool IsReloading() const { return false; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: DoneReloading - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Tells whether the device just finished reloading this frame. - // Arguments: None. - // Return value: Whether just done reloading this frame. - + /// Tells whether the device just finished reloading this frame. + /// @return Whether just done reloading this frame. virtual bool DoneReloading() const { return false; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: NeedsReloading - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Tells whether the device is curtrently in need of being reloaded. - // Arguments: None. - // Return value: Whetehr in need of reloading (ie not full). - + /// Tells whether the device is curtrently in need of being reloaded. + /// @return Whetehr in need of reloading (ie not full). virtual bool NeedsReloading() const { return false; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: IsFull - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Tells whether the device is curtrently full and reloading won't have - // any effect. - // Arguments: None. - // Return value: Whetehr magazine is full or not. - + /// Tells whether the device is curtrently full and reloading won't have + /// any effect. + /// @return Whetehr magazine is full or not. virtual bool IsFull() const { return true; } - /// /// Tells whether this HeldDevice is currently empty of ammo. - /// - /// Whether this HeldDevice is empty. + /// @return Whether this HeldDevice is empty. virtual bool IsEmpty() const { return false; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Update - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates this MovableObject. Supposed to be done every frame. - // Arguments: None. - // Return value: None. - + /// Updates this MovableObject. Supposed to be done every frame. void Update() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Draw - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws this HeldDevice's current graphical representation to a - // BITMAP of choice. - // Arguments: A pointer to a BITMAP to draw on. - // The absolute position of the target bitmap's upper left corner in the Scene. - // In which mode to draw in. See the DrawMode enumeration for the modes. - // Whether to not draw any extra 'ghost' items of this MovableObject, - // indicator arrows or hovering HUD text and so on. - // Return value: None. - + /// Draws this HeldDevice's current graphical representation to a + /// BITMAP of choice. + /// @param pTargetBitmap A pointer to a BITMAP to draw on. + /// @param targetPos The absolute position of the target bitmap's upper left corner in the Scene. (default: Vector()) + /// @param mode In which mode to draw in. See the DrawMode enumeration for the modes. (default: g_DrawColor) + /// @param onlyPhysical Whether to not draw any extra 'ghost' items of this MovableObject, (default: false) + /// indicator arrows or hovering HUD text and so on. void Draw(BITMAP* pTargetBitmap, const Vector& targetPos = Vector(), DrawMode mode = g_DrawColor, bool onlyPhysical = false) const override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: DrawHUD - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws this' current graphical HUD overlay representation to a - // BITMAP of choice. - // Arguments: A pointer to a BITMAP to draw on. - // The absolute position of the target bitmap's upper left corner in the Scene. - // Which player's screen this is being drawn to. May affect what HUD elements - // get drawn etc. - // Return value: None. - + /// Draws this' current graphical HUD overlay representation to a + /// BITMAP of choice. + /// @param pTargetBitmap A pointer to a BITMAP to draw on. + /// @param targetPos The absolute position of the target bitmap's upper left corner in the Scene. (default: Vector()) + /// @param whichScreen Which player's screen this is being drawn to. May affect what HUD elements (default: 0) + /// get drawn etc. void DrawHUD(BITMAP* pTargetBitmap, const Vector& targetPos = Vector(), int whichScreen = 0, bool playerControlled = false) override; - /// /// Resest all the timers used by this. Can be emitters, etc. This is to prevent backed up emissions to come out all at once while this has been held dormant in an inventory. - /// void ResetAllTimers() override { Attachable::ResetAllTimers(); m_ActivationTimer.Reset(); } #pragma region Force Transferral - /// /// Bundles up all the accumulated impulse forces of this HeldDevice and calculates how they transfer to the joint, and therefore to the parent. /// If the accumulated impulse forces exceed the joint strength or gib impulse limit of this HeldDevice, the jointImpulses Vector will be filled up to that limit and false will be returned. /// Additionally, in this case, the HeldDevice will remove itself from its parent, destabilizing said parent if it's an Actor, and gib itself if appropriate. - /// - /// A vector that will have the impulse forces affecting the joint ADDED to it. - /// An optional override for the HeldDevice's joint stiffness for this function call. Primarily used to allow subclasses to perform special behavior. - /// An optional override for the HeldDevice's joint strength for this function call. Primarily used to allow subclasses to perform special behavior. - /// An optional override for the HeldDevice's gib impulse limit for this function call. Primarily used to allow subclasses to perform special behavior. - /// False if the HeldDevice has no parent or its accumulated forces are greater than its joint strength or gib impulse limit, otherwise true. + /// @param jointImpulses A vector that will have the impulse forces affecting the joint ADDED to it. + /// @param jointStiffnessValueToUse An optional override for the HeldDevice's joint stiffness for this function call. Primarily used to allow subclasses to perform special behavior. + /// @param jointStrengthValueToUse An optional override for the HeldDevice's joint strength for this function call. Primarily used to allow subclasses to perform special behavior. + /// @param gibImpulseLimitValueToUse An optional override for the HeldDevice's gib impulse limit for this function call. Primarily used to allow subclasses to perform special behavior. + /// @return False if the HeldDevice has no parent or its accumulated forces are greater than its joint strength or gib impulse limit, otherwise true. bool TransferJointImpulses(Vector& jointImpulses, float jointStiffnessValueToUse = -1, float jointStrengthValueToUse = -1, float gibImpulseLimitValueToUse = -1) override; #pragma endregion - ////////////////////////////////////////////////////////////////////////////////////////// - // Protected member variable and method declarations - + /// Protected member variable and method declarations protected: // Member variables static Entity::ClassInfo m_sClass; @@ -662,18 +392,10 @@ namespace RTE { /// The multiplier for visual recoil float m_VisualRecoilMultiplier; - ////////////////////////////////////////////////////////////////////////////////////////// - // Private member variable and method declarations - + /// Private member variable and method declarations private: - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Clear - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears all the member variables of this HeldDevice, effectively - // resetting the members of this abstraction level only. - // Arguments: None. - // Return value: None. - + /// Clears all the member variables of this HeldDevice, effectively + /// resetting the members of this abstraction level only. void Clear(); // Disallow the use of some implicit methods. diff --git a/Source/Entities/Icon.cpp b/Source/Entities/Icon.cpp index 466884be63..eedb14647b 100644 --- a/Source/Entities/Icon.cpp +++ b/Source/Entities/Icon.cpp @@ -4,8 +4,6 @@ namespace RTE { ConcreteClassInfo(Icon, Entity, 80); - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void Icon::Clear() { m_BitmapFile.Reset(); m_FrameCount = 0; @@ -13,8 +11,6 @@ namespace RTE { m_BitmapsTrueColor.clear(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int Icon::Create() { if (m_BitmapsIndexed.empty() || m_BitmapsTrueColor.empty()) { if (m_BitmapFile.GetDataPath().empty()) { @@ -27,8 +23,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int Icon::Create(const Icon& reference) { Entity::Create(reference); @@ -40,8 +34,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int Icon::ReadProperty(const std::string_view& propName, Reader& reader) { StartPropertyList(return Entity::ReadProperty(propName, reader)); @@ -51,8 +43,6 @@ namespace RTE { EndPropertyList; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int Icon::Save(Writer& writer) const { Entity::Save(writer); writer.NewProperty("BitmapFile"); @@ -63,8 +53,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void Icon::Destroy(bool notInherited) { if (!notInherited) { Entity::Destroy(); diff --git a/Source/Entities/Icon.h b/Source/Entities/Icon.h index 364bf73b1f..0426350b67 100644 --- a/Source/Entities/Icon.h +++ b/Source/Entities/Icon.h @@ -6,9 +6,7 @@ namespace RTE { - /// /// Represents an Icon in the interface that can be loaded and stored from different data modules etc. - /// class Icon : public Entity { public: @@ -17,15 +15,11 @@ namespace RTE { ClassInfoGetters; #pragma region Creation - /// /// Constructor method used to instantiate an Icon object in system memory. Create() should be called before using the object. - /// Icon() { Clear(); } - /// /// Copy constructor method used to instantiate an Icon object identical to an already existing one. - /// - /// An Icon object which is passed in by reference. + /// @param reference An Icon object which is passed in by reference. Icon(const Icon& reference) { if (this != &reference) { Clear(); @@ -33,35 +27,25 @@ namespace RTE { } } - /// /// Makes the Icon object ready for use. - /// - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create() override; - /// /// Creates an Icon to be identical to another, by deep copy. - /// - /// A reference to the Icon to deep copy. - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @param reference A reference to the Icon to deep copy. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create(const Icon& reference); #pragma endregion #pragma region Destruction - /// /// Destructor method used to clean up an Icon object before deletion from system memory. - /// ~Icon() override { Destroy(true); } - /// /// Destroys and resets (through Clear()) the Icon object. - /// - /// Whether to only destroy the members defined in this derived class, or to destroy all inherited members also. + /// @param notInherited Whether to only destroy the members defined in this derived class, or to destroy all inherited members also. void Destroy(bool notInherited = false) override; - /// /// Resets the entire Icon, including its inherited members, to their default settings or values. - /// void Reset() override { Clear(); Entity::Reset(); @@ -69,31 +53,23 @@ namespace RTE { #pragma endregion #pragma region Getters and Setters - /// /// Gets the number of frames in this Icon's animation. - /// - /// The number of frames in the animation. + /// @return The number of frames in the animation. unsigned int GetFrameCount() const { return m_FrameCount; } - /// /// Gets the array of 8-bit bitmaps of this Icon, as many as GetFrameCount says. Neither the array nor the BITMAPs are transferred ownership! - /// - /// The BITMAPs in 8bpp of this Icon. + /// @return The BITMAPs in 8bpp of this Icon. std::vector GetBitmaps8() const { return m_BitmapsIndexed; } - /// /// Gets the array of 32-bit bitmaps of this Icon, as many as GetFrameCount says. Neither the array nor the BITMAPs are transferred ownership! - /// - /// The BITMAPs in 32bpp of this Icon. + /// @return The BITMAPs in 32bpp of this Icon. std::vector GetBitmaps32() const { return m_BitmapsTrueColor; } #pragma endregion #pragma region Operator Overloads - /// /// An assignment operator for setting one Icon equal to another. - /// - /// An Icon reference. - /// A reference to the changed Icon. + /// @param rhs An Icon reference. + /// @return A reference to the changed Icon. Icon& operator=(const Icon& rhs) { if (this != &rhs) { Destroy(); @@ -113,9 +89,7 @@ namespace RTE { std::vector m_BitmapsTrueColor; //!< Vector containing the 32bpp BITMAPs of this Icon. BITMAPs are NOT owned! private: - /// /// Clears all the member variables of this Icon, effectively resetting the members of this abstraction level only. - /// void Clear(); }; } // namespace RTE diff --git a/Source/Entities/Leg.cpp b/Source/Entities/Leg.cpp index 370a2a46e0..c894505038 100644 --- a/Source/Entities/Leg.cpp +++ b/Source/Entities/Leg.cpp @@ -6,8 +6,6 @@ namespace RTE { ConcreteClassInfo(Leg, Attachable, 50); - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void Leg::Clear() { m_Foot = nullptr; @@ -27,8 +25,6 @@ namespace RTE { m_MoveSpeed = 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int Leg::Create() { if (Attachable::Create() < 0) { return -1; @@ -50,8 +46,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int Leg::Create(const Leg& reference) { if (reference.m_Foot) { m_ReferenceHardcodedAttachableUniqueIDs.insert(reference.m_Foot->GetUniqueID()); @@ -77,8 +71,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int Leg::ReadProperty(const std::string_view& propName, Reader& reader) { StartPropertyList(return Attachable::ReadProperty(propName, reader)); @@ -98,8 +90,6 @@ namespace RTE { EndPropertyList; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int Leg::Save(Writer& writer) const { Attachable::Save(writer); @@ -119,8 +109,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void Leg::SetFoot(Attachable* newFoot) { if (m_Foot && m_Foot->IsAttached()) { RemoveAndDeleteAttachable(m_Foot); @@ -144,8 +132,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - AtomGroup* Leg::GetFootGroupFromFootAtomGroup() { if (!m_Foot) { return nullptr; @@ -198,8 +184,6 @@ namespace RTE { return footGroup; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void Leg::Update() { Attachable::PreUpdate(); @@ -225,8 +209,6 @@ namespace RTE { UpdateFootFrameAndRotation(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void Leg::UpdateCurrentAnkleOffset() { if (IsAttached()) { Vector targetOffset = g_SceneMan.ShortestDistance(m_JointPos, m_TargetPosition, g_SceneMan.SceneWrapsX()); @@ -244,8 +226,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void Leg::UpdateLegRotation() { if (IsAttached()) { m_Rotation = m_AnkleOffset.GetAbsRadAngle() + (m_HFlipped ? c_PI : 0); @@ -265,8 +245,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void Leg::UpdateFootFrameAndRotation() { if (m_Foot) { if (IsAttached() && m_AnkleOffset.GetY() > std::abs(m_AnkleOffset.GetX() * 0.3F)) { diff --git a/Source/Entities/Leg.h b/Source/Entities/Leg.h index 7d2ab1dd7b..7aa54b677a 100644 --- a/Source/Entities/Leg.h +++ b/Source/Entities/Leg.h @@ -7,9 +7,7 @@ namespace RTE { class HeldDevice; - /// /// A detachable Leg that will be controlled by LimbPaths. - /// class Leg : public Attachable { public: @@ -18,35 +16,25 @@ namespace RTE { ClassInfoGetters; #pragma region Creation - /// /// Constructor method used to instantiate a Leg object in system memory. Create() should be called before using the object. - /// Leg() { Clear(); } - /// /// Makes the Leg object ready for use. - /// - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create() override; - /// /// Creates a Leg to be identical to another, by deep copy. - /// - /// A reference to the Leg to deep copy. - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @param reference A reference to the Leg to deep copy. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create(const Leg& reference); #pragma endregion #pragma region Destruction - /// /// Destructor method used to clean up a Leg object before deletion from system memory. - /// ~Leg() override { Destroy(true); } - /// /// Destroys and resets (through Clear()) the Leg object. - /// - /// Whether to only destroy the members defined in this derived class, or to destroy all inherited members also. + /// @param notInherited Whether to only destroy the members defined in this derived class, or to destroy all inherited members also. void Destroy(bool notInherited = false) override { if (!notInherited) { Attachable::Destroy(); @@ -54,9 +42,7 @@ namespace RTE { Clear(); } - /// /// Resets the entire Leg, including its inherited members, to their default settings or values. - /// void Reset() override { Clear(); Attachable::Reset(); @@ -64,67 +50,47 @@ namespace RTE { #pragma endregion #pragma region Getters and Setters - /// /// Gets the foot of this Leg. - /// - /// A pointer to foot of this Leg. Ownership is NOT transferred! + /// @return A pointer to foot of this Leg. Ownership is NOT transferred! Attachable* GetFoot() const { return m_Foot; } - /// /// Sets the foot for this Leg. Ownership IS transferred! - /// - /// The new foot to use. + /// @param newFoot The new foot to use. void SetFoot(Attachable* newFoot); - /// /// Gets the min length this of Leg, the minimum allowed length from its joint to its ankle's position. - /// - /// The min length, in pixels, of this Leg. + /// @return The min length, in pixels, of this Leg. float GetMinLength() const { return m_MinExtension; } - /// /// Gets the max length this Leg, the maximum allowed length from its joint to its ankle's position. - /// - /// The max length, in pixels, of this Leg. + /// @return The max length, in pixels, of this Leg. float GetMaxLength() const { return m_MaxExtension; } - /// /// Gets the move speed of this Leg, where 1.0 is instant and 0.0 is no movement. - /// - /// The move speed of this Leg. + /// @return The move speed of this Leg. float GetMoveSpeed() const { return m_MoveSpeed; } - /// /// Sets the move speed of this Leg, where 1.0 is instant and 0.0 is no movement. - /// - /// The new move speed of this Leg. + /// @return The new move speed of this Leg. void SetMoveSpeed(float newMoveSpeed) { m_MoveSpeed = newMoveSpeed; } - /// /// Sets the position this Leg should move towards, in absolute coordinates. - /// - /// The position the Leg should move towards. + /// @param targetPosition The position the Leg should move towards. void SetTargetPosition(const Vector& targetPosition) { m_TargetPosition = targetPosition; } - /// /// Sets whether this Leg will go into idle offset mode if the target appears to be above the joint of the Leg. - /// - /// Whether to enable idling if the target offset is above the joint. + /// @param idle Whether to enable idling if the target offset is above the joint. void EnableIdle(bool idle = true) { m_WillIdle = idle; } #pragma endregion #pragma region Concrete Methods - /// /// Gets a copy of this Leg's foot AtomGroup to be used as an Actor's FootGroup. - /// - /// A copy of this Leg's foot AtomGroup to be used as an Actor's FootGroup. OWNERSHIP IS TRANSFERRED! + /// @return A copy of this Leg's foot AtomGroup to be used as an Actor's FootGroup. OWNERSHIP IS TRANSFERRED! AtomGroup* GetFootGroupFromFootAtomGroup(); #pragma endregion #pragma region Override Methods - /// /// Updates this Leg. Supposed to be done every frame. - /// void Update() override; #pragma endregion @@ -150,28 +116,20 @@ namespace RTE { private: #pragma region Update Breakdown - /// /// Updates the current ankle offset for this Leg. Should only be called from Update. /// If the Leg is attached, the current ankle offset is based on the target offset and move speed, and whether the Leg should idle or not, otherwise it puts it in a reasonable position. - /// void UpdateCurrentAnkleOffset(); - /// /// Updates the rotation of the Leg. Should only be called from Update. /// If the Leg is attached, this applies extra rotation to line up the Leg's sprite with its extension line, otherwise it does nothing. - /// void UpdateLegRotation(); - /// /// Updates the frame and rotation of the Leg's foot Attachable. Should only be called from Update. /// If the Leg is attached, the foot's rotation and frame depend on the ankle offset, otherwise the foot's rotation is set to be perpendicular to the Leg's rotation. - /// void UpdateFootFrameAndRotation(); #pragma endregion - /// /// Clears all the member variables of this Leg, effectively resetting the members of this abstraction level only. - /// void Clear(); // Disallow the use of some implicit methods. diff --git a/Source/Entities/LimbPath.cpp b/Source/Entities/LimbPath.cpp index 1ab6b095e6..aacdaefee2 100644 --- a/Source/Entities/LimbPath.cpp +++ b/Source/Entities/LimbPath.cpp @@ -1,15 +1,3 @@ -////////////////////////////////////////////////////////////////////////////////////////// -// File: LimbPath.cpp -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Source file for the LimbPath class. -// Project: Retro Terrain Engine -// Author(s): Daniel Tabar -// data@datarealms.com -// http://www.datarealms.com - -////////////////////////////////////////////////////////////////////////////////////////// -// Inclusions of header files - #include "LimbPath.h" #include "PresetMan.h" @@ -21,12 +9,6 @@ namespace RTE { ConcreteClassInfo(LimbPath, Entity, 20); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Clear - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears all the member variables of this LimbPath, effectively - // resetting the members of this abstraction level only. - void LimbPath::Clear() { m_Start.Reset(); m_StartSegCount = 0; @@ -55,11 +37,6 @@ namespace RTE { m_HFlipped = false; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes the LimbPath object ready for use. - int LimbPath::Create() { // Read all the properties if (Entity::Create() < 0) @@ -102,11 +79,6 @@ namespace RTE { } */ - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Creates a LimbPath to be identical to another, by deep copy. - int LimbPath::Create(const LimbPath& reference) { Entity::Create(reference); @@ -141,14 +113,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: ReadProperty - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Reads a property value from a reader stream. If the name isn't - // recognized by this class, then ReadProperty of the parent class - // is called. If the property isn't recognized by any of the base classes, - // false is returned, and the reader's position is untouched. - int LimbPath::ReadProperty(const std::string_view& propName, Reader& reader) { StartPropertyList(Entity::ReadProperty(propName, reader)); @@ -192,12 +156,6 @@ namespace RTE { return (((point - offset) * m_Rotation) + offset) + m_PositionOffset; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Save - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Saves the complete state of this LimbPath with a Writer for - // later recreation with Create(Reader &reader); - int LimbPath::Save(Writer& writer) const { Entity::Save(writer); @@ -223,11 +181,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destroys and resets (through Clear()) the LimbPath object. - void LimbPath::Destroy(bool notInherited) { if (!notInherited) @@ -235,12 +188,6 @@ namespace RTE { Clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetProgressPos - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the APPROXIMATE scene position that the limb was reported to be - // last frame. - Vector LimbPath::GetProgressPos() { Vector returnVec(m_Start); if (IsStaticPoint()) { @@ -261,11 +208,6 @@ namespace RTE { return m_JointPos + RotatePoint(returnVec); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetCurrentSegTarget - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the scene/world position target that the current segment represents. - Vector LimbPath::GetCurrentSegTarget() { Vector returnVec(m_Start); if (IsStaticPoint()) { @@ -285,15 +227,6 @@ namespace RTE { return m_JointPos + RotatePoint(returnVec); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetCurrentVel - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the velocity of the current position on the path. - // Note that this should be called BEFORE GetNextVec() if the - // appropriate matching velocity is to be returned here. If the limb - // doesn't hit the end of a segment before the time chunk runs out, - // the returned move vector is limited by the time chunk. - Vector LimbPath::GetCurrentVel(const Vector& limbPos) { Vector returnVel; Vector distVect = g_SceneMan.ShortestDistance(limbPos, GetCurrentSegTarget()); @@ -318,15 +251,6 @@ namespace RTE { return returnVel; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetNextTimeChunk - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the time needed to get to the target waypoint of the current - // segment at the current speed, if there are no obstacles. The chunk - // will not exceed the remaining time left on the frame, and will deduct - // itself from the remaining frame time tally (originally set by - // SetFrameTime()). - float LimbPath::GetNextTimeChunk(const Vector& limbPos) { float timeChunk; @@ -353,12 +277,6 @@ namespace RTE { return timeChunk; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ReportProgress - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Used to report how much progress was made to getting the limb close to - // the target (the next segment start). - void LimbPath::ReportProgress(const Vector& limbPos) { if (IsStaticPoint()) { const float staticPointEndedThreshold = 1.0F; @@ -391,12 +309,6 @@ namespace RTE { } } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetTotalProgress - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets a value representing the total progress that has been made on - // this entire path. If the path has ended, 0.0 is returned. - float LimbPath::GetTotalProgress() const { if (m_Ended || IsStaticPoint()) return 0.0; @@ -409,14 +321,6 @@ namespace RTE { return prog / m_TotalLength; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetRegularProgress - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets a value representing the progress that has been made on the - // regular part of this path, ie everything except the starting segments. - // If progress has not been made past the starting segments, < 0 will - // be returned. If the path has ended, 0.0 is returned. - float LimbPath::GetRegularProgress() const { if (m_Ended || IsStaticPoint()) return 0.0; @@ -429,8 +333,6 @@ namespace RTE { return prog / m_RegularLength; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int LimbPath::GetCurrentSegmentNumber() const { int progress = 0; if (!m_Ended && !IsStaticPoint()) { @@ -441,14 +343,6 @@ namespace RTE { return progress; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetSpeed - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the speed that a limb traveling this LimbPath should have to one - // of the three predefined speed settings. - void LimbPath::SetSpeed(int newSpeed) { if (newSpeed <= SLOW) m_WhichSpeed = SLOW; @@ -458,22 +352,12 @@ namespace RTE { m_WhichSpeed = NORMAL; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: OverrideSpeed - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the speed that a limb traveling this LimbPath with the specified preset should have. - void LimbPath::OverrideSpeed(int speedPreset, float newSpeed) { if (speedPreset == SLOW || speedPreset == FAST || speedPreset == NORMAL) { m_TravelSpeed[m_WhichSpeed] = newSpeed; } } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Terminate - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets this LimbPath's progress to its end. - void LimbPath::Terminate() { if (IsStaticPoint()) { m_Ended = true; @@ -484,12 +368,6 @@ namespace RTE { } } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Restart - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Restarts the position tracking of the limb that travels along this - // LimbPath. - void LimbPath::Restart() { m_CurrentSegment = m_Segments.begin(); m_PathTimer.Reset(); @@ -498,18 +376,6 @@ namespace RTE { m_Ended = false; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: RestartFree - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Restarts the position tracking of the limb that travels along this - // LimbPath at a point which does not contain terrain. In doing this, - // a list of potential starting segments are checked and the first to - // yield a starting position that is not in terrain will be picked. - // If none of the candidate starting segments are free of terrain, - // the last one in the list will be picked and false will be returned - // here. The passed in limbPos Vector will be set to the new position of - // the restarted path, if a free spot is found. - bool LimbPath::RestartFree(Vector& limbPos, MOID MOIDToIgnore, int ignoreTeam) { std::deque::iterator prevSeg = m_CurrentSegment; float prevProg = m_SegProgress; @@ -617,12 +483,6 @@ namespace RTE { return m_HFlipped ? -result : result; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Draw - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws this LimbPath's current graphical debug representation to a - // BITMAP of choice. - void LimbPath::Draw(BITMAP* pTargetBitmap, const Vector& targetPos, unsigned char color) const { diff --git a/Source/Entities/LimbPath.h b/Source/Entities/LimbPath.h index e7739347ad..fe0e0f0131 100644 --- a/Source/Entities/LimbPath.h +++ b/Source/Entities/LimbPath.h @@ -1,18 +1,11 @@ #ifndef _RTELIMBPATH_ #define _RTELIMBPATH_ -////////////////////////////////////////////////////////////////////////////////////////// -// File: LimbPath.h -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Header file for the LimbPath class. -// Project: Retro Terrain Engine -// Author(s): Daniel Tabar -// data@datarealms.com -// http://www.datarealms.com - -////////////////////////////////////////////////////////////////////////////////////////// -// Inclusions of header files - +/// Header file for the LimbPath class. +/// @author Daniel Tabar +/// data@datarealms.com +/// http://www.datarealms.com +/// Inclusions of header files #include "Entity.h" #include "Vector.h" #include "ActivityMan.h" @@ -28,51 +21,28 @@ namespace RTE { FAST }; - ////////////////////////////////////////////////////////////////////////////////////////// - // Class: LimbPath - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: A set of Vector:s making up a motion path for a AtomGroup's limb. The - // path is continuous. - // Parent(s): Entity. - // Class history: 05/25/2001 LimbPath created. - + /// A set of Vector:s making up a motion path for a AtomGroup's limb. The + /// path is continuous. class LimbPath : public Entity { - ////////////////////////////////////////////////////////////////////////////////////////// - // Public member variable, method and friend function declarations - + /// Public member variable, method and friend function declarations public: // Concrete allocation and cloning definitions EntityAllocation(LimbPath); SerializableOverrideMethods; ClassInfoGetters; - ////////////////////////////////////////////////////////////////////////////////////////// - // Constructor: LimbPath - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Constructor method used to instantiate a LimbPath object in system - // memory. Create() should be called before using the object. - // Arguments: None. - + /// Constructor method used to instantiate a LimbPath object in system + /// memory. Create() should be called before using the object. LimbPath() { Clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Destructor: ~LimbPath - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destructor method used to clean up a LimbPath object before deletion - // from system memory. - // Arguments: None. - + /// Destructor method used to clean up a LimbPath object before deletion + /// from system memory. ~LimbPath() override { Destroy(true); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes the LimbPath object ready for use. - // Arguments: None. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Makes the LimbPath object ready for use. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Create() override; /* @@ -96,66 +66,40 @@ namespace RTE { const float travelSpeed = 1.0); */ - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Creates a LimbPath to be identical to another, by deep copy. - // Arguments: A reference to the LimbPath to deep copy. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Creates a LimbPath to be identical to another, by deep copy. + /// @param reference A reference to the LimbPath to deep copy. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Create(const LimbPath& reference); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Reset - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Resets the entire LimbPath, including its inherited members, to their - // default settings or values. - // Arguments: None. - // Return value: None. - + /// Resets the entire LimbPath, including its inherited members, to their + /// default settings or values. void Reset() override { Clear(); Entity::Reset(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destroys and resets (through Clear()) the LimbPath object. - // Arguments: Whether to only destroy the members defined in this derived class, or - // to destroy all inherited members also. - // Return value: None. - + /// Destroys and resets (through Clear()) the LimbPath object. + /// @param notInherited Whether to only destroy the members defined in this derived class, or (default: false) + /// to destroy all inherited members also. void Destroy(bool notInherited = false) override; - /// /// Gets the coordinates where the limb should start at the start of the LimbPath cycle, relative to the owning AtomGroup's local origin. - /// - /// A Vector with the start position. + /// @return A Vector with the start position. const Vector& GetStartOffset() const { return m_Start; } - /// /// Sets the coordinates where the limb should start at the start of the LimbPath cycle, relative to the owning AtomGroup's local origin. - /// - /// A Vector with the new start offset. + /// @param newStartOffset A Vector with the new start offset. void SetStartOffset(const Vector& newStartOffset) { m_Start = newStartOffset; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetSegCount - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the number of Vector:s the internal array of 'waypoints' or - // segments of this LimbPath. - // Arguments: None. - // Return value: An int with he count. - + /// Gets the number of Vector:s the internal array of 'waypoints' or + /// segments of this LimbPath. + /// @return An int with he count. unsigned int GetSegCount() const { return m_Segments.size(); } - /// /// Gets a pointer to the segment at the given index. Ownership is NOT transferred. - /// - /// The index of the segment to get. - /// A pointer to the segment at the given index. Ownership is NOT transferred. + /// @param segmentIndex The index of the segment to get. + /// @return A pointer to the segment at the given index. Ownership is NOT transferred. Vector* GetSegment(int segmentIndex) { if (segmentIndex >= 0 && segmentIndex < m_Segments.size()) { return &m_Segments.at(segmentIndex); @@ -163,69 +107,39 @@ namespace RTE { return nullptr; } - /// /// Gets whether or not foot collisions should be disabled, i.e. the limbpath's progress is greater than the FootCollisionsDisabledSegment value. - /// - /// Whether or not foot collisions should be disabled for this limbpath at its current progress. + /// @return Whether or not foot collisions should be disabled for this limbpath at its current progress. bool FootCollisionsShouldBeDisabled() const { return m_FootCollisionsDisabledSegment >= 0 && GetSegCount() - GetCurrentSegmentNumber() <= m_FootCollisionsDisabledSegment; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetSegProgress - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets how far the limb was last reported to be away form the current - // segment target/waypoint. - // Arguments: None. - // Return value: A normalized float describing the progress made toward the current - // segment last frame. 0.5 means it was half the length of the current - // segment away from it. - + /// Gets how far the limb was last reported to be away form the current + /// segment target/waypoint. + /// @return A normalized float describing the progress made toward the current + /// segment last frame. 0.5 means it was half the length of the current + /// segment away from it. float GetSegProgress() const { return m_SegProgress; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetProgressPos - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the APPROXIMATE scene position that the limb was reported to be - // last frame. This really shouldn't be used by external clients. - // Arguments: None. - // Return value: A Vector with the APPROXIAMTE scene/world coordinates of the limb as - // reported last. - + /// Gets the APPROXIMATE scene position that the limb was reported to be + /// last frame. This really shouldn't be used by external clients. + /// @return A Vector with the APPROXIAMTE scene/world coordinates of the limb as + /// reported last. Vector GetProgressPos(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetCurrentSegTarget - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the scene/world position target that the current segment represents. - // Arguments: None. - // Return value: A vector with the scene position of the current segment target. - + /// Gets the scene/world position target that the current segment represents. + /// @return A vector with the scene position of the current segment target. Vector GetCurrentSegTarget(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetCurrentVel - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the velocity of the current position on the path. - // Arguments: The current world coordinate position of the Limb. - // Return value: A Vector with the current move velocity. - + /// Gets the velocity of the current position on the path. + /// @param limbPos The current world coordinate position of the Limb. + /// @return A Vector with the current move velocity. Vector GetCurrentVel(const Vector& limbPos); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetSpeed - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the speed that a limb traveling this LimbPath should have. - // Arguments: None. - // Return value: A float describing the speed in m/s. - + /// Gets the speed that a limb traveling this LimbPath should have. + /// @return A float describing the speed in m/s. float GetSpeed() const { return m_TravelSpeed[m_WhichSpeed] * m_TravelSpeedMultiplier; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetSpeed - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the speed that a limb traveling this LimbPath should have for the specified preset. - // Arguments: Predefined speed preset to set the value for. - // Return value: A float describing the speed in m/s. - + /// Gets the speed that a limb traveling this LimbPath should have for the specified preset. + /// @param speedPreset Predefined speed preset to set the value for. + /// @return A float describing the speed in m/s. float GetSpeed(int speedPreset) const { if (speedPreset == SLOW || speedPreset == NORMAL || speedPreset == FAST) return m_TravelSpeed[speedPreset]; @@ -233,381 +147,217 @@ namespace RTE { return 0; } - /// /// Sets the current travel speed multiplier. - /// - /// The new travel speed multiplier. + /// @param newValue The new travel speed multiplier. void SetTravelSpeedMultiplier(float newValue) { m_TravelSpeedMultiplier = newValue; } - /// /// Gets the current travel speed multiplier. - /// - /// The current travel speed multiplier. + /// @return The current travel speed multiplier. float GetTravelSpeedMultiplier() const { return m_TravelSpeedMultiplier; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetPushForce - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the force that a limb traveling this LimbPath can push against - // stuff in the scene with. It will increase to the double if progress - // isn't made on the segment. - // Arguments: None. - // Return value: The currently set force maximum, in kg * m/s^2. - + /// Gets the force that a limb traveling this LimbPath can push against + /// stuff in the scene with. It will increase to the double if progress + /// isn't made on the segment. + /// @return The currently set force maximum, in kg * m/s^2. float GetPushForce() const { return m_PushForce + (m_PushForce * (m_SegTimer.GetElapsedSimTimeMS() / 500)); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetPushForce - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets thedefault, unaltered force that a limb traveling this LimbPath can push against - // stuff in the scene with. - // Arguments: None. - // Return value: The default set force maximum, in kg * m/s^2. - + /// Gets thedefault, unaltered force that a limb traveling this LimbPath can push against + /// stuff in the scene with. + /// @return The default set force maximum, in kg * m/s^2. float GetDefaultPushForce() const { return m_PushForce; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetNextTimeChunk - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the time needed to get to the target waypoint of the current - // segment at the current speed, if there are no obstacles. The chunk - // will not exceed the remaining time left on the frame, and will deduct - // itself from the remaining frame time tally (originally set by - // SetFrameTime()). - // Arguments: The current world coordinate position of the Limb. - // Return value: A float describing the time chunk in seconds. - + /// Gets the time needed to get to the target waypoint of the current + /// segment at the current speed, if there are no obstacles. The chunk + /// will not exceed the remaining time left on the frame, and will deduct + /// itself from the remaining frame time tally (originally set by + /// SetFrameTime()). + /// @param limbPos The current world coordinate position of the Limb. + /// @return A float describing the time chunk in seconds. float GetNextTimeChunk(const Vector& limbPos); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetTotalPathTime - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the total time that this entire path should take to travel along - // with the current speed setting, including the start segments. - // Arguments: None. - // Return value: The total time (ms) this should take to travel along, if unobstructed. - + /// Gets the total time that this entire path should take to travel along + /// with the current speed setting, including the start segments. + /// @return The total time (ms) this should take to travel along, if unobstructed. float GetTotalPathTime() const { return ((m_TotalLength * c_MPP) / (m_TravelSpeed[m_WhichSpeed] * m_TravelSpeedMultiplier)) * 1000; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetRegularPathTime - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the total time that this path should take to travel along - // with the current speed setting, NOT including the start segments. - // Arguments: None. - // Return value: The total time (ms) this should take to travel along, if unobstructed. - + /// Gets the total time that this path should take to travel along + /// with the current speed setting, NOT including the start segments. + /// @return The total time (ms) this should take to travel along, if unobstructed. float GetRegularPathTime() const { return ((m_RegularLength * c_MPP) / (m_TravelSpeed[m_WhichSpeed] * m_TravelSpeedMultiplier)) * 1000; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetTotalTimeProgress - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the ratio of time since the path was restarted and the total time - // it should take to travel along the path with the current speed setting, - // including the start segments. - // Arguments: None. - // Return value: A positive scalar ratio showing the progress. 0 - 1.0 and beyond. - // If the path has ended, but not been reset, 0 is returned. - + /// Gets the ratio of time since the path was restarted and the total time + /// it should take to travel along the path with the current speed setting, + /// including the start segments. + /// @return A positive scalar ratio showing the progress. 0 - 1.0 and beyond. + /// If the path has ended, but not been reset, 0 is returned. float GetTotalTimeProgress() const { return m_Ended ? 0 : (m_PathTimer.GetElapsedSimTimeMS() / GetTotalPathTime()); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetRegularTimeProgress - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the ratio of time since the path was restarted and the total time - // it should take to travel along the path with the current speed setting, - // NOT including the start segments. - // Arguments: None. - // Return value: A positive scalar ratio showing the progress. 0 - 1.0 and beyond. - // If the path has ended, but not been reset, 0 is returned. - + /// Gets the ratio of time since the path was restarted and the total time + /// it should take to travel along the path with the current speed setting, + /// NOT including the start segments. + /// @return A positive scalar ratio showing the progress. 0 - 1.0 and beyond. + /// If the path has ended, but not been reset, 0 is returned. float GetRegularTimeProgress() const { return m_Ended ? 0 : (m_PathTimer.GetElapsedSimTimeMS() / GetRegularPathTime()); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ReportProgress - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Used to report how much progress was made to getting the limb close to - // the target (the current segment waypoint). - // Arguments: The new limb position in world coords. - // Return value: None. - + /// Used to report how much progress was made to getting the limb close to + /// the target (the current segment waypoint). + /// @param limbPos The new limb position in world coords. void ReportProgress(const Vector& limbPos); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetTotalProgress - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets a value representing the total progress that has been made on - // this entire path. If the path has ended, 0.0 is returned. - // Arguments: None. - // Return value: A float indicating the total progress made on the entire path, from - // 0.0 to 1.0. If the path has ended, 0.0 is returned. - + /// Gets a value representing the total progress that has been made on + /// this entire path. If the path has ended, 0.0 is returned. + /// @return A float indicating the total progress made on the entire path, from + /// 0.0 to 1.0. If the path has ended, 0.0 is returned. float GetTotalProgress() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetRegularProgress - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets a value representing the progress that has been made on the - // regular part of this path, ie averythign except the starting segments. - // If progress has not been made past the starting segments, < 0 will - // be returned. If the path has ended, 0.0 is returned. - // Arguments: None. - // Return value: A float indicating the total progress made on the regular path, from - // 0.0 to 1.0. If the path has ended, 0.0 is returned. - + /// Gets a value representing the progress that has been made on the + /// regular part of this path, ie averythign except the starting segments. + /// If progress has not been made past the starting segments, < 0 will + /// be returned. If the path has ended, 0.0 is returned. + /// @return A float indicating the total progress made on the regular path, from + /// 0.0 to 1.0. If the path has ended, 0.0 is returned. float GetRegularProgress() const; - /// /// Gets the current segment as a number, rather than an iterator. - /// - /// The current segment as a number. + /// @return The current segment as a number. int GetCurrentSegmentNumber() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetSegments - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets a new array of 'waypoints' or segments of this LimbPath. - // Arguments: An int specifying how many segments there are in the following - // segment array. This MUST match the actual size of the array! - // A pointer to the new Vector array. - // Return value: None. - + /// Sets a new array of 'waypoints' or segments of this LimbPath. + /// @param newSpeed An int specifying how many segments there are in the following + /// segment array. This MUST match the actual size of the array! + /// A pointer to the new Vector array. // void SetSegments(const unsigned int segCount, const Vector *newSegments); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetCurrentSeg - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the current seg pointer to whichever segment in the segment deque. - // Arguments: An int that is an index to a valid element of the internal segment array. - // Return value: None. - + /// Sets the current seg pointer to whichever segment in the segment deque. + /// @param newSpeed An int that is an index to a valid element of the internal segment array. // void SetCurrentSeg(unsigned int currentSeg) { m_CurrentSegment = currentSeg; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetSpeed - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the speed that a limb traveling this LimbPath should have to one - // of the three predefined speed settings. - // Arguments: An int specifying which discrete speed setting to use from the Speed - // enumeration. - // Return value: None. - + /// Sets the speed that a limb traveling this LimbPath should have to one + /// of the three predefined speed settings. + /// @param newSpeed An int specifying which discrete speed setting to use from the Speed + /// enumeration. void SetSpeed(int newSpeed); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: OverrideSpeed - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the speed that a limb traveling this LimbPath with the specified preset should have. - // Arguments: An int specifying which discrete speed setting to use from the Speed - // enumeration. New limb travel speed value. - // Return value: None. - + /// Sets the speed that a limb traveling this LimbPath with the specified preset should have. + /// @param speedPreset An int specifying which discrete speed setting to use from the Speed + /// enumeration. New limb travel speed value. void OverrideSpeed(int speedPreset, float newSpeed); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: OverridePushForce - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the force that a limb traveling this LimbPath can push against - // stuff in the scene with. - // Arguments: The new push force maximum, in kg * m/s^2. - // Return value: None. - + /// Sets the force that a limb traveling this LimbPath can push against + /// stuff in the scene with. + /// @param newForce The new push force maximum, in kg * m/s^2. void OverridePushForce(float newForce) { m_PushForce = newForce; }; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetFrameTime - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the amount of time that will be used by the limb to travel every - // frame. Defined in seconds. - // Arguments: A float describing the time in s. - // Return value: None. - + /// Sets the amount of time that will be used by the limb to travel every + /// frame. Defined in seconds. + /// @param newFrameTime A float describing the time in s. void SetFrameTime(float newFrameTime) { m_TimeLeft = newFrameTime; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetHFlip - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets whether this path is flipped horizontally or not. If being - // flipped the path automatically restarts. - // Arguments: A bool telling this path to be flipped or not. - // Return value: None. - + /// Sets whether this path is flipped horizontally or not. If being + /// flipped the path automatically restarts. + /// @param hflipped A bool telling this path to be flipped or not. void SetHFlip(bool hflipped) { m_HFlipped = hflipped; } - /// /// Gets the h flip. - /// - /// The h flip. + /// @return The h flip. bool GetHFlip() { return m_HFlipped; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetJointPos - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Informs this LimbPath of the absolute world coordinates of its owning - // Actor's limb's joint for this frame. Needs to be done before - // travelling anyhting along this path each frame. - // Arguments: A Vector with the updated joint position info. - // Return value: None. - + /// Informs this LimbPath of the absolute world coordinates of its owning + /// Actor's limb's joint for this frame. Needs to be done before + /// travelling anyhting along this path each frame. + /// @param jointPos A Vector with the updated joint position info. void SetJointPos(const Vector& jointPos) { m_JointPos = jointPos; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetJointVel - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Informs this LimbPath of the current velocity of its owning Actor's - // limb's joint for this frame. Needs to be done before travelling - // anyhting along this path each frame. - // Arguments: A Vector with the updated joint velocity info. - // Return value: None. - + /// Informs this LimbPath of the current velocity of its owning Actor's + /// limb's joint for this frame. Needs to be done before travelling + /// anyhting along this path each frame. + /// @param jointVel A Vector with the updated joint velocity info. void SetJointVel(const Vector& jointVel) { m_JointVel = jointVel; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetRotation - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Informs this LimbPath of the current rotation of its owning Actor's - // for this frame. Needs to be done before travelling - // anything along this path each frame. - // Arguments: A Matrix with the updated rotation info. - // Return value: None. - + /// Informs this LimbPath of the current rotation of its owning Actor's + /// for this frame. Needs to be done before travelling + /// anything along this path each frame. + /// @param rotation A Matrix with the updated rotation info. void SetRotation(const Matrix& rotation) { m_Rotation = rotation; m_Rotation.SetXFlipped(m_HFlipped); } - /// /// Sets the new rotation offset. - /// - /// The new rotation offset, in local space. + /// @param rotationOffset The new rotation offset, in local space. void SetRotationOffset(const Vector& rotationOffset) { m_RotationOffset = rotationOffset; } - /// /// Sets the new position offset. - /// - /// The new position offset, in local space. + /// @param rotationOffset The new position offset, in local space. void SetPositionOffset(const Vector& positionOffset) { m_PositionOffset = positionOffset; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: FrameDone - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns if GetNextMoveVec() have to be called again or not on this - // frame. If the last call didn't use up all the time moving on the - // current segment because it ended, this will return false. Then - // GetNextMoveVec() needs to be called at least one more time this frame. - // Arguments: None. - // Return value: A bool with the answer. - + /// Returns if GetNextMoveVec() have to be called again or not on this + /// frame. If the last call didn't use up all the time moving on the + /// current segment because it ended, this will return false. Then + /// GetNextMoveVec() needs to be called at least one more time this frame. + /// @return A bool with the answer. bool FrameDone() const { return m_TimeLeft <= 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: PathEnded - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Indicates whether the last call to ProgressMade() completed the - // entire path. Use Restart() to start the path over. - // Arguments: None. - // Return value: A bool with the answer. - + /// Indicates whether the last call to ProgressMade() completed the + /// entire path. Use Restart() to start the path over. + /// @return A bool with the answer. bool PathEnded() const { return m_Ended; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: PathIsAtStart - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Indicates whether the path has been restarted without making any - // progress yet. - // Arguments: None. - // Return value: A bool with the answer. - + /// Indicates whether the path has been restarted without making any + /// progress yet. + /// @return A bool with the answer. bool PathIsAtStart() const { return m_CurrentSegment == m_Segments.begin() && m_SegProgress == 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Terminate - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets this LimbPath's progress to its end. - // Arguments: None. - // Return value: None. - + /// Sets this LimbPath's progress to its end. void Terminate(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Restart - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Restarts the position tracking of the limb that travels along this - // LimbPath. - // Arguments: None. - // Return value: None. - + /// Restarts the position tracking of the limb that travels along this + /// LimbPath. void Restart(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: RestartFree - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Restarts the position tracking of the limb that travels along this - // LimbPath at a point which does not contain terrain. In doing this, - // a list of potential starting segments are checked and the first to - // yield a starting position that is not in terrain will be picked. - // If none of the candidate starting segments are free of terrain, - // the last one in the list will be picked and false will be returned - // here. The passed in limbPos Vector will be set to teh new position of - // the restarted path, if a free spot is found. - // Arguments: Limb scene pos which will be set to the new reset position if a free - // spot was found. - // The root MOID to ignore when looking for a free position. - // To enable ignoring of all MOIDs associated with an object of a specific - // team which also has team ignoring enabled itself. - // Return value: Whether a starting segment that yielded a starting pos free of terrain - // was found or not. - + /// Restarts the position tracking of the limb that travels along this + /// LimbPath at a point which does not contain terrain. In doing this, + /// a list of potential starting segments are checked and the first to + /// yield a starting position that is not in terrain will be picked. + /// If none of the candidate starting segments are free of terrain, + /// the last one in the list will be picked and false will be returned + /// here. The passed in limbPos Vector will be set to teh new position of + /// the restarted path, if a free spot is found. + /// @param limbPos Limb scene pos which will be set to the new reset position if a free + /// spot was found. + /// @param MOIDToIgnore The root MOID to ignore when looking for a free position. (default: g_NoMOID) + /// @param ignoreTeam To enable ignoring of all MOIDs associated with an object of a specific (default: Activity::NoTeam) + /// team which also has team ignoring enabled itself. + /// @return Whether a starting segment that yielded a starting pos free of terrain + /// was found or not. bool RestartFree(Vector& limbPos, MOID MOIDToIgnore = g_NoMOID, int ignoreTeam = Activity::NoTeam); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: IsInitialized - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Indicated whether this path is has been created and had some data set - // yet. - // Arguments: None. - // Return value: Whether this has been Create:ed yet. - + /// Indicated whether this path is has been created and had some data set + /// yet. + /// @return Whether this has been Create:ed yet. bool IsInitialized() const { return !m_Start.IsZero() || !m_Segments.empty(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: IsStaticPoint - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Indicated whether this path is in fact just a single point to where - // the limb will always be ordered to move toward. IE a standing still - // type limb movement. - // Arguments: None. - // Return value: None. - + /// Indicated whether this path is in fact just a single point to where + /// the limb will always be ordered to move toward. IE a standing still + /// type limb movement. bool IsStaticPoint() const { return m_Segments.empty(); } - /// /// Returns the lowest y position of this LimbPath. - /// - /// The lowest y position of this LimbPath. + /// @return The lowest y position of this LimbPath. float GetLowestY() const; - /// /// Returns the middle x position of this LimbPath. - /// - /// The middle x position of this LimbPath. + /// @return The middle x position of this LimbPath. float GetMiddleX() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Draw - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws this LimbPath's current graphical debug representation to a - // BITMAP of choice. - // Arguments: A pointer to a BITMAP to draw on. - // The absolute position of the target bitmap's upper left corner in the Scene. - // The color to draw the path's pixels as. - // Return value: None. - + /// Draws this LimbPath's current graphical debug representation to a + /// BITMAP of choice. + /// @param pTargetBitmap A pointer to a BITMAP to draw on. + /// @param targetPos The absolute position of the target bitmap's upper left corner in the Scene. (default: Vector()) + /// @param color The color to draw the path's pixels as. (default: 34) void Draw(BITMAP* pTargetBitmap, const Vector& targetPos = Vector(), unsigned char color = 34) const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Protected member variable and method declarations - + /// Protected member variable and method declarations protected: static Entity::ClassInfo m_sClass; @@ -675,25 +425,15 @@ namespace RTE { bool m_Ended; bool m_HFlipped; - ////////////////////////////////////////////////////////////////////////////////////////// - // Private member variable and method declarations - + /// Private member variable and method declarations private: - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Clear - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears all the member variables of this LimbPath, effectively - // resetting the members of this abstraction level only. - // Arguments: None. - // Return value: None. - + /// Clears all the member variables of this LimbPath, effectively + /// resetting the members of this abstraction level only. void Clear(); - /// /// Rotates a point to match our rotation and rotation offset. - /// - /// The point to rotate. - /// The rotated point. + /// @param point The point to rotate. + /// @return The rotated point. Vector RotatePoint(const Vector& point) const; }; diff --git a/Source/Entities/Loadout.cpp b/Source/Entities/Loadout.cpp index 18604cc71e..f7d2557318 100644 --- a/Source/Entities/Loadout.cpp +++ b/Source/Entities/Loadout.cpp @@ -1,15 +1,3 @@ -////////////////////////////////////////////////////////////////////////////////////////// -// File: Loadout.cpp -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Implementation file for the Loadout class -// Project: Retro Terrain Engine -// Author(s): Daniel Tabar -// dtabar@datarealms.com -// http://www.datarealms.com - -////////////////////////////////////////////////////////////////////////////////////////// -// Inclusions of header files - #include "Loadout.h" #include "PresetMan.h" #include "MovableObject.h" @@ -19,12 +7,6 @@ namespace RTE { ConcreteClassInfo(Loadout, Entity, 0); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Clear - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears all the member variables of this Loadout, effectively - // resetting the members of this abstraction level only. - void Loadout::Clear() { m_Complete = true; m_pDeliveryCraft = 0; @@ -46,11 +28,6 @@ namespace RTE { } */ - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Creates a Loadout to be identical to another, by deep copy. - int Loadout::Create(const Loadout& reference) { Entity::Create(reference); @@ -63,14 +40,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: ReadProperty - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Reads a property value from a reader stream. If the name isn't - // recognized by this class, then ReadProperty of the parent class - // is called. If the property isn't recognized by any of the base classes, - // false is returned, and the reader's position is untouched. - int Loadout::ReadProperty(const std::string_view& propName, Reader& reader) { StartPropertyList(return Entity::ReadProperty(propName, reader)); @@ -121,12 +90,6 @@ namespace RTE { EndPropertyList; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Save - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Saves the complete state of this Loadout with a Writer for - // later recreation with Create(Reader &reader); - int Loadout::Save(Writer& writer) const { Entity::Save(writer); @@ -164,13 +127,6 @@ namespace RTE { } */ - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: CreateFirstActor - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Creates and returns the first Actor that this Loadout has and equips. - // Ownership IS transferred!! All items of the Loadout of this Deployment - // will be added to the Actor's inventory as well (and also owned by it) - Actor* Loadout::CreateFirstActor(int nativeModule, float foreignMult, float nativeMult, float& costTally) const { // The Actor instance we return and pass ownership of Actor* pReturnActor = 0; @@ -252,12 +208,6 @@ namespace RTE { return pReturnActor; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: CreateFirstDevice - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Creates and returns the first Device that is defined in this Loadout. - // Ownership IS transferred!! Only the first Device is created. - SceneObject* Loadout::CreateFirstDevice(int nativeModule, float foreignMult, float nativeMult, float& costTally) const { // The Actor instance we return and pass ownership of SceneObject* pReturnObject = 0; diff --git a/Source/Entities/Loadout.h b/Source/Entities/Loadout.h index 2f66f335dd..9385484d88 100644 --- a/Source/Entities/Loadout.h +++ b/Source/Entities/Loadout.h @@ -1,19 +1,12 @@ #ifndef _LOADOUT_ #define _LOADOUT_ -////////////////////////////////////////////////////////////////////////////////////////// -// File: Loadout.h -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Loadout class -// Project: Retro Terrain Engine -// Author(s): Daniel Tabar -// dtabar@datarealms.com -// http://www.datarealms.com - -////////////////////////////////////////////////////////////////////////////////////////// -// Inclusions of header files - -//#include "FrameMan.h" +/// Loadout class +/// @author Daniel Tabar +/// dtabar@datarealms.com +/// http://www.datarealms.com +/// Inclusions of header files +// #include "FrameMan.h" #include "Entity.h" namespace RTE { @@ -23,40 +16,23 @@ namespace RTE { class ACraft; class Actor; - ////////////////////////////////////////////////////////////////////////////////////////// - // Nested class: Loadout - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Defines a delivery of Actors, with all their equipment etc. - // Parent(s): Entity. - // Class history: 2/21/2012 Loadout created. - + /// Defines a delivery of Actors, with all their equipment etc. class Loadout : public Entity { - ////////////////////////////////////////////////////////////////////////////////////////// - // Public member variable, method and friend function declarations - + /// Public member variable, method and friend function declarations public: // Concrete allocation and cloning definitions EntityAllocation(Loadout); SerializableOverrideMethods; ClassInfoGetters; - ////////////////////////////////////////////////////////////////////////////////////////// - // Constructor: Loadout - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Constructor method used to instantiate a Loadout object in system - // memory. Create() should be called before using the object. - // Arguments: None. - + /// Constructor method used to instantiate a Loadout object in system + /// memory. Create() should be called before using the object. Loadout() { Clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Constructor: Loadout - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Copy constructor method used to instantiate a Loadout object - // identical to an already existing one. - // Arguments: A Loadout object which is passed in by reference. - + /// Copy constructor method used to instantiate a Loadout object + /// identical to an already existing one. + /// @param reference A Loadout object which is passed in by reference. Loadout(const Loadout& reference) { if (this != &reference) { Clear(); @@ -64,13 +40,9 @@ namespace RTE { } } - ////////////////////////////////////////////////////////////////////////////////////////// - // Operator: Loadout assignment - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: An assignment operator for setting one Loadout equal to another. - // Arguments: A Loadout reference. - // Return value: A reference to the changed Loadout. - + /// An assignment operator for setting one Loadout equal to another. + /// @param rhs A Loadout reference. + /// @return A reference to the changed Loadout. Loadout& operator=(const Loadout& rhs) { if (this != &rhs) { Destroy(); @@ -79,111 +51,66 @@ namespace RTE { return *this; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Creates a Loadout to be identical to another, by deep copy. - // Arguments: A reference to the Loadout to deep copy. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Creates a Loadout to be identical to another, by deep copy. + /// @param reference A reference to the Loadout to deep copy. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Create(const Loadout& reference); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Reset - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Resets the entire Entity, including its inherited members, to their - // default settings or values. - // Arguments: None. - // Return value: None. - + /// Resets the entire Entity, including its inherited members, to their + /// default settings or values. void Reset() override { Clear(); Entity::Reset(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: IsComplete - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Shows whether this loadout is complete, or some Entity within could - // not be found on load. - // Arguments: None. - // Return value: Complete or not. - + /// Shows whether this loadout is complete, or some Entity within could + /// not be found on load. + /// @return Complete or not. bool IsComplete() { return m_Complete; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: CreateFirstActor - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Creates and returns the first Actor that this Loadout has and equips. - // Ownership IS transferred!! All items of the Loadout of this Deployment - // will be added to the Actor's inventory as well (and also owned by it) - // Arguments: Which in-game player to create the Actor for. - // A float which will be added to with the cost of the stuff returned here. - // Return value: The Actor instance, if any, that is first defined in this Loadout. - // OWNERSHIP IS TRANSFERRED! - + /// Creates and returns the first Actor that this Loadout has and equips. + /// Ownership IS transferred!! All items of the Loadout of this Deployment + /// will be added to the Actor's inventory as well (and also owned by it) + /// @param nativeModule Which in-game player to create the Actor for. + /// @param foreignMult A float which will be added to with the cost of the stuff returned here. + /// @return The Actor instance, if any, that is first defined in this Loadout. + /// OWNERSHIP IS TRANSFERRED! Actor* CreateFirstActor(int nativeModule, float foreignMult, float nativeMult, float& costTally) const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: CreateFirstDevice - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Creates and returns the first Device that is defined in this Loadout. - // Ownership IS transferred!! Only the first Device is created. - // Arguments: Which in-game player to create the device for. - // A float which will be added to with the cost of the stuff returned here. - // Return value: The SceneObject instance, if any, that this Loadout defines first. - // OWNERSHIP IS TRANSFERRED! - + /// Creates and returns the first Device that is defined in this Loadout. + /// Ownership IS transferred!! Only the first Device is created. + /// @param nativeModule Which in-game player to create the device for. + /// @param foreignMult A float which will be added to with the cost of the stuff returned here. + /// @return The SceneObject instance, if any, that this Loadout defines first. + /// OWNERSHIP IS TRANSFERRED! SceneObject* CreateFirstDevice(int nativeModule, float foreignMult, float nativeMult, float& costTally) const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetDeliveryCraft - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the preset of the delivery craft set for this loadout. Owenership - // is NOT transferred! - // Arguments: None. - // Return value: A pointer to the ACraft preset instance. OWNERSHIP IS NOT TRANSFERRED! - + /// Gets the preset of the delivery craft set for this loadout. Owenership + /// is NOT transferred! + /// @return A pointer to the ACraft preset instance. OWNERSHIP IS NOT TRANSFERRED! const ACraft* GetDeliveryCraft() const { return m_pDeliveryCraft; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetDeliveryCraft - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the preset of the delivery craft set for this loadout. Owenership - // is NOT transferred! - // Arguments: A pointer to the ACraft preset instance. OWNERSHIP IS NOT TRANSFERRED! - // Return value: None. - + /// Sets the preset of the delivery craft set for this loadout. Owenership + /// is NOT transferred! + /// @param pCraft A pointer to the ACraft preset instance. OWNERSHIP IS NOT TRANSFERRED! void SetDeliveryCraft(const ACraft* pCraft) { m_pDeliveryCraft = pCraft; m_Complete = m_Complete && m_pDeliveryCraft; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetCargoList - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the list of cargo Entity items this Loadout represents. - // Arguments: None. - // Return value: A pointer to the list of cargo Entity items. OWNERSHIP IS NOT TRANSFERRED! - + /// Gets the list of cargo Entity items this Loadout represents. + /// @return A pointer to the list of cargo Entity items. OWNERSHIP IS NOT TRANSFERRED! std::list* GetCargoList() { return &m_CargoItems; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: AddToCargoList - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Adds a new Preset to the list of cargo items to be included in this. - // Arguments: A const pointer to the ScneObject preset we want to add to this loadout. - // Return value: None. - + /// Adds a new Preset to the list of cargo items to be included in this. + /// @param pNewItem A const pointer to the ScneObject preset we want to add to this loadout. void AddToCargoList(const SceneObject* pNewItem) { if (pNewItem) m_CargoItems.push_back(pNewItem); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Protected member variable and method declarations - + /// Protected member variable and method declarations protected: // Member variables static Entity::ClassInfo m_sClass; @@ -194,18 +121,10 @@ namespace RTE { // The cargo of this loadout, all preset instances not owned by this std::list m_CargoItems; - ////////////////////////////////////////////////////////////////////////////////////////// - // Private member variable and method declarations - + /// Private member variable and method declarations private: - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Clear - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears all the member variables of this Loadout, effectively - // resetting the members of this abstraction level only. - // Arguments: None. - // Return value: None. - + /// Clears all the member variables of this Loadout, effectively + /// resetting the members of this abstraction level only. void Clear(); }; diff --git a/Source/Entities/MOPixel.cpp b/Source/Entities/MOPixel.cpp index 1feefb8c06..9199526c44 100644 --- a/Source/Entities/MOPixel.cpp +++ b/Source/Entities/MOPixel.cpp @@ -8,8 +8,6 @@ namespace RTE { ConcreteClassInfo(MOPixel, MovableObject, 2000); - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void MOPixel::Clear() { m_Atom = 0; m_Color.Reset(); @@ -20,8 +18,6 @@ namespace RTE { m_Staininess = 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int MOPixel::Create() { if (MovableObject::Create() < 0) { return -1; @@ -38,8 +34,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int MOPixel::Create(Color color, const float mass, const Vector& position, const Vector& velocity, Atom* atom, const unsigned long lifetime) { m_Color = color; m_Atom = atom; @@ -53,8 +47,6 @@ namespace RTE { return MovableObject::Create(mass, position, velocity, lifetime); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int MOPixel::Create(const MOPixel& reference) { MovableObject::Create(reference); @@ -70,8 +62,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int MOPixel::ReadProperty(const std::string_view& propName, Reader& reader) { StartPropertyList(return MovableObject::ReadProperty(propName, reader)); @@ -90,8 +80,6 @@ namespace RTE { EndPropertyList; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int MOPixel::Save(Writer& writer) const { MovableObject::Save(writer); @@ -109,8 +97,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void MOPixel::Destroy(bool notInherited) { delete m_Atom; @@ -120,24 +106,16 @@ namespace RTE { Clear(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int MOPixel::GetDrawPriority() const { return m_Atom->GetMaterial()->GetPriority(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - const Material* MOPixel::GetMaterial() const { return m_Atom->GetMaterial(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void MOPixel::SetAtom(Atom* newAtom) { delete m_Atom; m_Atom = newAtom; m_Atom->SetOwner(this); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void MOPixel::SetLethalRange(float range) { m_LethalRange = range; if (m_MinLethalRange < m_MaxLethalRange) { @@ -145,20 +123,14 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int MOPixel::GetTrailLength() const { return m_Atom->GetTrailLength(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void MOPixel::SetTrailLength(int trailLength) { m_Atom->SetTrailLength(trailLength); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool MOPixel::HitTestAtPixel(int pixelX, int pixelY) const { if (!GetsHitByMOs() || GetRootParent()->GetTraveling()) { return false; @@ -167,8 +139,6 @@ namespace RTE { return m_Pos.GetFloorIntX() == pixelX && m_Pos.GetFloorIntY() == pixelY; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void MOPixel::Travel() { MovableObject::Travel(); @@ -193,8 +163,6 @@ namespace RTE { m_Atom->ClearMOIDIgnoreList(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool MOPixel::CollideAtPoint(HitData& hd) { RTEAssert(hd.HitPoint.GetFloored() == m_Pos.GetFloored(), "Collision mismatch in MOPixel::CollideAtPoint!"); RTEAssert(hd.Body[HITOR], "Valid MO not passed into MOPixel::CollideAtPoint!"); @@ -211,8 +179,6 @@ namespace RTE { return true; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void MOPixel::RestDetection() { MovableObject::RestDetection(); @@ -224,8 +190,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void MOPixel::Update() { MovableObject::Update(); @@ -251,8 +215,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void MOPixel::Draw(BITMAP* targetBitmap, const Vector& targetPos, DrawMode mode, bool onlyPhysical) const { // Don't draw color if this isn't a drawing frame if (!g_TimerMan.DrawnSimUpdate() && mode == g_DrawColor) { @@ -291,8 +253,6 @@ namespace RTE { g_SceneMan.RegisterDrawing(targetBitmap, mode == g_DrawNoMOID ? g_NoMOID : m_MOID, pixelPos, 1.0F); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void MOPixel::SetPostScreenEffectToDraw() const { if (m_AgeTimer.GetElapsedSimTimeMS() >= m_EffectStartTime && (m_EffectStopTime == 0 || !m_AgeTimer.IsPastSimMS(m_EffectStopTime))) { if (m_EffectAlwaysShows || !g_SceneMan.ObscuredPoint(m_Pos.GetFloorIntX(), m_Pos.GetFloorIntY())) { diff --git a/Source/Entities/MOPixel.h b/Source/Entities/MOPixel.h index 2e8d7c6c6f..66a8659780 100644 --- a/Source/Entities/MOPixel.h +++ b/Source/Entities/MOPixel.h @@ -7,9 +7,7 @@ namespace RTE { class Atom; - /// /// A movable object with mass that is graphically represented by a single pixel. - /// class MOPixel : public MovableObject { public: @@ -18,66 +16,50 @@ namespace RTE { SerializableOverrideMethods; #pragma region Creation - /// /// Constructor method used to instantiate a MOPixel object in system memory. Create() should be called before using the object. - /// MOPixel() { Clear(); } - /// /// Convenience constructor to both instantiate a MOPixel in memory and Create it at the same time. - /// - /// A Color object specifying the color of this MOPixel. - /// A float specifying the object's mass in Kilograms (kg). - /// A Vector specifying the initial position. - /// A Vector specifying the initial velocity. - /// An Atom that will collide with the terrain. Ownership IS transferred! - /// The amount of time in ms this MOPixel will exist. 0 means unlimited. + /// @param color A Color object specifying the color of this MOPixel. + /// @param mass A float specifying the object's mass in Kilograms (kg). + /// @param position A Vector specifying the initial position. + /// @param velocity A Vector specifying the initial velocity. + /// @param atom An Atom that will collide with the terrain. Ownership IS transferred! + /// @param lifetime The amount of time in ms this MOPixel will exist. 0 means unlimited. MOPixel(Color color, const float mass, const Vector& position, const Vector& velocity, Atom* atom, const unsigned long lifetime = 0) { Clear(); Create(color, mass, position, velocity, atom, lifetime); } - /// /// Makes the MOPixel object ready for use. - /// - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create() override; - /// /// Makes the MOPixel object ready for use. - /// - /// A Color object specifying the color of this MOPixel. - /// A float specifying the object's mass in Kilograms (kg). - /// A Vector specifying the initial position. - /// A Vector specifying the initial velocity. - /// An Atom that will collide with the terrain. - /// The amount of time in ms this MOPixel will exist. 0 means unlimited. - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @param color A Color object specifying the color of this MOPixel. + /// @param mass A float specifying the object's mass in Kilograms (kg). + /// @param position A Vector specifying the initial position. + /// @param velocity A Vector specifying the initial velocity. + /// @param atom An Atom that will collide with the terrain. + /// @param lifetime The amount of time in ms this MOPixel will exist. 0 means unlimited. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create(Color color, const float mass, const Vector& position, const Vector& velocity, Atom* atom, const unsigned long lifetime = 0); - /// /// Creates a MOPixel to be identical to another, by deep copy. - /// - /// A reference to the MOPixel to deep copy. - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @param reference A reference to the MOPixel to deep copy. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create(const MOPixel& reference); #pragma endregion #pragma region Destruction - /// /// Destructor method used to clean up a MOPixel object before deletion from system memory. - /// ~MOPixel() override { Destroy(true); } - /// /// Destroys and resets (through Clear()) the MOPixel object. - /// - /// Whether to only destroy the members defined in this derived class, or to destroy all inherited members also. + /// @param notInherited Whether to only destroy the members defined in this derived class, or to destroy all inherited members also. void Destroy(bool notInherited = false) override; - /// /// Resets the entire MOPixel, including its inherited members, to their default settings or values. - /// void Reset() override { Clear(); MovableObject::Reset(); @@ -85,132 +67,92 @@ namespace RTE { #pragma endregion #pragma region Getters and Setters - /// /// Gets the drawing priority of this MOPixel, if two things were overlap when copying to the terrain, the higher priority MO would end up getting drawn. - /// - /// The drawing priority of this MOPixel. + /// @return The drawing priority of this MOPixel. int GetDrawPriority() const override; - /// /// Gets the main Material of this MOPixel. - /// - /// The Material of this MOPixel. + /// @return The Material of this MOPixel. const Material* GetMaterial() const override; - /// /// Gets the current Atom of this MOPixel. - /// - /// A const reference to the current Atom. + /// @return A const reference to the current Atom. const Atom* GetAtom() const { return m_Atom; } - /// /// Replaces the current Atom of this MOPixel with a new one. - /// - /// A reference to the new Atom. Ownership IS transferred! + /// @param newAtom A reference to the new Atom. Ownership IS transferred! void SetAtom(Atom* newAtom); - /// /// Gets the color of this MOPixel. - /// - /// A Color object describing the color. + /// @return A Color object describing the color. Color GetColor() const { return m_Color; } - /// /// Sets the color value of this MOPixel. - /// - /// A Color object specifying the new color index value. + /// @param newColor A Color object specifying the new color index value. void SetColor(Color newColor) { m_Color = newColor; } - /// /// Travel distance until the bullet start to lose lethality. - /// - /// The factor that modifies the base value. + /// @return The factor that modifies the base value. float GetMaxLethalRangeFactor() const { return m_MaxLethalRange; } - /// /// Travel distance until the bullet start to lose lethality. - /// - /// The distance in pixels. + /// @param range The distance in pixels. void SetLethalRange(float range); - /// /// Gets the longest a trail can be drawn, in pixels. - /// - /// The new max length, in pixels. If 0, no trail is drawn. + /// @return The new max length, in pixels. If 0, no trail is drawn. int GetTrailLength() const; - /// /// Sets the longest a trail can be drawn, in pixels. - /// - /// The new max length, in pixels. If 0, no trail is drawn. + /// @param trailLength The new max length, in pixels. If 0, no trail is drawn. void SetTrailLength(int trailLength); - /// /// Gets this MOPixel's staininess, which defines how likely a pixel is to stain a surface when it collides with it. - /// - /// This MOPixel's current staininess value. + /// @return This MOPixel's current staininess value. float GetStaininess() const { return m_Staininess; } - /// /// Sets this MOPixel's staininess, which defines how likely a pixel is to stain a surface when it collides with it. - /// - /// The new staininess value. + /// @param staininess The new staininess value. void SetStaininess(float staininess) { m_Staininess = staininess; } - /// /// Whether a set of X, Y coordinates overlap us (in world space). - /// - /// The given X coordinate, in world space. - /// The given Y coordinate, in world space. - /// Whether the given coordinate overlap us. + /// @param pixelX The given X coordinate, in world space. + /// @param pixelY The given Y coordinate, in world space. + /// @return Whether the given coordinate overlap us. bool HitTestAtPixel(int pixelX, int pixelY) const override; #pragma endregion #pragma region Virtual Override Methods - /// /// Travels this MOPixel, using its physical representation. - /// void Travel() override; - /// /// Calculates the collision response when another MO's Atom collides with this MO's physical representation. /// The effects will be applied directly to this MO, and also represented in the passed in HitData. - /// - /// Reference to the HitData struct which describes the collision. This will be modified to represent the results of the collision. - /// Whether the collision has been deemed valid. If false, then disregard any impulses in the HitData. + /// @param hitData Reference to the HitData struct which describes the collision. This will be modified to represent the results of the collision. + /// @return Whether the collision has been deemed valid. If false, then disregard any impulses in the HitData. bool CollideAtPoint(HitData& hitData) override; - /// /// Does the calculations necessary to detect whether this MOPixel is at rest or not. IsAtRest() retrieves the answer. - /// void RestDetection() override; - /// /// Defines what should happen when this MOPixel hits and then bounces off of something. This is called by the owned Atom/AtomGroup of this MOPixel during travel. - /// - /// The HitData describing the collision in detail. - /// Whether the MOPixel should immediately halt any travel going on after this bounce. + /// @param hd The HitData describing the collision in detail. + /// @return Whether the MOPixel should immediately halt any travel going on after this bounce. bool OnBounce(HitData& hd) override { return false; } - /// /// Defines what should happen when this MOPixel hits and then sink into something. This is called by the owned Atom/AtomGroup of this MOPixel during travel. - /// - /// The HitData describing the collision in detail. - /// Whether the MOPixel should immediately halt any travel going on after this sinkage. + /// @param hd The HitData describing the collision in detail. + /// @return Whether the MOPixel should immediately halt any travel going on after this sinkage. bool OnSink(HitData& hd) override { return false; } - /// /// Updates this MOPixel. Supposed to be done every frame. - /// void Update() override; - /// /// Draws this MOPixel's current graphical representation to a BITMAP of choice. - /// - /// A pointer to a BITMAP to draw on. - /// The absolute position of the target bitmap's upper left corner in the Scene. - /// In which mode to draw in. See the DrawMode enumeration for the modes. - /// Whether to not draw any extra 'ghost' items of this MOPixel, indicator arrows or hovering HUD text and so on. + /// @param targetBitmap A pointer to a BITMAP to draw on. + /// @param targetPos The absolute position of the target bitmap's upper left corner in the Scene. + /// @param mode In which mode to draw in. See the DrawMode enumeration for the modes. + /// @param onlyPhysical Whether to not draw any extra 'ghost' items of this MOPixel, indicator arrows or hovering HUD text and so on. void Draw(BITMAP* targetBitmap, const Vector& targetPos = Vector(), DrawMode mode = g_DrawColor, bool onlyPhysical = false) const override; #pragma endregion @@ -227,14 +169,10 @@ namespace RTE { float m_Staininess; //!< How likely a pixel is to stain a surface when it collides with it. Defaults to 0 (never stain). private: - /// /// Sets the screen effect to draw at the final post-processing stage. - /// void SetPostScreenEffectToDraw() const; - /// /// Clears all the member variables of this MOPixel, effectively resetting the members of this abstraction level only. - /// void Clear(); }; } // namespace RTE diff --git a/Source/Entities/MOSParticle.cpp b/Source/Entities/MOSParticle.cpp index 16bf673041..f9270d7a91 100644 --- a/Source/Entities/MOSParticle.cpp +++ b/Source/Entities/MOSParticle.cpp @@ -7,15 +7,11 @@ namespace RTE { ConcreteClassInfo(MOSParticle, MovableObject, 1000); - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void MOSParticle::Clear() { m_Atom = nullptr; m_SpriteAnimMode = OVERLIFETIME; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int MOSParticle::Create() { if (MOSprite::Create() < 0) { return -1; @@ -26,8 +22,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int MOSParticle::Create(const MOSParticle& reference) { MOSprite::Create(reference); @@ -37,8 +31,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int MOSParticle::ReadProperty(const std::string_view& propName, Reader& reader) { StartPropertyList(return MOSprite::ReadProperty(propName, reader)); @@ -53,8 +45,6 @@ namespace RTE { EndPropertyList; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int MOSParticle::Save(Writer& writer) const { MOSprite::Save(writer); @@ -67,8 +57,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void MOSParticle::Destroy(bool notInherited) { delete m_Atom; @@ -78,24 +66,16 @@ namespace RTE { Clear(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int MOSParticle::GetDrawPriority() const { return m_Atom->GetMaterial()->GetPriority(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - const Material* MOSParticle::GetMaterial() const { return m_Atom->GetMaterial(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void MOSParticle::SetAtom(Atom* newAtom) { delete m_Atom; m_Atom = newAtom; m_Atom->SetOwner(this); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void MOSParticle::RestDetection() { MOSprite::RestDetection(); @@ -107,8 +87,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void MOSParticle::Travel() { MOSprite::Travel(); @@ -157,8 +135,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void MOSParticle::Update() { MOSprite::Update(); @@ -167,8 +143,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void MOSParticle::Draw(BITMAP* targetBitmap, const Vector& targetPos, DrawMode mode, bool onlyPhysical) const { RTEAssert(!m_aSprite.empty(), "No sprite bitmaps loaded to draw " + GetPresetName()); RTEAssert(m_Frame >= 0 && m_Frame < m_FrameCount, "Frame is out of bounds for " + GetPresetName()); @@ -241,8 +215,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void MOSParticle::SetPostScreenEffectToDraw() const { if (m_AgeTimer.GetElapsedSimTimeMS() >= m_EffectStartTime && (m_EffectStopTime == 0 || !m_AgeTimer.IsPastSimMS(m_EffectStopTime))) { if (m_EffectAlwaysShows || !g_SceneMan.ObscuredPoint(m_Pos.GetFloorIntX(), m_Pos.GetFloorIntY())) { diff --git a/Source/Entities/MOSParticle.h b/Source/Entities/MOSParticle.h index 703feeb567..d2ed585fa9 100644 --- a/Source/Entities/MOSParticle.h +++ b/Source/Entities/MOSParticle.h @@ -7,9 +7,7 @@ namespace RTE { class Atom; - /// /// A small animated sprite that plays its animation and changes the animation and playback speed when it collides with other things. - /// class MOSParticle : public MOSprite { public: @@ -18,55 +16,41 @@ namespace RTE { SerializableOverrideMethods; #pragma region Creation - /// /// Constructor method used to instantiate a MOSParticle object in system memory. Create() should be called before using the object. - /// MOSParticle() { Clear(); } - /// /// Makes the MOSParticle object ready for use. - /// - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create() override; - /// /// Makes the MOSParticle object ready for use. - /// - /// A pointer to ContentFile that represents the bitmap file that will be used to create the Sprite. - /// The number of frames in the Sprite's animation. - /// A float specifying the object's mass in Kilograms (kg). - /// A Vector specifying the initial position. - /// A Vector specifying the initial velocity. - /// The amount of time in ms this MOSParticle will exist. 0 means unlimited. - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @param spriteFile A pointer to ContentFile that represents the bitmap file that will be used to create the Sprite. + /// @param frameCount The number of frames in the Sprite's animation. + /// @param mass A float specifying the object's mass in Kilograms (kg). + /// @param position A Vector specifying the initial position. + /// @param velocity A Vector specifying the initial velocity. + /// @param lifetime The amount of time in ms this MOSParticle will exist. 0 means unlimited. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create(ContentFile spriteFile, const int frameCount = 1, const float mass = 1, const Vector& position = Vector(0, 0), const Vector& velocity = Vector(0, 0), const unsigned long lifetime = 0) { MOSprite::Create(spriteFile, frameCount, mass, position, velocity, lifetime); return 0; } - /// /// Creates a MOSParticle to be identical to another, by deep copy. - /// - /// A reference to the MOSParticle to deep copy. - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @param reference A reference to the MOSParticle to deep copy. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create(const MOSParticle& reference); #pragma endregion #pragma region Destruction - /// /// Destructor method used to clean up a MOSParticle object before deletion from system memory. - /// ~MOSParticle() override { Destroy(true); } - /// /// Destroys and resets (through Clear()) the SceneLayer object. - /// - /// Whether to only destroy the members defined in this derived class, or to destroy all inherited members also. + /// @param notInherited Whether to only destroy the members defined in this derived class, or to destroy all inherited members also. void Destroy(bool notInherited = false) override; - /// /// Resets the entire MOSParticle, including its inherited members, to their default settings or values. - /// void Reset() override { Clear(); MOSprite::Reset(); @@ -74,76 +58,54 @@ namespace RTE { #pragma endregion #pragma region Getters and Setters - /// /// Gets the drawing priority of this MOSParticle. If two things are overlapping when copying to the terrain, the higher priority MO would end up getting drawn. - /// - /// The drawing priority of this MOSParticle. + /// @return The drawing priority of this MOSParticle. int GetDrawPriority() const override; - /// /// Gets the main material of this MOSParticle. - /// - /// The material of this MOSParticle. + /// @return The material of this MOSParticle. const Material* GetMaterial() const override; - /// /// Gets the current Atom of this MOSParticle. - /// - /// A const reference to the current Atom. + /// @return A const reference to the current Atom. const Atom* GetAtom() const { return m_Atom; } - /// /// Replaces the current Atom of this MOSParticle with a new one. - /// - /// A reference to the new Atom. + /// @param newAtom A reference to the new Atom. void SetAtom(Atom* newAtom); #pragma endregion #pragma region Virtual Override Methods - /// /// Travels this MOSParticle, using its physical representation. - /// void Travel() override; - /// /// Calculates the collision response when another MO's Atom collides with this MO's physical representation. /// The effects will be applied directly to this MO, and also represented in the passed in HitData. - /// - /// Reference to the HitData struct which describes the collision. This will be modified to represent the results of the collision. - /// Whether the collision has been deemed valid. If false, then disregard any impulses in the HitData. + /// @param hitData Reference to the HitData struct which describes the collision. This will be modified to represent the results of the collision. + /// @return Whether the collision has been deemed valid. If false, then disregard any impulses in the HitData. bool CollideAtPoint(HitData& hitData) override { return true; } - /// /// Does the calculations necessary to detect whether this MOSParticle is at rest or not. IsAtRest() retrieves the answer. - /// void RestDetection() override; - /// /// Defines what should happen when this MOSParticle hits and then bounces off of something. This is called by the owned Atom/AtomGroup of this MOSParticle during travel. - /// - /// The HitData describing the collision in detail. - /// Whether the MOSParticle should immediately halt any travel going on after this bounce. + /// @param hd The HitData describing the collision in detail. + /// @return Whether the MOSParticle should immediately halt any travel going on after this bounce. bool OnBounce(HitData& hd) override { return false; } - /// /// Defines what should happen when this MOSParticle hits and then sink into something. This is called by the owned Atom/AtomGroup of this MOSParticle during travel. - /// - /// The HitData describing the collision in detail. - /// Whether the MOSParticle should immediately halt any travel going on after this sinkage. + /// @param hd The HitData describing the collision in detail. + /// @return Whether the MOSParticle should immediately halt any travel going on after this sinkage. bool OnSink(HitData& hd) override { return false; } - /// /// Updates this MOParticle. Supposed to be done every frame. - /// void Update() override; - /// /// Draws this MOSParticle's current graphical representation to a BITMAP of choice. - /// - /// A pointer to a BITMAP to draw on. - /// The absolute position of the target bitmap's upper left corner in the Scene. - /// In which mode to draw in. See the DrawMode enumeration for the modes. - /// Whether to not draw any extra 'ghost' items of this MOSParticle, indicator arrows or hovering HUD text and so on. + /// @param targetBitmap A pointer to a BITMAP to draw on. + /// @param targetPos The absolute position of the target bitmap's upper left corner in the Scene. + /// @param mode In which mode to draw in. See the DrawMode enumeration for the modes. + /// @param onlyPhysical Whether to not draw any extra 'ghost' items of this MOSParticle, indicator arrows or hovering HUD text and so on. void Draw(BITMAP* targetBitmap, const Vector& targetPos = Vector(), DrawMode mode = g_DrawColor, bool onlyPhysical = false) const override; #pragma endregion @@ -154,14 +116,10 @@ namespace RTE { float m_TimeRest; //!< Accumulated time in seconds that did not cause a frame change. private: - /// /// Sets the screen effect to draw at the final post-processing stage. - /// void SetPostScreenEffectToDraw() const; - /// /// Clears all the member variables of this MOSParticle, effectively resetting the members of this abstraction level only. - /// void Clear(); // Disallow the use of some implicit methods. diff --git a/Source/Entities/MOSRotating.cpp b/Source/Entities/MOSRotating.cpp index 5c6e28996d..a3de86005c 100644 --- a/Source/Entities/MOSRotating.cpp +++ b/Source/Entities/MOSRotating.cpp @@ -1,15 +1,3 @@ -////////////////////////////////////////////////////////////////////////////////////////// -// File: MOSRotating.cpp -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Source file for the MOSRotating class. -// Project: Retro Terrain Engine -// Author(s): Daniel Tabar -// data@datarealms.com -// http://www.datarealms.com - -////////////////////////////////////////////////////////////////////////////////////////// -// Inclusions of header files - #include "MOSRotating.h" #include "CameraMan.h" @@ -43,12 +31,6 @@ namespace RTE { BITMAP* MOSRotating::m_spTempBitmapS256 = 0; BITMAP* MOSRotating::m_spTempBitmapS512 = 0; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Clear - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears all the member variables of this MOSRotating, effectively - // resetting the members of this abstraction level only. - void MOSRotating::Clear() { m_pAtomGroup = 0; m_pDeepGroup = 0; @@ -90,11 +72,6 @@ namespace RTE { m_FlashWhiteTimer.SetRealTimeLimitMS(0); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes the MOSParticle object ready for use. - int MOSRotating::Create() { if (MOSprite::Create() < 0) return -1; @@ -181,11 +158,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes the MOSParticle object ready for use. - int MOSRotating::Create(ContentFile spriteFile, const int frameCount, const float mass, @@ -204,11 +176,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Creates a MOSRotating to be identical to another, by deep copy. - int MOSRotating::Create(const MOSRotating& reference) { MOSprite::Create(reference); @@ -283,14 +250,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: ReadProperty - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Reads a property value from a reader stream. If the name isn't - // recognized by this class, then ReadProperty of the parent class - // is called. If the property isn't recognized by any of the base classes, - // false is returned, and the reader's position is untouched. - int MOSRotating::ReadProperty(const std::string_view& propName, Reader& reader) { StartPropertyList(return MOSprite::ReadProperty(propName, reader)); @@ -359,12 +318,6 @@ namespace RTE { EndPropertyList; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Save - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Saves the complete state of this MOSRotating with a Writer for - // later recreation with Create(Reader &reader); - int MOSRotating::Save(Writer& writer) const { MOSprite::Save(writer); @@ -408,8 +361,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int MOSRotating::GetGibWoundLimit(bool includePositiveDamageAttachables, bool includeNegativeDamageAttachables, bool includeNoDamageAttachables) const { int gibWoundLimit = m_GibWoundLimit; if (includePositiveDamageAttachables || includeNegativeDamageAttachables || includeNoDamageAttachables) { @@ -426,8 +377,6 @@ namespace RTE { return gibWoundLimit; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int MOSRotating::GetWoundCount(bool includePositiveDamageAttachables, bool includeNegativeDamageAttachables, bool includeNoDamageAttachables) const { int woundCount = m_Wounds.size(); if (includePositiveDamageAttachables || includeNegativeDamageAttachables || includeNoDamageAttachables) { @@ -444,8 +393,6 @@ namespace RTE { return woundCount; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - Attachable* MOSRotating::GetNearestDetachableAttachableToOffset(const Vector& offset) const { Attachable* nearestAttachable = nullptr; float closestRadius = m_SpriteRadius; @@ -461,8 +408,6 @@ namespace RTE { return nearestAttachable; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void MOSRotating::DetachAttachablesFromImpulse(Vector& impulseVector) { float impulseRemainder = impulseVector.GetMagnitude(); // Find the attachable closest to the impact point by using an inverted impulse vector. @@ -485,8 +430,6 @@ namespace RTE { impulseVector.SetMagnitude(impulseRemainder); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void MOSRotating::AddWound(AEmitter* woundToAdd, const Vector& parentOffsetToSet, bool checkGibWoundLimit) { if (woundToAdd && !m_ToDelete) { if (checkGibWoundLimit && m_GibWoundLimit > 0 && m_Wounds.size() + 1 >= m_GibWoundLimit) { @@ -513,8 +456,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - float MOSRotating::RemoveWounds(int numberOfWoundsToRemove, bool includePositiveDamageAttachables, bool includeNegativeDamageAttachables, bool includeNoDamageAttachables) { float damage = 0; int woundCount = GetWoundCount(includePositiveDamageAttachables, includeNegativeDamageAttachables, includeNoDamageAttachables); @@ -589,13 +530,6 @@ namespace RTE { MovableObject::DestroyScriptState(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destroys and resets (through Clear()) the MOSRotating object. - void MOSRotating::Destroy(bool notInherited) { delete m_pAtomGroup; delete m_pDeepGroup; @@ -623,8 +557,6 @@ namespace RTE { Clear(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void MOSRotating::SetAsNoID() { MovableObject::SetAsNoID(); for (Attachable* attachable: m_Attachables) { @@ -632,13 +564,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: GetMaterial - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the main Material of this MOSRotating. - Material const* MOSRotating::GetMaterial() const { // if (m_pAtomGroup) return m_pAtomGroup->GetMaterial(); @@ -660,13 +585,6 @@ namespace RTE { } */ - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: GetDrawPriority - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the drawing priority of this MovableObject, if two things were - // overlap when copying to the terrain, the higher priority MO would - // end up getting drawn. - int MOSRotating::GetDrawPriority() const { return INT_MAX; } @@ -699,24 +617,12 @@ namespace RTE { } */ - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: AddRecoil - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Adds recoil effects to this MOSprite. - void MOSRotating::AddRecoil() { m_RecoilOffset.SetXY(1, 0); m_RecoilOffset.RadRotate(m_Rotation.GetRadAngle() + c_PI); m_Recoiled = true; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: CollideAtPoint - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Calculates the collision response when another MO's Atom collides with - // this MO's physical representation. The effects will be applied - // directly to this MO, and also represented in the passed in HitData. - bool MOSRotating::CollideAtPoint(HitData& hd) { if (m_ToDelete) { return false; // TODO: Add a settings flag to enable old school particle sponges! @@ -785,37 +691,15 @@ namespace RTE { return true; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: OnBounce - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Defines what should happen when this MovableObject hits and then - // bounces off of something. This is called by the owned Atom/AtomGroup - // of this MovableObject during travel. - bool MOSRotating::OnBounce(HitData& hd) { return false; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: OnSink - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Defines what should happen when this MovableObject hits and then - // sink into something. This is called by the owned Atom/AtomGroup - // of this MovableObject during travel. - bool MOSRotating::OnSink(HitData& hd) { return false; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: ParticlePenetration - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Determines whether a particle which has hit this MO will penetrate, - // and if so, whether it gets lodged or exits on the other side of this - // MO. Appropriate effects will be determined and applied ONLY IF there - // was penetration! If not, nothing will be affected. - bool MOSRotating::ParticlePenetration(HitData& hd) { // Only particles can penetrate. if (!(dynamic_cast(hd.Body[HITOR]) || dynamic_cast(hd.Body[HITOR]))) @@ -982,8 +866,6 @@ namespace RTE { return false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void MOSRotating::GibThis(const Vector& impactImpulse, MovableObject* movableObjectToIgnore) { if (m_MissionCritical || m_ToDelete) { return; @@ -1016,8 +898,6 @@ namespace RTE { m_ToDelete = true; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void MOSRotating::CreateGibsWhenGibbing(const Vector& impactImpulse, MovableObject* movableObjectToIgnore) { if (m_GibScreenShakeAmount != -1.0F) { g_CameraMan.AddScreenShake(m_GibScreenShakeAmount, m_Pos); @@ -1141,8 +1021,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void MOSRotating::RemoveAttachablesWhenGibbing(const Vector& impactImpulse, MovableObject* movableObjectToIgnore) { const std::vector nonVolatileAttachablesVectorForLuaSafety{m_Attachables.begin(), m_Attachables.end()}; for (Attachable* attachable: nonVolatileAttachablesVectorForLuaSafety) { @@ -1169,21 +1047,10 @@ namespace RTE { m_Attachables.clear(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: MoveOutOfTerrain - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Checks whether any of the Atom:s in this MovableObject are on top of - // terrain pixels, and if so, attempt to move this out so none of this' - // Atoms are on top of the terrain any more. - bool MOSRotating::MoveOutOfTerrain(unsigned char strongerThan) { return m_pAtomGroup->ResolveTerrainIntersection(m_Pos, strongerThan); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void MOSRotating::ApplyForces() { float deltaTime = g_TimerMan.GetDeltaTimeSecs(); @@ -1196,8 +1063,6 @@ namespace RTE { MOSprite::ApplyForces(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void MOSRotating::ApplyImpulses() { for (const auto& [impulseForceVector, impulseForceOffset]: m_ImpulseForces) { if (!impulseForceOffset.IsZero()) { @@ -1230,15 +1095,6 @@ namespace RTE { MOSprite::ApplyImpulses(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: ResetAllTimers - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Resest all the timers used by this. Can be emitters, etc. This is to - // prevent backed up emissions to come out all at once while this has been - // held dormant in an inventory. - void MOSRotating::ResetAllTimers() { MovableObject::ResetAllTimers(); @@ -1249,8 +1105,6 @@ namespace RTE { (*attachable)->ResetAllTimers(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void MOSRotating::RestDetection() { MOSprite::RestDetection(); @@ -1289,8 +1143,6 @@ namespace RTE { m_PrevAngVel = m_AngularVel; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool MOSRotating::IsAtRest() { if (m_RestThreshold < 0 || m_PinStrength != 0) { return false; @@ -1300,8 +1152,6 @@ namespace RTE { return m_RestTimer.IsPastSimMS(m_RestThreshold); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool MOSRotating::IsOnScenePoint(Vector& scenePoint) const { if (!m_aSprite[m_Frame]) { return false; @@ -1326,13 +1176,6 @@ namespace RTE { return false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: EraseFromTerrain - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Cuts this' silhouette out from the terrain's material and color layers. - void MOSRotating::EraseFromTerrain() { Vector pivot = -m_SpriteOffset; @@ -1352,12 +1195,6 @@ namespace RTE { std::deque pixels = g_SceneMan.GetTerrain()->EraseSilhouette(m_HFlipped ? m_pFlipBitmap : m_aSprite[m_Frame], m_Pos, pivot, m_Rotation, m_Scale, false); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: DeepCheck - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Checks if any of this' deep group atmos are on top of the terrain, and - // if so, erases this' silhouette from the terrain. - bool MOSRotating::DeepCheck(bool makeMOPs, int skipMOP, int maxMOPs) { // Check for deep penetration of the terrain and // generate splash of MOPixels accordingly. @@ -1417,14 +1254,6 @@ namespace RTE { return false; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: PreTravel - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Does stuff that needs to be done before Travel(). Always call before - // calling Travel. - // Arguments: None. - // Return value: None. - void MOSRotating::PreTravel() { MOSprite::PreTravel(); @@ -1436,11 +1265,6 @@ namespace RTE { #endif } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Travel - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Travels this MovableObject, using its physical representation. - void MOSRotating::Travel() { MOSprite::Travel(); @@ -1474,12 +1298,6 @@ namespace RTE { m_pAtomGroup->ClearMOIDIgnoreList(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: PostTravel - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Does stuff that needs to be done after Update(). Always call after - // calling Update. - void MOSRotating::PostTravel() { // Check for stupid velocities to gib instead of outright deletion that MOSprite::PostTravel() will do if (IsTooFast()) { @@ -1526,11 +1344,6 @@ namespace RTE { } } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Update - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates this MOSRotating. Supposed to be done every frame. - void MOSRotating::Update() { MOSprite::Update(); @@ -1588,8 +1401,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void MOSRotating::PostUpdate() { for (auto itr = m_Wounds.begin(); itr != m_Wounds.end(); ++itr) { (*itr)->PostUpdate(); @@ -1602,8 +1413,6 @@ namespace RTE { MovableObject::PostUpdate(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool MOSRotating::DrawMOIDIfOverlapping(MovableObject* pOverlapMO) { if (pOverlapMO == this || !m_GetsHitByMOs || !pOverlapMO->GetsHitByMOs()) { return false; @@ -1621,8 +1430,6 @@ namespace RTE { return false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // TODO This should just be defined in MOSR instead of having an empty definition in MO. MOSR would need to override UpdateMOID accordingly, but this would clean things up a little. void MOSRotating::UpdateChildMOIDs(std::vector& MOIDIndex, MOID rootMOID, bool makeNewMOID) { MOSprite::UpdateChildMOIDs(MOIDIndex, m_RootMOID, makeNewMOID); @@ -1635,8 +1442,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool MOSRotating::AttachableIsHardcoded(const Attachable* attachableToCheck) const { if (attachableToCheck->GetParent() != this) { return false; @@ -1646,16 +1451,12 @@ namespace RTE { return m_HardcodedAttachableUniqueIDsAndRemovers.find(attachableUniqueID) != m_HardcodedAttachableUniqueIDsAndRemovers.end() || m_HardcodedAttachableUniqueIDsAndSetters.find(attachableUniqueID) != m_HardcodedAttachableUniqueIDsAndSetters.end(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void MOSRotating::AddAttachable(Attachable* attachable) { if (attachable) { AddAttachable(attachable, attachable->GetParentOffset()); } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void MOSRotating::AddAttachable(Attachable* attachable, const Vector& parentOffsetToSet) { if (attachable) { RTEAssert(!attachable->IsAttached(), "Tried to add Attachable " + attachable->GetModuleAndPresetName() + " but it already has a parent, " + (attachable->IsAttached() ? attachable->GetParent()->GetModuleAndPresetName() : "ERROR") + "."); @@ -1670,8 +1471,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - Attachable* MOSRotating::RemoveAttachable(long attachableUniqueID, bool addToMovableMan, bool addBreakWounds) { if (MovableObject* attachableAsMovableObject = g_MovableMan.FindObjectByUniqueID(attachableUniqueID)) { return RemoveAttachable(dynamic_cast(attachableAsMovableObject), addToMovableMan, addBreakWounds); @@ -1679,8 +1478,6 @@ namespace RTE { return nullptr; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - Attachable* MOSRotating::RemoveAttachable(Attachable* attachable, bool addToMovableMan, bool addBreakWounds) { if (!attachable || !attachable->IsAttached()) { return attachable; @@ -1751,15 +1548,11 @@ namespace RTE { return attachable; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void MOSRotating::RemoveAndDeleteAttachable(Attachable* attachable) { attachable->SetToDelete(); RemoveAttachable(attachable); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void MOSRotating::RemoveOrDestroyAllAttachables(bool destroy) { Attachable* attachable; for (auto attachableIterator = m_Attachables.begin(); attachableIterator != m_Attachables.end();) { @@ -1776,8 +1569,6 @@ namespace RTE { m_Attachables.clear(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void MOSRotating::GetMOIDs(std::vector& MOIDs) const { MOIDs.reserve(GetMOIDFootprint()); MOSprite::GetMOIDs(MOIDs); @@ -1788,8 +1579,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void MOSRotating::SetWhichMOToNotHit(MovableObject* moToNotHit, float forHowLong) { MOSprite::SetWhichMOToNotHit(moToNotHit, forHowLong); for (Attachable* attachable: m_Attachables) { @@ -1797,14 +1586,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Draw - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws this MOSRotating's current graphical representation to a - // BITMAP of choice. - void MOSRotating::Draw(BITMAP* pTargetBitmap, const Vector& targetPos, DrawMode mode, bool onlyPhysical) const { RTEAssert(!m_aSprite.empty(), "No sprite bitmaps loaded to draw!"); RTEAssert(m_Frame >= 0 && m_Frame < m_FrameCount, "Frame is out of bounds!"); @@ -2048,8 +1829,6 @@ namespace RTE { return false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void MOSRotating::CorrectAttachableAndWoundPositionsAndRotations() const { for (Attachable* attachable: m_Attachables) { attachable->PreUpdate(); @@ -2065,8 +1844,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void MOSRotating::OnSave() { for (AEmitter* wound: m_Wounds) { wound->OnSave(); @@ -2077,8 +1854,6 @@ namespace RTE { MovableObject::OnSave(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool MOSRotating::TransferForcesFromAttachable(Attachable* attachable) { bool intact = false; Vector forces; diff --git a/Source/Entities/MOSRotating.h b/Source/Entities/MOSRotating.h index eb900ae0e6..3d4a80c446 100644 --- a/Source/Entities/MOSRotating.h +++ b/Source/Entities/MOSRotating.h @@ -1,18 +1,11 @@ #ifndef _RTEMOSROTATING_ #define _RTEMOSROTATING_ -////////////////////////////////////////////////////////////////////////////////////////// -// File: MOSRotating.h -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Header file for the MOSRotating class. -// Project: Retro Terrain Engine -// Author(s): Daniel Tabar -// data@datarealms.com -// http://www.datarealms.com - -////////////////////////////////////////////////////////////////////////////////////////// -// Inclusions of header files - +/// Header file for the MOSRotating class. +/// @author Daniel Tabar +/// data@datarealms.com +/// http://www.datarealms.com +/// Inclusions of header files #include "MOSprite.h" #include "Gib.h" #include "PostProcessMan.h" @@ -25,18 +18,10 @@ namespace RTE { class AEmitter; class Attachable; - ////////////////////////////////////////////////////////////////////////////////////////// - // Class: MOSRotating - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: A sprite movable object that can rotate. - // Parent(s): MOSprite. - // Class history: 05/30/2002 MOSRotating created. - + /// A sprite movable object that can rotate. class MOSRotating : public MOSprite { - ////////////////////////////////////////////////////////////////////////////////////////// - // Public member variable, method and friend function declarations - + /// Public member variable, method and friend function declarations public: friend class AtomGroup; friend class SLTerrain; @@ -47,796 +32,493 @@ namespace RTE { SerializableOverrideMethods; ClassInfoGetters; - ////////////////////////////////////////////////////////////////////////////////////////// - // Constructor: MOSRotating - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Constructor method used to instantiate a MOSRotating object in system - // memory. Create() should be called before using the object. - // Arguments: None. - + /// Constructor method used to instantiate a MOSRotating object in system + /// memory. Create() should be called before using the object. MOSRotating() { Clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Destructor: ~MOSRotating - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destructor method used to clean up a MOSRotating object before deletion - // from system memory. - // Arguments: None. - + /// Destructor method used to clean up a MOSRotating object before deletion + /// from system memory. ~MOSRotating() override { Destroy(true); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes the MOSRotating object ready for use. - // Arguments: None. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Makes the MOSRotating object ready for use. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Create() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes the MOSRotating object ready for use. - // Arguments: A pointer to ContentFile that represents the bitmap file that will be - // used to create the Sprite. - // The number of frames in the Sprite's animation. - // A float specifying the object's mass in Kilograms (kg). - // A Vector specifying the initial position. - // A Vector specifying the initial velocity. - // The amount of time in ms this MovableObject will exist. 0 means unlim. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Makes the MOSRotating object ready for use. + /// @param spriteFile A pointer to ContentFile that represents the bitmap file that will be + /// used to create the Sprite. + /// @param frameCount The number of frames in the Sprite's animation. (default: 1) + /// @param mass A float specifying the object's mass in Kilograms (kg). (default: 1) + /// @param position A Vector specifying the initial position. (default: Vector(0) + /// @param 0) A Vector specifying the initial velocity. + /// @param velocity The amount of time in ms this MovableObject will exist. 0 means unlim. (default: Vector(0) + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Create(ContentFile spriteFile, const int frameCount = 1, const float mass = 1, const Vector& position = Vector(0, 0), const Vector& velocity = Vector(0, 0), const unsigned long lifetime = 0); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Creates a MOSRotating to be identical to another, by deep copy. - // Arguments: A reference to the MOSRotating to deep copy. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Creates a MOSRotating to be identical to another, by deep copy. + /// @param reference A reference to the MOSRotating to deep copy. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Create(const MOSRotating& reference); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Reset - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Resets the entire MOSRotating, including its inherited members, to their - // default settings or values. - // Arguments: None. - // Return value: None. - + /// Resets the entire MOSRotating, including its inherited members, to their + /// default settings or values. void Reset() override { Clear(); MOSprite::Reset(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destroys and resets (through Clear()) the SceneLayer object. - // Arguments: Whether to only destroy the members defined in this derived class, or - // to destroy all inherited members also. - // Return value: None. - + /// Destroys and resets (through Clear()) the SceneLayer object. + /// @param notInherited Whether to only destroy the members defined in this derived class, or (default: false) + /// to destroy all inherited members also. void Destroy(bool notInherited = false) override; - /// /// Gets the radius of this MOSRotating, not including any Attachables. - /// - /// + /// @return float GetIndividualRadius() const { return m_SpriteRadius; } - /// /// Gets the radius of this MOSRotating, including any Attachables. - /// - /// The radius of this MOSRotating, including any Attachables. + /// @return The radius of this MOSRotating, including any Attachables. float GetRadius() const override { return std::max(m_SpriteRadius, m_FarthestAttachableDistanceAndRadius); } - /// /// Gets the diameter of this MOSRotating, not including any Attachables. - /// - /// + /// @return float GetIndividualDiameter() const { return m_SpriteDiameter; } - /// /// Gets the diameter of this MOSRotating, including any Attachables. - /// - /// The diameter of this MOSRotating, including any Attachables. + /// @return The diameter of this MOSRotating, including any Attachables. float GetDiameter() const override { return GetRadius() * 2.0F; } - /// /// Checks if the given Attachable should affect radius, and handles it if it should. - /// - /// The Attachable to check. - /// Whether the radius affecting Attachable changed as a result of this call. + /// @param attachable The Attachable to check. + /// @return Whether the radius affecting Attachable changed as a result of this call. virtual bool HandlePotentialRadiusAffectingAttachable(const Attachable* attachable); - /// /// Gets the mass value of this MOSRotating, not including any Attachables or wounds. - /// - /// The mass of this MOSRotating. + /// @return The mass of this MOSRotating. float GetIndividualMass() const { return MovableObject::GetMass(); } - /// /// Gets the mass value of this MOSRotating, including the mass of all its Attachables and wounds, and their Attachables and so on. - /// - /// The mass of this MOSRotating and all of its Attachables and wounds in Kilograms (kg). + /// @return The mass of this MOSRotating and all of its Attachables and wounds in Kilograms (kg). float GetMass() const override { return MovableObject::GetMass() + m_AttachableAndWoundMass; } - /// /// Updates the total mass of Attachables and wounds for this MOSRotating, intended to be used when Attachables' masses get modified. Simply subtracts the old mass and adds the new one. - /// - /// The mass the Attachable or wound had before its mass was modified. - /// The up-to-date mass of the Attachable or wound after its mass was modified. + /// @param oldAttachableOrWoundMass The mass the Attachable or wound had before its mass was modified. + /// @param newAttachableOrWoundMass The up-to-date mass of the Attachable or wound after its mass was modified. virtual void UpdateAttachableAndWoundMass(float oldAttachableOrWoundMass, float newAttachableOrWoundMass) { m_AttachableAndWoundMass += newAttachableOrWoundMass - oldAttachableOrWoundMass; } - /// /// Gets the MOIDs of this MOSRotating and all its Attachables and Wounds, putting them into the MOIDs vector. - /// - /// The vector that will store all the MOIDs of this MOSRotating. + /// @param MOIDs The vector that will store all the MOIDs of this MOSRotating. void GetMOIDs(std::vector& MOIDs) const override; - /// /// Sets the MOID of this MOSRotating and any Attachables on it to be g_NoMOID (255) for this frame. - /// void SetAsNoID() override; - /// /// Sets this MOSRotating to not hit a specific other MO and all its children even though MO hitting is enabled on this MOSRotating. - /// - /// A pointer to the MO to not be hitting. Null pointer means don't ignore anything. Ownership is NOT transferred! - /// How long, in seconds, to ignore the specified MO. A negative number means forever. + /// @param moToNotHit A pointer to the MO to not be hitting. Null pointer means don't ignore anything. Ownership is NOT transferred! + /// @param forHowLong How long, in seconds, to ignore the specified MO. A negative number means forever. void SetWhichMOToNotHit(MovableObject* moToNotHit = nullptr, float forHowLong = -1) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetAtomGroup - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the current AtomGroup of this MOSRotating. - // Arguments: None. - // Return value: A const reference to the current AtomGroup. - + /// Gets the current AtomGroup of this MOSRotating. + /// @return A const reference to the current AtomGroup. AtomGroup* GetAtomGroup() { return m_pAtomGroup; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: GetMaterial - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the main Material of this MOSRotating. - // Arguments: None. - // Return value: The the Material of this MOSRotating. - + /// Gets the main Material of this MOSRotating. + /// @return The the Material of this MOSRotating. Material const* GetMaterial() const override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: GetDrawPriority - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the drawing priority of this MovableObject, if two things were - // overlap when copying to the terrain, the higher priority MO would - // end up getting drawn. - // Arguments: None. - // Return value: The the priority of this MovableObject. Higher number, the higher - // priority. - + /// Gets the drawing priority of this MovableObject, if two things were + /// overlap when copying to the terrain, the higher priority MO would + /// end up getting drawn. + /// @return The the priority of this MovableObject. Higher number, the higher + /// priority. int GetDrawPriority() const override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetRecoilForce - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the current recoil impulse force Vector of this MOSprite. - // Arguments: None. - // Return value: A const reference to the current recoil impulse force in kg * m/s. - + /// Gets the current recoil impulse force Vector of this MOSprite. + /// @return A const reference to the current recoil impulse force in kg * m/s. const Vector& GetRecoilForce() const { return m_RecoilForce; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetRecoilOffset - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the current recoil offset Vector of this MOSprite. - // Arguments: None. - // Return value: A const reference to the current recoil offset. - + /// Gets the current recoil offset Vector of this MOSprite. + /// @return A const reference to the current recoil offset. const Vector& GetRecoilOffset() const { return m_RecoilOffset; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetGibList - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets direct access to the list of object this is to generate upon gibbing. - // Arguments: None. - // Return value: A pointer to the list of gibs. Ownership is NOT transferred! - + /// Gets direct access to the list of object this is to generate upon gibbing. + /// @return A pointer to the list of gibs. Ownership is NOT transferred! std::list* GetGibList() { return &m_Gibs; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: AddRecoil - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Adds graphical recoil offset to this MOSprite according to its angle. - // Arguments: None. - // Return value: None. - + /// Adds graphical recoil offset to this MOSprite according to its angle. void AddRecoil(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetRecoil - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Adds recoil offset to this MOSprite. - // Arguments: A vector with the recoil impulse force in kg * m/s. - // A vector with the recoil offset in pixels. - // Whether recoil should be activated or not for the next Draw(). - // Return value: None. - + /// Adds recoil offset to this MOSprite. + /// @param force A vector with the recoil impulse force in kg * m/s. + /// @param offset A vector with the recoil offset in pixels. + /// @param recoil Whether recoil should be activated or not for the next Draw(). (default: true) void SetRecoil(const Vector& force, const Vector& offset, bool recoil = true) { m_RecoilForce = force; m_RecoilOffset = offset; m_Recoiled = recoil; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: IsRecoiled - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns whether this MOSprite is currently under the effects of - // recoil. - // Arguments: None. - // Return value: None. - + /// Returns whether this MOSprite is currently under the effects of + /// recoil. bool IsRecoiled() { return m_Recoiled; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: EnableDeepCheck - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets whether or not this MOSRotating should check for deep penetrations - // the terrain or not. - // Arguments: Whether to enable deep penetration checking or not. - // Return value: None. - + /// Sets whether or not this MOSRotating should check for deep penetrations + /// the terrain or not. + /// @param enable Whether to enable deep penetration checking or not. (default: true) void EnableDeepCheck(const bool enable = true) { m_DeepCheck = enable; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ForceDeepCheck - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets to force a deep checking of this' silhouette against the terrain - // and create an outline hole in the terrain, generating particles of the - // intersecting pixels in the terrain. - // Arguments: Whether to force a deep penetration check for this sim frame or not.. - // Return value: None. - + /// Sets to force a deep checking of this' silhouette against the terrain + /// and create an outline hole in the terrain, generating particles of the + /// intersecting pixels in the terrain. + /// @param enable Whether to force a deep penetration check for this sim frame or not.. (default: true) void ForceDeepCheck(const bool enable = true) { m_ForceDeepCheck = enable; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: CollideAtPoint - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Calculates the collision response when another MO's Atom collides with - // this MO's physical representation. The effects will be applied - // directly to this MO, and also represented in the passed in HitData. - // Arguments: Reference to the HitData struct which describes the collision. This - // will be modified to represent the results of the collision. - // Return value: Whether the collision has been deemed valid. If false, then disregard - // any impulses in the Hitdata. - + /// Calculates the collision response when another MO's Atom collides with + /// this MO's physical representation. The effects will be applied + /// directly to this MO, and also represented in the passed in HitData. + /// @param hitData Reference to the HitData struct which describes the collision. This + /// will be modified to represent the results of the collision. + /// @return Whether the collision has been deemed valid. If false, then disregard + /// any impulses in the Hitdata. bool CollideAtPoint(HitData& hitData) override; - /// /// Defines what should happen when this MovableObject hits and then bounces off of something. /// This is called by the owned Atom/AtomGroup of this MovableObject during travel. - /// - /// The HitData describing the collision in detail. - /// Whether the MovableObject should immediately halt any travel going on after this bounce. + /// @param hd The HitData describing the collision in detail. + /// @return Whether the MovableObject should immediately halt any travel going on after this bounce. bool OnBounce(HitData& hd) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: OnSink - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Defines what should happen when this MovableObject hits and then - // sink into something. This is called by the owned Atom/AtomGroup - // of this MovableObject during travel. - // Arguments: The HitData describing the collision in detail. - // Return value: Wheter the MovableObject should immediately halt any travel going on - // after this sinkage. - + /// Defines what should happen when this MovableObject hits and then + /// sink into something. This is called by the owned Atom/AtomGroup + /// of this MovableObject during travel. + /// @param hd The HitData describing the collision in detail. + /// @return Wheter the MovableObject should immediately halt any travel going on + /// after this sinkage. bool OnSink(HitData& hd) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: ParticlePenetration - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Determines whether a particle which has hit this MO will penetrate, - // and if so, whether it gets lodged or exits on the other side of this - // MO. Appropriate effects will be determined and applied ONLY IF there - // was penetration! If not, nothing will be affected. - // Arguments: The HitData describing the collision in detail, the impulses have to - // have been filled out! - // Return value: Whether the particle managed to penetrate into this MO or not. If - // somehting but a MOPixel or MOSParticle is being passed in as hitor, - // false will trivially be returned here. - + /// Determines whether a particle which has hit this MO will penetrate, + /// and if so, whether it gets lodged or exits on the other side of this + /// MO. Appropriate effects will be determined and applied ONLY IF there + /// was penetration! If not, nothing will be affected. + /// @param hd The HitData describing the collision in detail, the impulses have to + /// have been filled out! + /// @return Whether the particle managed to penetrate into this MO or not. If + /// somehting but a MOPixel or MOSParticle is being passed in as hitor, + /// false will trivially be returned here. virtual bool ParticlePenetration(HitData& hd); - /// /// Destroys this MOSRotating and creates its specified Gibs in its place with appropriate velocities. Any Attachables are removed and also given appropriate velocities. - /// - /// The impulse (kg * m/s) of the impact causing the gibbing to happen. - /// A pointer to an MO which the Gibs and Attachables should not be colliding with. + /// @param impactImpulse The impulse (kg * m/s) of the impact causing the gibbing to happen. + /// @param movableObjectToIgnore A pointer to an MO which the Gibs and Attachables should not be colliding with. virtual void GibThis(const Vector& impactImpulse = Vector(), MovableObject* movableObjectToIgnore = nullptr); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: MoveOutOfTerrain - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Checks whether any of the Atom:s in this MovableObject are on top of - // terrain pixels, and if so, attempt to move this out so none of this' - // Atoms are on top of the terrain any more. - // Arguments: Only consider materials stronger than this in the terrain for - // intersections. - // Return value: Whether any intersection was successfully resolved. Will return true - // even if there wasn't any intersections to begin with. - + /// Checks whether any of the Atom:s in this MovableObject are on top of + /// terrain pixels, and if so, attempt to move this out so none of this' + /// Atoms are on top of the terrain any more. + /// @param strongerThan Only consider materials stronger than this in the terrain for (default: g_MaterialAir) + /// intersections. + /// @return Whether any intersection was successfully resolved. Will return true + /// even if there wasn't any intersections to begin with. bool MoveOutOfTerrain(unsigned char strongerThan = g_MaterialAir) override; - /// /// Gathers, clears and applies this MOSRotating's accumulated forces. - /// void ApplyForces() override; - /// /// Gathers, clears and applies this MOSRotating's accumulated impulse forces, gibbing if appropriate. - /// void ApplyImpulses() override; - /// /// Gets the list of Attachables on this MOSRotating. - /// - /// The list of Attachables on this MOSRotating. + /// @return The list of Attachables on this MOSRotating. const std::list& GetAttachables() const { return m_Attachables; } - /// /// Gets whether or not the given Attachable is a hardcoded Attachable (e.g. an Arm, Leg, Turret, etc.) - /// - /// The Attachable to check. - /// Whether or not the Attachable is hardcoded. + /// @param attachableToCheck The Attachable to check. + /// @return Whether or not the Attachable is hardcoded. bool AttachableIsHardcoded(const Attachable* attachableToCheck) const; - /// /// Adds the passed in Attachable the list of Attachables and sets its parent to this MOSRotating. - /// - /// The Attachable to add. + /// @param attachable The Attachable to add. virtual void AddAttachable(Attachable* attachable); - /// /// Adds the passed in Attachable the list of Attachables, changes its parent offset to the passed in Vector, and sets its parent to this MOSRotating. - /// - /// The Attachable to add. - /// The Vector to set as the Attachable's parent offset. + /// @param attachable The Attachable to add. + /// @param parentOffsetToSet The Vector to set as the Attachable's parent offset. virtual void AddAttachable(Attachable* attachable, const Vector& parentOffsetToSet); - /// /// Removes the Attachable corresponding to the passed in UniqueID and sets its parent to nullptr. Does not add it to MovableMan or add break wounds. - /// - /// The UniqueID of the Attachable to remove. - /// A pointer to the removed Attachable. Ownership IS transferred! + /// @param attachableUniqueID The UniqueID of the Attachable to remove. + /// @return A pointer to the removed Attachable. Ownership IS transferred! virtual Attachable* RemoveAttachable(long attachableUniqueID) { return RemoveAttachable(attachableUniqueID, false, false); } - /// /// Removes the Attachable corresponding to the passed in UniqueID and sets its parent to nullptr. Optionally adds it to MovableMan and/or adds break wounds. /// If the Attachable is not set to delete or delete when removed from its parent, and addToMovableMan is false, the caller must hang onto a pointer to the Attachable ahead of time to avoid memory leaks. - /// - /// The UniqueID of the Attachable to remove. - /// Whether or not to add the Attachable to MovableMan once it has been removed. - /// Whether or not to add break wounds to the removed Attachable and this MOSRotating. - /// A pointer to the removed Attachable, if it wasn't added to MovableMan or nullptr if it was. Ownership IS transferred! + /// @param attachableUniqueID The UniqueID of the Attachable to remove. + /// @param addToMovableMan Whether or not to add the Attachable to MovableMan once it has been removed. + /// @param addBreakWounds Whether or not to add break wounds to the removed Attachable and this MOSRotating. + /// @return A pointer to the removed Attachable, if it wasn't added to MovableMan or nullptr if it was. Ownership IS transferred! virtual Attachable* RemoveAttachable(long attachableUniqueID, bool addToMovableMan, bool addBreakWounds); - /// /// Removes the passed in Attachable and sets its parent to nullptr. Does not add it to MovableMan or add break wounds. - /// - /// The Attachable to remove. - /// A pointer to the removed Attachable. Ownership IS transferred! + /// @param attachable The Attachable to remove. + /// @return A pointer to the removed Attachable. Ownership IS transferred! virtual Attachable* RemoveAttachable(Attachable* attachable) { return RemoveAttachable(attachable, false, false); } - /// /// Removes the passed in Attachable and sets its parent to nullptr. Optionally adds it to MovableMan and/or adds break wounds. /// If the Attachable is not set to delete or delete when removed from its parent, and addToMovableMan is false, the caller must hang onto a pointer to the Attachable ahead of time to avoid memory leaks. - /// - /// The Attachable to remove. - /// Whether or not to add the Attachable to MovableMan once it has been removed. - /// Whether or not to add break wounds to the removed Attachable and this MOSRotating. - /// A pointer to the removed Attachable, if it wasn't added to MovableMan or nullptr if it was. Ownership IS transferred! + /// @param attachable The Attachable to remove. + /// @param addToMovableMan Whether or not to add the Attachable to MovableMan once it has been removed. + /// @param addBreakWounds Whether or not to add break wounds to the removed Attachable and this MOSRotating. + /// @return A pointer to the removed Attachable, if it wasn't added to MovableMan or nullptr if it was. Ownership IS transferred! virtual Attachable* RemoveAttachable(Attachable* attachable, bool addToMovableMan, bool addBreakWounds); - /// /// Removes the passed in Attachable, and sets it to delete so it will go straight to MovableMan and be handled there. - /// - /// The Attacahble to remove and delete. + /// @param attachable The Attacahble to remove and delete. void RemoveAndDeleteAttachable(Attachable* attachable); - /// /// Either removes or deletes all of this MOSRotating's Attachables. - /// - /// Whether to remove or delete the Attachables. Setting this to true deletes them, setting it to false removes them. + /// @param destroy Whether to remove or delete the Attachables. Setting this to true deletes them, setting it to false removes them. void RemoveOrDestroyAllAttachables(bool destroy); - /// /// Gets a damage-transferring, impulse-vulnerable Attachable nearest to the passed in offset. - /// - /// The offset that will be compared to each Attachable's ParentOffset. - /// The nearest detachable Attachable, or nullptr if none was found. + /// @param offset The offset that will be compared to each Attachable's ParentOffset. + /// @return The nearest detachable Attachable, or nullptr if none was found. Attachable* GetNearestDetachableAttachableToOffset(const Vector& offset) const; - /// /// Gibs or detaches any Attachables that would normally gib or detach from the passed in impulses. - /// - /// The impulse vector which determines the Attachables to gib or detach. Will be filled out with the remainder of impulses. + /// @param impulseVector The impulse vector which determines the Attachables to gib or detach. Will be filled out with the remainder of impulses. void DetachAttachablesFromImpulse(Vector& impulseVector); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: ResetAllTimers - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Resest all the timers used by this. Can be emitters, etc. This is to - // prevent backed up emissions to come out all at once while this has been - // held dormant in an inventory. - // Arguments: None. - // Return value: None. - + /// Resest all the timers used by this. Can be emitters, etc. This is to + /// prevent backed up emissions to come out all at once while this has been + /// held dormant in an inventory. void ResetAllTimers() override; - /// /// Does the calculations necessary to detect whether this MOSRotating is at rest or not. IsAtRest() retrieves the answer. - /// void RestDetection() override; - /// /// Indicates whether this MOSRotating has been at rest with no movement for longer than its RestThreshold. - /// bool IsAtRest() override; - /// /// Indicates whether this MOSRotating's current graphical representation, including its Attachables, overlaps a point in absolute scene coordinates. - /// - /// The point in absolute scene coordinates to check for overlap with. - /// Whether or not this MOSRotating's graphical representation overlaps the given scene point. + /// @param scenePoint The point in absolute scene coordinates to check for overlap with. + /// @return Whether or not this MOSRotating's graphical representation overlaps the given scene point. bool IsOnScenePoint(Vector& scenePoint) const override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: EraseFromTerrain - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Cuts this' silhouette out from the terrain's material and color layers. - // Arguments: None. - // Return value: None. - + /// Cuts this' silhouette out from the terrain's material and color layers. void EraseFromTerrain(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: DeepCheck - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Checks if any of this' deep group atmos are on top of the terrain, and - // if so, erases this' silhouette from the terrain. - // Arguments: Whether to make any MOPixels from erased terrain pixels at all. - // The size of the gaps between MOPixels knocked loose by the terrain erasure. - // The max number of MOPixel:s to generate as dislodged particles from the - // erased terrain. - // Return value: Whether deep penetration was detected and erasure was done. - + /// Checks if any of this' deep group atmos are on top of the terrain, and + /// if so, erases this' silhouette from the terrain. + /// @param makeMOPs Whether to make any MOPixels from erased terrain pixels at all. (default: true) + /// @param skipMOP The size of the gaps between MOPixels knocked loose by the terrain erasure. (default: 2) + /// @param maxMOP The max number of MOPixel:s to generate as dislodged particles from the (default: 100) + /// erased terrain. + /// @return Whether deep penetration was detected and erasure was done. bool DeepCheck(bool makeMOPs = true, int skipMOP = 2, int maxMOP = 100); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: PreTravel - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Does stuff that needs to be done before Travel(). Always call before - // calling Travel. - // Arguments: None. - // Return value: None. - + /// Does stuff that needs to be done before Travel(). Always call before + /// calling Travel. void PreTravel() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Travel - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Travels this MOSRotatin, using its physical representation. - // Arguments: None. - // Return value: None. - + /// Travels this MOSRotatin, using its physical representation. void Travel() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: PostTravel - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Does stuff that needs to be done after Update(). Always call after - // calling Update. - // Arguments: None. - // Return value: None. - + /// Does stuff that needs to be done after Update(). Always call after + /// calling Update. void PostTravel() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Update - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates this MovableObject. Supposed to be done every frame. - // Arguments: None. - // Return value: None. - + /// Updates this MovableObject. Supposed to be done every frame. void Update() override; void PostUpdate() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: DrawMOIDIfOverlapping - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws the MOID representation of this to the SceneMan's MOID layer if - // this is found to potentially overlap another MovableObject. - // Arguments: The MovableObject to check this for overlap against. - // Return value: Whether it was drawn or not. - + /// Draws the MOID representation of this to the SceneMan's MOID layer if + /// this is found to potentially overlap another MovableObject. + /// @param pOverlapMO The MovableObject to check this for overlap against. + /// @return Whether it was drawn or not. bool DrawMOIDIfOverlapping(MovableObject* pOverlapMO) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Draw - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws this MOSRotating's current graphical representation to a - // BITMAP of choice. - // Arguments: A pointer to a BITMAP to draw on. - // The absolute position of the target bitmap's upper left corner in the Scene. - // In which mode to draw in. See the DrawMode enumeration for the modes. - // Whether to not draw any extra 'ghost' items of this MovableObject, - // indicator arrows or hovering HUD text and so on. - // Return value: None. - + /// Draws this MOSRotating's current graphical representation to a + /// BITMAP of choice. + /// @param pTargetBitmap A pointer to a BITMAP to draw on. + /// @param targetPos The absolute position of the target bitmap's upper left corner in the Scene. (default: Vector()) + /// @param mode In which mode to draw in. See the DrawMode enumeration for the modes. (default: g_DrawColor) + /// @param onlyPhysical Whether to not draw any extra 'ghost' items of this MovableObject, (default: false) + /// indicator arrows or hovering HUD text and so on. void Draw(BITMAP* pTargetBitmap, const Vector& targetPos = Vector(), DrawMode mode = g_DrawColor, bool onlyPhysical = false) const override; - /// /// Gets the gib impulse limit for this MOSRotating, i.e. the amount of impulse force required in a frame to gib this MOSRotating. - /// - /// The gib impulse limit of this MOSRotating. + /// @return The gib impulse limit of this MOSRotating. float GetGibImpulseLimit() const { return m_GibImpulseLimit; } - /// /// Sets the gib impulse limit for this MOSRotating, i.e. the amount of impulse force required in a frame to gib this MOSRotating. - /// - /// The new gib impulse limit to use. + /// @param newGibImpulseLimit The new gib impulse limit to use. void SetGibImpulseLimit(float newGibImpulseLimit) { m_GibImpulseLimit = newGibImpulseLimit; } - /// /// Gets the gib wound limit for this MOSRotating, i.e. the total number of wounds required to gib this MOSRotating. Does not include any Attachables. - /// - /// + /// @return int GetGibWoundLimit() const { return GetGibWoundLimit(false, false, false); } - /// /// Gets the gib wound limit for this MOSRotating, i.e. the total number of wounds required to gib this MOSRotating. /// Optionally adds the gib wound limits of Attachables (and their Attachables, etc.) that match the conditions set by the provided parameters. - /// - /// Whether to count wounds from Attachables that have a positive damage multiplier, i.e. those that damage their parent (this MOSRotating) when wounded. - /// Whether to count wounds from Attachables that have a negative damage multiplier, i.e. those that heal their parent (this MOSRotating) when wounded. - /// Whether to count wounds from Attachables that a zero damage multiplier, i.e. those that do not affect their parent (this MOSRotating) when wounded. - /// The wound limit of this MOSRotating and, optionally, its Attachables. + /// @param includePositiveDamageAttachables Whether to count wounds from Attachables that have a positive damage multiplier, i.e. those that damage their parent (this MOSRotating) when wounded. + /// @param includeNegativeDamageAttachables Whether to count wounds from Attachables that have a negative damage multiplier, i.e. those that heal their parent (this MOSRotating) when wounded. + /// @param includeNoDamageAttachables Whether to count wounds from Attachables that a zero damage multiplier, i.e. those that do not affect their parent (this MOSRotating) when wounded. + /// @return The wound limit of this MOSRotating and, optionally, its Attachables. int GetGibWoundLimit(bool includePositiveDamageAttachables, bool includeNegativeDamageAttachables, bool includeNoDamageAttachables) const; - /// /// Sets the gib wound limit for this MOSRotating, i.e. the total number of wounds required to gib this MOSRotating. /// This will not directly trigger gibbing, even if the limit is lower than the current number of wounds. - /// - /// The new gib wound limit to use. + /// @param newLimit The new gib wound limit to use. void SetGibWoundLimit(int newGibWoundLimit) { m_GibWoundLimit = newGibWoundLimit; } - /// /// Gets the rate at which wound count of this MOSRotating will diminish the impulse limit. - /// - /// The rate at which wound count affects the impulse limit. + /// @return The rate at which wound count affects the impulse limit. float GetWoundCountAffectsImpulseLimitRatio() const { return m_WoundCountAffectsImpulseLimitRatio; } - /// /// Gets whether this MOSRotating should gib at the end of its lifetime instead of just being deleted. - /// - /// Whether this MOSRotating should gib at the end of its lifetime instead of just being deleted. + /// @return Whether this MOSRotating should gib at the end of its lifetime instead of just being deleted. bool GetGibAtEndOfLifetime() const { return m_GibAtEndOfLifetime; } - /// /// Sets whether this MOSRotating should gib at the end of its lifetime instead of just being deleted. - /// - /// Whether or not this MOSRotating should gib at the end of its lifetime instead of just being deleted. + /// @param shouldGibAtEndOfLifetime Whether or not this MOSRotating should gib at the end of its lifetime instead of just being deleted. void SetGibAtEndOfLifetime(bool shouldGibAtEndOfLifetime) { m_GibAtEndOfLifetime = shouldGibAtEndOfLifetime; } - /// /// Gets the gib blast strength this MOSRotating, i.e. the strength with which Gibs and Attachables will be launched when this MOSRotating is gibbed. - /// - /// The gib blast strength of this MOSRotating. + /// @return The gib blast strength of this MOSRotating. float GetGibBlastStrength() const { return m_GibBlastStrength; } - /// /// Sets the gib blast strength this MOSRotating, i.e. the strength with which Gibs and Attachables will be launched when this MOSRotating is gibbed. - /// - /// The new gib blast strength to use. + /// @param newGibBlastStrength The new gib blast strength to use. void SetGibBlastStrength(float newGibBlastStrength) { m_GibBlastStrength = newGibBlastStrength; } - /// /// Gets the amount of screenshake this will cause upon gibbing. - /// - /// The amount of screenshake this will cause when gibbing. If -1, this is calculated automatically. + /// @return The amount of screenshake this will cause when gibbing. If -1, this is calculated automatically. float GetGibScreenShakeAmount() const { return m_GibScreenShakeAmount; } - /// /// Gets a const reference to the list of Attachables on this MOSRotating. - /// - /// A const reference to the list of Attachables on this MOSRotating. + /// @return A const reference to the list of Attachables on this MOSRotating. const std::list& GetAttachableList() const { return m_Attachables; } - /// /// Gets a const reference to the list of wounds on this MOSRotating. - /// - /// A const reference to the list of wounds on this MOSRotating. + /// @return A const reference to the list of wounds on this MOSRotating. const std::vector& GetWoundList() const { return m_Wounds; } - /// /// Gets the number of wounds attached to this MOSRotating. /// Includes any Attachables (and their Attachables, etc.) that have a positive damage multiplier. - /// The number of wounds on this MOSRotating. - /// + /// @return The number of wounds on this MOSRotating. int GetWoundCount() const { return GetWoundCount(true, false, false); } - /// /// Gets the number of wounds attached to this MOSRotating. /// Optionally adds the wound counts of Attachables (and their Attachables, etc.) that match the conditions set by the provided parameters. - /// Whether to count wounds from Attachables that have a positive damage multiplier, i.e. those that damage their parent (this MOSRotating) when wounded. - /// Whether to count wounds from Attachables that have a negative damage multiplier, i.e. those that heal their parent (this MOSRotating) when wounded. - /// Whether to count wounds from Attachables that a zero damage multiplier, i.e. those that do not affect their parent (this MOSRotating) when wounded. - /// The number of wounds on this MOSRotating and, optionally, its Attachables. - /// + /// @param includePositiveDamageAttachables Whether to count wounds from Attachables that have a positive damage multiplier, i.e. those that damage their parent (this MOSRotating) when wounded. + /// @param includeNegativeDamageAttachables Whether to count wounds from Attachables that have a negative damage multiplier, i.e. those that heal their parent (this MOSRotating) when wounded. + /// @param includeNoDamageAttachables Whether to count wounds from Attachables that a zero damage multiplier, i.e. those that do not affect their parent (this MOSRotating) when wounded. + /// @return The number of wounds on this MOSRotating and, optionally, its Attachables. int GetWoundCount(bool includePositiveDamageAttachables, bool includeNegativeDamageAttachables, bool includeNoDamageAttachables) const; - /// /// Adds the passed in wound AEmitter to the list of wounds and changes its parent offset to the passed in Vector. - /// - /// The wound AEmitter to add. - /// The vector to set as the wound AEmitter's parent offset. - /// Whether to gib this MOSRotating if adding this wound raises its wound count past its gib wound limit. Defaults to true. + /// @param woundToAdd The wound AEmitter to add. + /// @param parentOffsetToSet The vector to set as the wound AEmitter's parent offset. + /// @param checkGibWoundLimit Whether to gib this MOSRotating if adding this wound raises its wound count past its gib wound limit. Defaults to true. virtual void AddWound(AEmitter* woundToAdd, const Vector& parentOffsetToSet, bool checkGibWoundLimit = true); - /// /// Removes the specified number of wounds from this MOSRotating, and returns damage caused by these removed wounds. /// Includes any Attachables (and their Attachables, etc.) that have a positive damage multiplier. - /// - /// The number of wounds that should be removed. - /// The amount of damage caused by these wounds, taking damage multipliers into account. + /// @param numberOfWoundsToRemove The number of wounds that should be removed. + /// @return The amount of damage caused by these wounds, taking damage multipliers into account. virtual float RemoveWounds(int numberOfWoundsToRemove) { return RemoveWounds(numberOfWoundsToRemove, true, false, false); } - /// /// Removes the specified number of wounds from this MOSRotating, and returns damage caused by these removed wounds. /// Optionally removes wounds from Attachables (and their Attachables, etc.) that match the conditions set by the provided inclusion parameters. - /// - /// The number of wounds that should be removed. - /// Whether to count wounds from Attachables that have a positive damage multiplier, i.e. those that damage their parent (this MOSRotating) when wounded. - /// Whether to count wounds from Attachables that have a negative damage multiplier, i.e. those that heal their parent (this MOSRotating) when wounded. - /// Whether to count wounds from Attachables that a zero damage multiplier, i.e. those that do not affect their parent (this MOSRotating) when wounded. - /// The amount of damage caused by these wounds, taking damage multipliers into account. + /// @param numberOfWoundsToRemove The number of wounds that should be removed. + /// @param includePositiveDamageAttachables Whether to count wounds from Attachables that have a positive damage multiplier, i.e. those that damage their parent (this MOSRotating) when wounded. + /// @param includeNegativeDamageAttachables Whether to count wounds from Attachables that have a negative damage multiplier, i.e. those that heal their parent (this MOSRotating) when wounded. + /// @param includeNoDamageAttachables Whether to count wounds from Attachables that a zero damage multiplier, i.e. those that do not affect their parent (this MOSRotating) when wounded. + /// @return The amount of damage caused by these wounds, taking damage multipliers into account. virtual float RemoveWounds(int numberOfWoundsToRemove, bool includePositiveDamageAttachables, bool includeNegativeDamageAttachables, bool includeNoDamageAttachables); - /// /// Cleans up and destroys the script state of this object, calling the Destroy callback in lua - /// void DestroyScriptState(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetDamageMultiplier - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets damage multiplier of this attachable. - // Arguments: New multiplier value. - // Return value: None. - + /// Sets damage multiplier of this attachable. + /// @param newValue New multiplier value. void SetDamageMultiplier(float newValue) { m_DamageMultiplier = newValue; m_NoSetDamageMultiplier = false; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetDamageMultiplier - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns damage multiplier of this attachable. - // Arguments: None. - // Return value: Current multiplier value. - + /// Returns damage multiplier of this attachable. + /// @return Current multiplier value. float GetDamageMultiplier() const { return m_DamageMultiplier; } - /// /// Gets whether the damage multiplier for this MOSRotating has been directly set, or is at its default value. - /// - /// Whether the damage multiplier for this MOSRotating has been set. + /// @return Whether the damage multiplier for this MOSRotating has been set. bool HasNoSetDamageMultiplier() const { return m_NoSetDamageMultiplier; } - /// /// Gets the velocity orientation scalar of this MOSRotating. - /// - /// New scalar value. + /// @return New scalar value. float GetOrientToVel() const { return m_OrientToVel; } - /// /// Sets the velocity orientation scalar of this MOSRotating. - /// - /// New scalar value. + /// @param newValue New scalar value. void SetOrientToVel(float newValue) { m_OrientToVel = newValue; } - /// /// Sets this MOSRotating and all its children to drawn white for a specified amount of time. - /// - /// Duration of flash in real time MS. + /// @param durationMS Duration of flash in real time MS. void FlashWhite(int durationMS = 32) { m_FlashWhiteTimer.SetRealTimeLimitMS(durationMS); m_FlashWhiteTimer.Reset(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetTravelImpulse - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Retrurns the amount of impulse force exerted on this during the last frame. - // Arguments: None. - // Return value: The amount of impulse force exerted on this during the last frame. - + /// Retrurns the amount of impulse force exerted on this during the last frame. + /// @return The amount of impulse force exerted on this during the last frame. Vector GetTravelImpulse() const { return m_TravelImpulse; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetTravelImpulse - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the amount of impulse force exerted on this during the last frame. - // Arguments: New impulse value - // Return value: None. - + /// Sets the amount of impulse force exerted on this during the last frame. + /// @param impulse New impulse value void SetTravelImpulse(Vector impulse) { m_TravelImpulse = impulse; } - /// /// Gets this MOSRotating's gib sound. Ownership is NOT transferred! - /// - /// The SoundContainer for this MOSRotating's gib sound. + /// @return The SoundContainer for this MOSRotating's gib sound. SoundContainer* GetGibSound() const { return m_GibSound; } - /// /// Sets this MOSRotating's gib sound. Ownership IS transferred! - /// - /// The new SoundContainer for this MOSRotating's gib sound. + /// @param newSound The new SoundContainer for this MOSRotating's gib sound. void SetGibSound(SoundContainer* newSound) { m_GibSound = newSound; } - /// /// Ensures all attachables and wounds are positioned and rotated correctly. Must be run when this MOSRotating is added to MovableMan to avoid issues with Attachables spawning in at (0, 0). - /// virtual void CorrectAttachableAndWoundPositionsAndRotations() const; - /// /// Method to be run when the game is saved via ActivityMan::SaveCurrentGame. Not currently used in metagame or editor saving. - /// void OnSave() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Protected member variable and method declarations - + /// Protected member variable and method declarations protected: - /// /// Transfers forces and impulse forces from the given Attachable to this MOSRotating, gibbing and/or removing the Attachable if needed. - /// - /// A pointer to the Attachable to apply forces from. Ownership is NOT transferred! - /// Whether or not the Attachable has been removed, in which case it'll usually be passed to MovableMan. + /// @param attachable A pointer to the Attachable to apply forces from. Ownership is NOT transferred! + /// @return Whether or not the Attachable has been removed, in which case it'll usually be passed to MovableMan. bool TransferForcesFromAttachable(Attachable* attachable); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: UpdateChildMOIDs - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes this MO register itself and all its attached children in the - // MOID register and get ID:s for itself and its children for this frame. - // Arguments: The MOID index to register itself and its children in. - // The MOID of the root MO of this MO, ie the highest parent of this MO. - // 0 means that this MO is the root, ie it is owned by MovableMan. - // Whether this MO should make a new MOID to use for itself, or to use - // the same as the last one in the index (presumably its parent), - // Return value: None. - + /// Makes this MO register itself and all its attached children in the + /// MOID register and get ID:s for itself and its children for this frame. + /// @param MOIDIndex The MOID index to register itself and its children in. + /// @param rootMOID The MOID of the root MO of this MO, ie the highest parent of this MO. (default: g_NoMOID) + /// 0 means that this MO is the root, ie it is owned by MovableMan. + /// @param makeNewMOID Whether this MO should make a new MOID to use for itself, or to use (default: true) + /// the same as the last one in the index (presumably its parent), void UpdateChildMOIDs(std::vector& MOIDIndex, MOID rootMOID = g_NoMOID, bool makeNewMOID = true) override; - /// /// Creates the particles specified by this MOSRotating's list of Gibs and adds them to MovableMan with appropriately randomized velocities, based on this MOSRotating's gib blast strength. - /// - /// The impulse (kg * m/s) of the impact that caused the gibbing to happen. - /// A pointer to an MO which the Attachables should not be colliding with. + /// @param impactImpulse The impulse (kg * m/s) of the impact that caused the gibbing to happen. + /// @param movableObjectToIgnore A pointer to an MO which the Attachables should not be colliding with. void CreateGibsWhenGibbing(const Vector& impactImpulse, MovableObject* movableObjectToIgnore); - /// /// Removes all Attachables from this MOSR, deleting them or adding them to MovableMan as appropriate, and giving them randomized velocities based on their properties and this MOSRotating's gib blast strength. - /// - /// The impulse (kg * m/s) of the impact that caused the gibbing to happen. - /// A pointer to an MO which the Attachables should not be colliding with. + /// @param impactImpulse The impulse (kg * m/s) of the impact that caused the gibbing to happen. + /// @param movableObjectToIgnore A pointer to an MO which the Attachables should not be colliding with. void RemoveAttachablesWhenGibbing(const Vector& impactImpulse, MovableObject* movableObjectToIgnore); // Member variables @@ -920,18 +602,10 @@ namespace RTE { static BITMAP* m_spTempBitmapS256; static BITMAP* m_spTempBitmapS512; - ////////////////////////////////////////////////////////////////////////////////////////// - // Private member variable and method declarations - + /// Private member variable and method declarations private: - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Clear - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears all the member variables of this MOSRotating, effectively - // resetting the members of this abstraction level only. - // Arguments: None. - // Return value: None. - + /// Clears all the member variables of this MOSRotating, effectively + /// resetting the members of this abstraction level only. void Clear(); // Disallow the use of some implicit methods. diff --git a/Source/Entities/MOSprite.cpp b/Source/Entities/MOSprite.cpp index 4f5862373e..0970271e91 100644 --- a/Source/Entities/MOSprite.cpp +++ b/Source/Entities/MOSprite.cpp @@ -1,15 +1,3 @@ -////////////////////////////////////////////////////////////////////////////////////////// -// File: MOSprite.cpp -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Source file for the MOSprite class. -// Project: Retro Terrain Engine -// Author(s): Daniel Tabar -// data@datarealms.com -// http://www.datarealms.com - -////////////////////////////////////////////////////////////////////////////////////////// -// Inclusions of header files - #include "MOSprite.h" #include "AEmitter.h" @@ -19,12 +7,6 @@ namespace RTE { AbstractClassInfo(MOSprite, MovableObject); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Clear - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears all the member variables of this MOSprite, effectively - // resetting the members of this abstraction level only. - void MOSprite::Clear() { m_SpriteFile.Reset(); m_aSprite.clear(); @@ -50,11 +32,6 @@ namespace RTE { m_pExitWound = 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes the MOSprite object ready for use. - int MOSprite::Create() { if (MovableObject::Create() < 0) return -1; @@ -80,11 +57,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes the MOSprite object ready for use. - int MOSprite::Create(ContentFile spriteFile, const int frameCount, const float mass, @@ -110,11 +82,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Creates a MOSprite to be identical to another, by deep copy. - int MOSprite::Create(const MOSprite& reference) { MovableObject::Create(reference); @@ -146,14 +113,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: ReadProperty - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Reads a property value from a reader stream. If the name isn't - // recognized by this class, then ReadProperty of the parent class - // is called. If the property isn't recognized by any of the base classes, - // false is returned, and the reader's position is untouched. - int MOSprite::ReadProperty(const std::string_view& propName, Reader& reader) { StartPropertyList(return MovableObject::ReadProperty(propName, reader)); @@ -198,10 +157,6 @@ namespace RTE { EndPropertyList; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: SetEntryWound - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets entry wound emitter for this MOSprite void MOSprite::SetEntryWound(std::string presetName, std::string moduleName) { if (presetName == "") m_pEntryWound = 0; @@ -209,10 +164,6 @@ namespace RTE { m_pEntryWound = dynamic_cast(g_PresetMan.GetEntityPreset("AEmitter", presetName, moduleName)); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: SetExitWound - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets exit wound emitter for this MOSprite void MOSprite::SetExitWound(std::string presetName, std::string moduleName) { if (presetName == "") m_pExitWound = 0; @@ -220,30 +171,14 @@ namespace RTE { m_pExitWound = dynamic_cast(g_PresetMan.GetEntityPreset("AEmitter", presetName, moduleName)); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: GetEntryWoundPresetName - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns entry wound emitter preset name for this MOSprite - std::string MOSprite::GetEntryWoundPresetName() const { return m_pEntryWound ? m_pEntryWound->GetPresetName() : ""; }; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: GetExitWoundPresetName - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns exit wound emitter preset name for this MOSprite - std::string MOSprite::GetExitWoundPresetName() const { return m_pExitWound ? m_pExitWound->GetPresetName() : ""; }; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Save - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Saves the complete state of this MOSprite with a Writer for - // later recreation with Create(Reader &reader); - int MOSprite::Save(Writer& writer) const { MovableObject::Save(writer); // TODO: Make proper save system that knows not to save redundant data! @@ -274,11 +209,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destroys and resets (through Clear()) the MOSprite object. - void MOSprite::Destroy(bool notInherited) { // delete m_pEntryWound; Not doing this anymore since we're not owning // delete m_pExitWound; @@ -309,11 +239,6 @@ namespace RTE { return is_inside_bitmap(sprite, localX, localY, 0) && _getpixel(sprite, localX, localY) != ColorKeys::g_MaskColor; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetFrame - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Hard-sets the frame this sprite is supposed to show. - void MOSprite::SetFrame(unsigned int newFrame) { if (newFrame < 0) newFrame = 0; @@ -323,13 +248,6 @@ namespace RTE { m_Frame = newFrame; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetNextFrame - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Hard-sets the frame this sprite is supposed to show, to the - // consecutive one after the current one. If currently the last fame is - // this will set it to the be the first, looping the animation. - bool MOSprite::SetNextFrame() { if (++m_Frame >= m_FrameCount) { m_Frame = 0; @@ -338,12 +256,6 @@ namespace RTE { return false; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: IsOnScenePoint - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Indicates whether this' current graphical representation overlaps - // a point in absolute scene coordinates. - bool MOSprite::IsOnScenePoint(Vector& scenePoint) const { if (!m_aSprite[m_Frame]) return false; @@ -405,35 +317,18 @@ namespace RTE { return false; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: RotateOffset - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Rotates a vector offset from this MORotating's position according to - // the rotate angle and flipping. - Vector MOSprite::RotateOffset(const Vector& offset) const { Vector rotOff(offset.GetXFlipped(m_HFlipped)); rotOff *= const_cast(m_Rotation); return rotOff; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: UnRotateOffset - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Rotates a vector offset from this MORotating's position according to - // the NEGATIVE rotate angle and takes flipping into account. - Vector MOSprite::UnRotateOffset(const Vector& offset) const { Vector rotOff(offset.GetXFlipped(m_HFlipped)); rotOff /= const_cast(m_Rotation); return rotOff; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Pure v. method: Update - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates this MOSprite. Supposed to be done every frame. - void MOSprite::Update() { MovableObject::Update(); @@ -490,12 +385,6 @@ namespace RTE { } } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Draw - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws this MOSprite's current graphical representation to a - // BITMAP of choice. - void MOSprite::Draw(BITMAP* pTargetBitmap, const Vector& targetPos, DrawMode mode, diff --git a/Source/Entities/MOSprite.h b/Source/Entities/MOSprite.h index 7065f185ad..db82d0c387 100644 --- a/Source/Entities/MOSprite.h +++ b/Source/Entities/MOSprite.h @@ -1,18 +1,11 @@ #ifndef _RTEMOSPRITE_ #define _RTEMOSPRITE_ -////////////////////////////////////////////////////////////////////////////////////////// -// File: MOSprite.h -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Header file for the MOSprite class. -// Project: Retro Terrain Engine -// Author(s): Daniel Tabar -// data@datarealms.com -// http://www.datarealms.com - -////////////////////////////////////////////////////////////////////////////////////////// -// Inclusions of header files - +/// Header file for the MOSprite class. +/// @author Daniel Tabar +/// data@datarealms.com +/// http://www.datarealms.com +/// Inclusions of header files #include "MovableObject.h" #include "Box.h" @@ -20,237 +13,127 @@ namespace RTE { class AEmitter; - ////////////////////////////////////////////////////////////////////////////////////////// - // Abstract class: MOSprite - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: A movable object with mass that is graphically represented by a - // BITMAP. - // Parent(s): MovableObject. - // Class history: 03/18/2001 MOSprite created. - + /// A movable object with mass that is graphically represented by a + /// BITMAP. class MOSprite : public MovableObject { - ////////////////////////////////////////////////////////////////////////////////////////// - // Public member variable, method and friend function declarations - + /// Public member variable, method and friend function declarations public: SerializableOverrideMethods; ClassInfoGetters; - ////////////////////////////////////////////////////////////////////////////////////////// - // Constructor: MOSprite - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Constructor method used to instantiate a MOSprite object in system - // memory. Create() should be called before using the object. - // Arguments: None. - + /// Constructor method used to instantiate a MOSprite object in system + /// memory. Create() should be called before using the object. MOSprite() { Clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Destructor: ~MOSprite - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destructor method used to clean up a MOSprite object before deletion - // from system memory. - // Arguments: None. - + /// Destructor method used to clean up a MOSprite object before deletion + /// from system memory. ~MOSprite() override { Destroy(true); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes the MOSprite object ready for use. - // Arguments: A pointer to ContentFile that represents the bitmap file that will be - // used to create the Sprite. - // The number of frames in the Sprite's animation. - // A float specifying the object's mass in Kilograms (kg). - // A Vector specifying the initial position. - // A Vector specifying the initial velocity. - // The amount of time in ms this MovableObject will exist. 0 means unlim. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Makes the MOSprite object ready for use. + /// @param spriteFile A pointer to ContentFile that represents the bitmap file that will be + /// used to create the Sprite. + /// @param frameCount The number of frames in the Sprite's animation. (default: 1) + /// @param mass A float specifying the object's mass in Kilograms (kg). (default: 1) + /// @param position A Vector specifying the initial position. (default: Vector(0) + /// @param 0) A Vector specifying the initial velocity. + /// @param velocity The amount of time in ms this MovableObject will exist. 0 means unlim. (default: Vector(0) + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Create(ContentFile spriteFile, const int frameCount = 1, const float mass = 1, const Vector& position = Vector(0, 0), const Vector& velocity = Vector(0, 0), const unsigned long lifetime = 0); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Creates a MOSprite to be identical to another, by deep copy. - // Arguments: A reference to the MOSprite to deep copy. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Creates a MOSprite to be identical to another, by deep copy. + /// @param reference A reference to the MOSprite to deep copy. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Create(const MOSprite& reference); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes the MOSprite object ready for use. - // Arguments: None. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Makes the MOSprite object ready for use. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Create() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Reset - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Resets the entire MOSprite, including its inherited members, to their - // default settings or values. - // Arguments: None. - // Return value: None. - + /// Resets the entire MOSprite, including its inherited members, to their + /// default settings or values. void Reset() override { Clear(); MovableObject::Reset(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destroys and resets (through Clear()) the MOSprite object. - // Arguments: Whether to only destroy the members defined in this derived class, or - // to destroy all inherited members also. - // Return value: None. - + /// Destroys and resets (through Clear()) the MOSprite object. + /// @param notInherited Whether to only destroy the members defined in this derived class, or (default: false) + /// to destroy all inherited members also. void Destroy(bool notInherited = false) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: GetRadius - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the largest radius of this in pixels. - // Arguments: None. - // Return value: The radius from its center to the edge of its graphical representation. - + /// Gets the largest radius of this in pixels. + /// @return The radius from its center to the edge of its graphical representation. float GetRadius() const override { return m_SpriteRadius; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: GetDiameter - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the largest diameter of this in pixels. - // Arguments: None. - // Return value: The largest diameter across its graphical representation. - + /// Gets the largest diameter of this in pixels. + /// @return The largest diameter across its graphical representation. float GetDiameter() const override { return m_SpriteDiameter; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: GetAboveHUDPos - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the absoltue position of the top of this' HUD stack. - // Arguments: None. - // Return value: A Vector with the absolute position of this' HUD stack top point. - + /// Gets the absoltue position of the top of this' HUD stack. + /// @return A Vector with the absolute position of this' HUD stack top point. Vector GetAboveHUDPos() const override { return m_Pos + Vector(0, -GetRadius()); } // TODO: Improve this one! Really crappy fit - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: GetBoundingBox - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the oriented bounding box which is guaranteed to contain this, - // taking rotation etc into account. It's not guaranteed to be fit - // perfectly though. TODO: MAKE FIT BETTER - // Arguments: None. - // Return value: A Box which is guaranteed to contain this. Does nto take wrapping into - // account, and parts of this box may be out of bounds! - + /// Gets the oriented bounding box which is guaranteed to contain this, + /// taking rotation etc into account. It's not guaranteed to be fit + /// perfectly though. TODO MAKE FIT BETTER + /// @return A Box which is guaranteed to contain this. Does nto take wrapping into + /// account, and parts of this box may be out of bounds! Box GetBoundingBox() const { return Box(m_Pos + Vector(-GetRadius(), -GetRadius()), GetDiameter(), GetDiameter()); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetSpriteFrame - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets a frame of this MOSprite's BITMAP array. - // Arguments: Which frame to get. - // Return value: A pointer to the requested frame of this MOSprite's BITMAP array. - // Ownership is NOT transferred! - + /// Gets a frame of this MOSprite's BITMAP array. + /// @param whichFrame Which frame to get. (default: 0) + /// @return A pointer to the requested frame of this MOSprite's BITMAP array. + /// Ownership is NOT transferred! BITMAP* GetSpriteFrame(int whichFrame = 0) const { return (whichFrame >= 0 && whichFrame < m_FrameCount) ? m_aSprite[whichFrame] : 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetSpriteWidth - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the width of the bitmap of this MOSprite - // Arguments: 0. - // Return value: Sprite width if loaded. - + /// Gets the width of the bitmap of this MOSprite + /// @return Sprite width if loaded. int GetSpriteWidth() const { return m_aSprite[0] ? m_aSprite[0]->w : 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetSpriteHeight - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the height of the bitmap of this MOSprite - // Arguments: 0. - // Return value: Sprite height if loaded. - + /// Gets the height of the bitmap of this MOSprite + /// @return Sprite height if loaded. int GetSpriteHeight() const { return m_aSprite[0] ? m_aSprite[0]->h : 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetFrameCount - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the number of frames in this MOSprite's animation. - // Arguments: None. - // Return value: The frame count. - + /// Gets the number of frames in this MOSprite's animation. + /// @return The frame count. int GetFrameCount() const { return m_FrameCount; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetSpriteOffset - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the offset that the BITMAP has from the position of this - // MOSprite. - // Arguments: None. - // Return value: A vector with the offset. - + /// Gets the offset that the BITMAP has from the position of this + /// MOSprite. + /// @return A vector with the offset. Vector GetSpriteOffset() const { return m_SpriteOffset; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: IsHFlipped - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns whether this MOSprite is being drawn flipped horizontally - // (along the vertical axis), or not. - // Arguments: None. - // Return value: Whether flipped or not. - + /// Returns whether this MOSprite is being drawn flipped horizontally + /// (along the vertical axis), or not. + /// @return Whether flipped or not. bool IsHFlipped() const override { return m_HFlipped; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: GetRotMatrix - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the current rotational Matrix of of this. - // Arguments: None. - // Return value: The rotational Matrix of this MovableObject. - + /// Gets the current rotational Matrix of of this. + /// @return The rotational Matrix of this MovableObject. Matrix GetRotMatrix() const override { return m_Rotation; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: GetRotAngle - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the current rotational angle of of this, in radians. - // Arguments: None. - // Return value: The rotational angle of this, in radians. - + /// Gets the current rotational angle of of this, in radians. + /// @return The rotational angle of this, in radians. float GetRotAngle() const override { return m_Rotation.GetRadAngle(); } - /// /// Gets the previous rotational angle of this MOSprite, prior to this frame. - /// - /// The previous rotational angle in radians. + /// @return The previous rotational angle in radians. float GetPrevRotAngle() const { return m_PrevRotation.GetRadAngle(); } - /// /// Whether a set of X, Y coordinates overlap us (in world space). - /// - /// The given X coordinate, in world space. - /// The given Y coordinate, in world space. - /// Whether the given coordinate overlap us. + /// @param pixelX The given X coordinate, in world space. + /// @param pixelY The given Y coordinate, in world space. + /// @return Whether the given coordinate overlap us. bool HitTestAtPixel(int pixelX, int pixelY) const override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetAngularVel - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the current angular velocity of this MovableObject. Positive is - // a counter-clockwise rotation. - // Arguments: None. - // Return value: The angular velocity in radians per second. - + /// Gets the current angular velocity of this MovableObject. Positive is + /// a counter-clockwise rotation. + /// @return The angular velocity in radians per second. float GetAngularVel() const override { return m_AngularVel; } /* Can't do this since sprite is owned by ContentMan. @@ -264,136 +147,72 @@ namespace RTE { void SetSprite(BITMAP *pSprite) { delete m_aSprite; m_aSprite = pSprite; } */ - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetSpriteOffset - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the offset that the BITMAP has from the position of this - // MOSprite. - // Arguments: A vector with the new offset. - // Return value: None. - + /// Sets the offset that the BITMAP has from the position of this + /// MOSprite. + /// @param newOffset A vector with the new offset. void SetSpriteOffset(const Vector& newOffset) { m_SpriteOffset = newOffset; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetFrame - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Hard-sets the frame this sprite is supposed to show. - // Arguments: An unsigned int pecifiying the new frame. - // Return value: None. - + /// Hard-sets the frame this sprite is supposed to show. + /// @param newFrame An unsigned int pecifiying the new frame. void SetFrame(unsigned int newFrame); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetNextFrame - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Hard-sets the frame this sprite is supposed to show, to the - // consecutive one after the current one. If currently the last fame is - // this will set it to the be the first, looping the animation. - // Arguments: None. - // Return value: Whether the animation looped or not with this setting. - + /// Hard-sets the frame this sprite is supposed to show, to the + /// consecutive one after the current one. If currently the last fame is + /// this will set it to the be the first, looping the animation. + /// @return Whether the animation looped or not with this setting. bool SetNextFrame(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetFrame - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Tells which frame is currently set to show. - // Arguments: None. - // Return value: An unsigned int describing the current frame. - + /// Tells which frame is currently set to show. + /// @return An unsigned int describing the current frame. unsigned int GetFrame() const { return m_Frame; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetSpriteAnimMode - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the animation mode. - // Arguments: The animation mode we want to set. - // Return value: None. - + /// Sets the animation mode. + /// @param animMode The animation mode we want to set. (default: NOANIM) void SetSpriteAnimMode(int animMode = NOANIM) { m_SpriteAnimMode = (SpriteAnimMode)animMode; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetSpriteAnimMode - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the animation mode. - // Arguments: None. - // Return value: The animation mode currently in effect. - + /// Gets the animation mode. + /// @return The animation mode currently in effect. int GetSpriteAnimMode() const { return m_SpriteAnimMode; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virutal method: SetHFlipped - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets whether this MOSprite should be drawn flipped horizontally - // (along the vertical axis). - // Arguments: A bool with the new value. - // Return value: None. - + /// Sets whether this MOSprite should be drawn flipped horizontally + /// (along the vertical axis). + /// @param flipped A bool with the new value. void SetHFlipped(const bool flipped) override { m_HFlipped = flipped; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: SetRotAngle - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the current absolute angle of rotation of this MovableObject. - // Arguments: The new absolute angle in radians. - // Return value: None. - + /// Sets the current absolute angle of rotation of this MovableObject. + /// @param m_Rotation.SetRadAngle(newAngle The new absolute angle in radians. void SetRotAngle(float newAngle) override { m_Rotation.SetRadAngle(newAngle); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: SetAngularVel - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the current angular velocity of this MovableObject. Positive is - // a counter clockwise rotation. - // Arguments: The new angular velocity in radians per second. - // Return value: None. - + /// Sets the current angular velocity of this MovableObject. Positive is + /// a counter clockwise rotation. + /// @param newRotVel The new angular velocity in radians per second. void SetAngularVel(float newRotVel) override { m_AngularVel = newRotVel; } - /// /// Gets the GUI representation of this MOSprite, either based on the first frame of its sprite or separately defined icon file. - /// - /// The graphical representation of this MOSprite as a BITMAP. + /// @return The graphical representation of this MOSprite as a BITMAP. BITMAP* GetGraphicalIcon() const override { return m_GraphicalIcon != nullptr ? m_GraphicalIcon : m_aSprite[0]; } - /// /// Gets the width of this MOSprite's GUI icon. - /// - /// The width of the GUI icon bitmap. + /// @return The width of the GUI icon bitmap. int GetIconWidth() const { return GetGraphicalIcon()->w; } - /// /// Gets the height of this MOSprite's GUI icon. - /// - /// The height of the GUI icon bitmap. + /// @return The height of the GUI icon bitmap. int GetIconHeight() const { return GetGraphicalIcon()->h; } - /// /// Forces this MOSprite out of resting conditions. - /// void NotResting() override { MovableObject::NotResting(); m_AngOscillations = 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: IsTooFast - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Indicates whether this MO is moving or rotating stupidly fast in a way - // that will screw up the simulation. - // Arguments: None. - // Return value: Whether this is either moving or rotating too fast. - + /// Indicates whether this MO is moving or rotating stupidly fast in a way + /// that will screw up the simulation. + /// @return Whether this is either moving or rotating too fast. bool IsTooFast() const override { return m_Vel.MagnitudeIsGreaterThan(500.0F) || std::fabs(m_AngularVel) > (2000.0F / (GetRadius() + 1.0F)); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: FixTooFast - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Slows the speed of anything that is deemed to be too fast to within - // acceptable rates. - // Arguments: None. - // Return value: None. - + /// Slows the speed of anything that is deemed to be too fast to within + /// acceptable rates. void FixTooFast() override { while (IsTooFast()) { m_Vel *= 0.5F; @@ -401,134 +220,72 @@ namespace RTE { } } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: IsOnScenePoint - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Indicates whether this' current graphical representation overlaps - // a point in absolute scene coordinates. - // Arguments: The point in absolute scene coordinates. - // Return value: Whether this' graphical rep overlaps the scene point. - + /// Indicates whether this' current graphical representation overlaps + /// a point in absolute scene coordinates. + /// @param scenePoint The point in absolute scene coordinates. + /// @return Whether this' graphical rep overlaps the scene point. bool IsOnScenePoint(Vector& scenePoint) const override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: RotateOffset - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Takes a vector which is offset from the center of this when not rotated - // or flipped, and then rotates and/or flips it to transform it into this' - // 'local space', if applicable. - // Arguments: A vector which is supposed to be offset from this' center when upright. - // Return value: The resulting vector whihch has been flipped and rotated as appropriate. - + /// Takes a vector which is offset from the center of this when not rotated + /// or flipped, and then rotates and/or flips it to transform it into this' + /// 'local space', if applicable. + /// @param offset A vector which is supposed to be offset from this' center when upright. + /// @return The resulting vector whihch has been flipped and rotated as appropriate. Vector RotateOffset(const Vector& offset) const override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: UnRotateOffset - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Takes a vector which is offset from the center of this when not rotated - // or flipped, and then rotates and/or flips it to transform it into this' - // 'local space', but in REVERSE. - // Arguments: A vector which is supposed to be offset from this' center when upright. - // Return value: The resulting vector whihch has been flipped and rotated as appropriate. - + /// Takes a vector which is offset from the center of this when not rotated + /// or flipped, and then rotates and/or flips it to transform it into this' + /// 'local space', but in REVERSE. + /// @param offset A vector which is supposed to be offset from this' center when upright. + /// @return The resulting vector whihch has been flipped and rotated as appropriate. Vector UnRotateOffset(const Vector& offset) const; - /// /// Adjusts an absolute angle based on wether this MOSprite is flipped. - /// - /// The input angle in radians. - /// The output angle in radians, which will be unaltered if this MOSprite is not flipped. + /// @param angle The input angle in radians. + /// @return The output angle in radians, which will be unaltered if this MOSprite is not flipped. float FacingAngle(float angle) const { return (m_HFlipped ? c_PI : 0) + (angle * GetFlipFactor()); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: SetEntryWound - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets entry wound emitter for this MOSprite - // Arguments: Emitter preset name and module name - // Return value: None - + /// Sets entry wound emitter for this MOSprite + /// @param presetName Emitter preset name and module name void SetEntryWound(std::string presetName, std::string moduleName); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: SetExitWound - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets exit wound emitter for this MOSprite - // Arguments: Emitter preset name and module name - // Return value: None - + /// Sets exit wound emitter for this MOSprite + /// @param presetName Emitter preset name and module name void SetExitWound(std::string presetName, std::string moduleName); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: GetEntryWoundPresetName - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns entry wound emitter preset name for this MOSprite - // Arguments: None - // Return value: Wound emitter preset name - + /// Returns entry wound emitter preset name for this MOSprite + /// @return Wound emitter preset name std::string GetEntryWoundPresetName() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: GetExitWoundPresetName - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns exit wound emitter preset name for this MOSprite - // Arguments: None - // Return value: Wound emitter preset name - + /// Returns exit wound emitter preset name for this MOSprite + /// @return Wound emitter preset name std::string GetExitWoundPresetName() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: GetSpriteAnimDuration - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns animation duration in ms - // Arguments: None - // Return value: Animation duration in ms - + /// Returns animation duration in ms + /// @return Animation duration in ms int GetSpriteAnimDuration() const { return m_SpriteAnimDuration; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: SetSpriteAnimDuration - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets animation duration in ms - // Arguments: Animation duration in ms - // Return value: Mone - + /// Sets animation duration in ms + /// @param newDuration Animation duration in ms void SetSpriteAnimDuration(int newDuration) { m_SpriteAnimDuration = newDuration; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Update - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates this MovableObject. Supposed to be done every frame. - // Arguments: None. - // Return value: None. - + /// Updates this MovableObject. Supposed to be done every frame. void Update() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Draw - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws this MOSprite's current graphical representation to a - // BITMAP of choice. - // Arguments: A pointer to a BITMAP to draw on. - // The absolute position of the target bitmap's upper left corner in the Scene. - // In which mode to draw in. See the DrawMode enumeration for the modes. - // Whether to not draw any extra 'ghost' items of this MovableObject, - // indicator arrows or hovering HUD text and so on. - // Return value: None. - + /// Draws this MOSprite's current graphical representation to a + /// BITMAP of choice. + /// @param pTargetBitmap A pointer to a BITMAP to draw on. + /// @param targetPos The absolute position of the target bitmap's upper left corner in the Scene. (default: Vector()) + /// @param mode In which mode to draw in. See the DrawMode enumeration for the modes. (default: g_DrawColor) + /// @param onlyPhysical Whether to not draw any extra 'ghost' items of this MovableObject, (default: false) + /// indicator arrows or hovering HUD text and so on. void Draw(BITMAP* pTargetBitmap, const Vector& targetPos = Vector(), DrawMode mode = g_DrawColor, bool onlyPhysical = false) const override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: GetFlipFactor - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns a positive or negative number value to multiply with for external calculations. - // Arguments: None. - // Return value: 1 for not flipped, -1 for flipped. - + /// Returns a positive or negative number value to multiply with for external calculations. + /// @return 1 for not flipped, -1 for flipped. float GetFlipFactor() const { return m_HFlipped ? -1.0F : 1.0F; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Protected member variable and method declarations - + /// Protected member variable and method declarations protected: // Member variables static Entity::ClassInfo m_sClass; @@ -568,18 +325,10 @@ namespace RTE { // Exit wound template const AEmitter* m_pExitWound; - ////////////////////////////////////////////////////////////////////////////////////////// - // Private member variable and method declarations - + /// Private member variable and method declarations private: - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Clear - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears all the member variables of this MOSprite, effectively - // resetting the members of this abstraction level only. - // Arguments: None. - // Return value: None. - + /// Clears all the member variables of this MOSprite, effectively + /// resetting the members of this abstraction level only. void Clear(); // Disallow the use of some implicit methods. diff --git a/Source/Entities/Magazine.cpp b/Source/Entities/Magazine.cpp index 1001c97344..cbe72f7eb9 100644 --- a/Source/Entities/Magazine.cpp +++ b/Source/Entities/Magazine.cpp @@ -1,15 +1,3 @@ -////////////////////////////////////////////////////////////////////////////////////////// -// File: Magazine.cpp -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Source file for the Magazine class. -// Project: Retro Terrain Engine -// Author(s): Daniel Tabar -// data@datarealms.com -// http://www.datarealms.com - -////////////////////////////////////////////////////////////////////////////////////////// -// Inclusions of header files - #include "Magazine.h" #include "PresetMan.h" #include "AEmitter.h" @@ -18,12 +6,6 @@ namespace RTE { ConcreteClassInfo(Magazine, Attachable, 50); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Clear - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears all the member variables of this Magazine, effectively - // resetting the members of this abstraction level only. - void Magazine::Clear() { m_RoundCount = 0; m_FullCapacity = 0; @@ -40,11 +22,6 @@ namespace RTE { m_CollidesWithTerrainWhileAttached = false; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes the Magazine object ready for use. - int Magazine::Create() { if (Attachable::Create() < 0) return -1; @@ -72,11 +49,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Creates a Magazine to be identical to another, by deep copy. - int Magazine::Create(const Magazine& reference) { Attachable::Create(reference); @@ -93,14 +65,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: ReadProperty - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Reads a property value from a reader stream. If the name isn't - // recognized by this class, then ReadProperty of the parent class - // is called. If the property isn't recognized by any of the base classes, - // false is returned, and the reader's position is untouched. - int Magazine::ReadProperty(const std::string_view& propName, Reader& reader) { StartPropertyList(return Attachable::ReadProperty(propName, reader)); @@ -117,12 +81,6 @@ namespace RTE { EndPropertyList; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Save - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Saves the complete state of this Magazine with a Writer for - // later recreation with Create(Reader &reader); - int Magazine::Save(Writer& writer) const { Attachable::Save(writer); @@ -142,11 +100,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destroys and resets (through Clear()) the Magazine object. - void Magazine::Destroy(bool notInherited) { if (!notInherited) @@ -154,12 +107,6 @@ namespace RTE { Clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: GetNextRound - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the next Round preset of ammo in this Magazine, without removing - // it. Ownership IS NOT transferred! - const Round* Magazine::GetNextRound() const { const Round* tempRound = 0; if (m_RoundCount != 0) { @@ -171,12 +118,6 @@ namespace RTE { return tempRound; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: PopNextRound - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the next Round of ammo in this Magazine, and removes it from the - // stack. Ownership IS transferred! - Round* Magazine::PopNextRound() { Round* tempRound = 0; if (m_RoundCount != 0) { @@ -191,11 +132,6 @@ namespace RTE { return tempRound; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: EstimateDigStrength - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Estimates what material strength the rounds in the magazine can destroy. - float Magazine::EstimateDigStrength() const { float maxPenetration = 1; if (m_pTracerRound) { @@ -223,11 +159,6 @@ namespace RTE { return maxPenetration; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetBulletAccScalar - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the bullet acceleration scalar the AI use when aiming this weapon. - float Magazine::GetBulletAccScalar() { const Round* pRound = GetNextRound(); if (pRound) { @@ -239,11 +170,6 @@ namespace RTE { return 1; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Update - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates this Magazine. Supposed to be done every frame. - void Magazine::Update() { Attachable::Update(); diff --git a/Source/Entities/Magazine.h b/Source/Entities/Magazine.h index 07e3362686..6668445d37 100644 --- a/Source/Entities/Magazine.h +++ b/Source/Entities/Magazine.h @@ -1,260 +1,132 @@ #ifndef _RTEMAGAZINE_ #define _RTEMAGAZINE_ -////////////////////////////////////////////////////////////////////////////////////////// -// File: Magazine.h -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Header file for the Magazine class. -// Project: Retro Terrain Engine -// Author(s): Daniel Tabar -// data@datarealms.com -// http://www.datarealms.com - -////////////////////////////////////////////////////////////////////////////////////////// -// Inclusions of header files - +/// Header file for the Magazine class. +/// @author Daniel Tabar +/// data@datarealms.com +/// http://www.datarealms.com +/// Inclusions of header files #include "Attachable.h" #include "Round.h" namespace RTE { - ////////////////////////////////////////////////////////////////////////////////////////// - // Class: Magazine - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: An Attachable ammo magazine that can hold rounds that can be fired - // by HDFirearm:s. - // Parent(s): Attachable. - // Class history: 07/03/2002 Magazine created. - + /// An Attachable ammo magazine that can hold rounds that can be fired + /// by HDFirearm:s. class Magazine : public Attachable { - ////////////////////////////////////////////////////////////////////////////////////////// - // Public member variable, method and friend function declarations - + /// Public member variable, method and friend function declarations public: // Concrete allocation and cloning definitions EntityAllocation(Magazine); SerializableOverrideMethods; ClassInfoGetters; - ////////////////////////////////////////////////////////////////////////////////////////// - // Constructor: Magazine - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Constructor method used to instantiate a Magazine object in system - // memory. Create() should be called before using the object. - // Arguments: None. - + /// Constructor method used to instantiate a Magazine object in system + /// memory. Create() should be called before using the object. Magazine() { Clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Destructor: ~Magazine - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destructor method used to clean up a Magazine object before deletion - // from system memory. - // Arguments: None. - + /// Destructor method used to clean up a Magazine object before deletion + /// from system memory. ~Magazine() override { Destroy(true); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes the Magazine object ready for use. - // Arguments: None. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Makes the Magazine object ready for use. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Create() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Creates a Magazine to be identical to another, by deep copy. - // Arguments: A reference to the Magazine to deep copy. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Creates a Magazine to be identical to another, by deep copy. + /// @param reference A reference to the Magazine to deep copy. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Create(const Magazine& reference); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Reset - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Resets the entire Magazine, including its inherited members, to their - // default settings or values. - // Arguments: None. - // Return value: None. - + /// Resets the entire Magazine, including its inherited members, to their + /// default settings or values. void Reset() override { Clear(); Attachable::Reset(); m_CollidesWithTerrainWhileAttached = false; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destroys and resets (through Clear()) the SceneLayer object. - // Arguments: Whether to only destroy the members defined in this derived class, or - // to destroy all inherited members also. - // Return value: None. - + /// Destroys and resets (through Clear()) the SceneLayer object. + /// @param notInherited Whether to only destroy the members defined in this derived class, or (default: false) + /// to destroy all inherited members also. void Destroy(bool notInherited = false) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: GetNextRound - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the next Round preset of ammo in this Magazine, without removing - // it. Ownership IS NOT transferred! - // Arguments: None. - // Return value: A pointer to the next Round preset of ammo, or 0 if this Magazine is empty. - + /// Gets the next Round preset of ammo in this Magazine, without removing + /// it. Ownership IS NOT transferred! + /// @return A pointer to the next Round preset of ammo, or 0 if this Magazine is empty. const Round* GetNextRound() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: PopNextRound - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the next Round of ammo in this Magazine, and removes it from the - // stack. Ownership IS transferred! - // Arguments: None. - // Return value: A pointer to the next Round of ammo, or 0 if this Magazine is empty. - + /// Gets the next Round of ammo in this Magazine, and removes it from the + /// stack. Ownership IS transferred! + /// @return A pointer to the next Round of ammo, or 0 if this Magazine is empty. Round* PopNextRound(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetRoundCount - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns how many rounds are left in this Magazine. - // Arguments: None. - // Return value: The number of rounds left. Negative value means infinite ammo left! - + /// Returns how many rounds are left in this Magazine. + /// @return The number of rounds left. Negative value means infinite ammo left! int GetRoundCount() const { return m_RoundCount; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetRoundCount - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets how many rounds are left in this Magazine. - // Arguments: The new number of rounds left. Negative value means infinite ammo! - // Return value: None. - + /// Sets how many rounds are left in this Magazine. + /// @param newCount The new number of rounds left. Negative value means infinite ammo! void SetRoundCount(int newCount) { m_RoundCount = newCount; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: IsEmpty - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns whether this Magazine is out of rounds. - // Arguments: None. - // Return value: Whether this Magazine is out of rounds or not. - + /// Returns whether this Magazine is out of rounds. + /// @return Whether this Magazine is out of rounds or not. bool IsEmpty() const { return m_FullCapacity >= 0 && m_RoundCount == 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: IsFull - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns whether this Magazine has not used up any rounds yet. - // Arguments: None. - // Return value: Whether this Magazine has not used any rounds yet. - + /// Returns whether this Magazine has not used up any rounds yet. + /// @return Whether this Magazine has not used any rounds yet. bool IsFull() const { return m_FullCapacity > 0 ? (m_RoundCount == m_FullCapacity || m_RoundCount < 0) : m_FullCapacity < 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: IsOverHalfFull - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns whether this Magazine has not used up half of the rounds yet. - // Arguments: None. - // Return value: Whether this Magazine has not used half of its rounds yet. - + /// Returns whether this Magazine has not used up half of the rounds yet. + /// @return Whether this Magazine has not used half of its rounds yet. bool IsOverHalfFull() const { return m_FullCapacity > 0 ? ((m_RoundCount > (m_FullCapacity / 2)) || m_RoundCount < 0) : m_FullCapacity < 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetCapacity - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns teh number of rounds this can hold when it's full. - // Arguments: None. - // Return value: The number of rounds this can hold. Negative value means infinite ammo. - + /// Returns teh number of rounds this can hold when it's full. + /// @return The number of rounds this can hold. Negative value means infinite ammo. int GetCapacity() const { return m_FullCapacity; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: IsDiscardable - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Whether this Magazine should be released into the scene when discarded - // or just deleted. - // Arguments: None. - // Return value: Whether this Magazine should be relesed into scene or deleted when released. - + /// Whether this Magazine should be released into the scene when discarded + /// or just deleted. + /// @return Whether this Magazine should be relesed into scene or deleted when released. bool IsDiscardable() const { return m_Discardable; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: EstimateDigStrength - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Estimates what material strength the rounds in the magazine can destroy. - // Arguments: None. - // Return value: The material strength. - + /// Estimates what material strength the rounds in the magazine can destroy. + /// @return The material strength. float EstimateDigStrength() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetAimVel - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Tells the AI what muzzle velocity to assume when aiming this weapon. - // Arguments: None. - // Return value: Velocity in m/s. - + /// Tells the AI what muzzle velocity to assume when aiming this weapon. + /// @return Velocity in m/s. float GetAIAimVel() const { return m_AIAimVel; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetAIAimBlastRadius - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Tells the AI what distance in pixels from the rounds in this mag round - // are mostly safe. - // Arguments: None. - // Return value: Distance in pixels. - + /// Tells the AI what distance in pixels from the rounds in this mag round + /// are mostly safe. + /// @return Distance in pixels. int GetAIAimBlastRadius() const { return m_AIBlastRadius; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetAIAimPenetration - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Tells the AI how much material this projectile can penetrate. - // Arguments: None. - // Return value: The material strenght. - + /// Tells the AI how much material this projectile can penetrate. + /// @return The material strenght. float GetAIAimPenetration() const { return m_AIAimPenetration; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetBulletAccScalar - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the bullet acceleration scalar the AI use when aiming this weapon. - // Arguments: None. - // Return value: A float with the scalar. - + /// Gets the bullet acceleration scalar the AI use when aiming this weapon. + /// @return A float with the scalar. float GetBulletAccScalar(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Update - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates this MovableObject. Supposed to be done every frame. - // Arguments: None. - // Return value: None. - + /// Updates this MovableObject. Supposed to be done every frame. void Update() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Draw - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws this Magazine's current graphical representation to a - // BITMAP of choice. - // Arguments: A pointer to a BITMAP to draw on. - // The absolute position of the target bitmap's upper left corner in the Scene. - // In which mode to draw in. See the DrawMode enumeration for the modes. - // Whether to not draw any extra 'ghost' items of this MovableObject, - // indicator arrows or hovering HUD text and so on. - // Return value: None. - + /// Draws this Magazine's current graphical representation to a + /// BITMAP of choice. + /// @param pTargetBitmap A pointer to a BITMAP to draw on. + /// @param targetPos The absolute position of the target bitmap's upper left corner in the Scene. (default: Vector()) + /// @param mode In which mode to draw in. See the DrawMode enumeration for the modes. (default: g_DrawColor) + /// @param onlyPhysical Whether to not draw any extra 'ghost' items of this MovableObject, (default: false) + /// indicator arrows or hovering HUD text and so on. void Draw(BITMAP* pTargetBitmap, const Vector& targetPos = Vector(), DrawMode mode = g_DrawColor, bool onlyPhysical = false) const override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Protected member variable and method declarations - + /// Protected member variable and method declarations protected: // Member variables static Entity::ClassInfo m_sClass; @@ -280,18 +152,10 @@ namespace RTE { // Tells the AI what distance in pixels from this round is mostly safe. int m_AIBlastRadius; - ////////////////////////////////////////////////////////////////////////////////////////// - // Private member variable and method declarations - + /// Private member variable and method declarations private: - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Clear - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears all the member variables of this Magazine, effectively - // resetting the members of this abstraction level only. - // Arguments: None. - // Return value: None. - + /// Clears all the member variables of this Magazine, effectively + /// resetting the members of this abstraction level only. void Clear(); // Disallow the use of some implicit methods. diff --git a/Source/Entities/Material.cpp b/Source/Entities/Material.cpp index 0af3300309..7fa649ac08 100644 --- a/Source/Entities/Material.cpp +++ b/Source/Entities/Material.cpp @@ -5,8 +5,6 @@ namespace RTE { ConcreteClassInfo(Material, Entity, 0); - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void Material::Clear() { m_Index = 0; m_Priority = -1; @@ -30,8 +28,6 @@ namespace RTE { m_TerrainBGTexture = nullptr; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int Material::Create(const Material& reference) { Entity::Create(reference); @@ -59,8 +55,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int Material::ReadProperty(const std::string_view& propName, Reader& reader) { StartPropertyList(return Entity::ReadProperty(propName, reader)); @@ -106,8 +100,6 @@ namespace RTE { EndPropertyList; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int Material::Save(Writer& writer) const { Entity::Save(writer); // Materials should never be altered, so no point in saving additional properties when it's a copy diff --git a/Source/Entities/Material.h b/Source/Entities/Material.h index 6e37a692af..9cf8bde994 100644 --- a/Source/Entities/Material.h +++ b/Source/Entities/Material.h @@ -7,9 +7,7 @@ namespace RTE { - /// /// Represents a material and holds all the relevant data. - /// class Material : public Entity { public: @@ -18,15 +16,11 @@ namespace RTE { ClassInfoGetters; #pragma region Creation - /// /// Constructor method used to instantiate a Material object in system memory. Create() should be called before using the object. - /// Material() { Clear(); } - /// /// Copy constructor method used to instantiate a Material object identical to an already existing one. - /// - /// A Material object which is passed in by reference. + /// @param reference A Material object which is passed in by reference. Material(const Material& reference) { if (this != &reference) { Clear(); @@ -34,18 +28,14 @@ namespace RTE { } } - /// /// Creates a Material to be identical to another, by deep copy. - /// - /// A reference to the Material to deep copy. - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @param reference A reference to the Material to deep copy. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create(const Material& reference); #pragma endregion #pragma region Destruction - /// /// Resets the entire Material, including its inherited members, to it's default settings or values. - /// void Reset() override { Clear(); Entity::Reset(); @@ -53,115 +43,79 @@ namespace RTE { #pragma endregion #pragma region Getters and Setters - /// /// Gets the foreground texture bitmap of this Material, if any is associated with it. - /// - /// Pointer to the foreground texture bitmap of this Material. + /// @return Pointer to the foreground texture bitmap of this Material. BITMAP* GetFGTexture() const { return m_TerrainFGTexture; } - /// /// Gets the background texture bitmap of this Material, if any is associated with it. - /// - /// Pointer to the background texture bitmap of this Material. + /// @return Pointer to the background texture bitmap of this Material. BITMAP* GetBGTexture() const { return m_TerrainBGTexture; } - /// /// Gets the index of this Material in the material palette. - /// - /// The index of this Material in the material palette. 0 - 255. + /// @return The index of this Material in the material palette. 0 - 255. unsigned char GetIndex() const { return m_Index; } - /// /// Sets the index of this Material in the material palette to the next specified value. - /// - /// The new index of this Material in the material palette. 0 - 255. + /// @param newIndex The new index of this Material in the material palette. 0 - 255. void SetIndex(unsigned char newIndex) { m_Index = newIndex; } - /// /// Gets the drawing priority of this Material. The higher the number, the higher chances that a pixel of this material will be drawn on top of others. Will default to Integrity if no Priority has been defined. - /// - /// The drawing priority of this Material. + /// @return The drawing priority of this Material. int GetPriority() const { return m_Priority < 0 ? static_cast(std::ceil(m_Integrity)) : m_Priority; } - /// /// Gets the amount of times a dislodged pixel of this Material will attempt to relocate to an open position. - /// - /// The amount of attempts at relocating. + /// @return The amount of attempts at relocating. int GetPiling() const { return m_Piling; } - /// /// The impulse force that a particle needs to knock loose a terrain pixel of this material. In kg * m/s. - /// - /// The impulse force that a particle needs to knock loose a terrain pixel of this material. + /// @return The impulse force that a particle needs to knock loose a terrain pixel of this material. float GetIntegrity() const { return m_Integrity; } - /// /// Gets the scalar value that defines the restitution of this Material. 1.0 = no kinetic energy is lost in a collision, 0.0 = all energy is lost (plastic). - /// - /// A float scalar value that defines the restitution of this Material. + /// @return A float scalar value that defines the restitution of this Material. float GetRestitution() const { return m_Restitution; } - /// /// Gets the scalar value that defines the friction of this Material. 1.0 = will snag onto everything, 0.0 = will glide with no friction. - /// - /// A float scalar value that defines the friction of this Material. + /// @return A float scalar value that defines the friction of this Material. float GetFriction() const { return m_Friction; } - /// /// Gets the scalar value that defines the stickiness of this Material. 1.0 = will stick to everything, 0.0 = will never stick to anything. - /// - /// A float scalar value that defines the stickiness of this Material. + /// @return A float scalar value that defines the stickiness of this Material. float GetStickiness() const { return m_Stickiness; } - /// /// Gets the density of this Material in Kg/L. - /// - /// The density of this Material. + /// @return The density of this Material. float GetVolumeDensity() const { return m_VolumeDensity; } - /// /// Gets the density of this Material in kg/pixel, usually calculated from the KG per Volume L property. - /// - /// The pixel density of this Material. + /// @return The pixel density of this Material. float GetPixelDensity() const { return m_PixelDensity; } - /// /// If this material transforms into something else when settling into the terrain, this will return that different material index. If not, it will just return the regular index of this material. - /// - /// The settling material index of this or the regular index. + /// @return The settling material index of this or the regular index. unsigned char GetSettleMaterial() const { return (m_SettleMaterialIndex != 0) ? m_SettleMaterialIndex : m_Index; } - /// /// Gets the material index to spawn instead of this one for special effects. - /// - /// The material index to spawn instead of this one for special effects. 0 means to spawn the same material as this. + /// @return The material index to spawn instead of this one for special effects. 0 means to spawn the same material as this. unsigned char GetSpawnMaterial() const { return m_SpawnMaterialIndex; } - /// /// Whether this material is scrap material made from gibs of things that have already been blown apart. - /// - /// Whether this material is scrap material. + /// @return Whether this material is scrap material. bool IsScrap() const { return m_IsScrap; } - /// /// Gets the Color of this Material. - /// - /// The color of this material. + /// @return The color of this material. Color GetColor() const { return m_Color; } - /// /// Indicates whether or not to use the Material's own color when a pixel of this Material is knocked loose from the terrain. - /// - /// Whether the Material's color, or the terrain pixel's color should be applied. + /// @return Whether the Material's color, or the terrain pixel's color should be applied. bool UsesOwnColor() const { return m_UseOwnColor; } #pragma endregion #pragma region Operator Overloads - /// /// An assignment operator for setting one Material equal to another. - /// - /// A Material reference. - /// A reference to the changed Material. + /// @param rhs A Material reference. + /// @return A reference to the changed Material. Material& operator=(const Material& rhs) { if (this != &rhs) { Destroy(); @@ -203,9 +157,7 @@ namespace RTE { BITMAP* m_TerrainBGTexture; //!< The background texture of this Material, used when building an SLTerrain. Not owned. private: - /// /// Clears all the member variables of this Material, effectively resetting the members of this abstraction level only. - /// void Clear(); }; } // namespace RTE diff --git a/Source/Entities/MetaPlayer.cpp b/Source/Entities/MetaPlayer.cpp index 9213499cb5..bf6fd59ae7 100644 --- a/Source/Entities/MetaPlayer.cpp +++ b/Source/Entities/MetaPlayer.cpp @@ -7,8 +7,6 @@ namespace RTE { ConcreteClassInfo(MetaPlayer, Entity, 0); - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void MetaPlayer::Clear() { m_Name = ""; m_Team = Activity::NoTeam; @@ -30,8 +28,6 @@ namespace RTE { m_OffensiveTarget = ""; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int MetaPlayer::Create(const MetaPlayer& reference) { Entity::Create(reference); @@ -54,8 +50,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int MetaPlayer::ReadProperty(const std::string_view& propName, Reader& reader) { StartPropertyList(return Entity::ReadProperty(propName, reader)); @@ -85,8 +79,6 @@ namespace RTE { EndPropertyList; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int MetaPlayer::Save(Writer& writer) const { Entity::Save(writer); diff --git a/Source/Entities/MetaPlayer.h b/Source/Entities/MetaPlayer.h index 54f7d6f110..f9eaf58602 100644 --- a/Source/Entities/MetaPlayer.h +++ b/Source/Entities/MetaPlayer.h @@ -5,9 +5,7 @@ namespace RTE { - /// /// Holds data for a Metagame player aka "Tech" or "House". - /// class MetaPlayer : public Entity { friend class MetagameGUI; @@ -17,15 +15,11 @@ namespace RTE { ClassInfoGetters; #pragma region Creation - /// /// Constructor method used to instantiate a MetaPlayer object in system memory. Create() should be called before using the object. - /// MetaPlayer() { Clear(); } - /// /// Copy constructor method used to instantiate a MetaPlayer object identical to an already existing one. - /// - /// A MetaPlayer object which is passed in by reference. + /// @param reference A MetaPlayer object which is passed in by reference. MetaPlayer(const MetaPlayer& reference) { if (this != &reference) { Clear(); @@ -33,30 +27,22 @@ namespace RTE { } } - /// /// Makes the MetaPlayer object ready for use. - /// - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create() override { return Entity::Create(); } - /// /// Creates a MetaPlayer to be identical to another, by deep copy. - /// - /// A reference to the MetaPlayer to deep copy. - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @param reference A reference to the MetaPlayer to deep copy. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create(const MetaPlayer& reference); #pragma endregion #pragma region Destruction - /// /// Destructor method used to clean up a MetaPlayer object before deletion from system memory. - /// ~MetaPlayer() override { Destroy(true); } - /// /// Destroys and resets (through Clear()) the MetaPlayer object. - /// - /// Whether to only destroy the members defined in this derived class, or to destroy all inherited members also. + /// @param notInherited Whether to only destroy the members defined in this derived class, or to destroy all inherited members also. void Destroy(bool notInherited = false) override { if (!notInherited) { Entity::Destroy(); @@ -64,9 +50,7 @@ namespace RTE { Clear(); } - /// /// Resets the entire MetaPlayer, including its inherited members, to their default settings or values. - /// void Reset() override { Clear(); Entity::Reset(); @@ -74,207 +58,145 @@ namespace RTE { #pragma endregion #pragma region Getters and Setters - /// /// Gets the name of the MetaPlayer. - /// - /// The name of the player. + /// @return The name of the player. std::string GetName() const { return m_Name; } - /// /// Sets the name of the MetaPlayer. - /// - /// The new name to set. + /// @param newName The new name to set. void SetName(std::string newName) { m_Name = newName; } - /// /// Gets the Team of this MetaPlayer. - /// - /// The Team of this player. + /// @return The Team of this player. int GetTeam() const { return m_Team; } - /// /// Sets the Team of the MetaPlayer. - /// - /// The new team to set. + /// @param newTeam The new team to set. void SetTeam(int newTeam) { m_Team = newTeam; } - /// /// Indicates whether this MetaPlayer is human controlled or not (AI). - /// - /// Whether this player is human controlled. + /// @return Whether this player is human controlled. bool IsHuman() const { return m_Human; } - /// /// Sets whether this MetaPlayer is human controlled or not (AI). - /// - /// Whether this MetaPlayer is human controlled or not. + /// @param human Whether this MetaPlayer is human controlled or not. void SetHuman(bool human) { m_Human = human; } - /// /// Shows which in-game player controls this MetaPlayer is mapped to. - /// - /// The in-game player number this is mapped to. + /// @return The in-game player number this is mapped to. int GetInGamePlayer() const { return m_InGamePlayer; } - /// /// Gets ID of the DataModule that this MetaPlayer is native to. - /// - /// The ID of the DataModule this is native to. + /// @return The ID of the DataModule this is native to. int GetNativeTechModule() const { return m_NativeTechModule; } - /// /// Gets the normalized aggressiveness scalar of this player if an AI. - /// - /// The current aggressiveness scalar, 0 min to 1.0 max. + /// @return The current aggressiveness scalar, 0 min to 1.0 max. float GetAggressiveness() const { return m_Aggressiveness; } - /// /// Sets the normalized aggressiveness scalar of this player if an AI. - /// - /// The new aggressiveness scalar, 0 min to 1.0 max. + /// @param aggressiveness The new aggressiveness scalar, 0 min to 1.0 max. void SetAggressiveness(float aggressiveness) { m_Aggressiveness = aggressiveness; } - /// /// Indicates which round this MetaPlayer made it to. If negative, he is still in the game. - /// - /// Which round the MetaPlayer made it to. + /// @return Which round the MetaPlayer made it to. int GetGameOverRound() const { return m_GameOverRound; } - /// /// Sets which round this MetaPlayer lost out on. If set to negative, it means he's still in the game. - /// - /// The round the MetaPlayer lost out on. + /// @param gameOverRound The round the MetaPlayer lost out on. void SetGameOverRound(int gameOverRound) { m_GameOverRound = gameOverRound; } - /// /// Tells whether this MetaPlayer is out of the game on or before a particular round of the current metagame. - /// - /// Which round to check against. - /// Whether the MetaPlayer was flagged as being out of the game on that or any earlier round. + /// @param whichRound Which round to check against. + /// @return Whether the MetaPlayer was flagged as being out of the game on that or any earlier round. bool IsGameOverByRound(int whichRound) const { return m_GameOverRound >= 0 && m_GameOverRound <= whichRound; } - /// /// Gets the name of the scene this MetaPlayer is targeting for offensive. - /// - /// The name of the Scene this MetaPlayer is targeting. + /// @return The name of the Scene this MetaPlayer is targeting. std::string GetOffensiveTargetName() const { return m_OffensiveTarget; } - /// /// Sets the name of the scene this MetaPlayer is targeting for offensive. - /// - /// The name of the Scene this MetaPlayer is targeting. + /// @param targetName The name of the Scene this MetaPlayer is targeting. void SetOffensiveTargetName(std::string targetName) { m_OffensiveTarget = targetName; } #pragma endregion #pragma region Funds and Costs - /// /// Gets the amount of funds this MetaPlayer currently has in the game. - /// - /// A float with the funds tally for the requested MetaPlayer. + /// @return A float with the funds tally for the requested MetaPlayer. float GetFunds() const { return m_Funds; } - /// /// Sets the amount of funds this MetaPlayer currently has in the game. - /// - /// The new funds value for this MetaPlayer. + /// @param newFunds The new funds value for this MetaPlayer. void SetFunds(float newFunds) { m_Funds = newFunds; } - /// /// Changes this MetaPlayer's funds level by a certain amount. - /// - /// The amount with which to change the funds balance. - /// The new amount of funds of this MetaPlayer. + /// @param howMuch The amount with which to change the funds balance. + /// @return The new amount of funds of this MetaPlayer. float ChangeFunds(float howMuch) { return m_Funds += howMuch; } - /// /// Decreases this player's funds level by a certain absolute amount, and returns that difference as a positive value. /// If the amount isn't available to spend in the funds, the rest of the funds are spent and only that amount is returned. - /// - /// The amount with which to change the funds balance. This should be a positive value to decrease the funds amount. - /// The amount of funds that were spent. + /// @param howMuch The amount with which to change the funds balance. This should be a positive value to decrease the funds amount. + /// @return The amount of funds that were spent. float SpendFunds(float howMuch) { howMuch = std::min(m_Funds, howMuch); m_Funds -= howMuch; return howMuch; } - /// /// Gets the offensive budget of this MetaPlayer for this round, in oz. - /// - /// The offensive budget, in oz. + /// @return The offensive budget, in oz. float GetOffensiveBudget() const { return m_OffensiveBudget; } - /// /// Sets the offensive budget of this MetaPlayer for this round, in oz. - /// - /// The new offensive budget, in oz. + /// @param newBudget The new offensive budget, in oz. void SetOffensiveBudget(float newBudget) { m_OffensiveBudget = newBudget; } - /// /// Gets the multiplier of costs of any Tech items foreign to this MetaPlayer. - /// - /// The scalar multiplier of all costs of foreign tech items. + /// @return The scalar multiplier of all costs of foreign tech items. float GetForeignCostMultiplier() const { return m_ForeignCostMult; } - /// /// Gets the multiplier of costs of any Tech items native to this MetaPlayer. - /// - /// The scalar multiplier of all costs of native tech items. + /// @return The scalar multiplier of all costs of native tech items. float GetNativeCostMultiplier() const { return m_NativeCostMult; } - /// /// Sets the multiplier of costs of any Tech items native to this MetaPlayer. - /// - /// The scalar multiplier of all costs of native tech items. + /// @param newNativeCostMult The scalar multiplier of all costs of native tech items. void SetNativeCostMultiplier(float newNativeCostMult) { m_NativeCostMult = newNativeCostMult; } #pragma endregion #pragma region Brain Pool - /// /// Gets the number of brains in this MetaPlayer's brain pool. - /// - /// The number of brains that are available for deployment. + /// @return The number of brains that are available for deployment. int GetBrainPoolCount() const { return m_BrainPool; } - /// /// Sets the number of brains in this MetaPlayer's brain pool. - /// - /// The number of brains that should be available for deployment. + /// @param brainCount The number of brains that should be available for deployment. void SetBrainPoolCount(int brainCount) { m_BrainPool = brainCount; } - /// /// Alters the number of brains in this MetaPlayer's brain pool. - /// - /// The number of brains to add or remove from the pool. - /// The resulting count after the alteration. + /// @param change The number of brains to add or remove from the pool. + /// @return The resulting count after the alteration. int ChangeBrainPoolCount(int change) { return m_BrainPool += change; } - /// /// Gets the number of brains in this MetaPlayer that are out on the move between the pool and sites. - /// - /// The number of brains that are out in transit. + /// @return The number of brains that are out in transit. int GetBrainsInTransit() const { return m_BrainsInTransit; } - /// /// Sets the number of brains in this MetaPlayer that are out on the move between the pool and sites. - /// - /// The number of brains that are out in transit. + /// @param transitCount The number of brains that are out in transit. void SetBrainsInTransit(int transitCount) { m_BrainsInTransit = transitCount; } - /// /// Alters the number of brains of this MetaPlayer which are traveling. - /// - /// The number of brains to add or remove from transit. - /// The resulting count after the alteration. + /// @param change The number of brains to add or remove from transit. + /// @return The resulting count after the alteration. int ChangeBrainsInTransit(int change) { return m_BrainsInTransit += change; } #pragma endregion #pragma region Operator Overloads - /// /// An assignment operator for setting one MetaPlayer equal to another. - /// - /// A MetaPlayer reference. - /// A reference to the changed MetaPlayer. + /// @param rhs A MetaPlayer reference. + /// @return A reference to the changed MetaPlayer. MetaPlayer& operator=(const MetaPlayer& rhs) { if (this != &rhs) { Destroy(); @@ -310,9 +232,7 @@ namespace RTE { std::string m_OffensiveTarget; //!< Name of the Scene this player is targeting for its offensive this round. private: - /// /// Clears all the member variables of this MetaPlayer, effectively resetting the members of this abstraction level only. - /// void Clear(); }; } // namespace RTE diff --git a/Source/Entities/MetaSave.cpp b/Source/Entities/MetaSave.cpp index 241b246070..83579a890c 100644 --- a/Source/Entities/MetaSave.cpp +++ b/Source/Entities/MetaSave.cpp @@ -7,8 +7,6 @@ namespace RTE { ConcreteClassInfo(MetaSave, Entity, 0); - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void MetaSave::Clear() { m_SavePath.clear(); m_PlayerCount = 0; @@ -17,8 +15,6 @@ namespace RTE { m_SiteCount = 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int MetaSave::Create(std::string savePath) { if (Entity::Create() < 0) { return -1; @@ -37,8 +33,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int MetaSave::Create(const MetaSave& reference) { Entity::Create(reference); @@ -51,8 +45,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int MetaSave::ReadProperty(const std::string_view& propName, Reader& reader) { StartPropertyList(return Entity::ReadProperty(propName, reader)); @@ -65,8 +57,6 @@ namespace RTE { EndPropertyList; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int MetaSave::Save(Writer& writer) const { Entity::Save(writer); diff --git a/Source/Entities/MetaSave.h b/Source/Entities/MetaSave.h index 02b03f97b8..a28da5f8ff 100644 --- a/Source/Entities/MetaSave.h +++ b/Source/Entities/MetaSave.h @@ -5,9 +5,7 @@ namespace RTE { - /// /// A light-weight Entity for storing only the necessary info about how to load an entire MetaMan state from disk. - /// class MetaSave : public Entity { public: @@ -16,36 +14,26 @@ namespace RTE { ClassInfoGetters; #pragma region Creation - /// /// Constructor method used to instantiate a MetaSave object in system memory. Create() should be called before using the object. - /// MetaSave() { Clear(); } - /// /// Makes the MetaSave object ready for use from the currently loaded MetaMan state. - /// - /// The path of the file to where the MetaMan state should be saved. - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @param savePath The path of the file to where the MetaMan state should be saved. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create(std::string savePath); - /// /// Creates a MetaSave to be identical to another, by deep copy. - /// - /// A reference to the MetaSave to deep copy. - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @param reference A reference to the MetaSave to deep copy. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create(const MetaSave& reference); #pragma endregion #pragma region Destruction - /// /// Destructor method used to clean up a MetaSave object before deletion from system memory. - /// ~MetaSave() override { Destroy(true); } - /// /// Destroys and resets (through Clear()) the MetaSave object. - /// - /// Whether to only destroy the members defined in this derived class, or to destroy all inherited members also. + /// @param notInherited Whether to only destroy the members defined in this derived class, or to destroy all inherited members also. void Destroy(bool notInherited = false) override { if (!notInherited) { Entity::Destroy(); @@ -55,34 +43,24 @@ namespace RTE { #pragma endregion #pragma region Getters - /// /// Gets the full path to the ini file that stores the state of the MetaMan this is associated with. - /// - /// The path to the ini with the MetaMan state info. + /// @return The path to the ini with the MetaMan state info. std::string GetSavePath() const { return m_SavePath; } - /// /// Gets the total number of players this game has (including AIs). - /// - /// The player count. + /// @return The player count. int GetPlayerCount() const { return m_PlayerCount; } - /// /// Gets the difficulty for this game. - /// - /// Difficulty setting. + /// @return Difficulty setting. int GetDifficulty() const { return m_Difficulty; } - /// /// Gets the round number that this game is on. - /// - /// The round count. + /// @return The round count. int GetRoundCount() const { return m_RoundCount; } - /// /// Gets the total number of Scenes this game has. - /// - /// The number of Scenes. + /// @return The number of Scenes. int GetSiteCount() const { return m_SiteCount; } #pragma endregion @@ -96,9 +74,7 @@ namespace RTE { int m_SiteCount; //!< The site count of this game. private: - /// /// Clears all the member variables of this MetaSave, effectively resetting the members of this abstraction level only. - /// void Clear(); // Disallow the use of some implicit methods. diff --git a/Source/Entities/MovableObject.cpp b/Source/Entities/MovableObject.cpp index 642f381372..86315d9491 100644 --- a/Source/Entities/MovableObject.cpp +++ b/Source/Entities/MovableObject.cpp @@ -1,15 +1,3 @@ -////////////////////////////////////////////////////////////////////////////////////////// -// File: MovableObject.cpp -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Source file for the MovableObject class. -// Project: Retro Terrain Engine -// Author(s): Daniel Tabar -// data@datarealms.com -// http://www.datarealms.com - -////////////////////////////////////////////////////////////////////////////////////////// -// Inclusions of header files - #include "MovableObject.h" #include "ActivityMan.h" @@ -32,12 +20,6 @@ namespace RTE { std::atomic MovableObject::m_UniqueIDCounter = 1; std::string MovableObject::ms_EmptyString = ""; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Clear - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears all the member variables of this MovableObject, effectively - // resetting the members of this abstraction level only. - void MovableObject::Clear() { m_MOType = TypeGeneric; m_Mass = 0; @@ -140,11 +122,6 @@ namespace RTE { return *m_ThreadedLuaState; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes the MovableObject object ready for use. - int MovableObject::Create() { if (SceneObject::Create() < 0) return -1; @@ -167,11 +144,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes the MovableObject object ready for use. - int MovableObject::Create(const float mass, const Vector& position, const Vector& velocity, @@ -201,11 +173,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Creates a MovableObject to be identical to another, by deep copy. - int MovableObject::Create(const MovableObject& reference) { SceneObject::Create(reference); @@ -289,14 +256,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: ReadProperty - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Reads a property value from a reader stream. If the name isn't - // recognized by this class, then ReadProperty of the parent class - // is called. If the property isn't recognized by any of the base classes, - // false is returned, and the reader's position is untouched. - int MovableObject::ReadProperty(const std::string_view& propName, Reader& reader) { StartPropertyList(return SceneObject::ReadProperty(propName, reader)); @@ -419,12 +378,6 @@ namespace RTE { reader.NextProperty(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Save - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Saves the complete state of this MovableObject to an output stream for - // later recreation with Create(istream &stream); - int MovableObject::Save(Writer& writer) const { SceneObject::Save(writer); // TODO: Make proper save system that knows not to save redundant data! @@ -518,8 +471,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void MovableObject::DestroyScriptState() { if (m_ThreadedLuaState) { std::lock_guard lock(m_ThreadedLuaState->GetMutex()); @@ -535,8 +486,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void MovableObject::Destroy(bool notInherited) { // Unfortunately, shit can still get destroyed at random from Lua states having ownership and their GC deciding to delete it. // This skips the DestroyScriptState call... so there's leftover stale script state that we just can't do shit about. @@ -556,8 +505,6 @@ namespace RTE { Clear(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int MovableObject::LoadScript(const std::string& scriptPath, bool loadAsEnabledScript) { if (scriptPath.empty()) { return -1; @@ -598,8 +545,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int MovableObject::ReloadScripts() { if (m_AllLoadedScripts.empty()) { return 0; @@ -629,8 +574,6 @@ namespace RTE { return status; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int MovableObject::InitializeObjectScripts() { std::lock_guard lock(m_ThreadedLuaState->GetMutex()); m_ScriptObjectName = "_ScriptedObjects[\"" + std::to_string(m_UniqueID) + "\"]"; @@ -648,8 +591,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool MovableObject::EnableOrDisableScript(const std::string& scriptPath, bool enableScript) { if (m_AllLoadedScripts.empty()) { return false; @@ -676,8 +617,6 @@ namespace RTE { return false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void MovableObject::EnableOrDisableAllScripts(bool enableScripts) { for (const auto& [scriptPath, scriptIsEnabled]: m_AllLoadedScripts) { if (enableScripts != scriptIsEnabled) { @@ -686,8 +625,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int MovableObject::RunScriptedFunctionInAppropriateScripts(const std::string& functionName, bool runOnDisabledScripts, bool stopOnError, const std::vector& functionEntityArguments, const std::vector& functionLiteralArguments, const std::vector& functionObjectArguments) { int status = 0; @@ -718,8 +655,6 @@ namespace RTE { return status; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int MovableObject::RunFunctionOfScript(const std::string& scriptPath, const std::string& functionName, const std::vector& functionEntityArguments, const std::vector& functionLiteralArguments) { if (m_AllLoadedScripts.empty() || !ObjectScriptsInitialized()) { return -1; @@ -741,8 +676,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - /* ////////////////////////////////////////////////////////////////////////////////////////// // Constructor: MovableObject @@ -768,24 +701,14 @@ namespace RTE { } } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: GetAltitude - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the altitide of this' pos (or appropriate low point) over the - // terrain, in pixels. - float MovableObject::GetAltitude(int max, int accuracy) { return g_SceneMan.FindAltitude(m_Pos, max, accuracy); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void MovableObject::AddAbsForce(const Vector& force, const Vector& absPos) { m_Forces.push_back(std::make_pair(force, g_SceneMan.ShortestDistance(m_Pos, absPos) * c_MPP)); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void MovableObject::AddAbsImpulseForce(const Vector& impulse, const Vector& absPos) { #ifndef RELEASE_BUILD RTEAssert(impulse.GetLargest() < 500000, "HUEG IMPULSE FORCE"); @@ -794,8 +717,6 @@ namespace RTE { m_ImpulseForces.push_back(std::make_pair(impulse, g_SceneMan.ShortestDistance(m_Pos, absPos) * c_MPP)); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void MovableObject::RestDetection() { // Translational settling detection. if (m_Vel.Dot(m_PrevVel) < 0) { @@ -808,8 +729,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool MovableObject::IsAtRest() { if (m_RestThreshold < 0 || m_PinStrength) { return false; @@ -821,13 +740,6 @@ namespace RTE { } } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: OnMOHit - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Defines what should happen when this MovableObject hits another MO. - // This is called by the owned Atom/AtomGroup of this MovableObject during - // travel. - bool MovableObject::OnMOHit(HitData& hd) { if (hd.RootBody[HITOR] != hd.RootBody[HITEE] && (hd.Body[HITOR] == this || hd.Body[HITEE] == this)) { RunScriptedFunctionInAppropriateScripts("OnCollideWithMO", false, false, {hd.Body[hd.Body[HITOR] == this ? HITEE : HITOR], hd.RootBody[hd.Body[HITOR] == this ? HITEE : HITOR]}); @@ -845,8 +757,6 @@ namespace RTE { RunScriptedFunctionInAppropriateScripts("OnCollideWithTerrain", false, false, {}, {std::to_string(m_TerrainMatHit)}); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - Vector MovableObject::GetTotalForce() { Vector totalForceVector; for (const auto& [force, forceOffset]: m_Forces) { @@ -855,13 +765,6 @@ namespace RTE { return totalForceVector; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: ApplyForces - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gathers and applies the global and accumulated forces. Then it clears - // out the force list.Note that this does NOT apply the accumulated - // impulses (impulse forces)! - void MovableObject::ApplyForces() { // Don't apply forces to pinned objects if (m_PinStrength > 0) { @@ -890,13 +793,6 @@ namespace RTE { m_Forces.clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: ApplyImpulses - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gathers and applies the accumulated impulse forces. Then it clears - // out the impulse list.Note that this does NOT apply the accumulated - // regular forces (non-impulse forces)! - void MovableObject::ApplyImpulses() { // Don't apply forces to pinned objects if (m_PinStrength > 0) { @@ -917,12 +813,6 @@ namespace RTE { m_ImpulseForces.clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: PreTravel - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Does stuff that needs to be done before Travel(). Always call before - // calling Travel. - void MovableObject::PreTravel() { // Temporarily remove the representation of this from the scene MO sampler if (m_GetsHitByMOs) { @@ -943,20 +833,9 @@ namespace RTE { m_ParticleUniqueIDHit = 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Travel - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Travels this MovableObject, using its physical representation. - void MovableObject::Travel() { } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: PostTravel - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Does stuff that needs to be done after Travel(). Always call after - // calling Travel. - void MovableObject::PostTravel() { // Toggle whether this gets hit by other AtomGroup MOs depending on whether it's going slower than a set threshold if (m_IgnoresAGHitsWhenSlowerThan > 0) { @@ -1000,16 +879,12 @@ namespace RTE { m_DistanceTravelled += m_Vel.GetMagnitude() * c_PPM * g_TimerMan.GetDeltaTimeSecs(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void MovableObject::Update() { if (m_RandomizeEffectRotAngleEveryFrame) { m_EffectRotAngle = c_PI * 2.0F * RandomNormalNum(); } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void MovableObject::Draw(BITMAP* targetBitmap, const Vector& targetPos, DrawMode mode, bool onlyPhysical) const { if (mode == g_DrawMOID && m_MOID == g_NoMOID) { return; @@ -1018,8 +893,6 @@ namespace RTE { g_SceneMan.RegisterDrawing(targetBitmap, mode == g_DrawNoMOID ? g_NoMOID : m_MOID, m_Pos - targetPos, 1.0F); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int MovableObject::UpdateScripts() { m_SimUpdatesSinceLastScriptedUpdate++; @@ -1045,8 +918,6 @@ namespace RTE { return status; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - const std::string& MovableObject::GetStringValue(const std::string& key) const { auto itr = m_StringValueMap.find(key); if (itr == m_StringValueMap.end()) { @@ -1056,8 +927,6 @@ namespace RTE { return itr->second; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - std::string MovableObject::GetEncodedStringValue(const std::string& key) const { auto itr = m_StringValueMap.find(key); if (itr == m_StringValueMap.end()) { @@ -1067,8 +936,6 @@ namespace RTE { return base64_decode(itr->second); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - double MovableObject::GetNumberValue(const std::string& key) const { auto itr = m_NumberValueMap.find(key); if (itr == m_NumberValueMap.end()) { @@ -1078,8 +945,6 @@ namespace RTE { return itr->second; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - Entity* MovableObject::GetObjectValue(const std::string& key) const { auto itr = m_ObjectValueMap.find(key); if (itr == m_ObjectValueMap.end()) { @@ -1089,77 +954,50 @@ namespace RTE { return itr->second; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void MovableObject::SetStringValue(const std::string& key, const std::string& value) { m_StringValueMap[key] = value; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void MovableObject::SetEncodedStringValue(const std::string& key, const std::string& value) { m_StringValueMap[key] = base64_encode(value, true); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void MovableObject::SetNumberValue(const std::string& key, double value) { m_NumberValueMap[key] = value; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void MovableObject::SetObjectValue(const std::string& key, Entity* value) { m_ObjectValueMap[key] = value; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void MovableObject::RemoveStringValue(const std::string& key) { m_StringValueMap.erase(key); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void MovableObject::RemoveNumberValue(const std::string& key) { m_NumberValueMap.erase(key); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void MovableObject::RemoveObjectValue(const std::string& key) { m_ObjectValueMap.erase(key); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool MovableObject::StringValueExists(const std::string& key) const { return m_StringValueMap.find(key) != m_StringValueMap.end(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool MovableObject::NumberValueExists(const std::string& key) const { return m_NumberValueMap.find(key) != m_NumberValueMap.end(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool MovableObject::ObjectValueExists(const std::string& key) const { return m_ObjectValueMap.find(key) != m_ObjectValueMap.end(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int MovableObject::WhilePieMenuOpenListener(const PieMenu* pieMenu) { return RunScriptedFunctionInAppropriateScripts("WhilePieMenuOpen", false, false, {pieMenu}); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: UpdateMOID - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates this' and its childrens MOID status. Supposed to be done every frame. - void MovableObject::UpdateMOID(std::vector& MOIDIndex, MOID rootMOID, bool makeNewMOID) { // Register the own MOID RegMOID(MOIDIndex, rootMOID, makeNewMOID); @@ -1171,11 +1009,6 @@ namespace RTE { m_MOIDFootprint = MOIDIndex.size() - m_MOID; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: GetMOIDs - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Puts all MOIDs associated with this MO and all it's descendants into MOIDs vector - void MovableObject::GetMOIDs(std::vector& MOIDs) const { if (m_MOID != g_NoMOID) { MOIDs.push_back(m_MOID); @@ -1200,13 +1033,6 @@ namespace RTE { m_LastCollisionSimFrameNumber = g_MovableMan.GetSimUpdateFrameNumber(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: RegMOID - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes this MO register itself in the MOID register and get ID:s for - // itself and its children for this frame. - // BITMAP of choice. - void MovableObject::RegMOID(std::vector& MOIDIndex, MOID rootMOID, bool makeNewMOID) { if (!makeNewMOID && GetParent()) { m_MOID = GetParent()->GetID(); @@ -1222,8 +1048,6 @@ namespace RTE { m_RootMOID = rootMOID == g_NoMOID ? m_MOID : rootMOID; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool MovableObject::DrawToTerrain(SLTerrain* terrain) { if (!terrain) { return false; diff --git a/Source/Entities/MovableObject.h b/Source/Entities/MovableObject.h index bb4053e201..b30c9cf546 100644 --- a/Source/Entities/MovableObject.h +++ b/Source/Entities/MovableObject.h @@ -1,18 +1,11 @@ #ifndef _RTEMOVABLEOBJECT_ #define _RTEMOVABLEOBJECT_ -////////////////////////////////////////////////////////////////////////////////////////// -// File: MovableObject.h -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Header file for the MovableObject class. -// Project: Retro Terrain Engine -// Author(s): Daniel Tabar -// data@datarealms.com -// http://www.datarealms.com - -////////////////////////////////////////////////////////////////////////////////////////// -// Inclusions of header files, forward declarations, namespace stuff - +/// Header file for the MovableObject class. +/// @author Daniel Tabar +/// data@datarealms.com +/// http://www.datarealms.com +/// Inclusions of header files, forward declarations, namespace stuff #include "SceneObject.h" #include "Vector.h" #include "Matrix.h" @@ -32,21 +25,13 @@ namespace RTE { class SLTerrain; class LuaStateWrapper; - ////////////////////////////////////////////////////////////////////////////////////////// - // Abstract class: MovableObject - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: A movable object with mass. - // Parent(s): SceneObject. - // Class history: 03/18/2001 MovableObject created. - + /// A movable object with mass. class MovableObject : public SceneObject { friend class Atom; friend struct EntityLuaBindings; - ////////////////////////////////////////////////////////////////////////////////////////// - // Public member variable, method and friend function declarations - + /// Public member variable, method and friend function declarations public: ScriptFunctionNames("Create", "Destroy", "Update", "ThreadedUpdate", "SyncedUpdate", "OnScriptDisable", "OnScriptEnable", "OnCollideWithTerrain", "OnCollideWithMO", "WhilePieMenuOpen", "OnSave", "OnMessage", "OnGlobalMessage"); SerializableOverrideMethods; @@ -59,981 +44,539 @@ namespace RTE { TypeThrownDevice }; - ////////////////////////////////////////////////////////////////////////////////////////// - // Constructor: MovableObject - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Constructor method used to instantiate a MovableObject object in system - // memory. Create() should be called before using the object. - // Arguments: None. - + /// Constructor method used to instantiate a MovableObject object in system + /// memory. Create() should be called before using the object. MovableObject() { Clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Destructor: ~MovableObject - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destructor method used to clean up a MovableObject object before deletion - // from system memory. - // Arguments: None. - + /// Destructor method used to clean up a MovableObject object before deletion + /// from system memory. ~MovableObject() override { Destroy(true); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes the MovableObject object ready for use. - // Arguments: None. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Makes the MovableObject object ready for use. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Create() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes the MovableObject object ready for use. - // Arguments: A float specifying the object's mass in Kilograms (kg). - // A Vector specifying the initial position. - // A Vector specifying the initial velocity. - // The rotation angle in r. - // The angular velocity in r/s. - // The amount of time in ms this MovableObject will exist. 0 means unlim. - // Whether or not this MO will collide with other MO's while travelling. - // Whether or not this MO be collided with bt other MO's during their travel. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Makes the MovableObject object ready for use. + /// @param mass A float specifying the object's mass in Kilograms (kg). + /// @param position A Vector specifying the initial position. (default: Vector(0) + /// @param 0) A Vector specifying the initial velocity. + /// @param velocity The rotation angle in r. (default: Vector(0) + /// @param 0) The angular velocity in r/s. + /// @param rotAngle The amount of time in ms this MovableObject will exist. 0 means unlim. (default: 0) + /// @param angleVel Whether or not this MO will collide with other MO's while travelling. (default: 0) + /// @param lifetime Whether or not this MO be collided with bt other MO's during their travel. (default: 0) + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Create(float mass, const Vector& position = Vector(0, 0), const Vector& velocity = Vector(0, 0), float rotAngle = 0, float angleVel = 0, unsigned long lifetime = 0, bool hitMOs = true, bool getHitByMOs = false); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Creates a MovableObject to be identical to another, by deep copy. - // Arguments: A reference to the MovableObject to deep copy. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Creates a MovableObject to be identical to another, by deep copy. + /// @param reference A reference to the MovableObject to deep copy. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Create(const MovableObject& reference); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Reset - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Resets the entire MovableObject, including its inherited members, to their - // default settings or values. - // Arguments: None. - // Return value: None. - + /// Resets the entire MovableObject, including its inherited members, to their + /// default settings or values. void Reset() override { Clear(); SceneObject::Reset(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destroys and resets (through Clear()) the MovableObject object. - // Arguments: Whether to only destroy the members defined in this derived class, or - // to destroy all inherited members also. - // Return value: None. - + /// Destroys and resets (through Clear()) the MovableObject object. + /// @param notInherited Whether to only destroy the members defined in this derived class, or (default: false) + /// to destroy all inherited members also. void Destroy(bool notInherited = false) override; #pragma region Script Handling - /// /// Loads the script at the given script path onto the object, checking for appropriately named functions within it. /// If the script contains a Create function and this MO's scripts are running, the Create function will be run immediately. - /// - /// The path to the script to load. - /// Whether or not the script should load as enabled. Defaults to true. - /// 0 on success. -1 if scriptPath is empty. -2 if the script is already loaded. -3 if setup to load the script or modify the global lua state fails. -4 if the script fails to load. + /// @param scriptPath The path to the script to load. + /// @param loadAsEnabledScript Whether or not the script should load as enabled. Defaults to true. + /// @return 0 on success. -1 if scriptPath is empty. -2 if the script is already loaded. -3 if setup to load the script or modify the global lua state fails. -4 if the script fails to load. virtual int LoadScript(const std::string& scriptPath, bool loadAsEnabledScript = true); - /// /// Reloads the all of the scripts on this object. This will also reload scripts for the original preset in PresetMan so future objects spawned will use the new scripts. - /// - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int ReloadScripts() final; - /// /// Gets whether or not the object has a script name, and there were no errors when initializing its Lua scripts. If there were, the object would need to be reloaded. - /// - /// Whether or not the object's scripts have been successfully initialized. + /// @return Whether or not the object's scripts have been successfully initialized. bool ObjectScriptsInitialized() const { return !m_ScriptObjectName.empty() && m_ScriptObjectName != "ERROR"; } - /// /// Checks if this MO has any scripts on it. - /// - /// Whether or not this MO has any scripts on it. + /// @return Whether or not this MO has any scripts on it. bool HasAnyScripts() const { return !m_AllLoadedScripts.empty(); } - /// /// Checks if the script at the given path is one of the scripts on this MO. - /// - /// The path to the script to check. - /// Whether or not the script is on this MO. + /// @param scriptPath The path to the script to check. + /// @return Whether or not the script is on this MO. bool HasScript(const std::string& scriptPath) const { return m_AllLoadedScripts.find(scriptPath) != m_AllLoadedScripts.end(); } - /// /// Checks if the script at the given path is one of the enabled scripts on this MO. - /// - /// The path to the script to check. - /// Whether or not the script is enabled on this MO. + /// @param scriptPath The path to the script to check. + /// @return Whether or not the script is enabled on this MO. bool ScriptEnabled(const std::string& scriptPath) const { auto scriptPathIterator = m_AllLoadedScripts.find(scriptPath); return scriptPathIterator != m_AllLoadedScripts.end() && scriptPathIterator->second == true; } - /// /// Enables or dsiableds the script at the given path on this MO. - /// - /// The path to the script to enable or disable - /// Whether to enable the script, or disable it. - /// Whether or not the script was successfully eanbled/disabled. + /// @param scriptPath The path to the script to enable or disable + /// @param enableScript Whether to enable the script, or disable it. + /// @return Whether or not the script was successfully eanbled/disabled. bool EnableOrDisableScript(const std::string& scriptPath, bool enableScript); - /// /// Enables or disables all scripts on this MovableObject. - /// - /// Whether to enable (true) or disable (false) all scripts on this MovableObject. + /// @param enableScripts Whether to enable (true) or disable (false) all scripts on this MovableObject. void EnableOrDisableAllScripts(bool enableScripts); - /// /// Runs the given function in all scripts that have it, with the given arguments, with the ability to not run on disabled scripts and to cease running if there's an error. /// The first argument to the function will always be 'self'. If either argument list is not empty, its entries will be passed into the Lua function in order, with entity arguments first. - /// - /// The name of the function to run. - /// Whether to run the function on disabled scripts. Defaults to false. - /// Whether to stop if there's an error running any script, or simply print it to the console and continue. Defaults to false. - /// Optional vector of entity pointers that should be passed into the Lua function. Their internal Lua states will not be accessible. Defaults to empty. - /// Optional vector of strings, that should be passed into the Lua function. Entries must be surrounded with escaped quotes (i.e.`\"`) they'll be passed in as-is, allowing them to act as booleans, etc.. Defaults to empty. - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @param functionName The name of the function to run. + /// @param runOnDisabledScripts Whether to run the function on disabled scripts. Defaults to false. + /// @param stopOnError Whether to stop if there's an error running any script, or simply print it to the console and continue. Defaults to false. + /// @param functionEntityArguments Optional vector of entity pointers that should be passed into the Lua function. Their internal Lua states will not be accessible. Defaults to empty. + /// @param functionLiteralArguments Optional vector of strings, that should be passed into the Lua function. Entries must be surrounded with escaped quotes (i.e.`\"`) they'll be passed in as-is, allowing them to act as booleans, etc.. Defaults to empty. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int RunScriptedFunctionInAppropriateScripts(const std::string& functionName, bool runOnDisabledScripts = false, bool stopOnError = false, const std::vector& functionEntityArguments = std::vector(), const std::vector& functionLiteralArguments = std::vector(), const std::vector& functionObjectArguments = std::vector()); - /// /// Cleans up and destroys the script state of this object, calling the Destroy callback in lua - /// virtual void DestroyScriptState(); #pragma endregion - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: GetMOType - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the MO type code of this MO. Either Actor, Item, or Generic. - // Arguments: None. - // Return value: An int describing the MO Type code of this MovableObject. - + /// Gets the MO type code of this MO. Either Actor, Item, or Generic. + /// @return An int describing the MO Type code of this MovableObject. int GetMOType() const { return m_MOType; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: GetMass - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the mass value of this MovableObject. - // Arguments: None. - // Return value: A float describing the mass value in Kilograms (kg). - + /// Gets the mass value of this MovableObject. + /// @return A float describing the mass value in Kilograms (kg). virtual float GetMass() const { return m_Mass; } - /// /// Gets the previous position vector of this MovableObject, prior to this frame. - /// - /// A Vector describing the previous position vector. + /// @return A Vector describing the previous position vector. const Vector& GetPrevPos() const { return m_PrevPos; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetVel - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the velocity vector of this MovableObject. - // Arguments: None. - // Return value: A Vector describing the current velocity vector. - + /// Gets the velocity vector of this MovableObject. + /// @return A Vector describing the current velocity vector. const Vector& GetVel() const { return m_Vel; } - /// /// Gets the previous velocity vector of this MovableObject, prior to this frame. - /// - /// A Vector describing the previous velocity vector. + /// @return A Vector describing the previous velocity vector. const Vector& GetPrevVel() const { return m_PrevVel; } - /// /// Gets the amount of distance this MO has travelled since its creation, in pixels. - /// - /// The amount of distance this MO has travelled, in pixels. + /// @return The amount of distance this MO has travelled, in pixels. float GetDistanceTravelled() const { return m_DistanceTravelled; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetAngularVel - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the current angular velocity of this MovableObject. Positive is - // a counter-clockwise rotation. - // Arguments: None. - // Return value: The angular velocity in radians per second. - + /// Gets the current angular velocity of this MovableObject. Positive is + /// a counter-clockwise rotation. + /// @return The angular velocity in radians per second. virtual float GetAngularVel() const { return 0.0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: GetRadius - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the largest radius of this in pixels. - // Arguments: None. - // Return value: The radius from its center to the edge of its graphical representation. - + /// Gets the largest radius of this in pixels. + /// @return The radius from its center to the edge of its graphical representation. virtual float GetRadius() const { return 1.0f; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: GetDiameter - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the largest diameter of this in pixels. - // Arguments: None. - // Return value: The largest diameter across its graphical representation. - + /// Gets the largest diameter of this in pixels. + /// @return The largest diameter across its graphical representation. virtual float GetDiameter() const { return 2.0F; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetScale - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the current scale of this MOSRotating. This is mostly for fun. - // Arguments: None. - // Return value: The normalized scale. - + /// Gets the current scale of this MOSRotating. This is mostly for fun. + /// @return The normalized scale. float GetScale() const { return m_Scale; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetGlobalAccScalar - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets How this is affected by global effects, from +1.0 to -1.0. - // Something with a negative value will 'float' upward. - // Arguments: None. - // Return value: The global acceleration scalar. - + /// Gets How this is affected by global effects, from +1.0 to -1.0. + /// Something with a negative value will 'float' upward. + /// @return The global acceleration scalar. float GetGlobalAccScalar() const { return m_GlobalAccScalar; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetGlobalAccScalar - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets How this is affected by global effects, from +1.0 to -1.0. - // Something with a negative value will 'float' upward. - // Arguments: The global acceleration scalar. - // Return value: None. - + /// Sets How this is affected by global effects, from +1.0 to -1.0. + /// Something with a negative value will 'float' upward. + /// @param newValue The global acceleration scalar. void SetGlobalAccScalar(float newValue) { m_GlobalAccScalar = newValue; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetAirResistance - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: How much this is affected by air resistance when traveling over a - // second, 0 to 1.0, with 0 as default - // Arguments: None. - // Return value: The air resistance coefficient. - + /// How much this is affected by air resistance when traveling over a + /// second, 0 to 1.0, with 0 as default + /// @return The air resistance coefficient. float GetAirResistance() const { return m_AirResistance; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetAirResistance - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets how much this is affected by air resistance when traveling over a - // second, 0 to 1.0, with 0 as default - // Arguments: The air resistance coefficient. - // Return value: None. - + /// Sets how much this is affected by air resistance when traveling over a + /// second, 0 to 1.0, with 0 as default + /// @param newValue The air resistance coefficient. void SetAirResistance(float newValue) { m_AirResistance = newValue; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetAirThreshold - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: At which threshold of velocity, in m/s, the effect of AirResistance - // kicks in. - // Arguments: None. - // Return value: The air threshold speed. - + /// At which threshold of velocity, in m/s, the effect of AirResistance + /// kicks in. + /// @return The air threshold speed. float GetAirThreshold() const { return m_AirThreshold; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetAirThreshold - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets at which threshold of velocity, in m/s, the effect of AirResistance - // kicks in. - // Arguments: The air threshold speed. - // Return value: None. - + /// Sets at which threshold of velocity, in m/s, the effect of AirResistance + /// kicks in. + /// @param newValue The air threshold speed. void SetAirThreshold(float newValue) { m_AirThreshold = newValue; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetAge - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets real time age of this MovableObject. - // Arguments: None. - // Return value: A unsigned long describing the current age in ms. - + /// Gets real time age of this MovableObject. + /// @return A unsigned long describing the current age in ms. unsigned long GetAge() const { return m_AgeTimer.GetElapsedSimTimeMS(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetLifetime - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the amount of time this MovableObject will exist from creation. - // Arguments: None. - // Return value: A unsigned long describing the current lifetime in ms. 0 means unlimited. - + /// Gets the amount of time this MovableObject will exist from creation. + /// @return A unsigned long describing the current lifetime in ms. 0 means unlimited. unsigned long GetLifetime() const { return m_Lifetime; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetID - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the MOID of this MovableObject for this frame. - // Arguments: None. - // Return value: An int specifying the MOID that this MovableObject is - // assigned for the current frame only. - + /// Gets the MOID of this MovableObject for this frame. + /// @return An int specifying the MOID that this MovableObject is + /// assigned for the current frame only. MOID GetID() const { return m_MOID; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetRootID - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the MOID of the MovableObject which is the root MO of this MO for - // this frame. If same as what GetID returns, then this is owned by - // MovableMan. - // Arguments: None. - // Return value: An int specifying the MOID of the MO that this MovableObject - // is owned by for the current frame only. - + /// Gets the MOID of the MovableObject which is the root MO of this MO for + /// this frame. If same as what GetID returns, then this is owned by + /// MovableMan. + /// @return An int specifying the MOID of the MO that this MovableObject + /// is owned by for the current frame only. MOID GetRootID() const { return m_RootMOID; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetMOIDFootprint - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets how many total (subsequent) MOID's this MO and all its children - // are taking up this frame. ie if this MO has no children, this will - // likely be 1. Note this is only valid for this frame! - // Arguments: None. - // Return value: The number of MOID indices this MO and all its children are taking up. - + /// Gets how many total (subsequent) MOID's this MO and all its children + /// are taking up this frame. ie if this MO has no children, this will + /// likely be 1. Note this is only valid for this frame! + /// @return The number of MOID indices this MO and all its children are taking up. int GetMOIDFootprint() const { return m_MOIDFootprint; } - /// /// Returns whether or not this MovableObject has ever been added to MovableMan. Does not account for removal from MovableMan. - /// - /// Whether or not this MovableObject has ever been added to MovableMan. + /// @return Whether or not this MovableObject has ever been added to MovableMan. bool HasEverBeenAddedToMovableMan() const { return m_HasEverBeenAddedToMovableMan; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: GetSharpness - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the sharpness factor of this MO. - // Arguments: None. - // Return value: The sharpness factor of this MO. 1.0 means normal sharpness, no alter- - // ation to any of the impulses. - + /// Gets the sharpness factor of this MO. + /// @return The sharpness factor of this MO. 1.0 means normal sharpness, no alter- + /// ation to any of the impulses. float GetSharpness() const { return m_Sharpness; } - /// /// Placeholder method to allow for ease of use with Attachables. Returns nullptr for classes that aren't derived from Attachable. - /// - /// Nothing. + /// @return Nothing. virtual MOSRotating* GetParent() { return nullptr; } - /// /// Placeholder method to allow for ease of use with Attachables. Returns nullptr for classes that aren't derived from Attachable. - /// - /// Nothing. + /// @return Nothing. virtual const MOSRotating* GetParent() const { return nullptr; } - /// /// Returns a pointer to this MO, this is to enable Attachables to get their root nodes. - /// - /// A pointer to this MovableObject. + /// @return A pointer to this MovableObject. virtual MovableObject* GetRootParent() { return this; } - /// /// Returns a pointer to this MO, this is to enable Attachables to get their root nodes. - /// - /// A pointer to this MovableObject. + /// @return A pointer to this MovableObject. virtual const MovableObject* GetRootParent() const { return this; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: GetAltitude - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the altitide of this' pos (or appropriate low point) over the - // terrain, in pixels. - // Arguments: The max altitude you care to check for. 0 Means check the whole scene's height. - // The accuracy within which measurement is acceptable. Higher number - // here means less calculation. - // Return value: The rough altitude over the terrain, in pixels. - + /// Gets the altitide of this' pos (or appropriate low point) over the + /// terrain, in pixels. + /// @param max The max altitude you care to check for. 0 Means check the whole scene's height. (default: 0) + /// @param accuracy The accuracy within which measurement is acceptable. Higher number (default: 0) + /// here means less calculation. + /// @return The rough altitude over the terrain, in pixels. virtual float GetAltitude(int max = 0, int accuracy = 0); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: GetAboveHUDPos - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the absoltue position of the top of this' HUD stack. - // Arguments: None. - // Return value: A Vector with the absolute position of this' HUD stack top point. - + /// Gets the absoltue position of the top of this' HUD stack. + /// @return A Vector with the absolute position of this' HUD stack top point. virtual Vector GetAboveHUDPos() const { return m_Pos; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: IntersectionWarning - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Shows whether this may have started to intersect the terrain since the - // last frame, e g due to flipping. - // Arguments: None. - // Return value: Whether this may have started to intersect the terrain since last frame. - + /// Shows whether this may have started to intersect the terrain since the + /// last frame, e g due to flipping. + /// @return Whether this may have started to intersect the terrain since last frame. bool IntersectionWarning() const { return m_CheckTerrIntersection; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: HitsMOs - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets whether this MovableObject is set to collide with other - // MovableObject:s during its travel. - // Arguments: None. - // Return value: Whether this hits other MO's during its travel, or not. - + /// Gets whether this MovableObject is set to collide with other + /// MovableObject:s during its travel. + /// @return Whether this hits other MO's during its travel, or not. bool HitsMOs() const { return m_HitsMOs; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetsHitByMOs - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets whether this MovableObject is set to be able to get hit by other - // MovableObject:s during their travel. - // Arguments: None. - // Return value: Whether this can get hit by MO's, or not. - + /// Gets whether this MovableObject is set to be able to get hit by other + /// MovableObject:s during their travel. + /// @return Whether this can get hit by MO's, or not. bool GetsHitByMOs() const { return m_GetsHitByMOs; } - /// /// Sets the team of this MovableObject. - /// - /// The new team to assign. + /// @param team The new team to assign. void SetTeam(int team) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetIgnoresTeamHits - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets whether this will collide with any other MO of the same team. - // Arguments: Whether this can hit or get hit by other MOs of the same team. - // Return value: None. - + /// Sets whether this will collide with any other MO of the same team. + /// @param ignoreTeam Whether this can hit or get hit by other MOs of the same team. (default: true) void SetIgnoresTeamHits(bool ignoreTeam = true) { m_IgnoresTeamHits = ignoreTeam; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: IgnoresTeamHits - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Tells whether this will collide with any other MO of the same team. - // Arguments: None. - // Return value: Whether this can hit or get hit by other MOs of the same team. - + /// Tells whether this will collide with any other MO of the same team. + /// @return Whether this can hit or get hit by other MOs of the same team. bool IgnoresTeamHits() const { return m_IgnoresTeamHits; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: IgnoresWhichTeam - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Tells which team this would be ignoring hits with, if we're ignoring - // hits at all. - // Arguments: None. - // Return value: Which team this ignores hits with, if any. - + /// Tells which team this would be ignoring hits with, if we're ignoring + /// hits at all. + /// @return Which team this ignores hits with, if any. int IgnoresWhichTeam() const { return m_IgnoresTeamHits ? m_Team : Activity::NoTeam; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetIgnoresAtomGroupHits - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets whether this will collide with any other MO that uses an - // AtomGroup as a physical representation. This also overrides the - // IgnoresAGHitsWhenSlowerThan property. - // Arguments: Whether this can hit or get hit by other MOs which use AGs. - // Return value: None. - + /// Sets whether this will collide with any other MO that uses an + /// AtomGroup as a physical representation. This also overrides the + /// IgnoresAGHitsWhenSlowerThan property. + /// @param ignoreAG Whether this can hit or get hit by other MOs which use AGs. (default: true) void SetIgnoresAtomGroupHits(bool ignoreAG = true) { m_IgnoresAtomGroupHits = ignoreAG; if (ignoreAG) m_IgnoresAGHitsWhenSlowerThan = -1; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: IgnoresAtomGroupHits - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Tells whether this will collide with any MO that uses an AtomGroup - // as physical representation. (as opposed to single-atom ones) - // Arguments: None. - // Return value: Whether this can hit or get hit by other MOs that use AGs. - + /// Tells whether this will collide with any MO that uses an AtomGroup + /// as physical representation. (as opposed to single-atom ones) + /// @return Whether this can hit or get hit by other MOs that use AGs. bool IgnoresAtomGroupHits() const { return m_IgnoresAtomGroupHits; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: IgnoreTerrain - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Tells whether this will collide with any Terrain - // Arguments: None. - // Return value: Whether this can hit terrain. - + /// Tells whether this will collide with any Terrain + /// @return Whether this can hit terrain. bool IgnoreTerrain() const { return m_IgnoreTerrain; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetIgnoreTerrain - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets whether this will collide with any Terrain - // Arguments: Whether this can hit terrain. - // Return value: None. - + /// Sets whether this will collide with any Terrain + /// @param ignores Whether this can hit terrain. void SetIgnoreTerrain(bool ignores) { m_IgnoreTerrain = ignores; } - /// /// Gets whether this MO ignores collisions with actors. - /// - /// Whether this MO ignores collisions with actors. + /// @return Whether this MO ignores collisions with actors. bool GetIgnoresActorHits() const { return m_IgnoresActorHits; } - /// /// Sets whether this MO ignores collisions with actors. - /// - /// Whether this MO will ignore collisions with actors. + /// @param value Whether this MO will ignore collisions with actors. void SetIgnoresActorHits(bool value) { m_IgnoresActorHits = value; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Pure V. method: GetMaterial - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the main material of this MovableObject. - // Arguments: None. - // Return value: The the material of this MovableObject. - + /// Gets the main material of this MovableObject. + /// @return The the material of this MovableObject. virtual Material const* GetMaterial() const = 0; - ////////////////////////////////////////////////////////////////////////////////////////// - // Pure V. method: GetDrawPriority - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the drawing priority of this MovableObject, if two things were - // overlap when copying to the terrain, the higher priority MO would - // end up getting drawn. - // Arguments: None. - // Return value: The the priority of this MovableObject. Higher number, the higher - // priority. - + /// Gets the drawing priority of this MovableObject, if two things were + /// overlap when copying to the terrain, the higher priority MO would + /// end up getting drawn. + /// @return The the priority of this MovableObject. Higher number, the higher + /// priority. virtual int GetDrawPriority() const = 0; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetScreenEffect - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the screen effect this has loaded, which can be applied to post - // rendering. Ownership is NOT transferred! - // Arguments: None. - // Return value: The 32bpp screen effect BITMAP. Ownership is NOT transferred! - + /// Gets the screen effect this has loaded, which can be applied to post + /// rendering. Ownership is NOT transferred! + /// @return The 32bpp screen effect BITMAP. Ownership is NOT transferred! BITMAP* GetScreenEffect() const { return m_pScreenEffect; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetScreenEffectHash - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the hash of the path of this object's screen effect file. Used to - // transfer glow effects over network. The hash itself is calculated during - // load. - // Arguments: None. - // Return value: This effect's unique hash. - + /// Gets the hash of the path of this object's screen effect file. Used to + /// transfer glow effects over network. The hash itself is calculated during + /// load. + /// @return This effect's unique hash. size_t GetScreenEffectHash() const { return m_ScreenEffectHash; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: SetMass - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the mass of this MovableObject. - // Arguments: A float specifying the new mass value in Kilograms (kg). - // Return value: None. - + /// Sets the mass of this MovableObject. + /// @param newMass A float specifying the new mass value in Kilograms (kg). virtual void SetMass(const float newMass) { m_Mass = newMass; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetPrevPos - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the position at the start of the sim update. - // Arguments: A Vector specifying the new 'prev' pos. - // Return value: None. - + /// Sets the position at the start of the sim update. + /// @param newPrevPos A Vector specifying the new 'prev' pos. void SetPrevPos(const Vector& newPrevPos) { m_PrevPos = newPrevPos; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetVel - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the velocity vector of this MovableObject. - // Arguments: A Vector specifying the new velocity vector. - // Return value: None. - + /// Sets the velocity vector of this MovableObject. + /// @param newVel A Vector specifying the new velocity vector. void SetVel(const Vector& newVel) { m_Vel = newVel; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: SetRotAngle - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the current absolute angle of rotation of this MovableObject. - // Arguments: The new absolute angle in radians. - // Return value: None. - + /// Sets the current absolute angle of rotation of this MovableObject. + /// @param newAngle The new absolute angle in radians. void SetRotAngle(float newAngle) override {} - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: SetEffectRotAngle - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the current absolute angle of rotation of this MovableObject's effect. - // Arguments: The new absolute angle in radians. - // Return value: None. - + /// Sets the current absolute angle of rotation of this MovableObject's effect. + /// @param newAngle The new absolute angle in radians. void SetEffectRotAngle(float newAngle) { m_EffectRotAngle = newAngle; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: GetEffectRotAngle - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the current absolute angle of rotation of this MovableObject's effect. - // Arguments: None. - // Return value: The absolute angle in radians. - + /// Gets the current absolute angle of rotation of this MovableObject's effect. + /// @return The absolute angle in radians. float GetEffectRotAngle() const { return m_EffectRotAngle; } - /// /// Gets the starting strength of this MovableObject's effect. - /// - /// The starting strength of the effect, 0-255. + /// @return The starting strength of the effect, 0-255. int GetEffectStartStrength() const { return m_EffectStartStrength; } - /// /// Gets the stopping strength of this MovableObject's effect. - /// - /// The stopping strength of the effect, 0-255. + /// @return The stopping strength of the effect, 0-255. int GetEffectStopStrength() const { return m_EffectStopStrength; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: SetAngularVel - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the current angular velocity of this MovableObject. Positive is - // a counter clockwise rotation. - // Arguments: The new angular velocity in radians per second. - // Return value: None. - + /// Sets the current angular velocity of this MovableObject. Positive is + /// a counter clockwise rotation. + /// @param newRotVel The new angular velocity in radians per second. virtual void SetAngularVel(float newRotVel) {} - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetScale - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the current scale of this MOSRotating. This is mostly for fun. - // Arguments: The new normalized scale. - // Return value: None. - + /// Sets the current scale of this MOSRotating. This is mostly for fun. + /// @param newScale The new normalized scale. void SetScale(float newScale) { m_Scale = newScale; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetLifetime - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the amount of time this MovableObject will exist. - // Arguments: A unsigned long specifying amount of time in ms. 0 means unlimited life. - // Return value: None. - + /// Sets the amount of time this MovableObject will exist. + /// @param newLifetime A unsigned long specifying amount of time in ms. 0 means unlimited life. (default: 0) void SetLifetime(const int newLifetime = 0) { m_Lifetime = newLifetime; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetAge - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets this' age timer to a specific value, in ms. - // Arguments: The new age of this, in MS. - // Return value: None. - + /// Sets this' age timer to a specific value, in ms. + /// @param newAge The new age of this, in MS. (default: 0) { m_AgeTimer.SetElapsedSimTimeMS(newAge) void SetAge(double newAge = 0) { m_AgeTimer.SetElapsedSimTimeMS(newAge); } - /// /// Sets the MOID of this MovableObject to be g_NoMOID (255) for this frame. - /// virtual void SetAsNoID() { m_MOID = g_NoMOID; } - /// /// Sets this MovableObject as having been added to MovableMan. Should only really be done in MovableMan::Add/Remove Actor/Item/Particle. - /// - /// Whether or not this MovableObject has been added to MovableMan. + /// @param addedToMovableMan Whether or not this MovableObject has been added to MovableMan. void SetAsAddedToMovableMan(bool addedToMovableMan = true) { if (addedToMovableMan) { m_HasEverBeenAddedToMovableMan = true; } } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: SetSharpness - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the sharpness factor of this MO. - // Arguments: The sharpness factor of this MO. 1.0 means normal sharpness, no alter- - // ation to any of the impulses. - // Return value: None. - + /// Sets the sharpness factor of this MO. + /// @param sharpness The sharpness factor of this MO. 1.0 means normal sharpness, no alter- + /// ation to any of the impulses. void SetSharpness(const float sharpness) { m_Sharpness = sharpness; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetToHitMOs - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets this MovableObject to collide with other MovableObjects during - // travel. - // Arguments: Whether to hit other MO's during travel, or not. - // Return value: None. - + /// Sets this MovableObject to collide with other MovableObjects during + /// travel. + /// @param hitMOs Whether to hit other MO's during travel, or not. (default: true) void SetToHitMOs(bool hitMOs = true) { m_HitsMOs = hitMOs; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetToGetHitByMOs - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets this MovableObject to be able to be collided with by other - // MovableObjects during their travel. - // Arguments: Whether this should get hit by other MO's during travel, or not. - // Return value: None. - + /// Sets this MovableObject to be able to be collided with by other + /// MovableObjects during their travel. + /// @param getHitByMOs Whether this should get hit by other MO's during travel, or not. (default: true) void SetToGetHitByMOs(bool getHitByMOs = true) { m_GetsHitByMOs = getHitByMOs; } - /// /// Gets the MO this MO is set not to hit even when MO hitting is enabled on this MO. - /// - /// The MO this MO is set not to hit. + /// @return The MO this MO is set not to hit. const MovableObject* GetWhichMOToNotHit() const { return m_pMOToNotHit; } - /// /// Sets this MO to not hit a specific other MO and all its children even when MO hitting is enabled on this MO. - /// - /// A pointer to the MO to not be hitting. Null pointer means don't ignore anyhting. Ownership is NOT transferred! - /// How long, in seconds, to ignore the specified MO. A negative number means forever. + /// @param moToNotHit A pointer to the MO to not be hitting. Null pointer means don't ignore anyhting. Ownership is NOT transferred! + /// @param forHowLong How long, in seconds, to ignore the specified MO. A negative number means forever. virtual void SetWhichMOToNotHit(MovableObject* moToNotHit = nullptr, float forHowLong = -1) { m_pMOToNotHit = moToNotHit; m_MOIgnoreTimer.Reset(); m_MOIgnoreTimer.SetSimTimeLimitS(forHowLong); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetWrapDoubleDrawing - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Enables or disables double drawing of this across wrapping seams. - // Arguments: Wheter to enable or not. - // Return value: None. - + /// Enables or disables double drawing of this across wrapping seams. + /// @param wrapDraw Wheter to enable or not. (default: true) void SetWrapDoubleDrawing(bool wrapDraw = true) { m_WrapDoubleDraw = wrapDraw; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetToSettle - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Marks this MovableObject for settling onto the terrain at the end of - // the MovableMan update. - // Arguments: Whether to mark this MO for settling or not. - // Return value: None. - + /// Marks this MovableObject for settling onto the terrain at the end of + /// the MovableMan update. + /// @param toSettle Whether to mark this MO for settling or not. (default: true) void SetToSettle(bool toSettle = true) { m_ToSettle = toSettle; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetToDelete - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Marks this MovableObject for deletion at the end of the MovableMan - // update. - // Arguments: Whether to mark this MO for deletion or not. - // Return value: None. - + /// Marks this MovableObject for deletion at the end of the MovableMan + /// update. + /// @param toDelete Whether to mark this MO for deletion or not. (default: true) void SetToDelete(bool toDelete = true) { m_ToDelete = toDelete; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: IsSetToDelete - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Tells if this MovableObject is marked for deletion at the end of the - // update. - // Arguments: None. - // Return value: Whether this is marked for deletion or not. - + /// Tells if this MovableObject is marked for deletion at the end of the + /// update. + /// @return Whether this is marked for deletion or not. bool IsSetToDelete() const { return m_ToDelete; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: IsMissionCritical - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Shows whether this is mission critical and should therefore NEVER be - // settled or otherwise destroyed during teh course of a mission. - // Arguments: None. - // Return value: Whetehr this should be immune to settling and destruction. - + /// Shows whether this is mission critical and should therefore NEVER be + /// settled or otherwise destroyed during teh course of a mission. + /// @return Whetehr this should be immune to settling and destruction. bool IsMissionCritical() const { return m_MissionCritical; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetMissionCritical - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets whether this is mission critical and should therefore NEVER be - // settled or otherwise destroyed during teh course of a mission. - // Arguments: Whether this should be immune to settling and destruction. - // Return value: None. - + /// Sets whether this is mission critical and should therefore NEVER be + /// settled or otherwise destroyed during teh course of a mission. + /// @param missionCritical Whether this should be immune to settling and destruction. void SetMissionCritical(bool missionCritical) { m_MissionCritical = missionCritical; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: CanBeSquished - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Shows whether this can be squished by getting pushed into the ground. - // Arguments: None. - // Return value: Whetehr this should be immune to squishing or not. - + /// Shows whether this can be squished by getting pushed into the ground. + /// @return Whetehr this should be immune to squishing or not. bool CanBeSquished() const { return m_CanBeSquished; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetHUDVisible - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Tells whether this Actor's HUD is drawn or not. - // Arguments: None. - // Return value: Whether this' HUD gets drawn or not. - + /// Tells whether this Actor's HUD is drawn or not. + /// @return Whether this' HUD gets drawn or not. void SetHUDVisible(bool visible) { m_HUDVisible = visible; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetHUDVisible - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Tells whether this Actor's HUD is drawn or not. - // Arguments: None. - // Return value: Whether this' HUD gets drawn or not. - + /// Tells whether this Actor's HUD is drawn or not. + /// @return Whether this' HUD gets drawn or not. bool GetHUDVisible() const { return m_HUDVisible; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: IsTooFast - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Indicates whether this MO is moving or rotating stupidly fast in a way - // that will screw up the simulation. - // Arguments: None. - // Return value: Whether this is either moving or rotating too fast. - + /// Indicates whether this MO is moving or rotating stupidly fast in a way + /// that will screw up the simulation. + /// @return Whether this is either moving or rotating too fast. virtual bool IsTooFast() const { return m_Vel.MagnitudeIsGreaterThan(500.0F); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: FixTooFast - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Slows the speed of anyhting that is deemed to be too fast to within - // acceptable rates. - // Arguments: None. - // Return value: None. - + /// Slows the speed of anyhting that is deemed to be too fast to within + /// acceptable rates. virtual void FixTooFast() { if (IsTooFast()) { m_Vel.SetMagnitude(450.0F); } } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: IsGeneric - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Indicates whether this MO is an Generic or not. - // Arguments: None. - // Return value: Whether this MovableObject is of Type Generic or not. - + /// Indicates whether this MO is an Generic or not. + /// @return Whether this MovableObject is of Type Generic or not. bool IsGeneric() const { return m_MOType == TypeGeneric; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: IsActor - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Indicates whether this MO is an Actor or not. - // Arguments: None. - // Return value: Whether this MovableObject is of Type Actor or not. - + /// Indicates whether this MO is an Actor or not. + /// @return Whether this MovableObject is of Type Actor or not. bool IsActor() const { return m_MOType == TypeActor; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: IsDevice - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Indicates whether this MO is a Device or not. - // Arguments: None. - // Return value: Whether this MovableObject is of Type Device (Held or Thrown) or not. - + /// Indicates whether this MO is a Device or not. + /// @return Whether this MovableObject is of Type Device (Held or Thrown) or not. bool IsDevice() const { return m_MOType == TypeHeldDevice || m_MOType == TypeThrownDevice; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: IsHeldDevice - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Indicates whether this MO is a HeldDevice or not. - // Arguments: None. - // Return value: Whether this MovableObject is of Type HeldDevice or not. - + /// Indicates whether this MO is a HeldDevice or not. + /// @return Whether this MovableObject is of Type HeldDevice or not. // LEGACY CRAP bool IsHeldDevice() const { return m_MOType == TypeHeldDevice || m_MOType == TypeThrownDevice; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: IsThrownDevice - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Indicates whether this MO is a ThrownDevice or not. - // Arguments: None. - // Return value: Whether this MovableObject is of Type ThrownDevice or not. - + /// Indicates whether this MO is a ThrownDevice or not. + /// @return Whether this MovableObject is of Type ThrownDevice or not. bool IsThrownDevice() const { return m_MOType == TypeThrownDevice; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: IsGold - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Indicates whether this MO is made of Gold or not. - // Arguments: None. - // Return value: Whether this MovableObject is of Gold or not. - + /// Indicates whether this MO is made of Gold or not. + /// @return Whether this MovableObject is of Gold or not. bool IsGold() const { return m_MOType == TypeGeneric && GetMaterial()->GetIndex() == c_GoldMaterialID; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: IsDrawnAfterParent - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Indicates whether this MovableObject is to be drawn after - // (in front of) or before (behind) the parent. - // Arguments: None. - // Return value: Whether it's to be drawn after parent or not. - + /// Indicates whether this MovableObject is to be drawn after + /// (in front of) or before (behind) the parent. + /// @return Whether it's to be drawn after parent or not. virtual bool IsDrawnAfterParent() const { return true; } - /// /// Whether a set of X, Y coordinates overlap us (in world space). - /// - /// The given X coordinate, in world space. - /// The given Y coordinate, in world space. - /// Whether the given coordinate overlap us. + /// @param pixelX The given X coordinate, in world space. + /// @param pixelY The given Y coordinate, in world space. + /// @return Whether the given coordinate overlap us. virtual bool HitTestAtPixel(int pixelX, int pixelY) const { return false; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: HasObject - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Shows whether this is or carries a specifically named object in its - // inventory. Also looks through the inventories of potential passengers, - // as applicable. - // Arguments: The Preset name of the object to look for. - // Return value: Whetehr the object was found carried by this. - + /// Shows whether this is or carries a specifically named object in its + /// inventory. Also looks through the inventories of potential passengers, + /// as applicable. + /// @param objectName The Preset name of the object to look for. + /// @return Whetehr the object was found carried by this. virtual bool HasObject(std::string objectName) const { return m_PresetName == objectName; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: HasObjectInGroup - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Shows whether this is or carries a specifically grouped object in its - // inventory. Also looks through the inventories of potential passengers, - // as applicable. - // Arguments: The name of the group to look for. - // Return value: Whetehr the object in the group was found carried by this. - + /// Shows whether this is or carries a specifically grouped object in its + /// inventory. Also looks through the inventories of potential passengers, + /// as applicable. + /// @param const_cast(this)->IsInGroup(groupName The name of the group to look for. + /// @return Whetehr the object in the group was found carried by this. virtual bool HasObjectInGroup(std::string groupName) const { return const_cast(this)->IsInGroup(groupName); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: AddForce - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Adds force to this MovableObject for the next time Update() is called. - // Arguments: An Vector with the external force vector that will be added to this - // MovableObject and affect its path next Update(). In N or kg * m/s^2. - // A Vector with the offset, in METERS, of where the force is being - // applied relative to the center of this MovableObject. - // Return value: None.A - + /// Adds force to this MovableObject for the next time Update() is called. + /// @param force An Vector with the external force vector that will be added to this + /// @param offset MovableObject and affect its path next Update(). In N or kg * m/s^2. (default: Vector()) { m_Forces.push_back(std::make_pair(force) + /// @param offset) A Vector with the offset, in METERS, of where the force is being + /// applied relative to the center of this MovableObject. + /// @return None.A void AddForce(const Vector& force, const Vector& offset = Vector()) { m_Forces.push_back(std::make_pair(force, offset)); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: AddAbsForce - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Adds force to this MovableObject for the next time Update() is called. - // Arguments: An Vector with the external force vector that will be added to this - // MovableObject and affect its path next Update(). In N or kg * m/s^2. - // A Vector with the absolute world coordinates, in PIXELS, of where the - // force is being applied to the center of this MovableObject. - // Return value: None. - + /// Adds force to this MovableObject for the next time Update() is called. + /// @param force An Vector with the external force vector that will be added to this + /// @param absPos MovableObject and affect its path next Update(). In N or kg * m/s^2. + /// A Vector with the absolute world coordinates, in PIXELS, of where the + /// force is being applied to the center of this MovableObject. void AddAbsForce(const Vector& force, const Vector& absPos); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: AddImpulseForce - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Adds impulse force (or instant momentum) to this MovableObject for - // the next time Update() is called. - // Arguments: An Vector with the impulse force vector that will directly be added - // to this MovableObject's momentum next Update(). In kg * m/s. - // A Vector with the offset, in METERS, of where the impulse is being - // applied relative to the center of this MovableObject. - // Return value: None. - + /// Adds impulse force (or instant momentum) to this MovableObject for + /// the next time Update() is called. + /// @param impulse An Vector with the impulse force vector that will directly be added + /// to this MovableObject's momentum next Update(). In kg * m/s. + /// @param offset A Vector with the offset, in METERS, of where the impulse is being (default: Vector()) + /// applied relative to the center of this MovableObject. void AddImpulseForce(const Vector& impulse, const Vector& offset = Vector()) { #ifndef RELEASE_BUILD @@ -1044,248 +587,138 @@ namespace RTE { m_ImpulseForces.push_back({impulse, offset}); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: AddAbsImpulseForce - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Adds impulse force (or instant momentum) to this MovableObject for - // the next time Update() is called. - // Arguments: An Vector with the impulse force vector that will directly be added - // to this MovableObject's momentum next Update(). In kg * m/s. - // A Vector with the absolute world coordinates, in PIXELS, of where the - // force is being applied to the center of this MovableObject. - // Return value: None. - + /// Adds impulse force (or instant momentum) to this MovableObject for + /// the next time Update() is called. + /// @param impulse An Vector with the impulse force vector that will directly be added + /// to this MovableObject's momentum next Update(). In kg * m/s. + /// @param absPos A Vector with the absolute world coordinates, in PIXELS, of where the + /// force is being applied to the center of this MovableObject. void AddAbsImpulseForce(const Vector& impulse, const Vector& absPos); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: ClearForces - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears out all the forces this MO has accumulated during this frame. - // Arguments: None. - // Return value: None. - + /// Clears out all the forces this MO has accumulated during this frame. void ClearForces() { m_Forces.clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: ClearImpulseForces - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears out all the impulses this MO has accumulated during this frame. - // Arguments: None. - // Return value: None. - + /// Clears out all the impulses this MO has accumulated during this frame. void ClearImpulseForces() { m_ImpulseForces.clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetPinStrength - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the impulse force threshold which has to be exceeded to - // 'shake loose' this from a 'pinned' state. Pinned MOs don't get moved - // by travel algos. If 0, this isn't pinned. - // Arguments: None. - // Return value: The impulse threshold in kg * (m/s). 0 means no pinning - + /// Gets the impulse force threshold which has to be exceeded to + /// 'shake loose' this from a 'pinned' state. Pinned MOs don't get moved + /// by travel algos. If 0, this isn't pinned. + /// @return The impulse threshold in kg * (m/s). 0 means no pinning float GetPinStrength() const { return m_PinStrength; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetPinStrength - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets a impulse force threshold which has to be exceeded to - // 'shake loose' this from a 'pinned' state. Pinned MOs don't get moved - // by travel algos. If 0, this isn't pinned. - // Arguments: The impulse threshold in kg * (m/s). 0 means no pinning - // Return value: None. - + /// Sets a impulse force threshold which has to be exceeded to + /// 'shake loose' this from a 'pinned' state. Pinned MOs don't get moved + /// by travel algos. If 0, this isn't pinned. + /// @param pinStrength The impulse threshold in kg * (m/s). 0 means no pinning void SetPinStrength(float pinStrength) { m_PinStrength = pinStrength; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: ResetAllTimers - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Resest all the timers used by this. Can be emitters, etc. This is to - // prevent backed up emissions to come out all at once while this has been - // held dormant in an inventory. - // Arguments: None. - // Return value: None. - + /// Resest all the timers used by this. Can be emitters, etc. This is to + /// prevent backed up emissions to come out all at once while this has been + /// held dormant in an inventory. virtual void ResetAllTimers() {} - /// /// Does the calculations necessary to detect whether this MovableObject is at rest or not. IsAtRest() retrieves the answer. - /// virtual void RestDetection(); - /// /// Forces this MovableObject out of resting conditions. - /// virtual void NotResting() { m_RestTimer.Reset(); m_ToSettle = false; m_VelOscillations = 0; } - /// /// Indicates whether this MovableObject has been at rest with no movement for longer than its RestThreshold. - /// virtual bool IsAtRest(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: IsUpdated - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Indicates wheter this MovableObject has been updated yet during this - // frame. - // Arguments: None. - // Return value: Wheter or not the MovableObject has been updated yet during this frame. - + /// Indicates wheter this MovableObject has been updated yet during this + /// frame. + /// @return Wheter or not the MovableObject has been updated yet during this frame. bool IsUpdated() const { return m_IsUpdated; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: NewFrame - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Tell this MovableObject that a new frame has started. - // Arguments: None. - // Return value: None. - + /// Tell this MovableObject that a new frame has started. void NewFrame() { m_IsUpdated = false; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ToSettle - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Indicates whether this MO is marked for settling at the end of the - // MovableMan update. - // Arguments: None. - // Return value: Whether this MO is marked for settling ontot the terrain or not. - + /// Indicates whether this MO is marked for settling at the end of the + /// MovableMan update. + /// @return Whether this MO is marked for settling ontot the terrain or not. bool ToSettle() const { return !m_MissionCritical && m_ToSettle; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ToDelete - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Indicates whether this MO is marked for deletion at the end of the - // MovableMan update. - // Arguments: None. - // Return value: Whether this MO is marked for deletion or not. - + /// Indicates whether this MO is marked for deletion at the end of the + /// MovableMan update. + /// @return Whether this MO is marked for deletion or not. bool ToDelete() const { return m_ToDelete; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: DidWrap - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Indicates whether this MO moved across the scene wrap seam during the - // last update. - // Arguments: None. - // Return value: Whether this MO wrapped or not. - + /// Indicates whether this MO moved across the scene wrap seam during the + /// last update. + /// @return Whether this MO wrapped or not. bool DidWrap() { return m_DidWrap; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Pure v. method: CollideAtPoint - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Calculates the collision response when another MO's Atom collides with - // this MO's physical representation. The effects will be applied - // directly to this MO, and also represented in the passed in HitData. - // Arguments: Reference to the HitData struct which describes the collision. This - // will be modified to represent the results of the collision. - // Return value: Whether the collision has been deemed valid. If false, then disregard - // any impulses in the Hitdata. - + /// Calculates the collision response when another MO's Atom collides with + /// this MO's physical representation. The effects will be applied + /// directly to this MO, and also represented in the passed in HitData. + /// @param hitData Reference to the HitData struct which describes the collision. This + /// will be modified to represent the results of the collision. + /// @return Whether the collision has been deemed valid. If false, then disregard + /// any impulses in the Hitdata. virtual bool CollideAtPoint(HitData& hitData) = 0; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: OnMOHit - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Defines what should happen when this MovableObject hits another MO. - // This is called by the owned Atom/AtomGroup of this MovableObject during - // travel. - // Arguments: The HitData describing the collision in detail. - // Return value: Wheter the MovableObject should immediately halt any travel going on - // after this hit. - + /// Defines what should happen when this MovableObject hits another MO. + /// This is called by the owned Atom/AtomGroup of this MovableObject during + /// travel. + /// @param hd The HitData describing the collision in detail. + /// @return Wheter the MovableObject should immediately halt any travel going on + /// after this hit. bool OnMOHit(HitData& hd); - ////////////////////////////////////////////////////////////////////////////////////////// - // Pure v. method: OnBounce - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Defines what should happen when this MovableObject hits and then - // bounces off of something. This is called by the owned Atom/AtomGroup - // of this MovableObject during travel. - // Arguments: The HitData describing the collision in detail. - // Return value: Wheter the MovableObject should immediately halt any travel going on - // after this bounce. - + /// Defines what should happen when this MovableObject hits and then + /// bounces off of something. This is called by the owned Atom/AtomGroup + /// of this MovableObject during travel. + /// @param hd The HitData describing the collision in detail. + /// @return Wheter the MovableObject should immediately halt any travel going on + /// after this bounce. virtual bool OnBounce(HitData& hd) = 0; - ////////////////////////////////////////////////////////////////////////////////////////// - // Pure v. method: OnSink - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Defines what should happen when this MovableObject hits and then - // sink into something. This is called by the owned Atom/AtomGroup - // of this MovableObject during travel. - // Arguments: The HitData describing the collision in detail. - // Return value: Wheter the MovableObject should immediately halt any travel going on - // after this sinkage. - + /// Defines what should happen when this MovableObject hits and then + /// sink into something. This is called by the owned Atom/AtomGroup + /// of this MovableObject during travel. + /// @param hd The HitData describing the collision in detail. + /// @return Wheter the MovableObject should immediately halt any travel going on + /// after this sinkage. virtual bool OnSink(HitData& hd) = 0; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: MoveOutOfTerrain - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Checks whether any of the Atom:s in this MovableObject are on top of - // terrain pixels, and if so, attempt to move this out so none of this' - // Atoms are on top of the terrain any more. - // Arguments: Only consider materials stronger than this in the terrain for - // intersections. - // Return value: Whether any intersection was successfully resolved. Will return true - // even if there wasn't any intersections to begin with. - + /// Checks whether any of the Atom:s in this MovableObject are on top of + /// terrain pixels, and if so, attempt to move this out so none of this' + /// Atoms are on top of the terrain any more. + /// @param strongerThan Only consider materials stronger than this in the terrain for (default: g_MaterialAir) + /// intersections. + /// @return Whether any intersection was successfully resolved. Will return true + /// even if there wasn't any intersections to begin with. virtual bool MoveOutOfTerrain(unsigned char strongerThan = g_MaterialAir) { return true; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: RotateOffset - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Rotates a vector offset from this MORotating's position according to - // the rotate angle and flipping. - // Arguments: A const reference the offset Vector to rotate. - // Return value: A new vector that is the result of the rotation. - + /// Rotates a vector offset from this MORotating's position according to + /// the rotate angle and flipping. + /// @param offset A const reference the offset Vector to rotate. + /// @return A new vector that is the result of the rotation. virtual Vector RotateOffset(const Vector& offset) const { return offset; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: ApplyForces - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gathers and applies the global and accumulated forces. Then it clears - // out the force list.Note that this does NOT apply the accumulated - // impulses (impulse forces)! - // Arguments: None. - // Return value: None. - + /// Gathers and applies the global and accumulated forces. Then it clears + /// out the force list.Note that this does NOT apply the accumulated + /// impulses (impulse forces)! virtual void ApplyForces(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: ApplyImpulses - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gathers and applies the accumulated impulse forces. Then it clears - // out the impulse list.Note that this does NOT apply the accumulated - // regular forces (non-impulse forces)! - // Arguments: None. - // Return value: None. - + /// Gathers and applies the accumulated impulse forces. Then it clears + /// out the impulse list.Note that this does NOT apply the accumulated + /// regular forces (non-impulse forces)! virtual void ApplyImpulses(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: GetForcesCount() - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns the number of Forces vectors to apply. - // Arguments: None. - // Return value: Number of entries in Forces list. - + /// Returns the number of Forces vectors to apply. + /// @return Number of entries in Forces list. int GetForcesCount() { return m_Forces.size(); }; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: GetForceVector() - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns force vector in newtons of the specified Force record. - // Arguments: Force record index to get data from. - // Return value: Force vector in newtons of the specified Force record. - + /// Returns force vector in newtons of the specified Force record. + /// @param n Force record index to get data from. + /// @return Force vector in newtons of the specified Force record. Vector GetForceVector(int n) { if (n > 0 && n < m_Forces.size()) return m_Forces[n].first; @@ -1293,19 +726,13 @@ namespace RTE { return Vector(0, 0); } - /// /// Gets the total sum of all forces applied to this MovableObject in a single Vector. - /// - /// The total sum of all forces applied to this MovableObject. + /// @return The total sum of all forces applied to this MovableObject. virtual Vector GetTotalForce(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: GetForceOffset() - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns offset vector in METERS (not pixels) of the specified Force record. - // Arguments: Force record index to get data from. - // Return value: Offset vector in meters of the specified Force record. - + /// Returns offset vector in METERS (not pixels) of the specified Force record. + /// @param n Force record index to get data from. + /// @return Offset vector in meters of the specified Force record. Vector GetForceOffset(int n) { if (n > 0 && n < m_Forces.size()) return m_Forces[n].second; @@ -1313,52 +740,31 @@ namespace RTE { return Vector(0, 0); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: SetForceVector() - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets force vector in newtons of the specified Force record. - // Arguments: Force record index to get data from. New Vector force value in newtons. - // Return value: None. - + /// Sets force vector in newtons of the specified Force record. + /// @param n Force record index to get data from. New Vector force value in newtons. void SetForceVector(int n, Vector v) { if (n > 0 && n < m_Forces.size()) m_Forces[n].first = v; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: SetForceOffset() - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets offset vector in METERS (not pixels) of the specified Force record. - // Arguments: Force record index to get data from. New Vector offset value in meters. - // Return value: None. - + /// Sets offset vector in METERS (not pixels) of the specified Force record. + /// @param n Force record index to get data from. New Vector offset value in meters. void SetForceOffset(int n, Vector v) { if (n > 0 && n < m_Forces.size()) m_Forces[n].second = v; } - /// /// Gets the pairs of impulse forces and their offsets that have to be applied. - /// - /// A constant reference to the deque of impulses for this MovableObject. + /// @return A constant reference to the deque of impulses for this MovableObject. const std::deque>& GetImpulses() { return m_ImpulseForces; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: GetImpulsesCount() - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns the number of ImpulseForces vectors to apply. - // Arguments: None. - // Return value: Number of entries in ImpulseForces list. - + /// Returns the number of ImpulseForces vectors to apply. + /// @return Number of entries in ImpulseForces list. int GetImpulsesCount() { return m_ImpulseForces.size(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: GetImpulseVector() - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns Impulse vector in newtons of the specified Impulse record. - // Arguments: Impulse record index to get data from. - // Return value: Impulse vector in newtons of the specified Impulse record. - + /// Returns Impulse vector in newtons of the specified Impulse record. + /// @param n Impulse record index to get data from. + /// @return Impulse vector in newtons of the specified Impulse record. Vector GetImpulseVector(int n) { if (n > 0 && n < m_ImpulseForces.size()) return m_ImpulseForces[n].first; @@ -1366,13 +772,9 @@ namespace RTE { return Vector(0, 0); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: GetImpulseOffset() - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns offset vector in METERS (not pixels) of the specified Impulse record. - // Arguments: Impulse record index to get data from. - // Return value: Offset vector in meters of the specified Impulse record. - + /// Returns offset vector in METERS (not pixels) of the specified Impulse record. + /// @param n Impulse record index to get data from. + /// @return Offset vector in meters of the specified Impulse record. Vector GetImpulseOffset(int n) { if (n > 0 && n < m_ImpulseForces.size()) return m_ImpulseForces[n].second; @@ -1380,543 +782,318 @@ namespace RTE { return Vector(0, 0); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: SetImpulseVector() - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns offset vector in METERS (not pixels) of the specified Impulse record. - // Arguments: Impulse record index to get data from. - // Return value: Offset vector in meters of the specified Impulse record. - + /// Returns offset vector in METERS (not pixels) of the specified Impulse record. + /// @param n Impulse record index to get data from. + /// @return Offset vector in meters of the specified Impulse record. void SetImpulseVector(int n, Vector v) { if (n > 0 && n < m_ImpulseForces.size()) m_ImpulseForces[n].first = v; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: SetImpulseOffset() - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets offset vector in METERS (not pixels) of the specified Impulse record. - // Arguments: Impulse record index to get data from. New Vector offset value in meters. - // Return value: None. - + /// Sets offset vector in METERS (not pixels) of the specified Impulse record. + /// @param n Impulse record index to get data from. New Vector offset value in meters. void SetImpulseOffset(int n, Vector v) { if (n > 0 && n < m_ImpulseForces.size()) m_ImpulseForces[n].second = v; } - /// /// Gets the number of Sim updates that run between each script update for this MovableObject. - /// - /// The number of Sim updates that run between each script update for this MovableObject. + /// @return The number of Sim updates that run between each script update for this MovableObject. int GetSimUpdatesBetweenScriptedUpdates() const { return m_SimUpdatesBetweenScriptedUpdates; } - /// /// Sets the number of Sim updates that run between each script update for this MovableObject. - /// - /// The new number of Sim updates that run between each script update for this MovableObject. + /// @param newSimUpdatesBetweenScriptedUpdates The new number of Sim updates that run between each script update for this MovableObject. void SetSimUpdatesBetweenScriptedUpdates(int newSimUpdatesBetweenScriptedUpdates) { m_SimUpdatesBetweenScriptedUpdates = std::max(1, newSimUpdatesBetweenScriptedUpdates); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: PreTravel - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Does stuff that needs to be done before Travel(). Always call before - // calling Travel. - // Arguments: None. - // Return value: None. - + /// Does stuff that needs to be done before Travel(). Always call before + /// calling Travel. virtual void PreTravel(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Travel - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Travels this MovableObject, using its physical representation. - // Arguments: None. - // Return value: None. - + /// Travels this MovableObject, using its physical representation. virtual void Travel(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: PostTravel - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Does stuff that needs to be done after Travel(). Always call after - // calling Travel. - // Arguments: None. - // Return value: None. - + /// Does stuff that needs to be done after Travel(). Always call after + /// calling Travel. virtual void PostTravel(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: PreControllerUpdate - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Update called prior to controller update. Ugly hack. Supposed to be done every frame. - // Arguments: None. - // Return value: None. - + /// Update called prior to controller update. Ugly hack. Supposed to be done every frame. virtual void PreControllerUpdate(){}; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Update - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates this MovableObject. Supposed to be done every frame. This also - // applies and clear the accumulated impulse forces (impulses), and the - // transferred forces of MOs attached to this. - // Arguments: None. - // Return value: None. - + /// Updates this MovableObject. Supposed to be done every frame. This also + /// applies and clear the accumulated impulse forces (impulses), and the + /// transferred forces of MOs attached to this. void Update() override; void Draw(BITMAP* pTargetBitmap, const Vector& targetPos = Vector(), DrawMode mode = g_DrawColor, bool onlyPhysical = false) const override; - /// /// Updates this MovableObject's Lua scripts. - /// - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. virtual int UpdateScripts(); - /// /// Gets a const reference to this MOSRotating's map of string values. - /// - /// A const reference to this MOSRotating's map of string values. + /// @return A const reference to this MOSRotating's map of string values. const std::unordered_map& GetStringValueMap() const { return m_StringValueMap; } - /// /// Gets a const reference to this MOSRotating's map of number values. - /// - /// A const reference to this MOSRotating's map of number values. + /// @return A const reference to this MOSRotating's map of number values. const std::unordered_map& GetNumberValueMap() const { return m_NumberValueMap; } - /// /// Returns the string value associated with the specified key or "" if it does not exist. - /// - /// Key to retrieve value. - /// The value associated with the key. + /// @param key Key to retrieve value. + /// @return The value associated with the key. const std::string& GetStringValue(const std::string& key) const; - /// /// Returns an encoded string value associated with the specified key or "" if it does not exist. - /// - /// Key to retrieve value. - /// The value associated with the key. + /// @param key Key to retrieve value. + /// @return The value associated with the key. std::string GetEncodedStringValue(const std::string& key) const; - /// /// Returns the number value associated with the specified key or 0 if it does not exist. - /// - /// Key to retrieve value. - /// The value associated with the key. + /// @param key Key to retrieve value. + /// @return The value associated with the key. double GetNumberValue(const std::string& key) const; - /// /// Returns the entity value associated with the specified key or nullptr if it does not exist. - /// - /// Key to retrieve value. - /// The value associated with the key. + /// @param key Key to retrieve value. + /// @return The value associated with the key. Entity* GetObjectValue(const std::string& key) const; - /// /// Sets the string value associated with the specified key. - /// - /// Key to retrieve value. - /// The new value to be associated with the key. + /// @param key Key to retrieve value. + /// @param value The new value to be associated with the key. void SetStringValue(const std::string& key, const std::string& value); - /// /// Sets the string value associated with the specified key. - /// - /// Key to retrieve value. - /// The new value to be associated with the key. + /// @param key Key to retrieve value. + /// @param value The new value to be associated with the key. void SetEncodedStringValue(const std::string& key, const std::string& value); - /// /// Sets the number value associated with the specified key. - /// - /// Key to retrieve value. - /// The new value to be associated with the key. + /// @param key Key to retrieve value. + /// @param value The new value to be associated with the key. void SetNumberValue(const std::string& key, double value); - /// /// Sets the entity value associated with the specified key. - /// - /// Key to retrieve value. - /// The new value to be associated with the key. + /// @param key Key to retrieve value. + /// @param value The new value to be associated with the key. void SetObjectValue(const std::string& key, Entity* value); - /// /// Remove the string value associated with the specified key. - /// - /// The key to remove. + /// @param key The key to remove. void RemoveStringValue(const std::string& key); - /// /// Remove the number value associated with the specified key. - /// - /// The key to remove. + /// @param key The key to remove. void RemoveNumberValue(const std::string& key); - /// /// Remove the entity value associated with the specified key. - /// - /// The key to remove. + /// @param key The key to remove. void RemoveObjectValue(const std::string& key); - /// /// Checks whether the string value associated with the specified key exists. - /// - /// The key to check. - /// Whether or not there is an associated value for this key. + /// @param key The key to check. + /// @return Whether or not there is an associated value for this key. bool StringValueExists(const std::string& key) const; - /// /// Checks whether the number value associated with the specified key exists. - /// - /// The key to check. - /// Whether or not there is an associated value for this key. + /// @param key The key to check. + /// @return Whether or not there is an associated value for this key. bool NumberValueExists(const std::string& key) const; - /// /// Checks whether the entity value associated with the specified key exists. - /// - /// The key to check. - /// Whether or not there is an associated value for this key. + /// @param key The key to check. + /// @return Whether or not there is an associated value for this key. bool ObjectValueExists(const std::string& key) const; - /// /// Event listener to be run while this MovableObject's PieMenu is opened. - /// - /// The PieMenu this event listener needs to listen to. This will always be this' m_PieMenu and only exists for std::bind. - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @param pieMenu The PieMenu this event listener needs to listen to. This will always be this' m_PieMenu and only exists for std::bind. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. virtual int WhilePieMenuOpenListener(const PieMenu* pieMenu); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: UpdateMOID - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates this' and its its childrens' MOID's and foorprint. Should - // be done every frame. - // Arguments: None. - // Return value: None. - + /// Updates this' and its its childrens' MOID's and foorprint. Should + /// be done every frame. void UpdateMOID(std::vector& MOIDIndex, MOID rootMOID = g_NoMOID, bool makeNewMOID = true); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: DrawMOIDIfOverlapping - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws the MOID representation of this to the SceneMan's MOID layer if - // this is found to potentially overlap another MovableObject. - // Arguments: The MovableObject to check this for overlap against. - // Return value: Whether it was drawn or not. - + /// Draws the MOID representation of this to the SceneMan's MOID layer if + /// this is found to potentially overlap another MovableObject. + /// @param pOverlapMO The MovableObject to check this for overlap against. + /// @return Whether it was drawn or not. virtual bool DrawMOIDIfOverlapping(MovableObject* pOverlapMO) { return false; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: DrawHUD - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws this' current graphical HUD overlay representation to a - // BITMAP of choice. - // Arguments: A pointer to a BITMAP to draw on. - // The absolute position of the draw bitmap's upper left corner in the Scene. - // Which player's screen this is being drawn to. May affect what HUD elements - // get drawn etc. - // Return value: None. - + /// Draws this' current graphical HUD overlay representation to a + /// BITMAP of choice. + /// @param pTargetBitmap A pointer to a BITMAP to draw on. + /// @param targetPos The absolute position of the draw bitmap's upper left corner in the Scene. (default: Vector()) + /// @param whichScreen Which player's screen this is being drawn to. May affect what HUD elements (default: 0) + /// get drawn etc. virtual void DrawHUD(BITMAP* pTargetBitmap, const Vector& targetPos = Vector(), int whichScreen = 0, bool playerControlled = false) { return; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: GetRestThreshold - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns current rest threshold for this MO - // Arguments: None - // Return value: Rest threshold of this MO - + /// Returns current rest threshold for this MO + /// @return Rest threshold of this MO int GetRestThreshold() const { return m_RestThreshold; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: SetRestThreshold - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets current rest threshold for this MO - // Arguments: New rest threshold value - // Return value: None - + /// Sets current rest threshold for this MO + /// @param newRestThreshold New rest threshold value void SetRestThreshold(int newRestThreshold) { m_RestThreshold = newRestThreshold; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Static method: GetNextID - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns the next unique id for MO's and increments unique ID counter - // Arguments: None. - // Return value: Returns the next unique id. - + /// Returns the next unique id for MO's and increments unique ID counter + /// @return Returns the next unique id. static unsigned long int GetNextUniqueID() { return ++m_UniqueIDCounter; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Static method: GetUniqueID - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns this MO's unique persistent ID - // Arguments: None. - // Return value: Returns this MO's unique persistent ID - + /// Returns this MO's unique persistent ID + /// @return Returns this MO's unique persistent ID unsigned long int const GetUniqueID() const { return m_UniqueID; } - /// /// Gets the preset name and unique ID of this MO, often useful for error messages. - /// - /// A string containing the unique ID and preset name of this MO. + /// @return A string containing the unique ID and preset name of this MO. std::string GetPresetNameAndUniqueID() const { return m_PresetName + ", UID: " + std::to_string(m_UniqueID); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: DamageOnCollision - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: If not zero applyies specified ammount of damage points to actors on - // collision even without penetration. - // Arguments: None - // Return value: Amount of damage to apply. - + /// If not zero applyies specified ammount of damage points to actors on + /// collision even without penetration. + /// @return Amount of damage to apply. float DamageOnCollision() const { return m_DamageOnCollision; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: SetDamageOnCollision - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: If not zero applyies specified ammount of damage points to actors on - // collision even without penetration. - // Arguments: Amount of damage to apply. - // Return value: None. - + /// If not zero applyies specified ammount of damage points to actors on + /// collision even without penetration. + /// @param value Amount of damage to apply. void SetDamageOnCollision(float value) { m_DamageOnCollision = value; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: DamageOnPenetration - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: If not zero applies specified ammount of damage points to actors on - // collision if penetration occured. - // Arguments: None - // Return value: Amount of damage to apply. - + /// If not zero applies specified ammount of damage points to actors on + /// collision if penetration occured. + /// @return Amount of damage to apply. float DamageOnPenetration() const { return m_DamageOnPenetration; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: SetDamageOnPenetration - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: If not zero applies specified ammount of damage points to actors on - // collision if penetration occured. - // Arguments: Amount of damage to apply. - // Return value: None. - + /// If not zero applies specified ammount of damage points to actors on + /// collision if penetration occured. + /// @param value Amount of damage to apply. void SetDamageOnPenetration(float value) { m_DamageOnPenetration = value; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: WoundDamageMultiplier - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns damage multiplier transferred to wound inflicted by this object on penetration - // Arguments: None - // Return value: Damage multiplier to apply to wound. - + /// Returns damage multiplier transferred to wound inflicted by this object on penetration + /// @return Damage multiplier to apply to wound. float WoundDamageMultiplier() const { return m_WoundDamageMultiplier; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: SetWoundDamageMultiplier - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets damage multiplier transferred to wound inflicted by this object on penetration - // Arguments: New damage multiplier to apply to wound. - // Return value: None. - + /// Sets damage multiplier transferred to wound inflicted by this object on penetration + /// @param value New damage multiplier to apply to wound. void SetWoundDamageMultiplier(float value) { m_WoundDamageMultiplier = value; } - /// /// Gets whether or not this MovableObject should apply wound damage when it collides with another MovableObject. - /// - /// Whether or not this MovableObject should apply wound damage when it collides with another MovableObject. + /// @return Whether or not this MovableObject should apply wound damage when it collides with another MovableObject. bool GetApplyWoundDamageOnCollision() const { return m_ApplyWoundDamageOnCollision; } - /// /// Sets whether or not this MovableObject should apply wound damage when it collides with another MovableObject. - /// - /// Whether or not this MovableObject should apply wound damage on collision. + /// @param applyWoundDamageOnCollision Whether or not this MovableObject should apply wound damage on collision. void SetApplyWoundDamageOnCollision(bool applyWoundDamageOnCollision) { m_ApplyWoundDamageOnCollision = applyWoundDamageOnCollision; } - /// /// Gets whether or not this MovableObject should apply burst wound damage when it collides with another MovableObject. - /// - /// Whether or not this MovableObject should apply burst wound damage when it collides with another MovableObject. + /// @return Whether or not this MovableObject should apply burst wound damage when it collides with another MovableObject. bool GetApplyWoundBurstDamageOnCollision() const { return m_ApplyWoundBurstDamageOnCollision; } - /// /// Sets whether or not this MovableObject should apply burst wound damage when it collides with another MovableObject. - /// - /// Whether or not this MovableObject should apply burst wound damage on collision. + /// @param applyWoundDamageOnCollision Whether or not this MovableObject should apply burst wound damage on collision. void SetApplyWoundBurstDamageOnCollision(bool applyWoundBurstDamageOnCollision) { m_ApplyWoundBurstDamageOnCollision = applyWoundBurstDamageOnCollision; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: GetMOIDs - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Puts all MOIDs associated with this MO and all it's descendants into MOIDs vector - // Arguments: Vector to store MOIDs - // Return value: None. - + /// Puts all MOIDs associated with this MO and all it's descendants into MOIDs vector + /// @param MOIDs Vector to store MOIDs virtual void GetMOIDs(std::vector& MOIDs) const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: HitWhatMOID - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns the ID of the MO hit at the previously taken Travel - // This will only potentially return non-g_NoMOID if this object's Atom is set to - // hit MO's and the MO hit isn't marked to be ignored. - // Arguments: None. - // Return value: The ID of the non-ignored MO, if any, that this object's Atom or AtomGroup is now - // intersecting because of the last Travel taken. - + /// Returns the ID of the MO hit at the previously taken Travel + /// This will only potentially return non-g_NoMOID if this object's Atom is set to + /// hit MO's and the MO hit isn't marked to be ignored. + /// @return The ID of the non-ignored MO, if any, that this object's Atom or AtomGroup is now + /// intersecting because of the last Travel taken. MOID HitWhatMOID() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetHitWhatMOID - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the ID of the MO hit at the previously taken Travel - // This will only potentially return non-g_NoMOID if this object's Atom is set to - // hit MO's and the MO hit isn't marked to be ignored. - // Arguments: The ID of the non-ignored MO, if any, that this object's Atom or AtomGroup is now - // intersecting because of the last Travel taken. - // Return value: None. - + /// Sets the ID of the MO hit at the previously taken Travel + /// This will only potentially return non-g_NoMOID if this object's Atom is set to + /// hit MO's and the MO hit isn't marked to be ignored. + /// @param id The ID of the non-ignored MO, if any, that this object's Atom or AtomGroup is now + /// intersecting because of the last Travel taken. void SetHitWhatMOID(MOID id); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: HitWhatMOID - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns the unique ID of the particle hit at the previously taken Travel - // Arguments: None. - // Return value: Unique ID of the particle hit at the previously taken Travel - + /// Returns the unique ID of the particle hit at the previously taken Travel + /// @return Unique ID of the particle hit at the previously taken Travel long int HitWhatParticleUniqueID() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: HitWhatMOID - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns the unique ID of the particle hit at the previously taken Travel - // Arguments: Unique ID of the particle hit at the previously taken Travel. - // Return value: None. - + /// Returns the unique ID of the particle hit at the previously taken Travel + /// @param id Unique ID of the particle hit at the previously taken Travel. void SetHitWhatParticleUniqueID(long int id); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: HitWhatTerrMaterial - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns the terrain material the previously taken Tarvel - // hit, if any. - // Arguments: None. - // Return value: The ID of the material, if any, that this MO hit during the last Travel. - + /// Returns the terrain material the previously taken Tarvel + /// hit, if any. + /// @return The ID of the material, if any, that this MO hit during the last Travel. unsigned char HitWhatTerrMaterial() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetHitWhatTerrMaterial - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the terrain material the previously taken Tarvel hit, if any. - // Arguments: The ID of the material, if any, that this MO hit during the last Travel. - // Return value: None. - + /// Sets the terrain material the previously taken Tarvel hit, if any. + /// @param matID The ID of the material, if any, that this MO hit during the last Travel. void SetHitWhatTerrMaterial(unsigned char matID); - /// /// Gets whether this MO's RootParent can GetHitByMOs and is currently traveling. - /// - /// Whether this MO's RootParent can GetHitByMOs and is currently traveling. + /// @return Whether this MO's RootParent can GetHitByMOs and is currently traveling. bool GetTraveling() const { return GetRootParent()->m_IsTraveling; } - /// /// Sets whether this MO's RootParent is currently traveling. - /// - /// Whether this MO's RootParent is currently traveling. + /// @param newValue Whether this MO's RootParent is currently traveling. void SetTraveling(bool newValue) { GetRootParent()->m_IsTraveling = newValue; } - /// /// Draws this MovableObject's graphical and material representations to the specified SLTerrain's respective layers. - /// - /// The SLTerrain to draw this MovableObject to. Ownership is NOT transferred! - /// Whether the object was successfully drawn to the terrain. + /// @param terrain The SLTerrain to draw this MovableObject to. Ownership is NOT transferred! + /// @return Whether the object was successfully drawn to the terrain. bool DrawToTerrain(SLTerrain* terrain); - /// /// Used to get the Lua state that handles our scripts. - /// - /// Our lua state. Can potentially be nullptr if we're not setup yet. + /// @return Our lua state. Can potentially be nullptr if we're not setup yet. LuaStateWrapper* GetLuaState() { return m_ThreadedLuaState; } - /// /// Method to be run when the game is saved via ActivityMan::SaveCurrentGame. Not currently used in metagame or editor saving. - /// virtual void OnSave() { RunScriptedFunctionInAppropriateScripts("OnSave"); } - /// /// Requests a synced update for the MO this frame. - /// virtual void RequestSyncedUpdate() { m_RequestedSyncedUpdate = true; } - /// /// Resets the requested update flag. - /// virtual void ResetRequestedSyncedUpdateFlag() { m_RequestedSyncedUpdate = false; } - /// /// Returns whether this MO has requested a synced update this frame. - /// - /// Whether this MO has requested a synced update this frame. + /// @return Whether this MO has requested a synced update this frame. virtual bool HasRequestedSyncedUpdate() { return m_RequestedSyncedUpdate; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Protected member variable and method declarations - + /// Protected member variable and method declarations protected: - /// /// Does necessary work to setup a script object name for this object, allowing it to be accessed in Lua, then runs all of the MO's scripts' Create functions in Lua. - /// - /// 0 on success, -2 if it fails to setup the script object in Lua, and -3 if it fails to run any Create function. + /// @return 0 on success, -2 if it fails to setup the script object in Lua, and -3 if it fails to run any Create function. int InitializeObjectScripts(); - /// /// Runs the given function for the given script, with the given arguments. The first argument to the function will always be 'self'. /// If either argument list is not empty, its entries will be passed into the Lua function in order, with entity arguments first. - /// - /// The path to the script to run. - /// The name of the function to run. - /// Optional vector of entity pointers that should be passed into the Lua function. Their internal Lua states will not be accessible. Defaults to empty. - /// Optional vector of strings, that should be passed into the Lua function. Entries must be surrounded with escaped quotes (i.e.`\"`) they'll be passed in as-is, allowing them to act as booleans, etc.. Defaults to empty. - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @param scriptPath The path to the script to run. + /// @param functionName The name of the function to run. + /// @param functionEntityArguments Optional vector of entity pointers that should be passed into the Lua function. Their internal Lua states will not be accessible. Defaults to empty. + /// @param functionLiteralArguments Optional vector of strings, that should be passed into the Lua function. Entries must be surrounded with escaped quotes (i.e.`\"`) they'll be passed in as-is, allowing them to act as booleans, etc.. Defaults to empty. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int RunFunctionOfScript(const std::string& scriptPath, const std::string& functionName, const std::vector& functionEntityArguments = std::vector(), const std::vector& functionLiteralArguments = std::vector()); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: UpdateChildMOIDs - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes this MO register itself and all its attached children in the - // MOID register and get ID:s for itself and its children for this frame. - // Arguments: The MOID index to register itself and its children in. - // The MOID of the root MO of this MO, ie the highest parent of this MO. - // 0 means that this MO is the root, ie it is owned by MovableMan. - // Whether this MO should make a new MOID to use for itself, or to use - // the same as the last one in the index (presumably its parent), - // Return value: None. - + /// Makes this MO register itself and all its attached children in the + /// MOID register and get ID:s for itself and its children for this frame. + /// @param MOIDIndex The MOID index to register itself and its children in. + /// @param rootMOID The MOID of the root MO of this MO, ie the highest parent of this MO. (default: g_NoMOID) + /// 0 means that this MO is the root, ie it is owned by MovableMan. + /// @param makeNewMOID Whether this MO should make a new MOID to use for itself, or to use (default: true) + /// the same as the last one in the index (presumably its parent), virtual void UpdateChildMOIDs(std::vector& MOIDIndex, MOID rootMOID = g_NoMOID, bool makeNewMOID = true) {} - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: RegMOID - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes this MO register itself in the MOID register and get ID:s for - // itself and its children for this frame. - // BITMAP of choice. - // Arguments: The MOID index to register itself and its children in. - // The MOID of the root MO of this MO, ie the highest parent of this MO. - // 0 means that this MO is the root, ie it is owned by MovableMan. - // Whether this MO should make a new MOID to use for itself, or to use - // the same as the last one in the index (presumably its parent), - // Return value: None. - + /// Makes this MO register itself in the MOID register and get ID:s for + /// itself and its children for this frame. + /// BITMAP of choice. + /// @param MOIDIndex The MOID index to register itself and its children in. + /// @param rootMOID The MOID of the root MO of this MO, ie the highest parent of this MO. (default: g_NoMOID) + /// 0 means that this MO is the root, ie it is owned by MovableMan. + /// @param makeNewMOID Whether this MO should make a new MOID to use for itself, or to use (default: true) + /// the same as the last one in the index (presumably its parent), void RegMOID(std::vector& MOIDIndex, MOID rootMOID = g_NoMOID, bool makeNewMOID = true); - ////////////////////////////////////////////////////////////////////////////////////////// - // Constructor: MovableObject - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Copy constructor method used to instantiate a MovableObject object - // identical to an already existing one. - // Arguments: A MovableObject object which is passed in by reference. - + /// Copy constructor method used to instantiate a MovableObject object + /// identical to an already existing one. + /// @param A MovableObject object which is passed in by reference. // Member variables static Entity::ClassInfo m_sClass; // Global counter with unique ID's @@ -2080,28 +1257,20 @@ namespace RTE { int m_SimUpdatesBetweenScriptedUpdates; //!< The number of Sim updates between each scripted update for this MovableObject. int m_SimUpdatesSinceLastScriptedUpdate; //!< The counter for the current number of Sim updates since this MovableObject last ran a scripted update. - ////////////////////////////////////////////////////////////////////////////////////////// - // Private member variable and method declarations - + /// Private member variable and method declarations private: - /// /// Clears all the member variables of this MovableObject, effectively resetting the members of this abstraction level only. - /// void Clear(); - /// /// Handles reading for custom values, dealing with the various types of custom values. - /// - /// A Reader lined up to the custom value type to be read. + /// @param reader A Reader lined up to the custom value type to be read. void ReadCustomValueProperty(Reader& reader); - /// /// Returns the script state to use for a given script path. /// This will be locked to our thread and safe to use - ensure that it'll be unlocked after use! - /// - /// The path to the script to check for thread safety. - /// A LuaFunction, to use as an early-out check instead of redundantly hashing and checking the filepath string. - /// A script state. + /// @param scriptPath The path to the script to check for thread safety. + /// @param function A LuaFunction, to use as an early-out check instead of redundantly hashing and checking the filepath string. + /// @return A script state. LuaStateWrapper& GetAndLockStateForScript(const std::string& scriptPath, const LuaFunction* function = nullptr); // Disallow the use of some implicit methods. diff --git a/Source/Entities/PEmitter.cpp b/Source/Entities/PEmitter.cpp index 81bcc656a3..56d460ee8e 100644 --- a/Source/Entities/PEmitter.cpp +++ b/Source/Entities/PEmitter.cpp @@ -1,15 +1,3 @@ -////////////////////////////////////////////////////////////////////////////////////////// -// File: PEmitter.cpp -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Source file for the PEmitter class. -// Project: Retro Terrain Engine -// Author(s): Daniel Tabar -// data@datarealms.com -// http://www.datarealms.com - -////////////////////////////////////////////////////////////////////////////////////////// -// Inclusions of header files - #include "PEmitter.h" #include "Atom.h" #include "RTETools.h" @@ -20,12 +8,6 @@ namespace RTE { ConcreteClassInfo(PEmitter, MOSParticle, 100); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Clear - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears all the member variables of this PEmitter, effectively - // resetting the members of this abstraction level only. - void PEmitter::Clear() { m_EmissionList.clear(); m_EmissionSound.Reset(); @@ -57,11 +39,6 @@ namespace RTE { m_LoudnessOnEmit = 1.0f; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes the Emission object ready for use. - int PEmitter::Create() { if (MOSParticle::Create() < 0) return -1; @@ -69,11 +46,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Creates a PEmitter to be identical to another, by deep copy. - int PEmitter::Create(const PEmitter& reference) { MOSParticle::Create(reference); @@ -104,14 +76,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: ReadProperty - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Reads a property value from a reader stream. If the name isn't - // recognized by this class, then ReadProperty of the parent class - // is called. If the property isn't recognized by any of the base classes, - // false is returned, and the reader's position is untouched. - int PEmitter::ReadProperty(const std::string_view& propName, Reader& reader) { StartPropertyList(return MOSParticle::ReadProperty(propName, reader)); @@ -161,12 +125,6 @@ namespace RTE { EndPropertyList; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Save - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Saves the complete state of this PEmitter with a Writer for - // later recreation with Create(Reader &reader); - int PEmitter::Save(Writer& writer) const { MOSParticle::Save(writer); @@ -218,11 +176,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destroys and resets (through Clear()) the PEmitter object. - void PEmitter::Destroy(bool notInherited) { // Stop playback of sounds gracefully if (m_EmissionSound.IsBeingPlayed()) @@ -238,23 +191,12 @@ namespace RTE { Clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ResetEmissionTimers - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Reset the timers of all emissions so they will start/stop at the - // correct relative offsets from now. - void PEmitter::ResetEmissionTimers() { m_LastEmitTmr.Reset(); for (auto eItr = m_EmissionList.begin(); eItr != m_EmissionList.end(); ++eItr) (*eItr).ResetEmissionTimers(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: EnableEmission - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets this PEmitter to start emitting at the set rate, or to stop. - void PEmitter::EnableEmission(bool enable) { if (!m_EmitEnabled && enable) { m_LastEmitTmr.Reset(); @@ -266,11 +208,6 @@ namespace RTE { m_EmitEnabled = enable; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: EstimateImpulse - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Calculates the forces this emitter applies on any parent. - float PEmitter::EstimateImpulse(bool burst) { // Calculate the impulse generated by the emissions, once and store the result if ((!burst && m_AvgImpulse < 0) || (burst && m_AvgBurstImpulse < 0)) { @@ -325,11 +262,6 @@ namespace RTE { } */ - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Update - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates this PEmitter. Supposed to be done every frame. - void PEmitter::Update() { MOSParticle::Update(); @@ -474,12 +406,6 @@ namespace RTE { } } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Draw - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws this PEmitter's current graphical representation to a - // BITMAP of choice. - void PEmitter::Draw(BITMAP* pTargetBitmap, const Vector& targetPos, DrawMode mode, diff --git a/Source/Entities/PEmitter.h b/Source/Entities/PEmitter.h index 8395f77cb7..8fe3302c6f 100644 --- a/Source/Entities/PEmitter.h +++ b/Source/Entities/PEmitter.h @@ -1,36 +1,21 @@ #ifndef _RTEPEMITTER_ #define _RTEPEMITTER_ -////////////////////////////////////////////////////////////////////////////////////////// -// File: PEmitter.h -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Header file for the PEmitter class. -// Project: Retro Terrain Engine -// Author(s): Daniel Tabar -// data@datarealms.com -// http://www.datarealms.com - -////////////////////////////////////////////////////////////////////////////////////////// -// Inclusions of header files - +/// Header file for the PEmitter class. +/// @author Daniel Tabar +/// data@datarealms.com +/// http://www.datarealms.com +/// Inclusions of header files #include "MOSParticle.h" #include "Emission.h" #include "SoundContainer.h" namespace RTE { - ////////////////////////////////////////////////////////////////////////////////////////// - // Class: PEmitter - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: A particle MO that creates and emits particle MOs. - // Parent(s): MOSParticle. - // Class history: 02/29/2004 PEmitter created. - + /// A particle MO that creates and emits particle MOs. class PEmitter : public MOSParticle { - ////////////////////////////////////////////////////////////////////////////////////////// - // Public member variable, method and friend function declarations - + /// Public member variable, method and friend function declarations public: friend struct EntityLuaBindings; @@ -39,108 +24,56 @@ namespace RTE { SerializableOverrideMethods; ClassInfoGetters; - ////////////////////////////////////////////////////////////////////////////////////////// - // Constructor: PEmitter - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Constructor method used to instantiate a PEmitter object in system - // memory. Create() should be called before using the object. - // Arguments: None. - + /// Constructor method used to instantiate a PEmitter object in system + /// memory. Create() should be called before using the object. PEmitter() { Clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Destructor: ~PEmitter - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destructor method used to clean up a PEmitter object before deletion - // from system memory. - // Arguments: None. - + /// Destructor method used to clean up a PEmitter object before deletion + /// from system memory. ~PEmitter() override { Destroy(true); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes the PEmitter object ready for use. - // Arguments: None. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Makes the PEmitter object ready for use. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Create() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Creates a PEmitter to be identical to another, by deep copy. - // Arguments: A reference to the PEmitter to deep copy. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Creates a PEmitter to be identical to another, by deep copy. + /// @param reference A reference to the PEmitter to deep copy. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Create(const PEmitter& reference); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Reset - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Resets the entire PEmitter, including its inherited members, to their - // default settings or values. - // Arguments: None. - // Return value: None. - + /// Resets the entire PEmitter, including its inherited members, to their + /// default settings or values. void Reset() override { Clear(); MOSParticle::Reset(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destroys and resets (through Clear()) the SceneLayer object. - // Arguments: Whether to only destroy the members defined in this derived class, or - // to destroy all inherited members also. - // Return value: None. - + /// Destroys and resets (through Clear()) the SceneLayer object. + /// @param notInherited Whether to only destroy the members defined in this derived class, or (default: false) + /// to destroy all inherited members also. void Destroy(bool notInherited = false) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: IsEmitting - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Indicates whether this PEmitter is currently enabled and emitting. - // Arguments: None. - // Return value: Whether it's emitting or not. - + /// Indicates whether this PEmitter is currently enabled and emitting. + /// @return Whether it's emitting or not. bool IsEmitting() const { return m_EmitEnabled; } - /// /// Returns whether this emitter was emitting last frame. - /// - /// Whether this emitter was emitting last frame. + /// @return Whether this emitter was emitting last frame. bool WasEmitting() const { return m_WasEmitting; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ResetEmissionTimers - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Reset the timers of all emissions so they will start/stop at the - // correct relative offsets from now. - // Arguments: None. - // Return value: None. - + /// Reset the timers of all emissions so they will start/stop at the + /// correct relative offsets from now. void ResetEmissionTimers(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: EnableEmission - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets this PEmitter to start emitting at the set rate, or to stop. - // Arguments: Whether to enable or disable emission. - // Return value: None. - + /// Sets this PEmitter to start emitting at the set rate, or to stop. + /// @param enable Whether to enable or disable emission. (default: true) void EnableEmission(bool enable = true); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: EstimateImpulse - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Calculates the forces this emitter applies on any parent. - // Arguments: Whether to calculate a burst update or not. - // Return value: The approximate impulse generated by the emitter. - + /// Calculates the forces this emitter applies on any parent. + /// @param burst Whether to calculate a burst update or not. (default: false) + /// @return The approximate impulse generated by the emitter. float EstimateImpulse(bool burst = false); /* @@ -166,52 +99,27 @@ namespace RTE { int GetBurstCount() const { return m_BurstSize; } */ - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetBurstScale - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the scale factor that will be applied to the regular spread and - // emission velocity to get the burst particle parameters. - // Arguments: None. - // Return value: The scale factor. - + /// Gets the scale factor that will be applied to the regular spread and + /// emission velocity to get the burst particle parameters. + /// @return The scale factor. float GetBurstScale() const { return m_BurstScale; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetEmitAngle - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the angle of direction that the emitted particles will be shot at. - // Arguments: None. - // Return value: A float with the angle in radians. - + /// Gets the angle of direction that the emitted particles will be shot at. + /// @return A float with the angle in radians. float GetEmitAngle() const { return m_EmitAngle.GetRadAngle(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetEmitVector - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: A vector in the direction, including the rotation of the emitter, that - // the emitted particles will be shot at. - // Arguments: None. - // Return value: A unit vector. - + /// A vector in the direction, including the rotation of the emitter, that + /// the emitted particles will be shot at. + /// @return A unit vector. Vector GetEmitVector() const { return Vector(1, 0).RadRotate(m_HFlipped ? c_PI + m_Rotation.GetRadAngle() - m_EmitAngle.GetRadAngle() : m_Rotation.GetRadAngle() + m_EmitAngle.GetRadAngle()); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetRecoilVector - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: A vector in the opposite direction, including the rotation of the - // emitter, that the emitted particles will be shot at. - // Arguments: None. - // Return value: A unit vector. - + /// A vector in the opposite direction, including the rotation of the + /// emitter, that the emitted particles will be shot at. + /// @return A unit vector. Vector GetRecoilVector() const { return Vector(-1, 0).RadRotate(m_HFlipped ? c_PI + m_Rotation.GetRadAngle() - m_EmitAngle.GetRadAngle() : m_Rotation.GetRadAngle() + m_EmitAngle.GetRadAngle()); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetBurstSpacing - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the BurstSpacing for this emitter. - // Arguments: None. - // Return value: The BurstSpacing in ms. - + /// Gets the BurstSpacing for this emitter. + /// @return The BurstSpacing in ms. float GetBurstSpacing() const { return m_BurstSpacing; } /* @@ -250,28 +158,19 @@ namespace RTE { float GetEmitVelMax() const { return m_MaxVelocity; } */ - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetThrottle - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the normalized throttle scalar which controls how to affect the - // emission rate as per the emisison rate range. Depricated for Lua, use - // the Throttle property instead. - // Arguments: None. - // Return value: A float with the normalized throttle scalar. 1.0 means max throttle, - // 0 means normal, -1.0 means least emission rate. - + /// Gets the normalized throttle scalar which controls how to affect the + /// emission rate as per the emisison rate range. Depricated for Lua, use + /// the Throttle property instead. + /// @return A float with the normalized throttle scalar. 1.0 means max throttle, + /// 0 means normal, -1.0 means least emission rate. float GetThrottle() const { return m_Throttle; } - /// /// Gets the adjusted throttle multiplier that is factored into the emission rate of this PEmitter. - /// - /// The throttle strength as a multiplier. + /// @return The throttle strength as a multiplier. float GetThrottleFactor() const { return LERP(-1.0f, 1.0f, m_NegativeThrottleMultiplier, m_PositiveThrottleMultiplier, m_Throttle); } - /// /// Gets the throttle value that will achieve a given throttle factor that is factored into the emission rate of this AEmitter. - /// - /// The throttle value that will achieve the given throttle factor. + /// @return The throttle value that will achieve the given throttle factor. float GetThrottleForThrottleFactor(float throttleFactor) const { return LERP(m_NegativeThrottleMultiplier, m_PositiveThrottleMultiplier, -1.0f, 1.0f, throttleFactor); } /* @@ -297,59 +196,32 @@ namespace RTE { void SetBurstCount(const int count) { m_BurstSize = count; } */ - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetBurstScale - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the scale factor that will be applied to the regular spread and - // emission velocity to get the burst particle parameters. - // Arguments: The scale factor. - // Return value: None. - + /// Sets the scale factor that will be applied to the regular spread and + /// emission velocity to get the burst particle parameters. + /// @param scale The scale factor. void SetBurstScale(const float scale) { m_BurstScale = scale; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetBurstSpacing - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the BurstSpacing for this emitter. - // Arguments: The BurstSpacing in ms. - // Return value: None. - + /// Sets the BurstSpacing for this emitter. + /// @param spacing The BurstSpacing in ms. void SetBurstSpacing(const float spacing) { m_BurstSpacing = spacing; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetFlashScale - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the display scale factor of the flash effect. This is purely - // visual. - // Arguments: The scale factor of the flash draw. - // Return value: None. - + /// Sets the display scale factor of the flash effect. This is purely + /// visual. + /// @param flashScale The scale factor of the flash draw. (default: 1.0f) void SetFlashScale(float flashScale = 1.0f) { m_FlashScale = flashScale; } - /// /// Gets the display scale factor of the flash effect. This is purely visual. - /// - /// The scale factor of the flash draw. + /// @return The scale factor of the flash draw. float GetFlashScale() const { return m_FlashScale; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetEmitAngle - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the angle of direction that the emitted particles will be shot at. - // Arguments: A float with the angle in radians. - // Return value: None. - + /// Sets the angle of direction that the emitted particles will be shot at. + /// @param m_EmitAngle.SetRadAngle(angle A float with the angle in radians. void SetEmitAngle(const float angle) { m_EmitAngle.SetRadAngle(angle); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetThrottle - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the normalized throttle scalar which controls how to affect the - // emission rate as per the emisison rate range. - // Arguments: A float with the normalized throttle scalar. 1.0 means max throttle, - // 0 means normal, -1.0 means least emission rate. - // Return value: None. - + /// Sets the normalized throttle scalar which controls how to affect the + /// emission rate as per the emisison rate range. + /// @param m_Throttle A float with the normalized throttle scalar. 1.0 means max throttle, (default: throttle > 1.0f ? 1.0f : (throttle < -1.0f ? -1.0f : throttle) + /// 0 means normal, -1.0 means least emission rate. void SetThrottle(float throttle) { m_Throttle = throttle > 1.0f ? 1.0f : (throttle < -1.0f ? -1.0f : throttle); } /* @@ -388,111 +260,65 @@ namespace RTE { void SetEmitVelMax(const float maxVel) { m_MaxVelocity = maxVel; } */ - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: TriggerBurst - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Triggers a one-shot burst of emissions in the number that has - // previously been set. The burst will happen during the next Update of - // this PEmitter. - // Arguments: None. - // Return value: None. - + /// Triggers a one-shot burst of emissions in the number that has + /// previously been set. The burst will happen during the next Update of + /// this PEmitter. void TriggerBurst() { m_BurstTriggered = true; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: CanTriggerBurst - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Checks if it is possible to trigger a one-shot burst of emissions during - // the next Update of this PEmitter. - // Arguments: None. - // Return value: If it is possible to trigger a burst. - + /// Checks if it is possible to trigger a one-shot burst of emissions during + /// the next Update of this PEmitter. + /// @return If it is possible to trigger a burst. bool CanTriggerBurst() { if (m_BurstSpacing <= 0 || m_BurstTimer.IsPastSimMS(m_BurstSpacing)) return true; return false; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: IsSetToBurst - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Indicates whether this PEmitter is set to burst next update or not. - // Arguments: None. - // Return value: Whether a burst is gonna happen or not.. - + /// Indicates whether this PEmitter is set to burst next update or not. + /// @return Whether a burst is gonna happen or not.. bool IsSetToBurst() const { return m_BurstTriggered; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: AlarmOnEmit - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Registers a new AlarmEvent if this emitter has a loudness above zero. - // Arguments: Team that will ignore this AlarmEvent. - // Return value: None. - + /// Registers a new AlarmEvent if this emitter has a loudness above zero. + /// @param Team Team that will ignore this AlarmEvent. void AlarmOnEmit(int Team) const { if (m_LoudnessOnEmit > 0) g_MovableMan.RegisterAlarmEvent(AlarmEvent(m_Pos, Team, m_LoudnessOnEmit)); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: ResetAllTimers - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Resest all the timers used by this. Can be emitters, etc. This is to - // prevent backed up emissions to come out all at once while this has been - // held dormant in an inventory. - // Arguments: None. - // Return value: None. - + /// Resest all the timers used by this. Can be emitters, etc. This is to + /// prevent backed up emissions to come out all at once while this has been + /// held dormant in an inventory. void ResetAllTimers() override { m_BurstTimer.Reset(); m_LastEmitTmr.Reset(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Update - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates this MovableObject. Supposed to be done every frame. - // Arguments: None. - // Return value: None. - + /// Updates this MovableObject. Supposed to be done every frame. void Update() override; void PostUpdate() override { MOSParticle::PostUpdate(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Draw - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws this PEmitter's current graphical representation to a - // BITMAP of choice. - // Arguments: A pointer to a BITMAP to draw on. - // The absolute position of the target bitmap's upper left corner in the Scene. - // In which mode to draw in. See the DrawMode enumeration for the modes. - // Whether to not draw any extra 'ghost' items of this MovableObject, - // indicator arrows or hovering HUD text and so on. - // Return value: None. - + /// Draws this PEmitter's current graphical representation to a + /// BITMAP of choice. + /// @param pTargetBitmap A pointer to a BITMAP to draw on. + /// @param targetPos The absolute position of the target bitmap's upper left corner in the Scene. (default: Vector()) + /// @param mode In which mode to draw in. See the DrawMode enumeration for the modes. (default: g_DrawColor) + /// @param onlyPhysical Whether to not draw any extra 'ghost' items of this MovableObject, (default: false) + /// indicator arrows or hovering HUD text and so on. void Draw(BITMAP* pTargetBitmap, const Vector& targetPos = Vector(), DrawMode mode = g_DrawColor, bool onlyPhysical = false) const override; - /// /// Gets the number of emissions left before emitter is disabled. - /// - /// The number of emissions left before emitter is disabled. + /// @return The number of emissions left before emitter is disabled. long GetEmitCountLimit() const { return m_EmitCountLimit; } - /// /// Sets the number of emissions left before emitter is disabled. - /// - /// New number of emissions left. + /// @param newValue New number of emissions left. void SetEmitCountLimit(long newValue) { m_EmitCountLimit = newValue; } - /// /// Returns whether this emitter just started emitting this frame. - /// - /// Whether this emitter just started emitting this frame. + /// @return Whether this emitter just started emitting this frame. bool JustStartedEmitting() const { return !m_WasEmitting && m_EmitEnabled; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Protected member variable and method declarations - + /// Protected member variable and method declarations protected: // Member variables static Entity::ClassInfo m_sClass; @@ -550,18 +376,10 @@ namespace RTE { // Whether the burst sound follows the emitter bool m_BurstSoundFollowsEmitter; - ////////////////////////////////////////////////////////////////////////////////////////// - // Private member variable and method declarations - + /// Private member variable and method declarations private: - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Clear - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears all the member variables of this PEmitter, effectively - // resetting the members of this abstraction level only. - // Arguments: None. - // Return value: None. - + /// Clears all the member variables of this PEmitter, effectively + /// resetting the members of this abstraction level only. void Clear(); // Disallow the use of some implicit methods. diff --git a/Source/Entities/PieMenu.cpp b/Source/Entities/PieMenu.cpp index d25f8bbbb7..bd6e1bad40 100644 --- a/Source/Entities/PieMenu.cpp +++ b/Source/Entities/PieMenu.cpp @@ -41,8 +41,6 @@ namespace RTE { BITMAP* PieMenu::s_CursorBitmap = nullptr; - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PieMenu::Clear() { m_LargeFont = nullptr; @@ -93,8 +91,6 @@ namespace RTE { m_BGPieSlicesWithSubPieMenuBitmapNeedsRedrawing = true; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int PieMenu::Create() { if (!s_CursorBitmap) { s_CursorBitmap = ContentFile("Base.rte/GUIs/PieMenus/PieCursor.png").GetAsBitmap(); @@ -111,8 +107,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int PieMenu::Create(const PieMenu& reference) { Entity::Create(reference); @@ -160,8 +154,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PieMenu::Destroy(bool notInherited) { if (!notInherited) { Entity::Destroy(); @@ -172,8 +164,6 @@ namespace RTE { Clear(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int PieMenu::ReadProperty(const std::string_view& propName, Reader& reader) { StartPropertyList(return Entity::ReadProperty(propName, reader)); @@ -209,8 +199,6 @@ namespace RTE { EndPropertyList; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int PieMenu::Save(Writer& writer) const { Entity::Save(writer); @@ -232,8 +220,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PieMenu::SetOwner(Actor* newOwner) { RTEAssert((newOwner == nullptr) ? true : (newOwner->GetPieMenu() == this || IsSubPieMenu()), "Tried to set Pie Menu owning Actor to Actor with different Pie Menu."); if (m_Owner) { @@ -252,8 +238,6 @@ namespace RTE { m_Owner = newOwner; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - Controller* PieMenu::GetController() const { if (m_MenuController) { return m_MenuController; @@ -265,16 +249,12 @@ namespace RTE { return m_Owner->GetController(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PieMenu::SetPos(const Vector& newPos) { if (g_SceneMan.ShortestDistance(m_CenterPos, newPos, g_SceneMan.SceneWrapsX()).GetMagnitude() > 2.0F) { m_CenterPos = newPos; } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PieMenu::SetEnabled(bool enable, bool playSounds) { m_MenuMode = MenuMode::Normal; @@ -304,8 +284,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - const PieSlice* PieMenu::GetActivatedPieSlice() const { if (m_ActiveSubPieMenu) { return m_ActiveSubPieMenu->GetActivatedPieSlice(); @@ -313,15 +291,11 @@ namespace RTE { return m_ActivatedPieSlice; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - PieSlice::SliceType PieMenu::GetPieCommand() const { const PieSlice* activatedSlice = m_ActiveSubPieMenu ? m_ActiveSubPieMenu->GetActivatedPieSlice() : m_ActivatedPieSlice; return (activatedSlice == nullptr) ? PieSlice::SliceType::NoType : activatedSlice->GetType(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - PieSlice* PieMenu::GetFirstPieSliceByPresetName(const std::string& presetName) const { for (PieSlice* pieSlice: m_CurrentPieSlices) { if (pieSlice->GetPresetName() == presetName) { @@ -331,8 +305,6 @@ namespace RTE { return nullptr; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - PieSlice* PieMenu::GetFirstPieSliceByType(PieSlice::SliceType pieSliceType) const { for (PieSlice* pieSlice: m_CurrentPieSlices) { if (pieSlice->GetType() == pieSliceType) { @@ -342,8 +314,6 @@ namespace RTE { return nullptr; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool PieMenu::AddPieSlice(PieSlice* pieSliceToAdd, const Entity* pieSliceOriginalSource, bool allowQuadrantOverflow) { Directions pieSliceDirection = pieSliceToAdd->GetDirection(); if (pieSliceDirection != Directions::Any && !m_PieQuadrants.at(pieSliceDirection).m_Enabled) { @@ -381,8 +351,6 @@ namespace RTE { return sliceWasAdded; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool PieMenu::AddPieSliceIfPresetNameIsUnique(PieSlice* pieSliceToAdd, const Entity* pieSliceOriginalSource, bool onlyCheckPieSlicesWithSameOriginalSource, bool allowQuadrantOverflow) { const std::string& pieSlicePresetName = pieSliceToAdd->GetPresetName(); @@ -407,8 +375,6 @@ namespace RTE { return AddPieSlice(dynamic_cast(pieSliceToAdd->Clone()), pieSliceOriginalSource, allowQuadrantOverflow); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - PieSlice* PieMenu::RemovePieSlice(const PieSlice* pieSliceToRemove) { PieSlice* removedPieSlice = nullptr; @@ -435,8 +401,6 @@ namespace RTE { return removedPieSlice; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool PieMenu::RemovePieSlicesByPresetName(const std::string& presetNameToRemoveBy) { bool anyPieSlicesRemoved = false; @@ -454,8 +418,6 @@ namespace RTE { return anyPieSlicesRemoved; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool PieMenu::RemovePieSlicesByType(PieSlice::SliceType pieSliceTypeToRemoveBy) { bool anyPieSlicesRemoved = false; @@ -473,8 +435,6 @@ namespace RTE { return anyPieSlicesRemoved; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool PieMenu::RemovePieSlicesByOriginalSource(const Entity* originalSource) { bool anyPieSlicesRemoved = false; @@ -492,8 +452,6 @@ namespace RTE { return anyPieSlicesRemoved; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - PieSlice* PieMenu::ReplacePieSlice(const PieSlice* pieSliceToReplace, PieSlice* replacementPieSlice) { if (pieSliceToReplace == nullptr) { return nullptr; @@ -561,8 +519,6 @@ namespace RTE { return replacedPieSlice; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PieMenu::Update() { const Controller* controller = GetController(); @@ -665,8 +621,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PieMenu::Draw(BITMAP* targetBitmap, const Vector& targetPos) const { Vector drawPos; CalculateDrawPosition(targetBitmap, targetPos, drawPos); @@ -692,8 +646,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PieMenu::UpdateWobbling() { float innerRadiusChange = static_cast(m_EnableDisableAnimationTimer.GetElapsedRealTimeMS()) / 6.0F; @@ -710,8 +662,6 @@ namespace RTE { m_EnableDisableAnimationTimer.Reset(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PieMenu::UpdateEnablingAndDisablingProgress() { m_BGBitmapNeedsRedrawing = true; if (m_EnabledState == EnabledState::Enabling) { @@ -733,8 +683,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool PieMenu::HandleAnalogInput(const Vector& input) { const Controller* controller = GetController(); const PieSlice* pieSliceToSelect = nullptr; @@ -761,8 +709,6 @@ namespace RTE { return false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool PieMenu::HandleDigitalInput() { const Controller* controller = GetController(); if (!controller) { @@ -859,8 +805,6 @@ namespace RTE { return false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PieMenu::UpdateSliceActivation() { const Controller* controller = GetController(); if (controller && (controller->IsState(ControlState::PRESS_PRIMARY) || (m_HoveredPieSlice != m_AlreadyActivatedPieSlice && controller->IsState(ControlState::RELEASE_SECONDARY)))) { @@ -898,8 +842,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PieMenu::UpdatePredrawnMenuBackgroundBitmap() { int centerX = IsSubPieMenu() ? 0 : m_BGBitmap->w / 2; int centerY = IsSubPieMenu() ? 0 : m_BGBitmap->h / 2; @@ -956,8 +898,6 @@ namespace RTE { m_BGPieSlicesWithSubPieMenuBitmapNeedsRedrawing = false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PieMenu::CalculateDrawPosition(const BITMAP* targetBitmap, const Vector& targetPos, Vector& drawPos) const { drawPos = m_CenterPos - targetPos; if (!targetPos.IsZero()) { @@ -1005,8 +945,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PieMenu::DrawPieIcons(BITMAP* targetBitmap, const Vector& drawPos) const { for (const PieSlice* pieSlice: m_CurrentPieSlices) { BITMAP* pieSliceIcon = pieSlice->GetAppropriateIcon(pieSlice == m_HoveredPieSlice); @@ -1037,8 +975,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PieMenu::DrawPieCursorAndPieSliceDescriptions(BITMAP* targetBitmap, const Vector& drawPos) const { int nonLineSeparatorCorrection = m_IconSeparatorMode != IconSeparatorMode::Line ? -(m_BackgroundSeparatorSize) : 0; Vector cursorPos = Vector(static_cast(m_CurrentInnerRadius + nonLineSeparatorCorrection), 0.0F).RadRotate(m_CursorAngle); @@ -1060,8 +996,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PieMenu::RepopulateAndRealignCurrentPieSlices() { m_CurrentPieSlices.clear(); for (PieQuadrant& pieQuadrant: m_PieQuadrants) { @@ -1093,8 +1027,6 @@ namespace RTE { ExpandPieSliceIntoEmptySpaceIfPossible(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PieMenu::ExpandPieSliceIntoEmptySpaceIfPossible() { const std::unordered_map nextDirectionForGivenDirection{{Directions::Right, Directions::Up}, {Directions::Up, Directions::Left}, {Directions::Left, Directions::Down}, {Directions::Down, Directions::Right}}; @@ -1113,8 +1045,6 @@ namespace RTE { m_BGPieSlicesWithSubPieMenuBitmapNeedsRedrawing = true; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PieMenu::RecreateBackgroundBitmaps() { if (m_BGBitmap) { destroy_bitmap(m_BGBitmap); @@ -1142,8 +1072,6 @@ namespace RTE { m_BGPieSlicesWithSubPieMenuBitmapNeedsRedrawing = true; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PieMenu::DrawBackgroundPieSliceSeparators(BITMAP* backgroundBitmapToDrawTo, int pieCircleCenterX, int pieCircleCenterY, float subPieMenuRotationOffset) const { switch (m_IconSeparatorMode) { case IconSeparatorMode::Line: @@ -1189,8 +1117,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PieMenu::DrawBackgroundPieSliceSeparator(BITMAP* backgroundBitmapToDrawTo, int pieCircleCenterX, int pieCircleCenterY, float rotAngle, bool isHoveredPieSlice, bool pieSliceHasSubPieMenu, bool drawHalfSizedSeparator) const { Vector separatorOffset; int backgroundSeparatorSize = m_BackgroundSeparatorSize; @@ -1255,8 +1181,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool PieMenu::SetHoveredPieSlice(const PieSlice* pieSliceToSelect, bool moveCursorIconToSlice) { if (pieSliceToSelect == m_HoveredPieSlice) { return false; @@ -1280,8 +1204,6 @@ namespace RTE { return true; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool PieMenu::PreparePieSliceSubPieMenuForUse(const PieSlice* pieSliceWithSubPieMenu) const { PieMenu* subPieMenu = pieSliceWithSubPieMenu->GetSubPieMenu(); subPieMenu->m_ActivatedPieSlice = nullptr; @@ -1321,8 +1243,6 @@ namespace RTE { return true; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PieMenu::PrepareAnalogCursorForEnableOrDisable(bool enable) const { if (Controller* controller = GetController(); controller && (controller->IsMouseControlled() || controller->IsGamepadControlled())) { if (!IsSubPieMenu()) { diff --git a/Source/Entities/PieMenu.h b/Source/Entities/PieMenu.h index 44ea5d8ff9..714af6606c 100644 --- a/Source/Entities/PieMenu.h +++ b/Source/Entities/PieMenu.h @@ -12,9 +12,7 @@ namespace RTE { class GUIFont; class Actor; - /// /// A PieMenu for managing interactions with objects and Actors. - /// class PieMenu : public Entity { friend class PieSlice; @@ -25,52 +23,38 @@ namespace RTE { ClassInfoGetters #pragma region Creation - /// /// Constructor method used to instantiate a PieMenu object in system memory. Create() should be called before using the object. - /// PieMenu() { Clear(); } - /// /// Makes the PieMenu object ready for use. - /// - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create() override; - /// /// Makes the PieMenu object ready for use. - /// - /// The Actor which should act as the owner for this PieMenu. - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @param owner The Actor which should act as the owner for this PieMenu. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create(Actor* owner) { SetOwner(owner); return Create(); } - /// /// Creates a PieMenu to be identical to another, by deep copy. - /// - /// A reference to the Attachable to deep copy. - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @param reference A reference to the Attachable to deep copy. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create(const PieMenu& reference); #pragma endregion #pragma region Destruction - /// /// Destructor method used to clean up a PieMenu object before deletion from system memory. - /// ~PieMenu() override { Destroy(true); } - /// /// Destroys and resets (through Clear()) the PieMenu object. - /// - /// Whether to only destroy the members defined in this derived class, or to destroy all inherited members also. + /// @param notInherited Whether to only destroy the members defined in this derived class, or to destroy all inherited members also. void Destroy(bool notInherited = false) override; - /// /// Resets the entire PieMenu, including its inherited members, to their default settings or values. - /// void Reset() override { Clear(); Entity::Reset(); @@ -78,94 +62,64 @@ namespace RTE { #pragma endregion #pragma region Getters and Setters - /// /// Gets the owner Actor of this PieMenu. Ownership is NOT transferred! - /// - /// The owner Actor of this PieMenu. Ownership is NOT transferred! + /// @return The owner Actor of this PieMenu. Ownership is NOT transferred! const Actor* GetOwner() const { return m_Owner; } - /// /// Sets the owner Actor of this PieMenu, ensuring this is that Actor's PieMenu, and updates PieSlice sources accordingly. Ownership is NOT transferred! - /// - /// The new owner Actor for this PieMenu. Ownership is NOT transferred! + /// @param newOwner The new owner Actor for this PieMenu. Ownership is NOT transferred! void SetOwner(Actor* newOwner); - /// /// Gets the currently in-use Controller for this PieMenu - either the menu Controller if there's one set, or the owning Actor's Controller. Ownership IS NOT transferred! - /// - /// The currently in-use Controller for this PieMenu. + /// @return The currently in-use Controller for this PieMenu. Controller* GetController() const; - /// /// Sets the menu Controller used by this PieMenu, separate from any Controller on its owner Actor. Ownership is NOT transferred! - /// - /// The new Controller for this PieMenu. Ownership is NOT transferred! + /// @param menuController The new Controller for this PieMenu. Ownership is NOT transferred! void SetMenuController(Controller* menuController) { m_MenuController = menuController; } - /// /// Gets the currently affected MovableObject. Ownership is NOT transferred! - /// - /// The MovableObject this PieMenu affects. Ownership is NOT transferred! + /// @return The MovableObject this PieMenu affects. Ownership is NOT transferred! const MovableObject* GetAffectedObject() const { return m_AffectedObject; } - /// /// Sets the MovableObject this PieMenu should affect. Ownership is NOT transferred! - /// - /// The new MovableObject affected by this PieMenu. Ownership is NOT transferred! + /// @param affectedObject The new MovableObject affected by this PieMenu. Ownership is NOT transferred! void SetAffectedObject(MovableObject* affectedObject) { m_AffectedObject = affectedObject; } - /// /// Gets whether this PieMenu is a sub-PieMenu, i.e. it's owned by a PieSlice. - /// - /// Whether or not this PieMenu is a sub-PieMenu. + /// @return Whether or not this PieMenu is a sub-PieMenu. bool IsSubPieMenu() const { return m_DirectionIfSubPieMenu != Directions::None; } - /// /// Gets the absolute center position of this PieMenu. - /// - /// A Vector describing the current absolute position of this PieMenu in pixels. + /// @return A Vector describing the current absolute position of this PieMenu in pixels. const Vector& GetPos() const { return m_CenterPos; } - /// /// Sets the absolute center position of this PieMenu in the scene. - /// - /// A Vector describing the new absolute position of this PieMenu in pixels, in the scene. + /// @param newPos A Vector describing the new absolute position of this PieMenu in pixels, in the scene. void SetPos(const Vector& newPos); - /// /// Gets the absolute rotation of this PieMenu. - /// - /// A Matrix describing the current absolute rotation of this PieMenu. + /// @return A Matrix describing the current absolute rotation of this PieMenu. const Matrix& GetRotation() const { return m_Rotation; } - /// /// Gets the absolute rotation of this PieMenu in radians. - /// - /// The absolute rotation of this PieMenu in radians. + /// @return The absolute rotation of this PieMenu in radians. float GetRotAngle() const { return m_Rotation.GetRadAngle(); } - /// /// Sets the absolute rotation of this PieMenu. - /// - /// A Matrix describing the new rotation of this PieMenu. + /// @param newRotation A Matrix describing the new rotation of this PieMenu. void SetRotation(const Matrix& newRotation) { m_Rotation = newRotation; } - /// /// Sets the absolute rotation of this PieMenu to the specified rad angle. - /// - /// The angle in radians describing the new rotation of this PieMenu. + /// @param rotAngle The angle in radians describing the new rotation of this PieMenu. void SetRotAngle(float rotAngle) { m_Rotation.SetRadAngle(rotAngle); } - /// /// Gets the full inner radius of this PieMenu. - /// - /// Gets the full inner radius of this PieMenu. + /// @return Gets the full inner radius of this PieMenu. int GetFullInnerRadius() const { return m_FullInnerRadius; } - /// /// Sets the full inner radius of this PieMenu and recreates the background bitmap if it's changed. - /// - /// The new full inner radius of this PieMenu. + /// @param fullInnerRadius The new full inner radius of this PieMenu. void SetFullInnerRadius(int fullInnerRadius) { if (m_FullInnerRadius != fullInnerRadius) { if (m_CurrentInnerRadius == m_FullInnerRadius) { @@ -176,60 +130,42 @@ namespace RTE { } } - /// /// Gets whether or not the PieMenu is enabled or in the process of being enabled, and is not in wobble mode. - /// - /// Whether or not the PieMenu is enabled or in the process of being enabled. + /// @return Whether or not the PieMenu is enabled or in the process of being enabled. bool IsEnabled() const { return (m_EnabledState == EnabledState::Enabled || m_EnabledState == EnabledState::Enabling) && m_MenuMode != MenuMode::Wobble; } - /// /// Gets whether or not the PieMenu is in the process of being enabled. - /// - /// Whether or not the PieMenu is in the process of being enabled. + /// @return Whether or not the PieMenu is in the process of being enabled. bool IsEnabling() const { return m_EnabledState == EnabledState::Enabling; } - /// /// Gets whether or not the PieMenu is in the process of being disabled. - /// - /// Whether or not the PieMenu is in the process of being disabled. + /// @return Whether or not the PieMenu is in the process of being disabled. bool IsDisabling() const { return m_EnabledState == EnabledState::Enabling && m_MenuMode != MenuMode::Wobble; } - /// /// Gets whether or not the PieMenu is in the process of enabling or disabling. - /// - /// Whether or not the PieMenu is in the process of enabling or disabling. + /// @return Whether or not the PieMenu is in the process of enabling or disabling. bool IsEnablingOrDisabling() const { return (m_EnabledState == EnabledState::Enabling || m_EnabledState == EnabledState::Disabling) && m_MenuMode != MenuMode::Wobble; } - /// /// Gets whether or not the PieMenu is at all visible. - /// - /// Whether the PieMenu is visible. + /// @return Whether the PieMenu is visible. bool IsVisible() const { return m_EnabledState != EnabledState::Disabled || m_MenuMode == MenuMode::Freeze || m_MenuMode == MenuMode::Wobble; } - /// /// Gets whether or not the PieMenu is in the normal animation mode. - /// - /// Whether or not the PieMenu is in the normal animation mode. + /// @return Whether or not the PieMenu is in the normal animation mode. bool IsInNormalAnimationMode() const { return m_MenuMode == MenuMode::Normal; } - /// /// Enables or disables the PieMenu and animates it in and out of view. - /// - /// Whether to enable or disable the PieMenu. - /// Whether or not to play appropriate sounds when the menu is enabled or disabled. + /// @param enable Whether to enable or disable the PieMenu. + /// @param playSounds Whether or not to play appropriate sounds when the menu is enabled or disabled. void SetEnabled(bool enable, bool playSounds = true); - /// /// Gets whether this PieMenu has an open sub-PieMenu. - /// - /// Whether or not this PieMenu has an open sub-PieMenu. + /// @return Whether or not this PieMenu has an open sub-PieMenu. bool HasSubPieMenuOpen() const { return m_ActiveSubPieMenu != nullptr; } #pragma endregion #pragma region Special Animation Handling - /// /// Sets this PieMenu to normal MenuMode. - /// void SetAnimationModeToNormal() { if (m_MenuMode != MenuMode::Normal) { m_MenuMode = MenuMode::Normal; @@ -237,9 +173,7 @@ namespace RTE { } } - /// /// Plays the disabling animation, regardless of whether the PieMenu was enabled or not. - /// void DoDisableAnimation() { m_CurrentInnerRadius = m_FullInnerRadius; m_MenuMode = MenuMode::Normal; @@ -247,16 +181,12 @@ namespace RTE { m_EnabledState = EnabledState::Disabling; } - /// /// Plays an animation of the background circle expanding and contracting continuously. The PieMenu is effectively disabled while doing this. /// This animation will continue until the next call to SetEnabled. - /// void Wobble() { m_MenuMode = MenuMode::Wobble; } - /// /// Makes the background circle freeze at a certain radius until SetEnabled is called. The PieMenu is effectively disabled while doing this. - /// - /// The radius to make the background circle freeze at. + /// @param radius The radius to make the background circle freeze at. void FreezeAtRadius(int radius) { m_MenuMode = MenuMode::Freeze; m_CurrentInnerRadius = radius; @@ -265,136 +195,102 @@ namespace RTE { #pragma endregion #pragma region PieSlice Handling - /// /// Gets the activated PieSlice for this PieMenu in the last update. If there is a sub-PieMenu open for this PieMenu, it gets that activated PieSlice instead. - /// - /// The activated PieSlice for this PieMenu. + /// @return The activated PieSlice for this PieMenu. const PieSlice* GetActivatedPieSlice() const; - /// /// Gets the command issued by this PieMenu in the last update, i.e. the PieSlice SliceType of the currently activated PieSlice, or None if no slice was activated. - /// - /// The PieSlice type which has been picked, or None if none has been picked. + /// @return The PieSlice type which has been picked, or None if none has been picked. PieSlice::SliceType GetPieCommand() const; - /// /// Gets a const reference to the vector containing pointers to all the PieSlices in this PieMenu. - /// - /// A const reference to the vector containing pointers to all the PieSlices in this PieMenu. + /// @return A const reference to the vector containing pointers to all the PieSlices in this PieMenu. const std::vector& GetPieSlices() const { return m_CurrentPieSlices; } - /// /// Gets the first found PieSlice with the passed in preset name, if there is one. Ownership is NOT transferred! - /// - /// The preset name to look for. - /// The first found PieSlice with the passed in preset name, or nullptr if there are no PieSlices with that preset name in this PieMenu. + /// @param presetName The preset name to look for. + /// @return The first found PieSlice with the passed in preset name, or nullptr if there are no PieSlices with that preset name in this PieMenu. PieSlice* GetFirstPieSliceByPresetName(const std::string& presetName) const; - /// /// Gets the first found PieSlice with the passed in PieSlice SliceType, if there is one. Ownership is NOT transferred! - /// - /// The type of PieSlice to look for. - /// The first found PieSlice with the passed in PieSlice SliceType, or nullptr if there are no PieSlices with that SliceType in this PieMenu. + /// @param pieSliceType The type of PieSlice to look for. + /// @return The first found PieSlice with the passed in PieSlice SliceType, or nullptr if there are no PieSlices with that SliceType in this PieMenu. PieSlice* GetFirstPieSliceByType(PieSlice::SliceType pieSliceType) const; - /// /// Adds a PieSlice to the PieMenu, setting its original source to the specified sliceSource. Ownership IS transferred! /// The slice will be placed in the appropriate PieQuadrant for its Direction, with Any Direction using the first available PieQuadrant. /// If allowQuadrantOverflow is true, the PieSlice will be added to the next available PieQuadrant in Direction order. /// Note that if the slice could not be added, it will be deleted to avoid memory leaks, and the method will return false. - /// - /// The new PieSlice to add. Ownership IS transferred. - /// The source of the added PieSlice. Should be nullptr for slices not added by Entities. - /// Whether the new PieSlice can be placed in PieQuadrants other than the one specified by its Direction, if that PieQuadrant is full. - /// Whether or not the PieSlice was added successfully. + /// @param pieSliceToAdd The new PieSlice to add. Ownership IS transferred. + /// @param pieSliceOriginalSource The source of the added PieSlice. Should be nullptr for slices not added by Entities. + /// @param allowQuadrantOverflow Whether the new PieSlice can be placed in PieQuadrants other than the one specified by its Direction, if that PieQuadrant is full. + /// @return Whether or not the PieSlice was added successfully. bool AddPieSlice(PieSlice* pieSliceToAdd, const Entity* pieSliceOriginalSource, bool allowQuadrantOverflow = false); - /// /// Adds a PieSlice to the PieMenu, with the same conditions as AddPieSlice above, but only if no PieSlice exists in this PieMenu with the same PresetName (optionally with the same original source). Ownership IS transferred! - /// - /// The new PieSlice to add. Ownership IS transferred. - /// The source of the added PieSlice. Should be nullptr for slices not added by Entities. - /// Whether all PieSlices in the PieMenu should be checked to see if there are no duplicates, or only those with the same original source. - /// Whether the new PieSlice can be placed in PieQuadrants other than the one specified by its Direction, if that PieQuadrant is full. - /// Whether or not the PieSlice was added successfully. + /// @param pieSliceToAdd The new PieSlice to add. Ownership IS transferred. + /// @param pieSliceOriginalSource The source of the added PieSlice. Should be nullptr for slices not added by Entities. + /// @param onlyCheckPieSlicesWithSameOriginalSource Whether all PieSlices in the PieMenu should be checked to see if there are no duplicates, or only those with the same original source. + /// @param allowQuadrantOverflow Whether the new PieSlice can be placed in PieQuadrants other than the one specified by its Direction, if that PieQuadrant is full. + /// @return Whether or not the PieSlice was added successfully. bool AddPieSliceIfPresetNameIsUnique(PieSlice* pieSliceToAdd, const Entity* pieSliceOriginalSource, bool onlyCheckPieSlicesWithSameOriginalSource = false, bool allowQuadrantOverflow = false); - /// /// Removes and returns the passed in PieSlice from this PieMenu if it's in the PieMenu. Ownership IS transferred to the caller! - /// - /// The PieSlice to remove from this PieMenu. Ownership IS transferred to the caller! - /// The removed PieSlice, if it was in the PieMenu. + /// @param pieSliceToRemove The PieSlice to remove from this PieMenu. Ownership IS transferred to the caller! + /// @return The removed PieSlice, if it was in the PieMenu. PieSlice* RemovePieSlice(const PieSlice* pieSliceToRemove); - /// /// Removes any PieSlices in this PieMenu whose preset name matches the passed in preset name. - /// - /// The preset name to check against. - /// Whether or not any PieSlices were removed from this PieMenu. + /// @param presetNameToRemoveBy The preset name to check against. + /// @return Whether or not any PieSlices were removed from this PieMenu. bool RemovePieSlicesByPresetName(const std::string& presetNameToRemoveBy); - /// /// Removes any PieSlices in this PieMenu whose PieSlice SliceType matches the passed in PieSlice SliceType. - /// - /// The PieSlice SliceType to check against. - /// Whether or not any PieSlices were removed from this PieMenu. + /// @param pieSliceTypeToRemoveBy The PieSlice SliceType to check against. + /// @return Whether or not any PieSlices were removed from this PieMenu. bool RemovePieSlicesByType(PieSlice::SliceType pieSliceTypeToRemoveBy); - /// /// Removes any PieSlices in this PieMenu whose original source matches the passed in Entity. - /// - /// The original source whose PieSlices should be removed. - /// Whether or not any PieSlices were removed from this PieMenu. + /// @param originalSource The original source whose PieSlices should be removed. + /// @return Whether or not any PieSlices were removed from this PieMenu. bool RemovePieSlicesByOriginalSource(const Entity* originalSource); - /// /// Replaces the first PieSlice with the second, ensuring original source, direction, middle slice eligibility, angles and slot count are maintained. /// The existing PieSlice is returned, and ownership IS transferred both ways! - /// - /// The PieSlice that will be replaced. - /// The PieSlice that will replace the existing one. If this is nullptr, the existing one will just be removed. - /// The removed PieSlice, if there is one. Ownership IS transferred! + /// @param pieSliceToReplace The PieSlice that will be replaced. + /// @param replacementPieSlice The PieSlice that will replace the existing one. If this is nullptr, the existing one will just be removed. + /// @return The removed PieSlice, if there is one. Ownership IS transferred! PieSlice* ReplacePieSlice(const PieSlice* pieSliceToReplace, PieSlice* replacementPieSlice); #pragma endregion #pragma region Updating - /// /// Updates the state of this PieMenu each frame. - /// void Update(); - /// /// Draws the PieMenu. - /// - /// A pointer to a BITMAP to draw on. Generally a screen BITMAP. - /// The absolute position of the target bitmap's upper left corner in the scene. + /// @param targetBitmap A pointer to a BITMAP to draw on. Generally a screen BITMAP. + /// @param targetPos The absolute position of the target bitmap's upper left corner in the scene. void Draw(BITMAP* targetBitmap, const Vector& targetPos = Vector()) const; #pragma endregion #pragma region Event Handling - /// /// Add the passed in MovableObject and function as a listener to be run while this PieMenu is open. - /// - /// The MovableObject listening. - /// The function to be run on the MovableObject. + /// @param listeningObject The MovableObject listening. + /// @param listenerFunction The function to be run on the MovableObject. void AddWhilePieMenuOpenListener(const MovableObject* listeningObject, const std::function& listenerFunction) { if (listeningObject) { m_WhilePieMenuOpenListeners.try_emplace(listeningObject, listenerFunction); } } - /// /// Removes the passed in MovableObject and its listening function as a listener for when this PieMenu is opened. - /// - /// The MovableObject whose listening function should be removed. - /// Whether or not the MovableObject was found and removed as a listener. + /// @param objectToRemove The MovableObject whose listening function should be removed. + /// @return Whether or not the MovableObject was found and removed as a listener. bool RemoveWhilePieMenuOpenListener(const MovableObject* objectToRemove) { return m_WhilePieMenuOpenListeners.erase(objectToRemove) == 1; } #pragma endregion private: - /// /// Enumeration for enabled states when enabling/disabling the PieMenu. - /// enum class EnabledState { Enabling, Enabled, @@ -402,27 +298,21 @@ namespace RTE { Disabled }; - /// /// Enumeration for the modes a PieMenu can have. - /// enum class MenuMode { Normal, Wobble, Freeze }; - /// /// Enumeration for the different item separator modes available to the PieMenu. - /// enum class IconSeparatorMode { Line, Circle, Square }; - /// /// Enumeration for helping keyboard PieMenu navigation. Specifies the ways the cursor should move from one PieQuadrant to another. - /// enum class MoveToPieQuadrantMode { Start, Middle, @@ -486,124 +376,88 @@ namespace RTE { bool m_BGPieSlicesWithSubPieMenuBitmapNeedsRedrawing; //!< Whether the BG bitmap for PieSlices with sub-PieMenus should be redrawn when the BGBitmap is redrawn. #pragma region Update Breakdown - /// /// Handles the wobbling portion of Update. - /// void UpdateWobbling(); - /// /// Handles the enabling and disabling part of Update. - /// void UpdateEnablingAndDisablingProgress(); - /// /// Handles the analog input when updating. - /// - /// The analog input vector. - /// Whether or not enough input was received to do something. + /// @param input The analog input vector. + /// @return Whether or not enough input was received to do something. bool HandleAnalogInput(const Vector& input); - /// /// Handles the digital input when updating. - /// - /// Whether or not enough input was received to do something. + /// @return Whether or not enough input was received to do something. bool HandleDigitalInput(); - /// /// Handles the slice activation part of Update. - /// void UpdateSliceActivation(); - /// /// Redraws the pre-drawn background bitmap so it's up-to-date. - /// void UpdatePredrawnMenuBackgroundBitmap(); #pragma endregion #pragma region Draw Breakdown - /// /// Handles figuring out the position to draw the PieMenu at, accounting for any Scene seams. - /// - /// A pointer to the BITMAP to draw on. Generally a screen BITMAP. - /// The absolute position of the target bitmap's upper left corner in the scene. - /// Out parameter, a Vector to be filled in with the position at which the PieMenu should be drawn. + /// @param targetBitmap A pointer to the BITMAP to draw on. Generally a screen BITMAP. + /// @param targetPos The absolute position of the target bitmap's upper left corner in the scene. + /// @param drawPos Out parameter, a Vector to be filled in with the position at which the PieMenu should be drawn. void CalculateDrawPosition(const BITMAP* targetBitmap, const Vector& targetPos, Vector& drawPos) const; - /// /// Handles drawing icons for PieSlices' visual representation in the PieMenu. - /// - /// A pointer to the BITMAP to draw on. Generally a screen BITMAP. - /// The seam corrected position at which the PieMenu is being drawn. + /// @param targetBitmap A pointer to the BITMAP to draw on. Generally a screen BITMAP. + /// @param drawPos The seam corrected position at which the PieMenu is being drawn. void DrawPieIcons(BITMAP* targetBitmap, const Vector& drawPos) const; - /// /// Handles drawing the cursor and description text for selected PieSlices. - /// - /// A pointer to the BITMAP to draw on. Generally a screen BITMAP. - /// The seam corrected position at which the PieMenu is being drawn. + /// @param targetBitmap A pointer to the BITMAP to draw on. Generally a screen BITMAP. + /// @param drawPos The seam corrected position at which the PieMenu is being drawn. void DrawPieCursorAndPieSliceDescriptions(BITMAP* targetBitmap, const Vector& drawPos) const; #pragma endregion - /// /// Clears and refills the vector of current PieSlices for this PieMenu. Also realigns PieSlices and expands them into empty space if possible, to ensure everything is properly ready. - /// void RepopulateAndRealignCurrentPieSlices(); - /// /// Expands any PieSlices that border onto another PieQuadrant's unfilled slot, so they visually occupy that empty slot. - /// void ExpandPieSliceIntoEmptySpaceIfPossible(); - /// /// Recreates this PieMenu's background bitmap based on its full inner radius. - /// void RecreateBackgroundBitmaps(); - /// /// Draws the background separators for this PieMenu, based on its IconSeparatorMode, onto the passed in bitmap. - /// - /// The bitmap to draw the separators onto. - /// The center X position of the circle being separated. - /// The center Y position of the circle being separated. - /// The rotation offset used if this is a sub-PieMenu. + /// @param backgroundBitmapToDrawTo The bitmap to draw the separators onto. + /// @param pieCircleCenterX The center X position of the circle being separated. + /// @param pieCircleCenterY The center Y position of the circle being separated. + /// @param subPieMenuRotationOffset The rotation offset used if this is a sub-PieMenu. void DrawBackgroundPieSliceSeparators(BITMAP* backgroundBitmapToDrawTo, int pieCircleCenterX, int pieCircleCenterY, float subPieMenuRotationOffset) const; - /// /// Draws a background separator, based on this PieMenu's IconSeparatorMode, to the passed in bitmap. - /// - /// The bitmap to draw the separator onto. - /// The center X position of the circle the separator is drawn onto. - /// The center Y position of the circle the separator is drawn onto. - /// The rotation of the separator, not used for all separator types. - /// Whether the separator is being drawn for the PieMenu's hovered PieSlice. - /// Whether the PieSlice whose separator is being drawn has a sub-PieMenu. - /// Whether to draw a half-sized separator or a full-sized one. Defaults to drawing a full-sized one. + /// @param backgroundBitmapToDrawTo The bitmap to draw the separator onto. + /// @param pieCircleCenterX The center X position of the circle the separator is drawn onto. + /// @param pieCircleCenterY The center Y position of the circle the separator is drawn onto. + /// @param rotAngle The rotation of the separator, not used for all separator types. + /// @param isHoveredPieSlice Whether the separator is being drawn for the PieMenu's hovered PieSlice. + /// @param pieSliceHasSubPieMenu Whether the PieSlice whose separator is being drawn has a sub-PieMenu. + /// @param drawHalfSizedSeparator Whether to draw a half-sized separator or a full-sized one. Defaults to drawing a full-sized one. void DrawBackgroundPieSliceSeparator(BITMAP* backgroundBitmapToDrawTo, int pieCircleCenterX, int pieCircleCenterY, float rotAngle, bool isHoveredPieSlice, bool pieSliceHasSubPieMenu, bool drawHalfSizedSeparator = false) const; - /// /// Sets the passed in PieSlice as the hovered PieSlice of this PieMenu. If nullptr is passed in, no PieSlice will be hovered. - /// - /// The PieSlice to consider hovered, if any. Has to be a PieSlice currently in this PieMenu. - /// Whether to also move the cursor icon to the center of the new hovered PieSlice and set it to be drawn (generally for non-mouse inputs). Defaults to false. - /// Whether or not the PieSlice to set as hovered was different from the already hovered PieSlice. + /// @param pieSliceToSetAsHovered The PieSlice to consider hovered, if any. Has to be a PieSlice currently in this PieMenu. + /// @param moveCursorIconToSlice Whether to also move the cursor icon to the center of the new hovered PieSlice and set it to be drawn (generally for non-mouse inputs). Defaults to false. + /// @return Whether or not the PieSlice to set as hovered was different from the already hovered PieSlice. bool SetHoveredPieSlice(const PieSlice* pieSliceToSetAsHovered, bool moveCursorToPieSlice = false); - /// /// Prepares the passed in PieSlice's sub-PieMenu for use by setting flags, moving PieSlices around, and disabling PieQuadrants as appropriate. - /// - /// The PieSlice with a sub-PieMenu that needs to be prepared. - /// Whether the sub-PieMenu was prepared. PieMenus with the SubPieMenu flag already set will not have action taken on them. + /// @param pieSliceWithSubPieMenu The PieSlice with a sub-PieMenu that needs to be prepared. + /// @return Whether the sub-PieMenu was prepared. PieMenus with the SubPieMenu flag already set will not have action taken on them. bool PreparePieSliceSubPieMenuForUse(const PieSlice* pieSliceWithSubPieMenu) const; - /// /// If the Controller for this PieMenu is mouse or gamepad controlled, sets up analog cursor angle limits and positions for when the pie menu is enabled or disabled. Also used when a sub-PieMenu of this PieMenu is disabled. - /// - /// Whether the PieMenu is being enabled or disabled. + /// @param enable Whether the PieMenu is being enabled or disabled. void PrepareAnalogCursorForEnableOrDisable(bool enable) const; - /// /// Clears all the member variables of this PieMenu, effectively resetting the members of this abstraction level only. - /// void Clear(); // Disallow the use of some implicit methods. diff --git a/Source/Entities/PieSlice.cpp b/Source/Entities/PieSlice.cpp index 9129333743..6873eb9a6b 100644 --- a/Source/Entities/PieSlice.cpp +++ b/Source/Entities/PieSlice.cpp @@ -8,8 +8,6 @@ namespace RTE { ConcreteClassInfo(PieSlice, Entity, 80); - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PieSlice::Clear() { m_Type = SliceType::NoType; m_Direction = Directions::Any; @@ -31,8 +29,6 @@ namespace RTE { m_DrawFlippedToMatchAbsoluteAngle = false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int PieSlice::Create() { if (Entity::Create() < 0) { return -1; @@ -44,8 +40,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int PieSlice::Create(const PieSlice& reference) { Entity::Create(reference); @@ -75,8 +69,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int PieSlice::ReadProperty(const std::string_view& propName, Reader& reader) { StartPropertyList(return Entity::ReadProperty(propName, reader)); @@ -122,8 +114,6 @@ namespace RTE { EndPropertyList; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int PieSlice::Save(Writer& writer) const { Entity::Save(writer); @@ -148,8 +138,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - BITMAP* RTE::PieSlice::GetAppropriateIcon(bool sliceIsSelected) const { if (int iconFrameCount = m_Icon->GetFrameCount(); iconFrameCount > 0) { if (!IsEnabled() && iconFrameCount > 2) { @@ -163,20 +151,14 @@ namespace RTE { return nullptr; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - PieMenu* PieSlice::GetSubPieMenu() const { return m_SubPieMenu.get(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PieSlice::SetSubPieMenu(PieMenu* newSubPieMenu) { m_SubPieMenu = std::unique_ptr(newSubPieMenu); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int PieSlice::ReloadScripts() { int status = 0; @@ -193,14 +175,10 @@ namespace RTE { return status; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PieSlice::RecalculateMidAngle() { m_MidAngle = m_StartAngle + (static_cast(m_SlotCount) * PieQuadrant::c_PieSliceSlotSize / 2.0F); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PieSlice::PieMenuCustomDeleter::operator()(PieMenu* pieMenu) const { pieMenu->Destroy(true); } diff --git a/Source/Entities/PieSlice.h b/Source/Entities/PieSlice.h index e328227642..a26889b64d 100644 --- a/Source/Entities/PieSlice.h +++ b/Source/Entities/PieSlice.h @@ -9,9 +9,7 @@ namespace RTE { class PieMenu; - /// /// An individual PieSlice in a PieMenu. - /// class PieSlice : public Entity { public: @@ -19,9 +17,7 @@ namespace RTE { SerializableOverrideMethods; ClassInfoGetters; - /// /// Enumeration for the types of PieSlices. - /// enum SliceType { NoType, // Inventory management @@ -68,237 +64,167 @@ namespace RTE { }; #pragma region Creation - /// /// Constructor method used to instantiate a PieSlice object in system memory. Create() should be called before using the object. - /// PieSlice() { Clear(); } - /// /// Makes the PieSlice object ready for use. - /// - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create() override; - /// /// Creates a PieSlice to be identical to another, by deep copy. - /// - /// A reference to the PieSlice to deep copy. - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @param reference A reference to the PieSlice to deep copy. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create(const PieSlice& reference); #pragma endregion #pragma region Destruction - /// /// Destructor method used to clean up a PieSlice object before deletion from system memory. - /// ~PieSlice() override { Destroy(true); } - /// /// Resets the entire Serializable, including its inherited members, to their default settings or values. - /// void Reset() override { Clear(); } #pragma endregion #pragma region Getters and Setters - /// /// Gets the SliceType of this PieSlice. - /// - /// The SliceType of this PieSlice. + /// @return The SliceType of this PieSlice. SliceType GetType() const { return m_Type; } - /// /// Sets the SliceType of this PieSlice. - /// - /// The new SliceType of this PieSlice. + /// @param newType The new SliceType of this PieSlice. void SetType(SliceType newType) { m_Type = newType; } - /// /// Gets the Direction of this PieSlice. - /// - /// The Direction of this PieSlice. + /// @return The Direction of this PieSlice. Directions GetDirection() const { return m_Direction; } - /// /// Sets the Direction of this PieSlice. - /// - /// The new Direction of this PieSlice. + /// @param newDirection The new Direction of this PieSlice. void SetDirection(Directions newDirection) { if (newDirection != Directions::None) { m_Direction = newDirection; } } - /// /// Gets whether or not this PieSlice can be the middle PieSlice of a PieQuadrant. - /// - /// Whether or not this PieSlice can be the middle PieSlice of a PieQuadrant. + /// @return Whether or not this PieSlice can be the middle PieSlice of a PieQuadrant. bool GetCanBeMiddleSlice() const { return m_CanBeMiddleSlice; } - /// /// Sets whether or not this PieSlice can be the middle PieSlice of a PieQuadrant. - /// - /// Whether or not this PieSlice can be the middle PieSlice of a PieQuadrant. + /// @param newCanBeMiddleSlice Whether or not this PieSlice can be the middle PieSlice of a PieQuadrant. void SetCanBeMiddleSlice(bool newCanBeMiddleSlice) { m_CanBeMiddleSlice = newCanBeMiddleSlice; } - /// /// Gets the original Entity source of this PieSlice, if there is one. - /// - /// A pointer to the original Entity source of this PieSlice, if there is one. + /// @return A pointer to the original Entity source of this PieSlice, if there is one. const Entity* GetOriginalSource() const { return m_OriginalSource; } - /// /// Sets the original Entity source of this PieSlice. - /// - /// A pointer to the original Entity source of this PieSlice. + /// @param originalSource A pointer to the original Entity source of this PieSlice. void SetOriginalSource(const Entity* originalSource) { m_OriginalSource = originalSource; } - /// /// Gets whether or not this PieSlice is enabled. - /// - /// Whether or not this PieSlice is enabled. + /// @return Whether or not this PieSlice is enabled. bool IsEnabled() const { return m_Enabled; } - /// /// Sets whether or not this PieSlice should be enabled. - /// - /// Whether or not this PieSlice should be enabled. + /// @param enabled Whether or not this PieSlice should be enabled. void SetEnabled(bool enabled) { m_Enabled = enabled; } - /// /// Gets whether or not this PieSlice has a valid Icon. - /// - /// Whether or not this PieSlice has a valid Icon. + /// @return Whether or not this PieSlice has a valid Icon. bool HasIcon() const { return m_Icon && m_Icon->GetFrameCount() > 0; } - /// /// Gets the appropriate icon frame for this PieSlice. - /// - /// Whether or not this PieSlice is selected, which may affect which icon is appropriate. - /// The icon for this PieSlice. + /// @param sliceIsSelected Whether or not this PieSlice is selected, which may affect which icon is appropriate. + /// @return The icon for this PieSlice. BITMAP* GetAppropriateIcon(bool sliceIsSelected = false) const; - /// /// Sets the new Icon for this PieSlice. Ownership IS transferred. - /// - /// The new Icon for this PieSlice. + /// @param newIcon The new Icon for this PieSlice. void SetIcon(Icon* newIcon) { m_Icon = std::unique_ptr(newIcon); } - /// /// Gets the LuabindObjectWrapper for the function this PieSlice should run when activated. - /// - /// The LuabindObjectWrapper this PieSlice should run when activated. + /// @return The LuabindObjectWrapper this PieSlice should run when activated. const LuabindObjectWrapper* GetLuabindFunctionObjectWrapper() const { return m_LuabindFunctionObject.get(); } - /// /// Gets the file path of the Lua file this PieSlice should run when activated, if any. - /// - /// The file path to the script file this PieSlice should load when activated. + /// @return The file path to the script file this PieSlice should load when activated. std::string GetScriptPath() const { return m_LuabindFunctionObject ? m_LuabindFunctionObject->GetFilePath() : ""; } - /// /// Sets the file path of the scripted file this PieSlice should run when activated. - /// - /// The file path of the Lua file this PieSlice should run when activated. + /// @param newScriptPath The file path of the Lua file this PieSlice should run when activated. void SetScriptPath(const std::string& newScriptPath) { m_LuabindFunctionObject = std::make_unique(nullptr, newScriptPath); ReloadScripts(); } - /// /// Gets the name of the Lua function to run when this PieSlice is activated. - /// - /// The name of the Lua function this PieSlice should execute when activated. + /// @return The name of the Lua function this PieSlice should execute when activated. const std::string& GetFunctionName() const { return m_FunctionName; } - /// /// Sets the name of the Lua function to run when this PieSlice is activated as a scripted pie menu option. - /// - /// The name of the Lua function to run when this PieSlice is activated. + /// @param newFunctionName The name of the Lua function to run when this PieSlice is activated. void SetFunctionName(const std::string& newFunctionName) { m_FunctionName = newFunctionName; ReloadScripts(); } // TODO Ideally this would be done with a weak_ptr but I'm not sure how it'll go with LuaMan. Try it out and see - /// /// Gets the sub-PieMenu for this PieSlice if there is one. Ownership is NOT transferred. - /// - /// The sub-PieMenu for this PieSlice if there is one. Ownership is NOT transferred. + /// @return The sub-PieMenu for this PieSlice if there is one. Ownership is NOT transferred. PieMenu* GetSubPieMenu() const; - /// /// Sets the sub-PieMenu for this PieSlice. Ownership IS transferred. - /// - /// The new sub-PieMenu for this PieSlice. Ownership IS transferred. + /// @param newSubPieMenu The new sub-PieMenu for this PieSlice. Ownership IS transferred. void SetSubPieMenu(PieMenu* newSubPieMenu); #pragma endregion #pragma region Angle Getter and Setters - /// /// Gets the start angle this PieSlice's area is set to be at in its pie menu. - /// - /// The start angle of this PieSlice's area. + /// @return The start angle of this PieSlice's area. float GetStartAngle() const { return m_StartAngle; } - /// /// Sets the start angle this PieSlice's area should be at in its pie menu. - /// - /// The start angle to set for the PieSlice's area. + /// @param startAngle The start angle to set for the PieSlice's area. void SetStartAngle(float startAngle) { m_StartAngle = startAngle; RecalculateMidAngle(); } - /// /// Gets the number of slots this PieSlice takes up. - /// - /// The number of slots this PieSlice takes up. + /// @return The number of slots this PieSlice takes up. int GetSlotCount() const { return m_SlotCount; } - /// /// Sets the number of slots this PieSlice takes up. - /// - /// The number of slots this PieSlice should take up. + /// @param slotCount The number of slots this PieSlice should take up. void SetSlotCount(int slotCount) { m_SlotCount = std::max(1, slotCount); RecalculateMidAngle(); } - /// /// Gets the mid angle this PieSlice's area is set to be at in its pie menu. - /// - /// The mid angle of this PieSlice's area. + /// @return The mid angle of this PieSlice's area. float GetMidAngle() const { return m_MidAngle; } - /// /// Sets the mid angle this PieSlice's area should be at in its pie menu. - /// - /// The mid angle to set for the PieSlice's area. + /// @param midAngle The mid angle to set for the PieSlice's area. void SetMidAngle(float midAngle) { m_MidAngle = midAngle; } - /// /// Gets whether or not this PieSlice should draw itself flipped to match its absolute angle (i.e. its angle accounting for its PieMenu's rotation). - /// - /// Whether or not this PieSlice should draw itself flipped to match its absolute angle. + /// @return Whether or not this PieSlice should draw itself flipped to match its absolute angle. bool GetDrawFlippedToMatchAbsoluteAngle() const { return m_DrawFlippedToMatchAbsoluteAngle; } - /// /// Sets whether or not this PieSlice should draw itself flipped to match its absolute angle (i.e. its angle accounting for its PieMenu's rotation). - /// - /// Whether or not this PieSlice should draw itself flipped to match its absolute angle. + /// @param shouldDrawFlippedToMatchAbsoluteAngle Whether or not this PieSlice should draw itself flipped to match its absolute angle. void SetDrawFlippedToMatchAbsoluteAngle(bool shouldDrawFlippedToMatchAbsoluteAngle) { m_DrawFlippedToMatchAbsoluteAngle = shouldDrawFlippedToMatchAbsoluteAngle; } #pragma endregion - /// /// Reloads the the script on this PieSlice. - /// - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int ReloadScripts() final; private: - /// /// Custom deleter for PieMenu to avoid include problems with unique_ptr. - /// struct PieMenuCustomDeleter { void operator()(PieMenu* pieMenu) const; }; @@ -324,14 +250,10 @@ namespace RTE { bool m_DrawFlippedToMatchAbsoluteAngle; //!< Whether or not this PieSlice should draw flipped based on its absolute angle (i.e. its angle accounting for its pie menu's rotation). - /// /// Recalculates this PieSlice's mid angle based on its start angle and slot count. - /// void RecalculateMidAngle(); - /// /// Clears all the member variables of this PieSlice, effectively resetting the members of this abstraction level only. - /// void Clear(); // Disallow the use of some implicit methods. diff --git a/Source/Entities/Round.cpp b/Source/Entities/Round.cpp index 05f810a353..b6a8047c23 100644 --- a/Source/Entities/Round.cpp +++ b/Source/Entities/Round.cpp @@ -6,8 +6,6 @@ namespace RTE { ConcreteClassInfo(Round, Entity, 500); - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void Round::Clear() { m_Particle = 0; m_ParticleCount = 0; @@ -23,8 +21,6 @@ namespace RTE { m_AIPenetration = -1; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int Round::Create() { if (Entity::Create() < 0) { return -1; @@ -48,8 +44,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int Round::Create(const Round& reference) { Entity::Create(reference); @@ -69,8 +63,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int Round::ReadProperty(const std::string_view& propName, Reader& reader) { StartPropertyList(return Entity::ReadProperty(propName, reader)); @@ -93,8 +85,6 @@ namespace RTE { EndPropertyList; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int Round::Save(Writer& writer) const { Entity::Save(writer); @@ -125,8 +115,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - MovableObject* Round::PopNextParticle() { MovableObject* tempParticle = (m_ParticleCount > 0) ? dynamic_cast(m_Particle->Clone()) : 0; m_ParticleCount--; diff --git a/Source/Entities/Round.h b/Source/Entities/Round.h index 694044f0b6..efe1c02baa 100644 --- a/Source/Entities/Round.h +++ b/Source/Entities/Round.h @@ -7,9 +7,7 @@ namespace RTE { class MovableObject; - /// /// A round containing a number of projectile particles and one shell. - /// class Round : public Entity { public: @@ -18,35 +16,25 @@ namespace RTE { ClassInfoGetters; #pragma region Creation - /// /// Constructor method used to instantiate a Round object in system memory. Create() should be called before using the object. - /// Round() { Clear(); } - /// /// Makes the Round object ready for use. - /// - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create() override; - /// /// Creates a Round to be identical to another, by deep copy. - /// - /// A reference to the Round to deep copy. - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @param reference A reference to the Round to deep copy. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create(const Round& reference); #pragma endregion #pragma region Destruction - /// /// Destructor method used to clean up a Round object before deletion from system memory. - /// ~Round() override { Destroy(true); } - /// /// Destroys and resets (through Clear()) the Round object. - /// - /// Whether to only destroy the members defined in this derived class, or to destroy all inherited members also. + /// @param notInherited Whether to only destroy the members defined in this derived class, or to destroy all inherited members also. void Destroy(bool notInherited = false) override { if (!notInherited) { Entity::Destroy(); @@ -54,9 +42,7 @@ namespace RTE { Clear(); } - /// /// Resets the entire Round, including its inherited members, to their default settings or values. - /// void Reset() override { Clear(); Entity::Reset(); @@ -64,96 +50,66 @@ namespace RTE { #pragma endregion #pragma region Getters and Setters - /// /// Returns how many particles are contained within this Round, not counting the shell. - /// - /// The number of particles. + /// @return The number of particles. int ParticleCount() const { return m_ParticleCount; } - /// /// Returns whether this Round is out of particles or not. - /// - /// Whether this Round is out of particles or not. + /// @return Whether this Round is out of particles or not. bool IsEmpty() const { return m_ParticleCount <= 0; } - /// /// Gets the next particle contained in this Round. Ownership is NOT transferred! - /// - /// A pointer to the next particle, or 0 if this Round is empty. + /// @return A pointer to the next particle, or 0 if this Round is empty. const MovableObject* GetNextParticle() const { return (m_ParticleCount > 0) ? m_Particle : 0; } - /// /// Gets the next particle contained in this Round, and removes it from the stack. Ownership IS transferred! - /// - /// A pointer to the next particle, or 0 if this Round is empty. + /// @return A pointer to the next particle, or 0 if this Round is empty. MovableObject* PopNextParticle(); - /// /// Gets the velocity at which this round is to be fired. - /// - /// A float with the velocity in m/s. + /// @return A float with the velocity in m/s. float GetFireVel() const { return m_FireVel; } - /// /// Gets whether or not this Round should inherit velocity from its firer. - /// - /// Whether or not this Round should inherit velocity from its firer. + /// @return Whether or not this Round should inherit velocity from its firer. bool GetInheritsFirerVelocity() const { return m_InheritsFirerVelocity; } - /// /// Gets the separation of particles in this round. - /// - /// A float with the separation range in pixels. + /// @return A float with the separation range in pixels. float GetSeparation() const { return m_Separation; } - /// /// Gets the variation in lifetime of the fired particles in this Round. - /// - /// A float with the life variation scalar. + /// @return A float with the life variation scalar. float GetLifeVariation() const { return m_LifeVariation; } - /// /// Gets the shell casing preset of this Round. Ownership IS NOT transferred! - /// - /// A pointer to the shell casing preset, or 0 if this Round has no shell. + /// @return A pointer to the shell casing preset, or 0 if this Round has no shell. const MovableObject* GetShell() const { return m_Shell; } - /// /// Gets the maximum velocity at which this round's shell is to be ejected. - /// - /// A float with the maximum shell velocity in m/s. + /// @return A float with the maximum shell velocity in m/s. float GetShellVel() const { return m_ShellVel; } - /// /// Shows whether this Round has an extra sound sample to play when fired. - /// - /// Whether the firing Sound of this has been loaded, or the firing Device will make the noise alone. + /// @return Whether the firing Sound of this has been loaded, or the firing Device will make the noise alone. bool HasFireSound() const { return m_FireSound.HasAnySounds(); } - /// /// Gets the extra firing sound of this Round, which can be played in addition to the weapon's own firing sound. OWNERSHIP IS NOT TRANSFERRED! - /// - /// A sound with the firing sample of this round. + /// @return A sound with the firing sample of this round. SoundContainer* GetFireSound() { return &m_FireSound; } #pragma endregion #pragma region AI Properties - /// /// Returns the lifetime of the projectile used by the AI when executing the shooting scripts. - /// - /// The life time in MS used by the AI. + /// @return The life time in MS used by the AI. unsigned long GetAILifeTime() const { return m_AILifeTime; } - /// /// Returns the FireVelocity of the projectile used by the AI when executing the shooting scripts. - /// - /// The FireVelocity in m/s used by the AI. + /// @return The FireVelocity in m/s used by the AI. int GetAIFireVel() const { return m_AIFireVel; } - /// /// Returns the bullet's ability to penetrate material when executing the AI shooting scripts. - /// - /// A value equivalent to Mass * Sharpness * Vel. + /// @return A value equivalent to Mass * Sharpness * Vel. int GetAIPenetration() const { return m_AIPenetration; } #pragma endregion @@ -177,9 +133,7 @@ namespace RTE { int m_AIPenetration; //!< For overriding the bullets ability to penetrate material when executing the AI shooting scripts. private: - /// /// Clears all the member variables of this Round, effectively resetting the members of this abstraction level only. - /// void Clear(); // Disallow the use of some implicit methods. diff --git a/Source/Entities/SLBackground.cpp b/Source/Entities/SLBackground.cpp index 680e6b7ee4..6ac68a6878 100644 --- a/Source/Entities/SLBackground.cpp +++ b/Source/Entities/SLBackground.cpp @@ -7,8 +7,6 @@ namespace RTE { ConcreteClassInfo(SLBackground, SceneLayer, 0); - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SLBackground::Clear() { m_Bitmaps.clear(); m_FrameCount = 1; @@ -32,8 +30,6 @@ namespace RTE { m_IgnoreAutoScale = false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int SLBackground::Create() { SceneLayer::Create(); @@ -58,8 +54,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int SLBackground::Create(const SLBackground& reference) { SceneLayer::Create(reference); @@ -90,8 +84,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int SLBackground::ReadProperty(const std::string_view& propName, Reader& reader) { StartPropertyList(return SceneLayer::ReadProperty(propName, reader)); @@ -123,8 +115,6 @@ namespace RTE { EndPropertyList; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int SLBackground::Save(Writer& writer) const { SceneLayer::Save(writer); @@ -145,8 +135,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SLBackground::InitScaleFactors() { if (!m_IgnoreAutoScale) { float fitScreenScaleFactor = std::clamp(static_cast(std::min(g_SceneMan.GetSceneHeight(), g_FrameMan.GetPlayerScreenHeight())) / static_cast(m_MainBitmap->h), 1.0F, 2.0F); @@ -167,8 +155,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SLBackground::Update() { if (!m_IsAnimatedManually && m_SpriteAnimMode != SpriteAnimMode::NOANIM) { int prevFrame = m_Frame; @@ -214,8 +200,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SLBackground::Draw(BITMAP* targetBitmap, Box& targetBox, bool offsetNeedsScrollRatioAdjustment) { SceneLayer::Draw(targetBitmap, targetBox, !IsAutoScrolling()); diff --git a/Source/Entities/SLBackground.h b/Source/Entities/SLBackground.h index c368521edd..7c78d226ba 100644 --- a/Source/Entities/SLBackground.h +++ b/Source/Entities/SLBackground.h @@ -6,9 +6,7 @@ namespace RTE { - /// /// A scrolling background layer of the Scene, placed behind the terrain. - /// class SLBackground : public SceneLayer { friend class NetworkServer; @@ -18,35 +16,25 @@ namespace RTE { ClassInfoGetters; #pragma region Creation - /// /// Constructor method used to instantiate a SLBackground object in system memory. Create() should be called before using the object. - /// SLBackground() { Clear(); } - /// /// Makes the SLBackground object ready for use. - /// - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create() override; - /// /// Creates a SLBackground to be identical to another, by deep copy. - /// - /// A reference to the SLBackground to deep copy. - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @param reference A reference to the SLBackground to deep copy. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create(const SLBackground& reference); #pragma endregion #pragma region Destruction - /// /// Destructor method used to clean up a SLBackground object before deletion from system memory. - /// ~SLBackground() override { Destroy(true); } - /// /// Destroys and resets (through Clear()) the SLBackground object. - /// - /// Whether to only destroy the members defined in this derived class, or to destroy all inherited members also. + /// @param notInherited Whether to only destroy the members defined in this derived class, or to destroy all inherited members also. void Destroy(bool notInherited = false) override { if (!notInherited) { SceneLayer::Destroy(); @@ -56,160 +44,110 @@ namespace RTE { #pragma endregion #pragma region Getters and Setters - /// /// Gets whether this SLBackground's animation is handled manually/externally. - /// - /// Whether this SLBackground's animation is handled manually/externally. If true, animation will not be handled during Update(). + /// @return Whether this SLBackground's animation is handled manually/externally. If true, animation will not be handled during Update(). bool IsAnimatedManually() const { return m_IsAnimatedManually; } - /// /// Sets whether this SLBackground is animated manually/externally. - /// - /// Whether this SLBackground is animated manually/externally and should skip animation handling during Update(). + /// @param isAnimatedManually Whether this SLBackground is animated manually/externally and should skip animation handling during Update(). void SetAnimatedManually(bool isAnimatedManually) { m_IsAnimatedManually = isAnimatedManually; } - /// /// Gets the frame number of this SLBackground that is currently set to be drawn. - /// - /// The frame number that is currently set to be drawn. + /// @return The frame number that is currently set to be drawn. int GetFrame() const { return m_Frame; } - /// /// Sets frame number that this SLBackground will draw. - /// - /// The frame number that is supposed to be drawn. + /// @param newFrame The frame number that is supposed to be drawn. void SetFrame(int newFrame) { m_Frame = std::clamp(newFrame, 0, m_FrameCount - 1); } - /// /// Gets the animation mode of this SLBackground. - /// - /// The currently set animation mode. See SpriteAnimMode enumeration. + /// @return The currently set animation mode. See SpriteAnimMode enumeration. int GetSpriteAnimMode() const { return m_SpriteAnimMode; } - /// /// Sets the animation mode of this SLBackground. - /// - /// The new animation mode. See SpirteAnimMode enumeration. + /// @param newAnimMode The new animation mode. See SpirteAnimMode enumeration. void SetSpriteAnimMode(SpriteAnimMode newAnimMode = SpriteAnimMode::NOANIM) { m_SpriteAnimMode = std::clamp(newAnimMode, SpriteAnimMode::NOANIM, SpriteAnimMode::ALWAYSPINGPONG); } - /// /// Gets the time it takes to complete a full animation cycle of this SLBackground. - /// - /// The animation cycle duration, in milliseconds. + /// @return The animation cycle duration, in milliseconds. int GetSpriteAnimDuration() const { return m_SpriteAnimDuration; } - /// /// Sets the time it takes to complete a full animation cycle of this SLBackground. - /// - /// The new animation cycle duration, in milliseconds. + /// @param newDuration The new animation cycle duration, in milliseconds. void SetSpriteAnimDuration(int newDuration) { m_SpriteAnimDuration = newDuration; } - /// /// Gets whether this SLBackground has auto-scrolling enabled and meets the requirements to actually auto-scroll. - /// - /// Whether this has auto-scrolling enabled and meets the requirements to actually auto-scroll. + /// @return Whether this has auto-scrolling enabled and meets the requirements to actually auto-scroll. bool IsAutoScrolling() const { return (m_WrapX && m_CanAutoScrollX) || (m_WrapY && m_CanAutoScrollY); } - /// /// Gets whether auto-scrolling is enabled on the X axis. - /// - /// Whether auto-scrolling is enabled on the X axis. This may be true even if auto-scrolling isn't actually happening due to not meeting requirements. + /// @return Whether auto-scrolling is enabled on the X axis. This may be true even if auto-scrolling isn't actually happening due to not meeting requirements. bool GetAutoScrollX() const { return m_CanAutoScrollX; } - /// /// Sets whether auto-scrolling is enabled on the X axis. - /// - /// Whether auto-scrolling is enabled on the X axis or not. If requirements aren't met, this will not auto-scroll even if set to true. + /// @param autoScroll Whether auto-scrolling is enabled on the X axis or not. If requirements aren't met, this will not auto-scroll even if set to true. void SetAutoScrollX(bool autoScroll) { m_CanAutoScrollX = autoScroll; } - /// /// Gets whether auto-scrolling is enabled on the Y axis. - /// - /// Whether auto-scrolling is enabled on the Y axis. This may be true even if auto-scrolling isn't actually happening due to not meeting requirements. + /// @return Whether auto-scrolling is enabled on the Y axis. This may be true even if auto-scrolling isn't actually happening due to not meeting requirements. bool GetAutoScrollY() const { return m_CanAutoScrollY; } - /// /// Sets whether auto-scrolling is enabled on the Y axis. - /// - /// Whether auto-scrolling is enabled on the Y axis or not. If requirements aren't met, this will not auto-scroll even if set to true. + /// @param autoScroll Whether auto-scrolling is enabled on the Y axis or not. If requirements aren't met, this will not auto-scroll even if set to true. void SetAutoScrollY(bool autoScroll) { m_CanAutoScrollY = autoScroll; } - /// /// Gets the duration between auto-scroll steps. - /// - /// The duration between auto-scroll steps, in milliseconds. + /// @return The duration between auto-scroll steps, in milliseconds. int GetAutoScrollStepInterval() const { return m_AutoScrollStepInterval; } - /// /// Sets the duration between auto-scroll steps. - /// - /// The new duration between auto-scroll steps, in milliseconds. + /// @param newStepInterval The new duration between auto-scroll steps, in milliseconds. void SetAutoScrollStepInterval(int newStepInterval) { m_AutoScrollStepInterval = newStepInterval; } - /// /// Gets the auto-scroll step (pixels to advance per interval) values. - /// - /// A Vector with the auto-scroll step values. + /// @return A Vector with the auto-scroll step values. Vector GetAutoScrollStep() const { return m_AutoScrollStep; } - /// /// Sets the auto-scroll step (pixels to advance per interval) values. - /// - /// A Vector with the new auto-scroll step values. + /// @param newStep A Vector with the new auto-scroll step values. void SetAutoScrollStep(const Vector& newStep) { m_AutoScrollStep = newStep; } - /// /// Gets the auto-scroll step (pixels to advance per interval) value on the X axis. - /// - /// The auto-scroll step value on the X axis. + /// @return The auto-scroll step value on the X axis. float GetAutoScrollStepX() const { return m_AutoScrollStep.GetX(); } - /// /// Sets the auto-scroll step (pixels to advance per interval) value on the X axis. - /// - /// The new auto-scroll step value on the X axis. + /// @param newStepX The new auto-scroll step value on the X axis. void SetAutoScrollStepX(float newStepX) { m_AutoScrollStep.SetX(newStepX); } - /// /// Gets the auto-scroll step (pixels to advance per interval) value on the Y axis. - /// - /// The auto-scroll step value on the Y axis. + /// @return The auto-scroll step value on the Y axis. float GetAutoScrollStepY() const { return m_AutoScrollStep.GetY(); } - /// /// Sets the auto-scroll step (pixels to advance per interval) value on the Y axis. - /// - /// The new auto-scroll step value on the Y axis. + /// @param newStepY The new auto-scroll step value on the Y axis. void SetAutoScrollStepY(float newStepY) { m_AutoScrollStep.SetY(newStepY); } #pragma endregion #pragma region Concrete Methods - /// /// Initializes the scale factors for all auto-scaling modes for this SLBackground, then sets the appropriate factor according to the auto-scaling setting. /// Has to be done during Scene loading to correctly adjust the factors in cases the Scene does not vertically cover the player's whole screen. - /// void InitScaleFactors(); #pragma endregion #pragma region Virtual Override Methods - /// /// Updates the state of this SLBackground. - /// void Update() override; - /// /// Draws this SLBackground's current scrolled position to a bitmap. - /// - /// The bitmap to draw to. - /// The box on the target bitmap to limit drawing to, with the corner of box being where the scroll position lines up. - /// Whether the offset of this SceneLayer or the passed in offset override need to be adjusted to scroll ratio. + /// @param targetBitmap The bitmap to draw to. + /// @param targetBox The box on the target bitmap to limit drawing to, with the corner of box being where the scroll position lines up. + /// @param offsetNeedsScrollRatioAdjustment Whether the offset of this SceneLayer or the passed in offset override need to be adjusted to scroll ratio. void Draw(BITMAP* targetBitmap, Box& targetBox, bool offsetNeedsScrollRatioAdjustment = false) override; #pragma endregion private: - /// /// Enumeration for the different modes of SLBackground auto-scaling. - /// enum LayerAutoScaleMode { AutoScaleOff, FitScreen, @@ -244,9 +182,7 @@ namespace RTE { bool m_IgnoreAutoScale; //!< Whether auto-scaling settings are ignored and the read-in scale factor is used instead. - /// /// Clears all the member variables of this SLBackground, effectively resetting the members of this abstraction level only. - /// void Clear(); // Disallow the use of some implicit methods. diff --git a/Source/Entities/SLTerrain.cpp b/Source/Entities/SLTerrain.cpp index 6bc50fe73b..4971f69421 100644 --- a/Source/Entities/SLTerrain.cpp +++ b/Source/Entities/SLTerrain.cpp @@ -13,8 +13,6 @@ namespace RTE { ConcreteClassInfo(SLTerrain, SceneLayer, 0); - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SLTerrain::Clear() { m_Width = 0; m_Height = 0; @@ -29,8 +27,6 @@ namespace RTE { m_OrbitDirection = Directions::Up; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int SLTerrain::Create() { SceneLayer::Create(); @@ -47,8 +43,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int SLTerrain::Create(const SLTerrain& reference) { SceneLayer::Create(reference); @@ -79,8 +73,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int SLTerrain::ReadProperty(const std::string_view& propName, Reader& reader) { StartPropertyList(return SceneLayer::ReadProperty(propName, reader)); @@ -127,8 +119,6 @@ namespace RTE { EndPropertyList; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int SLTerrain::Save(Writer& writer) const { SceneLayer::Save(writer); @@ -179,8 +169,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // TODO: Break this down and refactor. void SLTerrain::TexturizeTerrain() { BITMAP* defaultBGLayerTexture = m_DefaultBGTextureFile.GetAsBitmap(); @@ -263,8 +251,6 @@ namespace RTE { }); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int SLTerrain::LoadData() { SceneLayer::LoadData(); @@ -297,8 +283,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int SLTerrain::SaveData(const std::string& pathBase, bool doAsyncSaves) { if (pathBase.empty()) { return -1; @@ -309,8 +293,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int SLTerrain::ClearData() { RTEAssert(SceneLayer::ClearData() == 0, "Failed to clear material bitmap data of an SLTerrain!"); RTEAssert(m_FGColorLayer && m_FGColorLayer->ClearData() == 0, "Failed to clear the foreground color bitmap data of an SLTerrain!"); @@ -318,15 +300,11 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool SLTerrain::IsAirPixel(const int pixelX, const int pixelY) const { int checkPixel = GetPixel(pixelX, pixelY); return checkPixel == MaterialColorKeys::g_MaterialAir || checkPixel == MaterialColorKeys::g_MaterialCavity; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool SLTerrain::IsBoxBuried(const Box& checkBox) const { bool buried = true; buried = buried && !IsAirPixel(checkBox.GetCorner().GetFloorIntX(), checkBox.GetCorner().GetFloorIntY()); @@ -336,8 +314,6 @@ namespace RTE { return buried; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SLTerrain::CleanAir() { std::vector rows(m_MainBitmap->h); // we loop through h first, because we want each thread to have sequential memory that they're touching std::iota(std::begin(rows), std::end(rows), 0); @@ -357,8 +333,6 @@ namespace RTE { }); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SLTerrain::CleanAirBox(const Box& box, bool wrapsX, bool wrapsY) { int width = m_MainBitmap->w; int height = m_MainBitmap->h; @@ -398,8 +372,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // TODO: OPTIMIZE THIS, IT'S A TIME HOG. MAYBE JSUT STAMP THE OUTLINE AND SAMPLE SOME RANDOM PARTICLES? std::deque SLTerrain::EraseSilhouette(BITMAP* sprite, const Vector& pos, const Vector& pivot, const Matrix& rotation, float scale, bool makeMOPs, int skipMOP, int maxMOPs) { RTEAssert(sprite, "Null BITMAP passed to SLTerrain::EraseSilhouette"); @@ -489,8 +461,6 @@ namespace RTE { return dislodgedMOPixels; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SLTerrain::Update() { SceneLayer::Update(); @@ -498,8 +468,6 @@ namespace RTE { m_BGColorLayer->SetOffset(m_Offset); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SLTerrain::Draw(BITMAP* targetBitmap, Box& targetBox, bool offsetNeedsScrollRatioAdjustment) { switch (m_LayerToDraw) { case LayerType::MaterialLayer: diff --git a/Source/Entities/SLTerrain.h b/Source/Entities/SLTerrain.h index a1ff35a368..36d37131c7 100644 --- a/Source/Entities/SLTerrain.h +++ b/Source/Entities/SLTerrain.h @@ -11,9 +11,7 @@ namespace RTE { class TerrainObject; class TerrainDebris; - /// /// Collection of scrolling layers that compose the terrain of the Scene. - /// class SLTerrain : public SceneLayer { public: @@ -21,9 +19,7 @@ namespace RTE { SerializableOverrideMethods; ClassInfoGetters; - /// /// Enumeration for the different type of layers in the SLTerrain. - /// enum class LayerType { ForegroundLayer, BackgroundLayer, @@ -31,35 +27,25 @@ namespace RTE { }; #pragma region Creation - /// /// Constructor method used to instantiate a SLTerrain object in system memory. Create() should be called before using the object. - /// SLTerrain() { Clear(); } - /// /// Makes the SLTerrain object ready for use. - /// - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create() override; - /// /// Creates a SLTerrain to be identical to another, by deep copy. - /// - /// A reference to the SLTerrain to deep copy. - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @param reference A reference to the SLTerrain to deep copy. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create(const SLTerrain& reference); #pragma endregion #pragma region Destruction - /// /// Destructor method used to clean up a SLTerrain object before deletion from system memory. - /// ~SLTerrain() override { Destroy(true); } - /// /// Destroys and resets (through Clear()) the SLTerrain object. - /// - /// Whether to only destroy the members defined in this derived class, or to destroy all inherited members also. + /// @param notInherited Whether to only destroy the members defined in this derived class, or to destroy all inherited members also. void Destroy(bool notInherited = false) override { if (!notInherited) { SceneLayer::Destroy(); @@ -69,193 +55,141 @@ namespace RTE { #pragma endregion #pragma region Data Handling - /// /// Whether this SLTerrain's bitmap data is loaded from a file or was generated at runtime. - /// - /// Whether this SLTerrain's bitmap data was loaded from a file or was generated at runtime. + /// @return Whether this SLTerrain's bitmap data was loaded from a file or was generated at runtime. bool IsLoadedFromDisk() const override { return (m_FGColorLayer && m_FGColorLayer->IsLoadedFromDisk()) && (m_BGColorLayer && m_BGColorLayer->IsLoadedFromDisk()); } - /// /// Loads previously specified/created bitmap data into memory. Has to be done before using this SLTerrain if the bitmap was not generated at runtime. - /// - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int LoadData() override; - /// /// Saves bitmap data currently in memory to disk. - /// - /// The filepath base to the where to save the Bitmap data. This means everything up to the extension. "FG" and "Mat" etc will be added. - /// Whether or not to save asynchronously. - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @param pathBase The filepath base to the where to save the Bitmap data. This means everything up to the extension. "FG" and "Mat" etc will be added. + /// @param doAsyncSaves Whether or not to save asynchronously. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int SaveData(const std::string& pathBase, bool doAsyncSaves = true) override; - /// /// Clears out any previously loaded bitmap data from memory. - /// - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int ClearData() override; #pragma endregion #pragma region Getters and Setters - /// /// Gets the width of this SLTerrain as determined by the main (material) bitmap. - /// - /// The width of this SLTerrain, in pixels. + /// @return The width of this SLTerrain, in pixels. int GetWidth() const { return m_Width; } - /// /// Gets the height of this SLTerrain as determined by the main (material) bitmap. - /// - /// The height of this SLTerrain, in pixels. + /// @return The height of this SLTerrain, in pixels. int GetHeight() const { return m_Height; } - /// /// Sets the layer of this SLTerrain that should be drawn to the screen when Draw() is called. - /// - /// The layer that should be drawn. See LayerType enumeration. + /// @param layerToDraw The layer that should be drawn. See LayerType enumeration. void SetLayerToDraw(LayerType layerToDraw) { m_LayerToDraw = layerToDraw; } - /// /// Gets the foreground color bitmap of this SLTerrain. - /// - /// A pointer to the foreground color bitmap. + /// @return A pointer to the foreground color bitmap. BITMAP* GetFGColorBitmap() { return m_FGColorLayer->GetBitmap(); } - /// /// Gets the background color bitmap of this SLTerrain. - /// - /// A pointer to the background color bitmap. + /// @return A pointer to the background color bitmap. BITMAP* GetBGColorBitmap() { return m_BGColorLayer->GetBitmap(); } - /// /// Gets the material bitmap of this SLTerrain. - /// - /// A pointer to the material bitmap. + /// @return A pointer to the material bitmap. BITMAP* GetMaterialBitmap() { return m_MainBitmap; } - /// /// Gets a specific pixel from the foreground color bitmap of this. LockBitmaps() must be called before using this method. - /// - /// The X coordinate of the pixel to get. - /// The Y coordinate of the pixel to get. - /// An int specifying the requested pixel's foreground color index. + /// @param pixelX The X coordinate of the pixel to get. + /// @param pixelY The Y coordinate of the pixel to get. + /// @return An int specifying the requested pixel's foreground color index. int GetFGColorPixel(int pixelX, int pixelY) const { return m_FGColorLayer->GetPixel(pixelX, pixelY); } - /// /// Sets a specific pixel on the foreground color bitmap of this SLTerrain to a specific color. LockBitmaps() must be called before using this method. - /// - /// The X coordinate of the pixel to set. - /// The Y coordinate of the pixel to set. - /// The color index to set the pixel to. + /// @param pixelX The X coordinate of the pixel to set. + /// @param pixelY The Y coordinate of the pixel to set. + /// @param materialID The color index to set the pixel to. void SetFGColorPixel(int pixelX, int pixelY, const int materialID) const { m_FGColorLayer->SetPixel(pixelX, pixelY, materialID); } - /// /// Gets a specific pixel from the background color bitmap of this. LockBitmaps() must be called before using this method. - /// - /// The X coordinate of the pixel to get. - /// The Y coordinate of the pixel to get. - /// An int specifying the requested pixel's background color index. + /// @param pixelX The X coordinate of the pixel to get. + /// @param pixelY The Y coordinate of the pixel to get. + /// @return An int specifying the requested pixel's background color index. int GetBGColorPixel(int pixelX, int pixelY) const { return m_BGColorLayer->GetPixel(pixelX, pixelY); } - /// /// Sets a specific pixel on the background color bitmap of this SLTerrain to a specific color. LockBitmaps() must be called before using this method. - /// - /// The X coordinate of the pixel to set. - /// The Y coordinate of the pixel to set. - /// The color index to set the pixel to. + /// @param pixelX The X coordinate of the pixel to set. + /// @param pixelY The Y coordinate of the pixel to set. + /// @param materialID The color index to set the pixel to. void SetBGColorPixel(int pixelX, int pixelY, int materialID) const { m_BGColorLayer->SetPixel(pixelX, pixelY, materialID); } - /// /// Gets a specific pixel from the material bitmap of this SceneLayer. LockBitmaps() must be called before using this method. - /// - /// The X coordinate of the pixel to get. - /// The Y coordinate of the pixel to get. - /// An int specifying the requested pixel's material index. + /// @param pixelX The X coordinate of the pixel to get. + /// @param pixelY The Y coordinate of the pixel to get. + /// @return An int specifying the requested pixel's material index. int GetMaterialPixel(int pixelX, int pixelY) const { return GetPixel(pixelX, pixelY); } - /// /// Sets a specific pixel on the material bitmap of this SLTerrain to a specific material. LockMaterialBitmap() must be called before using this method. - /// - /// The X coordinate of the pixel to set. - /// The Y coordinate of the pixel to set. - /// The material index to set the pixel to. + /// @param pixelX The X coordinate of the pixel to set. + /// @param pixelY The Y coordinate of the pixel to set. + /// @param materialID The material index to set the pixel to. void SetMaterialPixel(int pixelX, int pixelY, int materialID) { SetPixel(pixelX, pixelY, materialID); } - /// /// Indicates whether a terrain pixel is of Air or Cavity material. - /// - /// The X coordinate of the pixel to check. - /// The Y coordinate of the pixel to check. - /// Whether the terrain pixel is of Air or Cavity material. + /// @param pixelX The X coordinate of the pixel to check. + /// @param pixelY The Y coordinate of the pixel to check. + /// @return Whether the terrain pixel is of Air or Cavity material. bool IsAirPixel(int pixelX, int pixelY) const; - /// /// Checks whether a bounding box is completely buried in the terrain. - /// - /// The box to check. - /// Whether the box is completely buried, i.e. no corner sticks out in the Air or Cavity. + /// @param checkBox The box to check. + /// @return Whether the box is completely buried, i.e. no corner sticks out in the Air or Cavity. bool IsBoxBuried(const Box& checkBox) const; #pragma endregion #pragma region Concrete Methods - /// /// Gets a deque of unwrapped boxes which show the areas where the material layer has had objects applied to it since last call to ClearUpdatedMaterialAreas(). - /// - /// Reference to the deque that has been filled with Boxes which are unwrapped and may be out of bounds of the scene! + /// @return Reference to the deque that has been filled with Boxes which are unwrapped and may be out of bounds of the scene! std::deque& GetUpdatedMaterialAreas() { return m_UpdatedMaterialAreas; } - /// /// Adds a notification that an area of the material terrain has been updated. - /// - /// The Box defining the newly updated material area that can be unwrapped and may be out of bounds of the scene. + /// @param newArea The Box defining the newly updated material area that can be unwrapped and may be out of bounds of the scene. void AddUpdatedMaterialArea(const Box& newArea) { m_UpdatedMaterialAreas.emplace_back(newArea); } - /// /// Removes any color pixel in the color layer of this SLTerrain wherever there is an air material pixel in the material layer. - /// void CleanAir(); - /// /// Removes any color pixel in the color layer of this SLTerrain wherever there is an air material pixel in the material layer inside the specified box. - /// - /// Box to clean. - /// Whether the scene is X-wrapped. - /// Whether the scene is Y-wrapped. + /// @param box Box to clean. + /// @param wrapsX Whether the scene is X-wrapped. + /// @param wrapsY Whether the scene is Y-wrapped. void CleanAirBox(const Box& box, bool wrapsX, bool wrapsY); - /// /// Takes a BITMAP and scans through the pixels on this terrain for pixels which overlap with it. Erases them from the terrain and can optionally generate MOPixels based on the erased or 'dislodged' terrain pixels. - /// - /// A pointer to the source BITMAP whose silhouette will be used as a cookie-cutter on the terrain. - /// The position coordinates of the sprite. - /// The pivot coordinate of the sprite. - /// The sprite's current rotation in radians. - /// The sprite's current scale coefficient. - /// Whether to generate any MOPixels from the erased terrain pixels. - /// How many pixels to skip making MOPixels from, between each that gets made. 0 means every pixel turns into an MOPixel. - /// The max number of MOPixels to make, if they are to be made. - /// A deque filled with the MOPixels of the terrain that are now dislodged. This will be empty if makeMOPs is false. Note that ownership of all the MOPixels in the deque IS transferred! + /// @param sprite A pointer to the source BITMAP whose silhouette will be used as a cookie-cutter on the terrain. + /// @param pos The position coordinates of the sprite. + /// @param pivot The pivot coordinate of the sprite. + /// @param rotation The sprite's current rotation in radians. + /// @param scale The sprite's current scale coefficient. + /// @param makeMOPs Whether to generate any MOPixels from the erased terrain pixels. + /// @param skipMOP How many pixels to skip making MOPixels from, between each that gets made. 0 means every pixel turns into an MOPixel. + /// @param maxMOPs The max number of MOPixels to make, if they are to be made. + /// @return A deque filled with the MOPixels of the terrain that are now dislodged. This will be empty if makeMOPs is false. Note that ownership of all the MOPixels in the deque IS transferred! std::deque EraseSilhouette(BITMAP* sprite, const Vector& pos, const Vector& pivot, const Matrix& rotation, float scale, bool makeMOPs = true, int skipMOP = 2, int maxMOPs = 150); - /// /// Returns the direction of the out-of-bounds "orbit" for this scene, where the brain must path to and where dropships/rockets come from. - /// - /// The orbit direction, either Up, Down, Left or Right.. + /// @return The orbit direction, either Up, Down, Left or Right.. Directions GetOrbitDirection() { return m_OrbitDirection; } #pragma endregion #pragma region Virtual Override Methods - /// /// Updates the state of this SLTerrain. - /// void Update() override; - /// /// Draws this SLTerrain's current scrolled position to a bitmap. - /// - /// The bitmap to draw to. - /// The box on the target bitmap to limit drawing to, with the corner of box being where the scroll position lines up. - /// Whether the offset of this SceneLayer or the passed in offset override need to be adjusted to scroll ratio. + /// @param targetBitmap The bitmap to draw to. + /// @param targetBox The box on the target bitmap to limit drawing to, with the corner of box being where the scroll position lines up. + /// @param offsetNeedsScrollRatioAdjustment Whether the offset of this SceneLayer or the passed in offset override need to be adjusted to scroll ratio. void Draw(BITMAP* targetBitmap, Box& targetBox, bool offsetNeedsScrollRatioAdjustment = false) override; #pragma endregion @@ -280,14 +214,10 @@ namespace RTE { Directions m_OrbitDirection; //!< The direction of the out-of-bounds "orbit" for this scene, where the brain must path to and where dropships/rockets come from. - /// /// Applies Material textures to the foreground and background color layers, based on the loaded material layer (main bitmap). - /// void TexturizeTerrain(); - /// /// Clears all the member variables of this SLTerrain, effectively resetting the members of this abstraction level only. - /// void Clear(); // Disallow the use of some implicit methods. diff --git a/Source/Entities/Scene.cpp b/Source/Entities/Scene.cpp index 91a11c0ab4..0194149c1f 100644 --- a/Source/Entities/Scene.cpp +++ b/Source/Entities/Scene.cpp @@ -1,15 +1,3 @@ -////////////////////////////////////////////////////////////////////////////////////////// -// File: Scene.cpp -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Source file for the Scene class. -// Project: Retro Terrain Engine -// Author(s): Daniel Tabar -// data@datarealms.com -// http://www.datarealms.com - -////////////////////////////////////////////////////////////////////////////////////////// -// Inclusions of header files - #include "Scene.h" #include "PresetMan.h" @@ -54,22 +42,11 @@ namespace RTE { // Holds the path calculated by CalculateScenePath thread_local std::list s_ScenePath; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Clear - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears all the member variables of this Area, effectively - // resetting the members of this abstraction level only. - void Scene::Area::Clear() { m_BoxList.clear(); m_Name.clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Creates a Area to be identical to another, by deep copy. - int Scene::Area::Create(const Area& reference) { for (std::vector::const_iterator itr = reference.m_BoxList.begin(); itr != reference.m_BoxList.end(); ++itr) m_BoxList.push_back(*itr); @@ -79,11 +56,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes the Area object ready for use. - int Scene::Area::Create() { if (Serializable::Create() < 0) return -1; @@ -91,14 +63,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: ReadProperty - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Reads a property value from a reader stream. If the name isn't - // recognized by this class, then ReadProperty of the parent class - // is called. If the property isn't recognized by any of the base classes, - // false is returned, and the reader's position is untouched. - int Scene::Area::ReadProperty(const std::string_view& propName, Reader& reader) { StartPropertyList(return Serializable::ReadProperty(propName, reader)); @@ -111,12 +75,6 @@ namespace RTE { EndPropertyList; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Save - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Saves the complete state of this Area with a Writer for - // later recreation with Create(Reader &reader); - int Scene::Area::Save(Writer& writer) const { Serializable::Save(writer); @@ -130,11 +88,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: AddBox - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Adds a Box to this' area coverage. - bool Scene::Area::AddBox(const Box& newBox) { if (newBox.IsEmpty()) return false; @@ -143,8 +96,6 @@ namespace RTE { return true; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool Scene::Area::RemoveBox(const Box& boxToRemove) { std::vector::iterator boxToRemoveIterator = std::find(m_BoxList.begin(), m_BoxList.end(), boxToRemove); if (boxToRemoveIterator != m_BoxList.end()) { @@ -154,14 +105,6 @@ namespace RTE { return false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: HasNoArea - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Shows whether this really has no Area at all, ie it doesn't have any - // Box:es with both width and height. - bool Scene::Area::HasNoArea() const { // If no boxes, then yeah we don't have any area if (m_BoxList.empty()) @@ -176,11 +119,6 @@ namespace RTE { return true; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: IsInside - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Shows whether a point is anywhere inside this Area's coverage. - bool Scene::Area::IsInside(const Vector& point) const { std::list wrappedBoxes; for (std::vector::const_iterator aItr = m_BoxList.begin(); aItr != m_BoxList.end(); ++aItr) { @@ -197,12 +135,6 @@ namespace RTE { return false; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: IsInsideX - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Shows whether a coordinate is anywhere inside this Area's coverage, in the - // X-axis only. - bool Scene::Area::IsInsideX(float pointX) const { std::list wrappedBoxes; for (std::vector::const_iterator aItr = m_BoxList.begin(); aItr != m_BoxList.end(); ++aItr) { @@ -219,12 +151,6 @@ namespace RTE { return false; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: IsInsideY - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Shows whether a coordinate is anywhere inside this Area's coverage, in the - // Y-axis only. - bool Scene::Area::IsInsideY(float pointY) const { std::list wrappedBoxes; for (std::vector::const_iterator aItr = m_BoxList.begin(); aItr != m_BoxList.end(); ++aItr) { @@ -241,12 +167,6 @@ namespace RTE { return false; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: MovePointInsideX - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Moves a coordinate to the closest value which is within any of this - // Area's Box:es, in the X axis only. - bool Scene::Area::MovePointInsideX(float& pointX, int direction) const { if (HasNoArea() || IsInsideX(pointX)) return false; @@ -298,11 +218,6 @@ namespace RTE { return true; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: GetBoxInside - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the first Box encountered in this that contains a specific point. - Box* Scene::Area::GetBoxInside(const Vector& point) { std::list wrappedBoxes; for (std::vector::iterator aItr = m_BoxList.begin(); aItr != m_BoxList.end(); ++aItr) { @@ -320,11 +235,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: RemoveBoxInside - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Removes the first Box encountered in this that contains a specific point. - Box Scene::Area::RemoveBoxInside(const Vector& point) { Box returnBox; @@ -347,12 +257,6 @@ namespace RTE { return returnBox; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: GetCenterPoint - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets a center point for this of all the boxes waeighted by their sizes. - // Arguments: None. - Vector Scene::Area::GetCenterPoint() const { Vector areaCenter; @@ -374,11 +278,6 @@ namespace RTE { return areaCenter; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: GetRandomPoint - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets a random coordinate contained within any of this' Box:es. - Vector Scene::Area::GetRandomPoint() const { // If no boxes, then can't return valid point if (m_BoxList.empty()) @@ -388,12 +287,6 @@ namespace RTE { return m_BoxList[RandomNum(0, m_BoxList.size() - 1)].GetRandomPoint(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Clear - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears all the member variables of this Scene, effectively - // resetting the members of this abstraction level only. - void Scene::Clear() { m_Location.Reset(); m_LocationOffset.Reset(); @@ -454,14 +347,6 @@ namespace RTE { } */ - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes the Scene object ready for use. - // Arguments: The Terrain to use. Ownership IS transferred! - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - int Scene::Create(SLTerrain* pNewTerrain) { m_pTerrain = pNewTerrain; // TODO: allow setting of other stuff too @@ -470,11 +355,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Creates a MOPixel to be identical to another, by deep copy. - int Scene::Create(const Scene& reference) { Entity::Create(reference); @@ -538,12 +418,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: LoadData - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Actually loads previously specified/created data into memory. Has - // to be done before using this SceneLayer. - int Scene::LoadData(bool placeObjects, bool initPathfinding, bool placeUnits) { RTEAssert(m_pTerrain, "Terrain not instantiated before trying to load its data!"); @@ -842,12 +716,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: ExpandAIPlanAssemblySchemes - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: - // - int Scene::ExpandAIPlanAssemblySchemes() { std::list newAIPlan; @@ -910,11 +778,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: SaveData - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Saves currently loaded bitmap data in memory to disk. - int Scene::SaveData(std::string pathBase, bool doAsyncSaves) { const std::string fullPathBase = g_PresetMan.GetFullModulePath(pathBase); if (fullPathBase.empty()) @@ -947,12 +810,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: SavePreview - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Saves preview bitmap for this scene. - // - int Scene::SavePreview(const std::string& bitmapPath) { // Do not save preview for MetaScenes! if (!m_MetasceneParent.empty()) { @@ -1034,11 +891,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: ClearData - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears out any previously loaded bitmap data from memory. - int Scene::ClearData() { if (!m_pTerrain) return 0; @@ -1063,14 +915,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: ReadProperty - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Reads a property value from a reader stream. If the name isn't - // recognized by this class, then ReadProperty of the parent class - // is called. If the property isn't recognized by any of the base classes, - // false is returned, and the reader's position is untouched. - int Scene::ReadProperty(const std::string_view& propName, Reader& reader) { StartPropertyList(return Entity::ReadProperty(propName, reader)); @@ -1167,12 +1011,6 @@ namespace RTE { EndPropertyList; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Save - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Saves the complete state of this Scene with a Writer for - // later recreation with Create(Reader &reader); - int Scene::Save(Writer& writer) const { Entity::Save(writer); @@ -1294,8 +1132,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void Scene::SaveSceneObject(Writer& writer, const SceneObject* sceneObjectToSave, bool isChildAttachable, bool saveFullData) const { auto WriteHardcodedAttachableOrNone = [this, &writer, &saveFullData](const std::string& propertyName, const Attachable* harcodedAttachable) { if (harcodedAttachable) { @@ -1546,13 +1382,6 @@ namespace RTE { writer.ObjectEnd(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destroys and resets (through Clear()) the Scene object. - void Scene::Destroy(bool notInherited) { delete m_pTerrain; @@ -1591,12 +1420,6 @@ namespace RTE { Clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual Method: MigrateToModule - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes this an original Preset in a different module than it was before. - // It severs ties deeply to the old module it was saved in. - bool Scene::MigrateToModule(int whichModule) { if (!Entity::MigrateToModule(whichModule)) return false; @@ -1606,12 +1429,6 @@ namespace RTE { return true; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: FillUnseenLayer - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Creates a new SceneLayer for a specific team and fills it with black - // pixels that end up being a specific size on the screen. - void Scene::FillUnseenLayer(Vector pixelSize, int team, bool createNow) { if (team == Activity::NoTeam || !(pixelSize.m_X >= 1.0 && pixelSize.m_Y >= 1.0)) return; @@ -1632,11 +1449,6 @@ namespace RTE { } } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetUnseenLayer - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the unseen layer of a specific team. - void Scene::SetUnseenLayer(SceneLayer* pNewLayer, int team) { if (team == Activity::NoTeam || !pNewLayer) return; @@ -1648,11 +1460,6 @@ namespace RTE { m_apUnseenLayer[team]->SetScaleFactor(Vector((float)GetTerrain()->GetBitmap()->w / (float)m_apUnseenLayer[team]->GetBitmap()->w, (float)GetTerrain()->GetBitmap()->h / (float)m_apUnseenLayer[team]->GetBitmap()->h)); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ClearSeenPixels - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears the pixels that have been seen on a team's unseen layer. - void Scene::ClearSeenPixels(int team) { if (team != Activity::NoTeam) { // Clear all the pixels off the map, set them to key color @@ -1684,12 +1491,6 @@ namespace RTE { } } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: CleanOrphanPixel - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Checks a specific unseen pixel for only having two or less unseen - // neighbors, and if so, makes it seen. - bool Scene::CleanOrphanPixel(int posX, int posY, NeighborDirection checkingFrom, int team) { if (team == Activity::NoTeam || !m_apUnseenLayer[team]) return false; @@ -1763,8 +1564,6 @@ namespace RTE { return false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - Vector Scene::GetDimensions() const { if (m_pTerrain) { if (const BITMAP* terrainBitmap = m_pTerrain->GetBitmap()) { @@ -1775,8 +1574,6 @@ namespace RTE { return Vector(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int Scene::GetWidth() const { if (m_pTerrain) { if (const BITMAP* terrainBitmap = m_pTerrain->GetBitmap()) { @@ -1787,8 +1584,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int Scene::GetHeight() const { if (m_pTerrain) { if (const BITMAP* terrainBitmap = m_pTerrain->GetBitmap()) { @@ -1799,26 +1594,10 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: WrapsX - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Indicates whether the scene wraps its scrolling around the X axis. - bool Scene::WrapsX() const { return m_pTerrain ? m_pTerrain->WrapsX() : false; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: WrapsY - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Indicates whether the scene wraps its scrolling around the Y axis. - bool Scene::WrapsY() const { return m_pTerrain ? m_pTerrain->WrapsY() : false; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: PlaceResidentBrain - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Places the individual brain of a single player which may be stationed - // on this Scene, and registers them as such in an Activity. - bool Scene::PlaceResidentBrain(int player, Activity& newActivity) { if (m_ResidentBrains[player]) { #ifdef DEBUG_BUILD @@ -1844,12 +1623,6 @@ namespace RTE { return false; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: PlaceResidentBrains - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Places the individual brains of the various players which may be - // stationed on this Scene, and registers them as such in an Activity. - int Scene::PlaceResidentBrains(Activity& newActivity) { int found = 0; @@ -1861,13 +1634,6 @@ namespace RTE { return found; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: RetrieveResidentBrains - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Looks at the Activity and its players' registered brain Actors, and - // saves them as resident brains for this Scene. Done when a fight is over - // and the survivors remain! - int Scene::RetrieveResidentBrains(Activity& oldActivity) { int found = 0; @@ -1893,8 +1659,6 @@ namespace RTE { return found; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int Scene::RetrieveSceneObjects(bool transferOwnership, int onlyTeam, bool noBrains) { int found = 0; @@ -1905,13 +1669,6 @@ namespace RTE { return found; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: AddPlacedObject - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Adds a SceneObject to be placed in this scene. Ownership IS transferred! - void Scene::AddPlacedObject(int whichSet, SceneObject* pObjectToAdd, int listOrder) { if (!pObjectToAdd) return; @@ -1934,11 +1691,6 @@ namespace RTE { } } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: RemovePlacedObject - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Removes a SceneObject placed in this scene. - void Scene::RemovePlacedObject(int whichSet, int whichToRemove) { if (m_PlacedObjects[whichSet].empty()) return; @@ -1957,12 +1709,6 @@ namespace RTE { } } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: PickPlacedObject - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns the last placed object that graphically overlaps an absolute - // point in the scene. - const SceneObject* Scene::PickPlacedObject(int whichSet, Vector& scenePoint, int* pListOrderPlace) const { // REVERSE! int i = m_PlacedObjects[whichSet].size() - 1; @@ -1979,20 +1725,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: PickPlacedActorInRange - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns the last placed actor object that is closer than range to scenePoint - // - // Arguments: Which set of placed objects to pick from. See the PlacedObjectSets enum. - // The point in absolute scene coordinates that will be used to pick the - // closest placed SceneObject near it. - // The range to check for nearby objects. - // An int which will be filled out with the order place of any found object - // in the list. if nothing is found, it will get a value of -1. - // - // Return value: The closest actor SceneObject, if any. Ownership is NOT transferred! - const SceneObject* Scene::PickPlacedActorInRange(int whichSet, Vector& scenePoint, int range, int* pListOrderPlace) const { SceneObject* pFoundObject = 0; float sqrDistance = static_cast(range * range); @@ -2019,12 +1751,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: UpdatePlacedObjects - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updated the objects in the placed scene objects list of this. This is - // mostly for the editor to represent the items correctly. - void Scene::UpdatePlacedObjects(int whichSet) { if (whichSet == PLACEONLOAD) { for (int player = Players::PlayerOne; player < Players::MaxPlayerCount; ++player) @@ -2037,11 +1763,6 @@ namespace RTE { } } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ClearPlacedObjectSet - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Removes all entries in a specific set of placed Objects. - int Scene::ClearPlacedObjectSet(int whichSet, bool weHaveOwnership) { if (weHaveOwnership) { for (std::list::iterator itr = m_PlacedObjects[whichSet].begin(); itr != m_PlacedObjects[whichSet].end(); ++itr) { @@ -2054,12 +1775,6 @@ namespace RTE { return count; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetResidentBrain - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the resident brain Actor of a specific player from this scene, - // if there is any. OWNERSHIP IS NOT TRANSFERRED! - SceneObject* Scene::GetResidentBrain(int player) const { // if (m_ResidentBrains[player]) return m_ResidentBrains[player]; @@ -2070,12 +1785,6 @@ namespace RTE { // } } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetResidentBrain - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the resident brain Actor of a specific player from this scene, - // if there is any. Ownership IS transferred! - void Scene::SetResidentBrain(int player, SceneObject* pNewBrain) { if (MovableObject* asMo = dynamic_cast(m_ResidentBrains[player])) { asMo->DestroyScriptState(); @@ -2084,11 +1793,6 @@ namespace RTE { m_ResidentBrains[player] = pNewBrain; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetResidentBrainCount - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the number of brains currently residing in this scene. - int Scene::GetResidentBrainCount() const { int count = 0; for (int p = Players::PlayerOne; p < Players::MaxPlayerCount; ++p) { @@ -2098,11 +1802,6 @@ namespace RTE { return count; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetArea - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Adds or modifies an existing area of this Scene. - bool Scene::SetArea(Area& newArea) { for (std::list::iterator aItr = m_AreaList.begin(); aItr != m_AreaList.end(); ++aItr) { // Try to find an existing area of the same name @@ -2119,12 +1818,6 @@ namespace RTE { return false; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: HasArea - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Checks for the existence of a specific Area identified by a name. - // This won't throw any errors to the console if the Area isn't found. - bool Scene::HasArea(std::string areaName) { for (std::list::iterator aItr = m_AreaList.begin(); aItr != m_AreaList.end(); ++aItr) { if ((*aItr).GetName() == areaName) @@ -2133,11 +1826,6 @@ namespace RTE { return false; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetArea - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets a specific area box identified by a name. Ownership is NOT transferred! - Scene::Area* Scene::GetArea(const std::string_view& areaName, bool required) { for (Scene::Area& area: m_AreaList) { if (area.GetName() == areaName) { @@ -2152,11 +1840,6 @@ namespace RTE { return nullptr; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: RemoveArea - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Removes a specific Area identified by a name. - bool Scene::RemoveArea(std::string areaName) { for (std::list::iterator aItr = m_AreaList.begin(); aItr != m_AreaList.end(); ++aItr) { if ((*aItr).GetName() == areaName) { @@ -2167,13 +1850,6 @@ namespace RTE { return false; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: WithinArea - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Checks if a point is within a specific named Area of this Scene. If - // no Area of the name is found, this just returns false without error. - // Arguments: The name of the Area to try to check against. - bool Scene::WithinArea(std::string areaName, const Vector& point) const { if (areaName.empty()) return false; @@ -2186,11 +1862,6 @@ namespace RTE { return false; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetTeamOwnership - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the team who owns this Scene in a Metagame - void Scene::SetTeamOwnership(int newTeam) { m_OwnedByTeam = newTeam; @@ -2203,12 +1874,6 @@ namespace RTE { } } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: CalcBuildBudgetUse - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Figure out exactly how much of the build budget would be used if - // as many blueprint objects as can be afforded and exists would be built. - float Scene::CalcBuildBudgetUse(int player, int* pAffordCount, int* pAffordAIPlanCount) const { if (pAffordCount) *pAffordCount = 0; @@ -2320,13 +1985,6 @@ namespace RTE { return fundsAfforded; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ApplyAIPlan - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Puts the pre-built AI base plan into effect by transferring as many - // pieces as the current base budget allows from the AI plan to the actual - // blueprints to be built at this Scene. - float Scene::ApplyAIPlan(int player, int* pObjectsApplied) { if (pObjectsApplied) *pObjectsApplied = 0; @@ -2385,13 +2043,6 @@ namespace RTE { return valueOfApplied; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ApplyBuildBudget - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Actually builds as many objects in the specific player's Blueprint - // list as can be afforded by his build budget. The budget is deducted - // accordingly. - float Scene::ApplyBuildBudget(int player, int* pObjectsBuilt) { if (pObjectsBuilt) *pObjectsBuilt = 0; @@ -2599,12 +2250,6 @@ namespace RTE { return fundsSpent; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: RemoveAllPlacedActors - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Remove all actors that are in the placed set of objects to load for - // this scene. All except for an optionally specified team, that is. - int Scene::RemoveAllPlacedActors(int exceptTeam) { int removedCount = 0; @@ -2641,12 +2286,6 @@ namespace RTE { return removedCount; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetOwnerOfAllDoors - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the ownership of all doors placed in this scene to a specific team - // Arguments: The team to change the ownership to - int Scene::SetOwnerOfAllDoors(int team, int player) { int changedCount = 0; @@ -2670,12 +2309,6 @@ namespace RTE { return changedCount; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ResetPathFinding - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Recalculates all of the pathfinding data. This is very expensive, so - // do very rarely! - void Scene::ResetPathFinding() { GetPathFinder(Activity::Teams::NoTeam)->RecalculateAllCosts(); for (int team = Activity::Teams::TeamOne; team < Activity::Teams::MaxTeamCount; ++team) { @@ -2685,20 +2318,12 @@ namespace RTE { } } - ////////////////////////////////////////////////////////////////////////////////////////// - void Scene::BlockUntilAllPathingRequestsComplete() { for (int team = Activity::Teams::NoTeam; team < Activity::Teams::MaxTeamCount; ++team) { while (GetPathFinder(static_cast(team))->GetCurrentPathingRequests() != 0) {}; } } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: UpdatePathFinding - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Recalculates only the areas of the pathfinding data that have been - // marked as outdated. - void Scene::UpdatePathFinding() { ZoneScoped; @@ -2743,12 +2368,6 @@ namespace RTE { m_PathfindingUpdated = true; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: CalculatePath - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Calculates and returns the least difficult path between two points on - // the current scene. Takes both distance and materials into account. - float Scene::CalculatePath(const Vector& start, const Vector& end, std::list& pathResult, float digStrength, Activity::Teams team) { float totalCostResult = -1; @@ -2786,15 +2405,6 @@ namespace RTE { return false; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Lock - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Locks all dynamic internal scene bitmaps so that manipulaitons of the - // scene's color and matter representations can take place. - // Doing it in a separate method like this is more efficient because - // many bitmap manipulaitons can be performed between a lock and unlock. - // UnlockScene() should always be called after accesses are completed. - void Scene::Lock() { // RTEAssert(!m_Locked, "Hey, locking already locked scene!"); if (!m_Locked) { @@ -2803,14 +2413,6 @@ namespace RTE { } } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Unlock - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Unlocks the scene's bitmaps and prevents access to display memory. - // Doing it in a separate method like this is more efficient because - // many bitmap accesses can be performed between a lock and an unlock. - // UnlockScene() should only be called after LockScene(). - void Scene::Unlock() { // RTEAssert(m_Locked, "Hey, unlocking already unlocked scene!"); if (m_Locked) { @@ -2819,12 +2421,6 @@ namespace RTE { } } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Update - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the state of this Scene. Supposed to be done every frame - // before drawing. - void Scene::Update() { ZoneScoped; @@ -2868,8 +2464,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - std::unique_ptr& Scene::GetPathFinder(Activity::Teams team) { // Note - we use + 1 when getting pathfinders by index, because our shared NoTeam pathfinder occupies index 0, and the rest come after that. return m_pPathFinders[static_cast(team) + 1]; diff --git a/Source/Entities/Scene.h b/Source/Entities/Scene.h index b0df3366c2..2b06d4929e 100644 --- a/Source/Entities/Scene.h +++ b/Source/Entities/Scene.h @@ -1,18 +1,11 @@ #ifndef _RTESCENE_ #define _RTESCENE_ -////////////////////////////////////////////////////////////////////////////////////////// -// File: Scene.h -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Header file for the Scene class. -// Project: Retro Terrain Engine -// Author(s): Daniel Tabar -// data@datarealms.com -// http://www.datarealms.com - -////////////////////////////////////////////////////////////////////////////////////////// -// Inclusions of header files - +/// Header file for the Scene class. +/// @author Daniel Tabar +/// data@datarealms.com +/// http://www.datarealms.com +/// Inclusions of header files #include "Entity.h" #include "Box.h" #include "Activity.h" @@ -30,20 +23,12 @@ namespace RTE { class SceneObject; class Deployment; - ////////////////////////////////////////////////////////////////////////////////////////// - // Class: Scene - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Contains everything that defines a complete scene. - // Parent(s): Entity. - // Class history: 08/02/2006 Scene created. - + /// Contains everything that defines a complete scene. class Scene : public Entity { friend struct EntityLuaBindings; - ////////////////////////////////////////////////////////////////////////////////////////// - // Public member variable, method and friend function declarations - + /// Public member variable, method and friend function declarations public: SerializableOverrideMethods; ClassInfoGetters; @@ -56,13 +41,7 @@ namespace RTE { PLACEDSETSCOUNT }; - ////////////////////////////////////////////////////////////////////////////////////////// - // Nested class: Area - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Something to bundle the properties of scene areas together - // Parent(s): Serializable. - // Class history: 07/18/2008 Area created. - + /// Something to bundle the properties of scene areas together class Area : public Serializable { @@ -72,20 +51,13 @@ namespace RTE { friend struct EntityLuaBindings; - ////////////////////////////////////////////////////////////////////////////////////////// - // Public member variable, method and friend function declarations - + /// Public member variable, method and friend function declarations public: SerializableClassNameGetter; SerializableOverrideMethods; - ////////////////////////////////////////////////////////////////////////////////////////// - // Constructor: Area - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Constructor method used to instantiate a Area object in system - // memory. Create() should be called before using the object. - // Arguments: None. - + /// Constructor method used to instantiate a Area object in system + /// memory. Create() should be called before using the object. Area() { Clear(); Create(); @@ -100,185 +72,106 @@ namespace RTE { Create(reference); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes the Area object ready for use. - // Arguments: None. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Makes the Area object ready for use. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Create() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Creates a Area to be identical to another, by deep copy. - // Arguments: A reference to the Area to deep copy. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Creates a Area to be identical to another, by deep copy. + /// @param reference A reference to the Area to deep copy. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Create(const Area& reference); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Reset - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Resets the entire Serializable, including its inherited members, to their - // default settings or values. - // Arguments: None. - // Return value: None. - + /// Resets the entire Serializable, including its inherited members, to their + /// default settings or values. void Reset() override { Clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: AddBox - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Adds a Box to this' area coverage. - // Arguments: The Box to add. A copy will be made and added. - // Return value: Whether the Box was successfully added or not. - + /// Adds a Box to this' area coverage. + /// @param newBox The Box to add. A copy will be made and added. + /// @return Whether the Box was successfully added or not. bool AddBox(const Box& newBox); - /// /// Removes the first Box in the Area that has the same Corner, Width and Height of the passed-in Box. - /// - /// A Box whose values are used to determine what Box to remove. - /// Whether or not a Box was removed. + /// @param boxToRemove A Box whose values are used to determine what Box to remove. + /// @return Whether or not a Box was removed. bool RemoveBox(const Box& boxToRemove); - /// /// Gets the first Box in this Area. - /// - /// The first Box in this Area. + /// @return The first Box in this Area. const Box* GetFirstBox() const { return m_BoxList.empty() ? nullptr : &m_BoxList[0]; } - /// /// Gets the boxes for this area. - /// - /// The boxes in this Area. + /// @return The boxes in this Area. const std::vector& GetBoxes() const { return m_BoxList; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: HasNoArea - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Shows whether this really has no Area at all, ie it doesn't have any - // Box:es with both width and height. - // Arguments: None. - // Return value: Whether this Area actually covers any area. - + /// Shows whether this really has no Area at all, ie it doesn't have any + /// Box:es with both width and height. + /// @return Whether this Area actually covers any area. bool HasNoArea() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: IsInside - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Shows whether a point is anywhere inside this Area's coverage. - // Arguments: The point to check if it's inside the Area, in absolute scene coordinates. - // Return value: Whether the point is inside any of this Area's Box:es. - + /// Shows whether a point is anywhere inside this Area's coverage. + /// @param point The point to check if it's inside the Area, in absolute scene coordinates. + /// @return Whether the point is inside any of this Area's Box:es. bool IsInside(const Vector& point) const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: IsInsideX - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Shows whether a coordinate is anywhere inside this Area's coverage, in the - // X-axis only. - // Arguments: The x coord to check if it's inside the Area, in absolute scene units. - // Return value: Whether the point is inside any of this Area's Box:es in the X axis. - + /// Shows whether a coordinate is anywhere inside this Area's coverage, in the + /// X-axis only. + /// @param pointX The x coord to check if it's inside the Area, in absolute scene units. + /// @return Whether the point is inside any of this Area's Box:es in the X axis. bool IsInsideX(float pointX) const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: IsInsideY - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Shows whether a coordinate is anywhere inside this Area's coverage, in the - // Y-axis only. - // Arguments: The x coord to check if it's inside the Area, in absolute scene units. - // Return value: Whether the point is inside any of this Area's Box:es in the Y axis. - + /// Shows whether a coordinate is anywhere inside this Area's coverage, in the + /// Y-axis only. + /// @param pointY The x coord to check if it's inside the Area, in absolute scene units. + /// @return Whether the point is inside any of this Area's Box:es in the Y axis. bool IsInsideY(float pointY) const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: MovePointInsideX - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Moves a coordinate to the closest value which is within any of this - // Area's Box:es, in the X axis only. - // Arguments: The x coord to transform to the closest inside poistion in the x-axis. - // Which direction to limit the search to. < 0 means can only look in the - // negative dir, 0 means can look in both directions. - // Return value: Whether the point was moved at all to get inside this' x-space. - + /// Moves a coordinate to the closest value which is within any of this + /// Area's Box:es, in the X axis only. + /// @param pointX The x coord to transform to the closest inside poistion in the x-axis. + /// @param direction Which direction to limit the search to. < 0 means can only look in the (default: 0) + /// negative dir, 0 means can look in both directions. + /// @return Whether the point was moved at all to get inside this' x-space. bool MovePointInsideX(float& pointX, int direction = 0) const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: GetBoxInside - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the first Box encountered in this that contains a specific point. - // Arguments: The point to check for Box collision, in absolute scene coordinates. - // Return value: Pointer to the first Box which was found to contain the point. 0 if - // none was found. OWNERSHIP IS NOT TRANSFERRED! - + /// Gets the first Box encountered in this that contains a specific point. + /// @param point The point to check for Box collision, in absolute scene coordinates. + /// @return Pointer to the first Box which was found to contain the point. 0 if + /// none was found. OWNERSHIP IS NOT TRANSFERRED! Box* GetBoxInside(const Vector& point); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: RemoveBoxInside - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Removes the first Box encountered in this that contains a specific point. - // Arguments: The point to check for Box collision, in absolute scene coordinates. - // Return value: Copy of the Box that was removed. Will be NoArea Box if none was found. - + /// Removes the first Box encountered in this that contains a specific point. + /// @param point The point to check for Box collision, in absolute scene coordinates. + /// @return Copy of the Box that was removed. Will be NoArea Box if none was found. Box RemoveBoxInside(const Vector& point); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: GetCenterPoint - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets a center point for this of all the boxes waeighted by their sizes. - // Arguments: None. - // Return value: A center point of this area, can be outside the actual area though, if - // pulled apart by two separate boxes, for example. 0,0 if this has no Area - + /// Gets a center point for this of all the boxes waeighted by their sizes. + /// @return A center point of this area, can be outside the actual area though, if + /// pulled apart by two separate boxes, for example. 0,0 if this has no Area Vector GetCenterPoint() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: GetRandomPoint - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets a random coordinate contained within any of this' Box:es. - // Arguments: None. - // Return value: A random point that is within this Area. 0,0 if this has no Area - + /// Gets a random coordinate contained within any of this' Box:es. + /// @return A random point that is within this Area. 0,0 if this has no Area Vector GetRandomPoint() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: GetName - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the name of the Area - // Arguments: None. - // Return value: The name used to ID this Area. - + /// Gets the name of the Area + /// @return The name used to ID this Area. std::string GetName() const { return m_Name; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Protected member variable and method declarations - + /// Protected member variable and method declarations protected: // The list of Box:es defining the Area in the owner Scene std::vector m_BoxList; // The name tag of this Area std::string m_Name; - ////////////////////////////////////////////////////////////////////////////////////////// - // Private member variable and method declarations - + /// Private member variable and method declarations private: static const std::string c_ClassName; //!< A string with the friendly-formatted type name of this object. - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Clear - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears all the member variables of this Exit, effectively - // resetting the members of this abstraction level only. - // Arguments: None. - // Return value: None. - + /// Clears all the member variables of this Exit, effectively + /// resetting the members of this abstraction level only. void Clear(); }; @@ -303,582 +196,326 @@ namespace RTE { // Concrete allocation and cloning definitions EntityAllocation(Scene) - ////////////////////////////////////////////////////////////////////////////////////////// - // Constructor: Scene - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Constructor method used to instantiate a Scene object in system - // memory. Create() should be called before using the object. - // Arguments: None. - + /// Constructor method used to instantiate a Scene object in system + /// memory. Create() should be called before using the object. Scene() { Clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Destructor: ~Scene - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destructor method used to clean up a Scene object before deletion - // from system memory. - // Arguments: None. - + /// Destructor method used to clean up a Scene object before deletion + /// from system memory. ~Scene() override { Destroy(true); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes the Scene object ready for use. - // Arguments: The Terrain to use. Ownership IS transferred! - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Makes the Scene object ready for use. + /// @param pNewTerrain The Terrain to use. Ownership IS transferred! + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Create(SLTerrain* pNewTerrain); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Creates a Scene to be identical to another, by deep copy. - // Arguments: A reference to the Scene to deep copy. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Creates a Scene to be identical to another, by deep copy. + /// @param reference A reference to the Scene to deep copy. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Create(const Scene& reference); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: LoadData - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Actually loads previously specified/created data into memory. Has - // to be done before using this Scene. - // Arguments: Whetehr to actually place out all the sceneobjects associated with the - // Scene's definition. If not, they still remain in the internal placed - // objects list. This avoids messing with the MovableMan at all. - // Whether to do pathfinding init, which should be avoided if we are only - // loading and saving purposes of MetaMan, for example. - // Whether to place actors and deployments (doors not affected). - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Actually loads previously specified/created data into memory. Has + /// to be done before using this Scene. + /// @param placeObjects Whetehr to actually place out all the sceneobjects associated with the (default: true) + /// @param initPathfinding Scene's definition. If not, they still remain in the internal placed (default: true) + /// objects list. This avoids messing with the MovableMan at all. + /// @param placeUnits Whether to do pathfinding init, which should be avoided if we are only (default: true) + /// loading and saving purposes of MetaMan, for example. + /// Whether to place actors and deployments (doors not affected). + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int LoadData(bool placeObjects = true, bool initPathfinding = true, bool placeUnits = true); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: ExpandAIPlanAssemblySchemes - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Replace all assembly shemes by corresponding bunker assemblies in - // AI plan objects set. - // Arguments: None. - // Return value: None. - + /// Replace all assembly shemes by corresponding bunker assemblies in + /// AI plan objects set. int ExpandAIPlanAssemblySchemes(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: SaveData - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Saves data currently in memory to disk. - // Arguments: The filepath base to the where to save the Bitmap data. This means - // everything up to the extension. "FG" and "Mat" etc will be added. - // Whether or not to save asynchronously. - // Return value: An error return value signaling success or any particular failure. - // Anything below 0 is an error signal. - + /// Saves data currently in memory to disk. + /// @param pathBase The filepath base to the where to save the Bitmap data. This means + /// everything up to the extension. "FG" and "Mat" etc will be added. + /// @param doAsyncSaves Whether or not to save asynchronously. (default: true) + /// @return An error return value signaling success or any particular failure. + /// Anything below 0 is an error signal. int SaveData(std::string pathBase, bool doAsyncSaves = true); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: SavePreview - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Saves preview bitmap for this scene. - // - // Arguments: The full filepath the where to save the Bitmap data. - // Return value: None. - + /// Saves preview bitmap for this scene. + /// @param bitmapPath The full filepath the where to save the Bitmap data. int SavePreview(const std::string& bitmapPath); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: ClearData - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears out any previously loaded bitmap data from memory. - // Arguments: None. - // Return value: An error return value signaling success or any particular failure. - // Anything below 0 is an error signal. - + /// Clears out any previously loaded bitmap data from memory. + /// @return An error return value signaling success or any particular failure. + /// Anything below 0 is an error signal. int ClearData(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Reset - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Resets the entire Scene, including its inherited members, to - // their default settings or values. - // Arguments: None. - // Return value: None. - + /// Resets the entire Scene, including its inherited members, to + /// their default settings or values. void Reset() override { Clear(); Entity::Reset(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Pure V. method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destroys and resets (through Clear()) the Scene object. - // Arguments: Whether to only destroy the members defined in this derived class, or - // to destroy all inherited members also. - // Return value: None. - + /// Destroys and resets (through Clear()) the Scene object. + /// @param notInherited Whether to only destroy the members defined in this derived class, or (default: false) + /// to destroy all inherited members also. void Destroy(bool notInherited = false) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual Method: MigrateToModule - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes this an original Preset in a different module than it was before. - // It severs ties deeply to the old module it was saved in. - // Arguments: The ID of the new module. - // Return value: Whether the migration was successful. If you tried to migrate to the - // same module it already was in, this would return false. - + /// Makes this an original Preset in a different module than it was before. + /// It severs ties deeply to the old module it was saved in. + /// @param whichModule The ID of the new module. + /// @return Whether the migration was successful. If you tried to migrate to the + /// same module it already was in, this would return false. bool MigrateToModule(int whichModule) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetLocation - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the specified location of this scene on the planet view - // Arguments: None. - // Return value: A Vector showing the location of this scene on the planet view. - + /// Gets the specified location of this scene on the planet view + /// @return A Vector showing the location of this scene on the planet view. Vector GetLocation() const { return m_Location; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetLocationOffset - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the specified temporary location offset of this scene on the planet view. - // Arguments: None. - // Return value: A Vector showing the temporary location offset of this scene on the planet view. - + /// Gets the specified temporary location offset of this scene on the planet view. + /// @return A Vector showing the temporary location offset of this scene on the planet view. Vector GetLocationOffset() const { return m_LocationOffset; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetLocationOffset - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the specified temporary location offset of this scene on the planet view. - // Arguments: A Vector showing the temporary location offset of this scene on the planet view. - // Return value: None. - + /// Sets the specified temporary location offset of this scene on the planet view. + /// @param newOffset A Vector showing the temporary location offset of this scene on the planet view. void SetLocationOffset(Vector newOffset) { m_LocationOffset = newOffset; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: IsMetagamePlayable - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Shows whether this is compatible with metagame play at all. - // Arguments: None. - // Return value: Whether this can be used on the metagame map. - + /// Shows whether this is compatible with metagame play at all. + /// @return Whether this can be used on the metagame map. bool IsMetagamePlayable() const { return m_MetagamePlayable; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: IsRevealed - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Shows whether this is revealed on the metagame map. - // Arguments: None. - // Return value: Whether this can be seen on the metagame map yet. - + /// Shows whether this is revealed on the metagame map. + /// @return Whether this can be seen on the metagame map yet. bool IsRevealed() const { return m_Revealed; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetTeamOwnership - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Shows which team owns this Scene in a Metagame, if any - // Arguments: None. - // Return value: The team that owns this site in a Metagame, if any - + /// Shows which team owns this Scene in a Metagame, if any + /// @return The team that owns this site in a Metagame, if any int GetTeamOwnership() const { return m_OwnedByTeam; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetRoundIncome - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Shows how much income this Scene pulls in for its owning team each - // round of a metagame. - // Arguments: None. - // Return value: The income in oz that this generates each metagame round. - + /// Shows how much income this Scene pulls in for its owning team each + /// round of a metagame. + /// @return The income in oz that this generates each metagame round. float GetRoundIncome() const { return m_RoundIncome; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetBuildBudget - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Shows how much gold this Scene is budgeted to be built for this round. - // Arguments: Which player's set budget to show. - // Return value: The budget in oz that this is allocated to have built for this round. - + /// Shows how much gold this Scene is budgeted to be built for this round. + /// @param player Which player's set budget to show. + /// @return The budget in oz that this is allocated to have built for this round. float GetBuildBudget(int player) const { return m_BuildBudget[player]; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetBuildBudgetRatio - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Shows how much of a player's budget this Scene is allocated to be - // built for this round. - // Arguments: Which player's set budget ratio to show. - // Return value: The budget in normalized ratio that this is allocated last round. - + /// Shows how much of a player's budget this Scene is allocated to be + /// built for this round. + /// @param player Which player's set budget ratio to show. + /// @return The budget in normalized ratio that this is allocated last round. float GetBuildBudgetRatio(int player) const { return m_BuildBudgetRatio[player]; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetAutoDesigned - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets whether this should be automatically designed by the AI plan - // even if owned by human players. - // Arguments: What to set the setting to. - // Return value: None. - + /// Sets whether this should be automatically designed by the AI plan + /// even if owned by human players. + /// @param autoDesigned What to set the setting to. (default: true) void SetAutoDesigned(bool autoDesigned = true) { m_AutoDesigned = autoDesigned; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetAutoDesigned - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Tells whether this should be automatically designed by the AI plan - // even if owned by human players. - // Arguments: None. - // Return value: Whether this should be autodesigned or not. - + /// Tells whether this should be automatically designed by the AI plan + /// even if owned by human players. + /// @return Whether this should be autodesigned or not. bool GetAutoDesigned() const { return m_AutoDesigned; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetTotalInvestment - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the total defense investment this scene has experienced by all - // teams since the metagame started. - // Arguments: What to set the total investment in gold oz) to. - // Return value: None. - + /// Sets the total defense investment this scene has experienced by all + /// teams since the metagame started. + /// @param totalInvestment What to set the total investment in gold oz) to. void SetTotalInvestment(float totalInvestment) { m_TotalInvestment = totalInvestment; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetTotalInvestment - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the total defense investment this scene has experienced by all - // teams since the metagame started. - // Arguments: None. - // Return value: The total investment in this scene. - + /// Gets the total defense investment this scene has experienced by all + /// teams since the metagame started. + /// @return The total investment in this scene. float GetTotalInvestment() const { return m_TotalInvestment; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetTerrain - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the SLTerrain. - // Arguments: None. - // Return value: A pointer to the SLTerrain. Ownership is NOT transferred! - + /// Gets the SLTerrain. + /// @return A pointer to the SLTerrain. Ownership is NOT transferred! SLTerrain* GetTerrain() { return m_pTerrain; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetBackLayers - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets access to the background layer list. - // Arguments: None. - // Return value: A reference to the std::list containing all the background layers. - // Ownership is NOT transferred! - + /// Gets access to the background layer list. + /// @return A reference to the std::list containing all the background layers. + /// Ownership is NOT transferred! std::list& GetBackLayers() { return m_BackLayerList; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: AddArea - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Adds area to the list if this scene's areas. - // Arguments: Area to add. - // Return value: None. - + /// Adds area to the list if this scene's areas. + /// @param m_AreaList.push_back(newArea Area to add. void AddArea(Scene::Area& newArea) { m_AreaList.push_back(newArea); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: FillUnseenLayer - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Creates a new SceneLayer for a specific team and fills it with black - // pixels that end up being a specific size on the screen. - // Arguments: A Vector with the desired dimensions of the unseen layer's chunky pixels. - // Which team to get the unseen layer for. - // Whether to create the unseen layers now, or wait until next time - // LoadData is called on this. - // Return value: None. - + /// Creates a new SceneLayer for a specific team and fills it with black + /// pixels that end up being a specific size on the screen. + /// @param pixelSize A Vector with the desired dimensions of the unseen layer's chunky pixels. + /// @param team Which team to get the unseen layer for. (default: Activity::TeamOne) + /// @param createNow Whether to create the unseen layers now, or wait until next time (default: true) + /// LoadData is called on this. void FillUnseenLayer(Vector pixelSize, int team = Activity::TeamOne, bool createNow = true); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetUnseenLayer - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the unseen layer of a specific team. - // Arguments: The new SceneLayer to use as the new unseen layer, Ownership IS XFERRED! - // Which team to get the unseen layer for. - // Return value: None. - + /// Sets the unseen layer of a specific team. + /// @param pNewLayer The new SceneLayer to use as the new unseen layer, Ownership IS XFERRED! + /// @param team Which team to get the unseen layer for. (default: Activity::TeamOne) void SetUnseenLayer(SceneLayer* pNewLayer, int team = Activity::TeamOne); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetUnseenLayer - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the unseen layer of a specific team. - // Arguments: Which team to get the unseen layer for. - // Return value: A pointer to the SceneLayer representing what hasn't been seen by a - // specific team yet. Ownership is NOT transferred! - + /// Gets the unseen layer of a specific team. + /// @param team Which team to get the unseen layer for. (default: Activity::TeamOne) + /// @return A pointer to the SceneLayer representing what hasn't been seen by a + /// specific team yet. Ownership is NOT transferred! SceneLayer* GetUnseenLayer(int team = Activity::TeamOne) const { return team != Activity::NoTeam ? m_apUnseenLayer[team] : 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetSeenPixels - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the list of pixels that have been seen on a team's unseen layer. - // Arguments: Which team to get the unseen layer for. - // Return value: The list of pixel coordinates in the unseen layer's scale. - + /// Gets the list of pixels that have been seen on a team's unseen layer. + /// @param team Which team to get the unseen layer for. (default: Activity::TeamOne) + /// @return The list of pixel coordinates in the unseen layer's scale. std::list& GetSeenPixels(int team = Activity::TeamOne) { return m_SeenPixels[team]; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ClearSeenPixels - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears the pixels that have been seen on a team's unseen layer. - // Arguments: Which team to get the unseen layer for. - // Return value: None. - + /// Clears the pixels that have been seen on a team's unseen layer. + /// @param team Which team to get the unseen layer for. (default: Activity::TeamOne) void ClearSeenPixels(int team = Activity::TeamOne); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: CleanOrphanPixel - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Checks a specific unseen pixel for only having two or less unseen - // neighbors, and if so, makes it seen. - // Arguments: Coordinates to the pixel to check for orphaness. - // The direction we might be checking 'from', ie the neighbor we can - // already assume is seen without poking at the unseen map. - // Which team's unseen layer to check the pixel on. - // Return value: Whether the pixel was deemed to be orphan and thus cleaned up. - + /// Checks a specific unseen pixel for only having two or less unseen + /// neighbors, and if so, makes it seen. + /// @param posX Coordinates to the pixel to check for orphaness. + /// @param posY The direction we might be checking 'from', ie the neighbor we can + /// already assume is seen without poking at the unseen map. + /// @param checkingFrom Which team's unseen layer to check the pixel on. (default: NODIR) + /// @return Whether the pixel was deemed to be orphan and thus cleaned up. bool CleanOrphanPixel(int posX, int posY, NeighborDirection checkingFrom = NODIR, int team = Activity::TeamOne); - /// /// Gets the total dimensions (width and height) of the scene, in pixels. - /// - /// A Vector describing the scene dimensions. + /// @return A Vector describing the scene dimensions. Vector GetDimensions() const; - /// /// Gets the total width of the scene, in pixels. - /// - /// An int describing the scene width. + /// @return An int describing the scene width. int GetWidth() const; - /// /// Gets the total height of the scene, in pixels. - /// - /// An int describing the scene height. + /// @return An int describing the scene height. int GetHeight() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: WrapsX - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Indicates whether the scene wraps its scrolling around the X axis. - // Arguments: None. - // Return value: Whether the scene wraps around the X axis or not. - + /// Indicates whether the scene wraps its scrolling around the X axis. + /// @return Whether the scene wraps around the X axis or not. bool WrapsX() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: WrapsY - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Indicates whether the scene wraps its scrolling around the Y axis. - // Arguments: None. - // Return value: Whether the scene wraps around the Y axis or not. - + /// Indicates whether the scene wraps its scrolling around the Y axis. + /// @return Whether the scene wraps around the Y axis or not. bool WrapsY() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: PlaceResidentBrain - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Places the individual brain of a single player which may be stationed - // on this Scene, and registers them as such in an Activity. - // Arguments: The player's brain to place. - // The Activity to register the placed brains with. OWNERSHIP IS NOT TRANSFERRED! - // Return value: If the brain was successfully found as resident and placed. - + /// Places the individual brain of a single player which may be stationed + /// on this Scene, and registers them as such in an Activity. + /// @param player The player's brain to place. + /// @param newActivity The Activity to register the placed brains with. OWNERSHIP IS NOT TRANSFERRED! + /// @return If the brain was successfully found as resident and placed. bool PlaceResidentBrain(int player, Activity& newActivity); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: PlaceResidentBrains - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Places the individual brains of the various players which may be - // stationed on this Scene, and registers them as such in an Activity. - // Arguments: The Activity to register the placed brains with. OWNERSHIP IS NOT TRANSFERRED! - // Return value: How many brains were finally placed. - + /// Places the individual brains of the various players which may be + /// stationed on this Scene, and registers them as such in an Activity. + /// @param newActivity The Activity to register the placed brains with. OWNERSHIP IS NOT TRANSFERRED! + /// @return How many brains were finally placed. int PlaceResidentBrains(Activity& newActivity); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: RetrieveResidentBrains - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Looks at the Activity and its players' registered brain Actors, and - // saves them as resident brains for this Scene. Done when a fight is over - // and the survivors remain! - // Arguments: The Activity to check for registered brains. OWNERSHIP IS NOT TRANSFERRED! - // Return value: How many brains were found registered with the passed in Activity. - + /// Looks at the Activity and its players' registered brain Actors, and + /// saves them as resident brains for this Scene. Done when a fight is over + /// and the survivors remain! + /// @param oldActivity The Activity to check for registered brains. OWNERSHIP IS NOT TRANSFERRED! + /// @return How many brains were found registered with the passed in Activity. int RetrieveResidentBrains(Activity& oldActivity); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: RetrieveSceneObjects - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sucks up all the Actors, Items and Particles currently active in MovableMan and - // puts them into this' list of objects to place on next load. - // Arguments: The team to only retrieve Actors of. If NoTeam, then all will be grabbed. - // Whether to not get any brains at all. - // Return value: How many objects were found knocking about in the world, and stored. - + /// Sucks up all the Actors, Items and Particles currently active in MovableMan and + /// puts them into this' list of objects to place on next load. + /// @param transferOwnership The team to only retrieve Actors of. If NoTeam, then all will be grabbed. + /// @param onlyTeam Whether to not get any brains at all. (default: -1) + /// @return How many objects were found knocking about in the world, and stored. int RetrieveSceneObjects(bool transferOwnership, int onlyTeam = -1, bool noBrains = false); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetPlacedObjects - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the list of SceneObject:s which are placed in this scene on loading. - // Arguments: Which set of placed objects to get. See the PlacedObjectSets enum. - // Return value: The list of of placed objects. Ownership is NOT transferred! - + /// Gets the list of SceneObject:s which are placed in this scene on loading. + /// @param whichSet Which set of placed objects to get. See the PlacedObjectSets enum. + /// @return The list of of placed objects. Ownership is NOT transferred! const std::list* GetPlacedObjects(int whichSet) const { return &m_PlacedObjects[whichSet]; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: AddPlacedObject - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Adds a SceneObject to be placed in this scene. Ownership IS transferred! - // Arguments: Which set of placed objects to add to. See the PlacedObjectSets enum. - // The SceneObject instance to add, OIT! - // Where in the list the object should be inserted. -1 means at the end - // of the list. - // Return value: None. - + /// Adds a SceneObject to be placed in this scene. Ownership IS transferred! + /// @param whichSet Which set of placed objects to add to. See the PlacedObjectSets enum. + /// @param pObjectToAdd The SceneObject instance to add, OIT! + /// @param listOrder Where in the list the object should be inserted. -1 means at the end (default: -1) + /// of the list. void AddPlacedObject(int whichSet, SceneObject* pObjectToAdd, int listOrder = -1); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: RemovePlacedObject - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Removes a SceneObject placed in this scene. - // Arguments: Which set of placed objects to rem from. See the PlacedObjectSets enum. - // The list order number of the object to remove. If -1, the last one is removed. - // Return value: None. - + /// Removes a SceneObject placed in this scene. + /// @param whichSet Which set of placed objects to rem from. See the PlacedObjectSets enum. + /// @param whichToRemove The list order number of the object to remove. If -1, the last one is removed. (default: -1) void RemovePlacedObject(int whichSet, int whichToRemove = -1); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: PickPlacedObject - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns the last placed object that graphically overlaps an absolute - // point in the scene. - // Arguments: Which set of placed objects to pick from. See the PlacedObjectSets enum. - // The point in absolute scene coordinates that will be used to pick the - // last placed SceneObject which overlaps it. - // An int which will be filled out with the order place of any found object - // in the list. if nothing is found, it will get a value of -1. - // Return value: The last hit SceneObject, if any. Ownership is NOT transferred! - + /// Returns the last placed object that graphically overlaps an absolute + /// point in the scene. + /// @param whichSet Which set of placed objects to pick from. See the PlacedObjectSets enum. + /// @param scenePoint The point in absolute scene coordinates that will be used to pick the + /// last placed SceneObject which overlaps it. + /// @param pListOrderPlace An int which will be filled out with the order place of any found object (default: 0) + /// in the list. if nothing is found, it will get a value of -1. + /// @return The last hit SceneObject, if any. Ownership is NOT transferred! const SceneObject* PickPlacedObject(int whichSet, Vector& scenePoint, int* pListOrderPlace = 0) const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: PickPlacedActorInRange - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns the last placed actor object that is closer than range to scenePoint - // - // Arguments: Which set of placed objects to pick from. See the PlacedObjectSets enum. - // The point in absolute scene coordinates that will be used to pick the - // closest placed SceneObject near it. - // The range to check for nearby objects. - // An int which will be filled out with the order place of any found object - // in the list. if nothing is found, it will get a value of -1. - // - // Return value: The closest actor SceneObject, if any. Ownership is NOT transferred! - + /// Returns the last placed actor object that is closer than range to scenePoint + /// @param whichSet Which set of placed objects to pick from. See the PlacedObjectSets enum. + /// @param scenePoint The point in absolute scene coordinates that will be used to pick the + /// closest placed SceneObject near it. + /// @param range The range to check for nearby objects. + /// @param pListOrderPlace An int which will be filled out with the order place of any found object + /// in the list. if nothing is found, it will get a value of -1. + /// @return The closest actor SceneObject, if any. Ownership is NOT transferred! const SceneObject* PickPlacedActorInRange(int whichSet, Vector& scenePoint, int range, int* pListOrderPlace) const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: UpdatePlacedObjects - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updated the objects in the placed scene objects list of this. This is - // mostly for the editor to represent the items correctly. - // Arguments: Which set of placed objects to update. See the PlacedObjectSets enum. - // Return value: None. - + /// Updated the objects in the placed scene objects list of this. This is + /// mostly for the editor to represent the items correctly. + /// @param whichSet Which set of placed objects to update. See the PlacedObjectSets enum. void UpdatePlacedObjects(int whichSet); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ClearPlacedObjectSet - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Removes all entries in a specific set of placed Objects. - // Arguments: Which set of placed objects to clear. See the PlacedObjectSets enum. - // Whether or not we have ownership of these items, and should delete them. - // Return value: How many things were removed in teh process of clearing that set. - + /// Removes all entries in a specific set of placed Objects. + /// @param whichSet Which set of placed objects to clear. See the PlacedObjectSets enum. + /// @param weHaveOwnership Whether or not we have ownership of these items, and should delete them. (default: true) + /// @return How many things were removed in teh process of clearing that set. int ClearPlacedObjectSet(int whichSet, bool weHaveOwnership = true); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetResidentBrain - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the resident brain Actor of a specific player from this scene, - // if there is any. OWNERSHIP IS NOT TRANSFERRED! - // Arguments: Which player to get the resident brain of. - // Return value: The SO containing the brain, or 0 if there aren't any of that player. - + /// Gets the resident brain Actor of a specific player from this scene, + /// if there is any. OWNERSHIP IS NOT TRANSFERRED! + /// @param player Which player to get the resident brain of. + /// @return The SO containing the brain, or 0 if there aren't any of that player. SceneObject* GetResidentBrain(int player) const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetResidentBrain - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the resident brain Actor of a specific player from this scene, - // if there is any. Ownership IS transferred! - // Arguments: Which player to set the resident brain of. - // The Actor to set as the resident brain of the specified player. - // Return value: None. - + /// Sets the resident brain Actor of a specific player from this scene, + /// if there is any. Ownership IS transferred! + /// @param player Which player to set the resident brain of. + /// @param pNewBrain The Actor to set as the resident brain of the specified player. void SetResidentBrain(int player, SceneObject* pNewBrain); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetResidentBrainCount - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the number of brains currently residing in this scene. - // Arguments: None. - // Return value: The number of resident brains who are installed here. - + /// Gets the number of brains currently residing in this scene. + /// @return The number of resident brains who are installed here. int GetResidentBrainCount() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetArea - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Adds one or modifies an existing area of this Scene. - // Arguments: The area to add or modify of the same name in this Scene. Ownership is - // NOT transferred! - // Return value: Whether the specified area was previously defined in this scene. - + /// Adds one or modifies an existing area of this Scene. + /// @param newArea The area to add or modify of the same name in this Scene. Ownership is + /// NOT transferred! + /// @return Whether the specified area was previously defined in this scene. bool SetArea(Area& newArea); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: HasArea - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Checks for the existence of a specific Area identified by a name. - // This won't throw any errors to the console if the Area isn't found. - // Arguments: The name of the Area to try to find in this Scene. - // Return value: Whether the specified area is defined in this Scene. - + /// Checks for the existence of a specific Area identified by a name. + /// This won't throw any errors to the console if the Area isn't found. + /// @param areaName The name of the Area to try to find in this Scene. + /// @return Whether the specified area is defined in this Scene. bool HasArea(std::string areaName); - /// /// Gets a specified Area identified by name. Ownership is NOT transferred! - /// - /// The name of the Area to try to get. - /// Whether the area is required, and should throw an error if not found. - /// A pointer to the Area asked for, or nullptr if no Area of that name was found. + /// @param areaName The name of the Area to try to get. + /// @param required Whether the area is required, and should throw an error if not found. + /// @return A pointer to the Area asked for, or nullptr if no Area of that name was found. Area* GetArea(const std::string_view& areaName, bool required); - /// /// Gets a specified Area identified by name. Ownership is NOT transferred! - /// - /// The name of the Area to try to get. - /// A pointer to the Area asked for, or nullptr if no Area of that name was found. + /// @param areaName The name of the Area to try to get. + /// @return A pointer to the Area asked for, or nullptr if no Area of that name was found. Area* GetArea(const std::string& areaName) { return GetArea(areaName, true); } - /// /// Gets a specified Area identified by name, showing a Lua warning if it's not found. Ownership is NOT transferred! /// Using this function will not add the area to the list of required areas which Scenario GUI uses to show compatible areas. - /// - /// The name of the Area to try to get. - /// A pointer to the Area asked for, or nullptr if no Area of that name was found. + /// @param areaName The name of the Area to try to get. + /// @return A pointer to the Area asked for, or nullptr if no Area of that name was found. Area* GetOptionalArea(const std::string& areaName) { return GetArea(areaName, false); } void AddNavigatableArea(const std::string& areaName) { @@ -890,362 +527,200 @@ namespace RTE { m_NavigatableAreasUpToDate = false; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: RemoveArea - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Removes a specific Area identified by a name. - // Arguments: The name of the Area to try to remove. - // Return value: Whether an Area of that name was found, and subsequently removed. - + /// Removes a specific Area identified by a name. + /// @param areaName The name of the Area to try to remove. + /// @return Whether an Area of that name was found, and subsequently removed. bool RemoveArea(std::string areaName); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: WithinArea - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Checks if a point is within a specific named Area of this Scene. If - // no Area of the name is found, this just returns false without error. - // Arguments: The name of the Area to try to check against. - // The point to see if it's within the specified Area. - // Return value: Whether any Area of that name was found, AND the point falls within it. - + /// Checks if a point is within a specific named Area of this Scene. If + /// no Area of the name is found, this just returns false without error. + /// @param areaName The name of the Area to try to check against. + /// @param point The point to see if it's within the specified Area. + /// @return Whether any Area of that name was found, AND the point falls within it. bool WithinArea(std::string areaName, const Vector& point) const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetGlobalAcc - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the global acceleration (in m/s^2) that is applied to all movable - // objects' velocities during every frame. Typically models gravity. - // Arguments: None. - // Return value: A Vector describing the global acceleration. - + /// Gets the global acceleration (in m/s^2) that is applied to all movable + /// objects' velocities during every frame. Typically models gravity. + /// @return A Vector describing the global acceleration. Vector GetGlobalAcc() const { return m_GlobalAcc; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetGlobalAcc - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the global acceleration (in m/s^2) that is applied to all movable - // objects' velocities during every frame. Typically models gravity. - // Arguments: A Vector describing the global acceleration. - // Return value: None. - + /// Sets the global acceleration (in m/s^2) that is applied to all movable + /// objects' velocities during every frame. Typically models gravity. + /// @param newValue A Vector describing the global acceleration. void SetGlobalAcc(Vector newValue) { m_GlobalAcc = newValue; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetMetasceneParent - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns parent scene name of this metascene. - // Arguments: None. - // Return value: Name of a parent scene. - + /// Returns parent scene name of this metascene. + /// @return Name of a parent scene. std::string GetMetasceneParent() const { return m_MetasceneParent; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetLocation - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the specified location of this Scene in the scene - // Arguments: A Vector with the desired location of this Scene in the scene. - // Return value: None. - + /// Sets the specified location of this Scene in the scene + /// @param newLocation A Vector with the desired location of this Scene in the scene. void SetLocation(const Vector& newLocation) { m_Location = newLocation; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetMetagamePlayable - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets whether this can be played in the Metagame map at all. - // Arguments: Whether this is compatible with metagame play at all. - // Return value: None. - + /// Sets whether this can be played in the Metagame map at all. + /// @param isPlayable Whether this is compatible with metagame play at all. void SetMetagamePlayable(bool isPlayable) { m_MetagamePlayable = isPlayable; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetRevealed - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets whether this should show up on the Metagame map yet. - // Arguments: Whether to reveal this on the metagame map or not. - // Return value: None. - + /// Sets whether this should show up on the Metagame map yet. + /// @param isRevealed Whether to reveal this on the metagame map or not. void SetRevealed(bool isRevealed) { m_Revealed = isRevealed; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetTeamOwnership - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the team who owns this Scene in a Metagame - // Arguments: The team who should now own this Scene - // Return value: None. - + /// Sets the team who owns this Scene in a Metagame + /// @param newTeam The team who should now own this Scene void SetTeamOwnership(int newTeam); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetBuildBudget - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets how much gold this Scene is budgeted to be built for this round. - // Arguments: The player whom is setting the budget. - // The budget in oz that this is allocated to have built for this round. - // Return value: None. - + /// Sets how much gold this Scene is budgeted to be built for this round. + /// @param player The player whom is setting the budget. + /// @param budget The budget in oz that this is allocated to have built for this round. void SetBuildBudget(int player, float budget) { m_BuildBudget[player] = budget; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetBuildBudgetRatio - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets how much of a player's budget this Scene is budgeted to be build - // for each turn. - // Arguments: The player whom is setting the budget ratio. - // The budget in normalized ratio that this is allocated of the total. - // Return value: None. - + /// Sets how much of a player's budget this Scene is budgeted to be build + /// for each turn. + /// @param player The player whom is setting the budget ratio. + /// @param budgetRatio The budget in normalized ratio that this is allocated of the total. void SetBuildBudgetRatio(int player, float budgetRatio) { m_BuildBudgetRatio[player] = budgetRatio; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: CalcBuildBudgetUse - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Figure out exactly how much of the build budget would be used if - // as many blueprint objects as can be afforded and exists would be built. - // Arguments: The player for whom we are calculating this budget use. - // An optional int that will be filled with number of objects that can - // acutally be built. - // An optional int that will be filled with number of objects that can - // built out of the AI plan set, AFTER the blueprints are built. - // Return value: The amount of funds that would be applied to the building of objects. - + /// Figure out exactly how much of the build budget would be used if + /// as many blueprint objects as can be afforded and exists would be built. + /// @param player The player for whom we are calculating this budget use. + /// @param pAffordCount An optional int that will be filled with number of objects that can (default: 0) + /// acutally be built. + /// @param pAffordAIPlanCount An optional int that will be filled with number of objects that can (default: 0) + /// built out of the AI plan set, AFTER the blueprints are built. + /// @return The amount of funds that would be applied to the building of objects. float CalcBuildBudgetUse(int player, int* pAffordCount = 0, int* pAffordAIPlanCount = 0) const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ApplyAIPlan - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Puts the pre-built AI base plan into effect by transferring as many - // pieces as the current base budget allows from the AI plan to the actual - // blueprints to be built at this Scene. - // Arguments: The AI player whom is putting his plans into motion. - // An optional int that will be filled with number of objects that were - // acutally moved from the AI plan to the blueprints. - // Return value: The value of the AI plan objects that were put onto the blueprints. - + /// Puts the pre-built AI base plan into effect by transferring as many + /// pieces as the current base budget allows from the AI plan to the actual + /// blueprints to be built at this Scene. + /// @param player The AI player whom is putting his plans into motion. + /// @param pObjectsApplied An optional int that will be filled with number of objects that were (default: 0) + /// acutally moved from the AI plan to the blueprints. + /// @return The value of the AI plan objects that were put onto the blueprints. float ApplyAIPlan(int player, int* pObjectsApplied = 0); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ApplyBuildBudget - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Actually builds as many objects in the specific player's Blueprint - // list as can be afforded by his build budget. The budget is deducted - // accordingly. - // Arguments: The player whom is using his budget. - // An optional int that will be filled with number of objects that were - // acutally built. - // Return value: The amount of funds that were applied to the building of objects. - + /// Actually builds as many objects in the specific player's Blueprint + /// list as can be afforded by his build budget. The budget is deducted + /// accordingly. + /// @param player The player whom is using his budget. + /// @param pObjectsBuilt An optional int that will be filled with number of objects that were (default: 0) + /// acutally built. + /// @return The amount of funds that were applied to the building of objects. float ApplyBuildBudget(int player, int* pObjectsBuilt = 0); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: RemoveAllPlacedActors - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Remove all actors that are in the placed set of objects to load for - // this scene. All except for an optionally specified team, that is. - // Arguments: Remove all actors but of this team. - // Return value: How many actors were actually removed. - + /// Remove all actors that are in the placed set of objects to load for + /// this scene. All except for an optionally specified team, that is. + /// @param exceptTeam Remove all actors but of this team. (default: -1) + /// @return How many actors were actually removed. int RemoveAllPlacedActors(int exceptTeam = -1); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetOwnerOfAllDoors - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the ownership of all doors placed in this scene to a specific team - // Arguments: The team to change the ownership to - // The player which placed these doors. - // Return value: How many doors were actually affected. - + /// Sets the ownership of all doors placed in this scene to a specific team + /// @param team The team to change the ownership to + /// @param player The player which placed these doors. + /// @return How many doors were actually affected. int SetOwnerOfAllDoors(int team, int player); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: IsScanScheduled - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Tells whether a specific team has scheduled an orbital Scan of this. - // Arguments: The team to check for. - // Return value: Whether the scan has been scheduled and paid for. - + /// Tells whether a specific team has scheduled an orbital Scan of this. + /// @param team The team to check for. + /// @return Whether the scan has been scheduled and paid for. bool IsScanScheduled(int team) const { return m_ScanScheduled[team]; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetScheduledScan - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets this to be orbitally scanned by a specific team on next load. - // Arguments: The team to schedule the scan for. - // Whether to actually schedule the scan or clear it. - // Return value: None. - + /// Sets this to be orbitally scanned by a specific team on next load. + /// @param team The team to schedule the scan for. + /// @param scan Whether to actually schedule the scan or clear it. (default: true) void SetScheduledScan(int team, bool scan = true) { m_ScanScheduled[team] = scan; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ResetPathFinding - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Recalculates all of the pathfinding data. This is very expensive, so - // do very rarely! - // Arguments: None. - // Return value: None. - + /// Recalculates all of the pathfinding data. This is very expensive, so + /// do very rarely! void ResetPathFinding(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: BlockUntilAllPathingRequestsComplete - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Blocks this thread until all pathing requests are completed. - // Arguments: None. - // Return value: None. - + /// Blocks this thread until all pathing requests are completed. void BlockUntilAllPathingRequestsComplete(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: UpdatePathFinding - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Recalculates only the areas of the pathfinding data that have been - // marked as outdated. - // Arguments: None. - // Return value: None. - + /// Recalculates only the areas of the pathfinding data that have been + /// marked as outdated. void UpdatePathFinding(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: PathFindingUpdated - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Tells whether the pathfinding data has been updated in the last frame. - // Arguments: None. - // Return value: Whether the pathfinding data was recalculated fully or partially. - + /// Tells whether the pathfinding data has been updated in the last frame. + /// @return Whether the pathfinding data was recalculated fully or partially. bool PathFindingUpdated() { return m_PathfindingUpdated; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: CalculatePath - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Calculates and returns the least difficult path between two points on - // the current scene. Takes both distance and materials into account. - // When pathing using the NoTeam pathFinder, no doors are considered passable. - // Arguments: Start and end positions on the scene to find the path between. - // A list which will be filled out with waypoints between the start and end. - // The maximum material strength any actor traveling along the path can dig through. - // The team we're pathing for (doors for this team will be considered passable) - // Return value: The total minimum difficulty cost calculated between the two points on - // the scene. - + /// Calculates and returns the least difficult path between two points on + /// the current scene. Takes both distance and materials into account. + /// When pathing using the NoTeam pathFinder, no doors are considered passable. + /// @param start Start and end positions on the scene to find the path between. + /// @param end A list which will be filled out with waypoints between the start and end. + /// @param pathResult The maximum material strength any actor traveling along the path can dig through. + /// @param digStrength The team we're pathing for (doors for this team will be considered passable) (default: c_PathFindingDefaultDigStrength) + /// @return The total minimum difficulty cost calculated between the two points on + /// the scene. float CalculatePath(const Vector& start, const Vector& end, std::list& pathResult, float digStrength = c_PathFindingDefaultDigStrength, Activity::Teams team = Activity::Teams::NoTeam); - /// /// Asynchronously calculates the least difficult path between two points on the current Scene. Takes both distance and materials into account. /// When pathing using the NoTeam pathFinder, no doors are considered passable. - /// - /// Start position of the pathfinding request. - /// End position of the pathfinding request. - /// The maximum material strength any actor traveling along the path can dig through. - /// The team we're pathing for (doors for this team will be considered passable) - /// A shared pointer to the volatile PathRequest to be used to track whehter the asynchrnous path calculation has been completed, and check its results. + /// @param start Start position of the pathfinding request. + /// @param end End position of the pathfinding request. + /// @param digStrength The maximum material strength any actor traveling along the path can dig through. + /// @param team The team we're pathing for (doors for this team will be considered passable) + /// @return A shared pointer to the volatile PathRequest to be used to track whehter the asynchrnous path calculation has been completed, and check its results. std::shared_ptr CalculatePathAsync(const Vector& start, const Vector& end, float digStrength = c_PathFindingDefaultDigStrength, Activity::Teams team = Activity::Teams::NoTeam, PathCompleteCallback callback = nullptr); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetScenePathSize - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets how many waypoints there are in the ScenePath currently - // Arguments: None. - // Return value: The number of waypoints in the ScenePath. - + /// Gets how many waypoints there are in the ScenePath currently + /// @return The number of waypoints in the ScenePath. int GetScenePathSize() const; std::list& GetScenePath(); - /// /// Returns whether two position represent the same path nodes. - /// - /// First coordinates to compare. - /// Second coordinates to compare. - /// Whether both coordinates represent the same path node. + /// @param pos1 First coordinates to compare. + /// @param pos2 Second coordinates to compare. + /// @return Whether both coordinates represent the same path node. bool PositionsAreTheSamePathNode(const Vector& pos1, const Vector& pos2) const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Lock - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Locks all dynamic internal scene bitmaps so that manipulaitons of the - // scene's color and matter representations can take place. - // Doing it in a separate method like this is more efficient because - // many bitmap manipulaitons can be performed between a lock and unlock. - // UnlockScene() should always be called after accesses are completed. - // Arguments: None. - // Return value: None. - + /// Locks all dynamic internal scene bitmaps so that manipulaitons of the + /// scene's color and matter representations can take place. + /// Doing it in a separate method like this is more efficient because + /// many bitmap manipulaitons can be performed between a lock and unlock. + /// UnlockScene() should always be called after accesses are completed. void Lock(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Unlock - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Unlocks the scene's bitmaps and prevents access to display memory. - // Doing it in a separate method like this is more efficient because - // many bitmap accesses can be performed between a lock and an unlock. - // UnlockScene() should only be called after LockScene(). - // Arguments: None. - // Return value: None. - + /// Unlocks the scene's bitmaps and prevents access to display memory. + /// Doing it in a separate method like this is more efficient because + /// many bitmap accesses can be performed between a lock and an unlock. + /// UnlockScene() should only be called after LockScene(). void Unlock(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: IsLocked - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Indicates whether the entire scene is currently locked or not. - // Arguments: None. - // Return value: Whether the entire scene is currently locked or not. - + /// Indicates whether the entire scene is currently locked or not. + /// @return Whether the entire scene is currently locked or not. bool IsLocked() const { return m_Locked; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Update - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the state of this Scene. Supposed to be done every frame - // before drawing. - // Arguments: None. - // Return value: None. - + /// Updates the state of this Scene. Supposed to be done every frame + /// before drawing. void Update(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: IsMetagameInternal - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Whether this scene is a temprorary metagame scene and should - // not be used anywhere except in metagame. - // Arguments: None. - // Return value: Whether scene belongs to metagame or not. - + /// Whether this scene is a temprorary metagame scene and should + /// not be used anywhere except in metagame. + /// @return Whether scene belongs to metagame or not. bool IsMetagameInternal() const { return m_IsMetagameInternal; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetMetagameInternal - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets whether this scene is a temprorary metagame scene and should - // not be used anywhere except in metagame. - // Arguments: New value. - // Return value: None. - + /// Sets whether this scene is a temprorary metagame scene and should + /// not be used anywhere except in metagame. + /// @param newValue New value. void SetMetagameInternal(bool newValue) { m_IsMetagameInternal = newValue; } - /// /// Gets whether this Scene is a saved game Scene copy and should not be used anywhere except for game saving and loading. - /// - /// Whether this Scene is a saved game Scene copy. + /// @return Whether this Scene is a saved game Scene copy. bool IsSavedGameInternal() const { return m_IsSavedGameInternal; } - /// /// Sets whether this Scene is a saved game Scene copy and should not be used anywhere except for game saving and loading. - /// - /// Whether this Scene is a saved game Scene copy. + /// @param newValue Whether this Scene is a saved game Scene copy. void SetSavedGameInternal(bool newValue) { m_IsSavedGameInternal = newValue; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetPreviewBitmap - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns preview bitmap pointer for this scene. - // Arguments: None. - // Return value: Pointer to preview bitmap. - + /// Returns preview bitmap pointer for this scene. + /// @return Pointer to preview bitmap. BITMAP* GetPreviewBitmap() const { return m_pPreviewBitmap; }; - ////////////////////////////////////////////////////////////////////////////////////////// - // Protected member variable and method declarations - + /// Protected member variable and method declarations protected: // Member variables static Entity::ClassInfo m_sClass; @@ -1329,34 +804,22 @@ namespace RTE { std::list m_Deployments; - ////////////////////////////////////////////////////////////////////////////////////////// - // Private member variable and method declarations - + /// Private member variable and method declarations private: - /// /// Gets the pathfinder for a given team. - /// - /// The team to get the pathfinder for. NoTeam is valid, and will give a shared pathfinder. - /// A pointer to the pathfinder for the given team. + /// @param team The team to get the pathfinder for. NoTeam is valid, and will give a shared pathfinder. + /// @return A pointer to the pathfinder for the given team. std::unique_ptr& GetPathFinder(Activity::Teams team); - /// /// Serializes the SceneObject via the Writer. Necessary because full serialization doesn't know how to deal with duplicate properties. - /// - /// The Writer being used for serialization. - /// The SceneObject to save. - /// Convenience flag for whether or not this SceneObject is a child Attachable, and certain properties shouldn't be saved. - /// Whether or not to save most data. Turned off for stuff like SceneEditor saves. + /// @param writer The Writer being used for serialization. + /// @param sceneObjectToSave The SceneObject to save. + /// @param isChildAttachable Convenience flag for whether or not this SceneObject is a child Attachable, and certain properties shouldn't be saved. + /// @param saveFullData Whether or not to save most data. Turned off for stuff like SceneEditor saves. void SaveSceneObject(Writer& writer, const SceneObject* sceneObjectToSave, bool isChildAttachable, bool saveFullData) const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Clear - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears all the member variables of this Scene, effectively - // resetting the members of this abstraction level only. - // Arguments: None. - // Return value: None. - + /// Clears all the member variables of this Scene, effectively + /// resetting the members of this abstraction level only. void Clear(); // Disallow the use of some implicit methods. diff --git a/Source/Entities/SceneLayer.cpp b/Source/Entities/SceneLayer.cpp index ac2b6804c9..11bbfe84d3 100644 --- a/Source/Entities/SceneLayer.cpp +++ b/Source/Entities/SceneLayer.cpp @@ -13,8 +13,6 @@ namespace RTE { ConcreteClassInfo(SceneLayerTracked, Entity, 0); ConcreteClassInfo(SceneLayer, Entity, 0); - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - template void SceneLayerImpl::Clear() { m_BitmapFile.Reset(); @@ -34,8 +32,6 @@ namespace RTE { m_ScaledDimensions.SetXY(1.0F, 1.0F); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - template int SceneLayerImpl::Create(const ContentFile& bitmapFile, bool drawMasked, const Vector& offset, bool wrapX, bool wrapY, const Vector& scrollInfo) { m_BitmapFile = bitmapFile; @@ -47,8 +43,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - template int SceneLayerImpl::Create(BITMAP* bitmap, bool drawMasked, const Vector& offset, bool wrapX, bool wrapY, const Vector& scrollInfo) { m_MainBitmap = bitmap; @@ -70,8 +64,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - template int SceneLayerImpl::Create(const SceneLayerImpl& reference) { Entity::Create(reference); @@ -108,8 +100,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - template int SceneLayerImpl::ReadProperty(const std::string_view& propName, Reader& reader) { StartPropertyList(return Entity::ReadProperty(propName, reader)); @@ -121,8 +111,6 @@ namespace RTE { EndPropertyList; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - template int SceneLayerImpl::Save(Writer& writer) const { Entity::Save(writer); @@ -134,8 +122,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - template void SceneLayerImpl::Destroy(bool notInherited) { if (m_MainBitmapOwned) { @@ -150,8 +136,6 @@ namespace RTE { Clear(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - template void SceneLayerImpl::InitScrollRatios(bool initForNetworkPlayer, int player) { float mainBitmapWidth = static_cast(m_MainBitmap->w); @@ -188,8 +172,6 @@ namespace RTE { m_ScaledDimensions.SetXY(mainBitmapWidth * m_ScaleFactor.GetX(), mainBitmapHeight * m_ScaleFactor.GetY()); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - template int SceneLayerImpl::LoadData() { // Load from disk and take ownership. Don't cache because the bitmap will be modified. @@ -203,8 +185,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - template int SceneLayerImpl::SaveData(const std::string& bitmapPath, bool doAsyncSaves) { if (bitmapPath.empty()) { @@ -235,8 +215,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - template int SceneLayerImpl::ClearData() { if (m_MainBitmap && m_MainBitmapOwned) { @@ -254,8 +232,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - template void SceneLayerImpl::SetScaleFactor(const Vector& newScale) { m_ScaleFactor = newScale; @@ -264,16 +240,12 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - template int SceneLayerImpl::GetPixel(int pixelX, int pixelY) const { WrapPosition(pixelX, pixelY); return (pixelX < 0 || pixelX >= m_MainBitmap->w || pixelY < 0 || pixelY >= m_MainBitmap->h) ? MaterialColorKeys::g_MaterialAir : _getpixel(m_MainBitmap, pixelX, pixelY); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - template void SceneLayerImpl::SetPixel(int pixelX, int pixelY, int materialID) { RTEAssert(m_MainBitmapOwned, "Trying to set a pixel of a SceneLayer's bitmap which isn't owned!"); @@ -288,15 +260,11 @@ namespace RTE { RegisterDrawing(pixelX, pixelY, pixelX, pixelY); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - template bool SceneLayerImpl::IsWithinBounds(const int pixelX, const int pixelY, const int margin) const { return (m_WrapX || (pixelX >= -margin && pixelX < m_MainBitmap->w + margin)) && (m_WrapY || (pixelY >= -margin && pixelY < m_MainBitmap->h + margin)); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - template void SceneLayerImpl::ClearBitmap(ColorKeys clearTo) { RTEAssert(m_MainBitmapOwned, "Bitmap not owned! We shouldn't be clearing this!"); @@ -323,8 +291,6 @@ namespace RTE { m_Drawings.clear(); // This was copied into the new thread, so can be safely deleted. } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - template bool SceneLayerImpl::WrapPosition(int& posX, int& posY) const { int oldX = posX; @@ -349,8 +315,6 @@ namespace RTE { return oldX != posX || oldY != posY; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - template bool SceneLayerImpl::ForceBounds(int& posX, int& posY) const { bool wrapped = false; @@ -396,8 +360,6 @@ namespace RTE { return wrapped; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - template bool SceneLayerImpl::ForceBoundsOrWrapPosition(Vector& pos, bool forceBounds) const { int posX = pos.GetFloorIntX(); @@ -408,8 +370,6 @@ namespace RTE { return wrapped; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - template void SceneLayerImpl::RegisterDrawing(int left, int top, int right, int bottom) { if constexpr (TRACK_DRAWINGS) { @@ -417,8 +377,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - template void SceneLayerImpl::RegisterDrawing(const Vector& center, float radius) { if (radius != 0.0F) { @@ -426,8 +384,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - template void SceneLayerImpl::Draw(BITMAP* targetBitmap, Box& targetBox, bool offsetNeedsScrollRatioAdjustment) { RTEAssert(m_MainBitmap, "Data of this SceneLayerImpl has not been loaded before trying to draw!"); @@ -459,8 +415,6 @@ namespace RTE { set_clip_rect(targetBitmap, 0, 0, targetBitmap->w - 1, targetBitmap->h - 1); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - template void SceneLayerImpl::DrawWrapped(BITMAP* targetBitmap, const Box& targetBox, bool drawScaled) const { if (!drawScaled) { @@ -498,8 +452,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - template void SceneLayerImpl::DrawTiled(BITMAP* targetBitmap, const Box& targetBox, bool drawScaled) const { int bitmapWidth = m_ScaledDimensions.GetFloorIntX(); @@ -538,8 +490,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - template void SceneLayerImpl::ClearDrawings(BITMAP* bitmap, const std::vector& drawings, ColorKeys clearTo) const { if constexpr (TRACK_DRAWINGS) { @@ -584,8 +534,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // Force instantiation template class SceneLayerImpl; template class SceneLayerImpl; diff --git a/Source/Entities/SceneLayer.h b/Source/Entities/SceneLayer.h index dfa8d3f4d6..73ab8f7b30 100644 --- a/Source/Entities/SceneLayer.h +++ b/Source/Entities/SceneLayer.h @@ -7,9 +7,7 @@ namespace RTE { - /// /// A scrolling layer of the Scene. - /// template class SceneLayerImpl : public Entity { friend class NetworkServer; @@ -19,259 +17,191 @@ namespace RTE { SerializableOverrideMethods; #pragma region Creation - /// /// Constructor method used to instantiate a SceneLayerImpl object in system memory. Create() should be called before using the object. - /// SceneLayerImpl() { Clear(); } - /// /// Makes the SceneLayer object ready for use. - /// - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create() override { return Entity::Create(); } - /// /// Makes the SceneLayer object ready for use. - /// - /// The ContentFile to load as this SceneLayer's graphical representation. - /// Whether to draw masked (transparent) or not. - /// The initial scroll offset. - /// Whether the layer should wrap around or stop when scrolling beyond its bitmap's boundaries on the X axis. - /// Whether the layer should wrap around or stop when scrolling beyond its bitmap's boundaries on the Y axis. - /// + /// @param bitmapFile The ContentFile to load as this SceneLayer's graphical representation. + /// @param drawMasked Whether to draw masked (transparent) or not. + /// @param offset The initial scroll offset. + /// @param wrapX Whether the layer should wrap around or stop when scrolling beyond its bitmap's boundaries on the X axis. + /// @param wrapY Whether the layer should wrap around or stop when scrolling beyond its bitmap's boundaries on the Y axis. + /// @param scrollInfo /// A vector whose components define two different things, depending on wrap arguments. /// If a wrap argument is set to false, the corresponding component here will be interpreted as the width (X) or height (Y) (in pixels) of the total bitmap area that this layer is allowed to scroll across before stopping at an edge. /// If wrapping is set to true, the value in scrollInfo is simply the ratio of offset at which any scroll operations will be done in. /// A special command is if wrap is false and the corresponding component is -1.0, that signals that the own width or height should be used as scrollInfo input. - /// - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create(const ContentFile& bitmapFile, bool drawMasked, const Vector& offset, bool wrapX, bool wrapY, const Vector& scrollInfo); - /// /// Makes the SceneLayer object ready for use. - /// - /// The BITMAP to use for this SceneLayer. Ownership IS transferred! - /// Whether to draw masked (transparent) or not. - /// The initial scroll offset. - /// Whether the layer should wrap around or stop when scrolling beyond its bitmap's boundaries on the X axis. - /// Whether the layer should wrap around or stop when scrolling beyond its bitmap's boundaries on the Y axis. - /// + /// @param bitmap The BITMAP to use for this SceneLayer. Ownership IS transferred! + /// @param drawMasked Whether to draw masked (transparent) or not. + /// @param offset The initial scroll offset. + /// @param wrapX Whether the layer should wrap around or stop when scrolling beyond its bitmap's boundaries on the X axis. + /// @param wrapY Whether the layer should wrap around or stop when scrolling beyond its bitmap's boundaries on the Y axis. + /// @param scrollInfo /// A vector whose components define two different things, depending on wrap arguments. /// If a wrap argument is set to false, the corresponding component here will be interpreted as the width (X) or height (Y) (in pixels) of the total bitmap area that this layer is allowed to scroll across before stopping at an edge. /// If wrapping is set to true, the value in scrollInfo is simply the ratio of offset at which any scroll operations will be done in. /// A special command is if wrap is false and the corresponding component is -1.0, that signals that the own width or height should be used as scrollInfo input. - /// - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create(BITMAP* bitmap, bool drawMasked, const Vector& offset, bool wrapX, bool wrapY, const Vector& scrollInfo); - /// /// Creates a SceneLayer to be identical to another, by deep copy. - /// - /// A reference to the SceneLayer to deep copy. - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @param reference A reference to the SceneLayer to deep copy. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create(const SceneLayerImpl& reference); #pragma endregion #pragma region Destruction - /// /// Destructor method used to clean up a SceneLayer object before deletion from system memory. - /// ~SceneLayerImpl() override { Destroy(true); } - /// /// Destroys and resets (through Clear()) the SceneLayer object. - /// - /// Whether to only destroy the members defined in this derived class, or to destroy all inherited members also. + /// @param notInherited Whether to only destroy the members defined in this derived class, or to destroy all inherited members also. void Destroy(bool notInherited = false) override; #pragma endregion #pragma region Data Handling - /// /// Whether this SceneLayer's bitmap data is loaded from a file or was generated at runtime. - /// - /// Whether this SceneLayer's bitmap data was loaded from a file or not. + /// @return Whether this SceneLayer's bitmap data was loaded from a file or not. virtual bool IsLoadedFromDisk() const { return !m_BitmapFile.GetDataPath().empty(); } - /// /// Loads previously specified/created data into memory. Has to be done before using this SceneLayer if the bitmap was not generated at runtime. - /// - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. virtual int LoadData(); - /// /// Saves data currently in memory to disk. - /// - /// The filepath to the where to save the bitmap data. - /// Whether or not to save asynchronously. - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @param bitmapPath The filepath to the where to save the bitmap data. + /// @param doAsyncSaves Whether or not to save asynchronously. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. virtual int SaveData(const std::string& bitmapPath, bool doAsyncSaves = true); - /// /// Clears out any previously loaded bitmap data from memory. - /// - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. virtual int ClearData(); #pragma endregion #pragma region Getters and Setters - /// /// Gets the scroll offset of this SceneLayer. - /// - /// A Vector with the scroll offset. + /// @return A Vector with the scroll offset. Vector GetOffset() const { return m_Offset; } - /// /// Sets the scroll offset of this SceneLayer. Observe that this offset will be modified by the scroll ratio before applied. - /// - /// The new offset Vector. + /// @param newOffset The new offset Vector. void SetOffset(const Vector& newOffset) { m_Offset = newOffset; } - /// /// Gets the scroll ratio that modifies the offset. - /// - /// A copy of the ratio. + /// @return A copy of the ratio. Vector GetScrollRatio() const { return m_ScrollRatio; } - /// /// Sets the scroll ratio of this SceneLayer. This modifies the offset before any actual scrolling occurs. - /// - /// The new scroll ratio vector. + /// @param newRatio The new scroll ratio vector. void SetScrollRatio(const Vector& newRatio) { m_ScrollRatio = newRatio; } - /// /// Gets the scale factor that this is drawn in. - /// - /// The scale factor of this to the target it is drawn to. (2x if this is half the res, etc.) + /// @return The scale factor of this to the target it is drawn to. (2x if this is half the res, etc.) Vector GetScaleFactor() const { return m_ScaleFactor; } - /// /// Sets the scale that this should be drawn at when using DrawScaled. - /// - /// The new scale factor vector. + /// @param newScale The new scale factor vector. void SetScaleFactor(const Vector& newScale); - /// /// Indicates whether the layer is set to wrap around the X axis when scrolled out of bounds. - /// - /// Whether this SceneLayer wraps on the X axis or not. + /// @return Whether this SceneLayer wraps on the X axis or not. bool WrapsX() const { return m_WrapX; } - /// /// Indicates whether the layer is set to wrap around the Y axis when scrolled out of bounds. - /// - /// Whether this SceneLayer wraps on the Y axis or not. + /// @return Whether this SceneLayer wraps on the Y axis or not. bool WrapsY() const { return m_WrapY; } - /// /// Gets a specific pixel from the bitmap of this SceneLayer. LockBitmaps() must be called before using this method. - /// - /// The X coordinate of the pixel to get. - /// The Y coordinate of the pixel to get. - /// An int specifying the requested pixel's color index. + /// @param pixelX The X coordinate of the pixel to get. + /// @param pixelY The Y coordinate of the pixel to get. + /// @return An int specifying the requested pixel's color index. int GetPixel(int pixelX, int pixelY) const; - /// /// Sets a specific pixel on the bitmap of this SceneLayer to a specific value. LockBitmaps() must be called before using this method. - /// - /// The X coordinate of the pixel to set. - /// The Y coordinate of the pixel to set. - /// The color index to set the pixel to. + /// @param pixelX The X coordinate of the pixel to set. + /// @param pixelY The Y coordinate of the pixel to set. + /// @param materialID The color index to set the pixel to. void SetPixel(int pixelX, int pixelY, int materialID); - /// /// Returns whether the integer coordinates passed in are within the bounds of this SceneLayer. - /// - /// The X coordinates of the pixel. - /// The Y coordinates of the pixel. - /// - /// Whether within bounds or not. + /// @param pixelX The X coordinates of the pixel. + /// @param pixelY The Y coordinates of the pixel. + /// @param margin + /// @return Whether within bounds or not. bool IsWithinBounds(int pixelX, int pixelY, int margin = 0) const; #pragma endregion #pragma region Concrete Methods - /// /// Lock the internal bitmap so it can be accessed by GetPixel() etc. UnlockBitmaps() should always be called after accesses are completed. /// Doing it in a separate method like this is more efficient because many bitmap accesses can be performed between a lock and unlock. - /// void LockBitmaps() { /*acquire_bitmap(m_MainBitmap);*/ } - /// /// Unlocks the internal bitmaps and prevents access to display memory. UnlockBitmaps() should only be called after LockBitmaps(). /// Doing it in a separate method like this is more efficient because many bitmap accesses can be performed between a lock and an unlock. - /// void UnlockBitmaps() { /*release_bitmap(m_MainBitmap);*/ } - /// /// Clears our BITMAP. - /// - /// What color to clear the bitmap to. + /// @param clearTo What color to clear the bitmap to. void ClearBitmap(ColorKeys clearTo); - /// /// Wraps the given position coordinate if it is out of bounds of this SceneLayer and wrapping is enabled on the appropriate axes. /// Does not force the position coordinate within bounds if wrapping is not enabled. - /// - /// The X coordinates of the position to wrap. - /// The Y coordinates of the position to wrap. - /// Whether wrapping was performed or not. + /// @param posX The X coordinates of the position to wrap. + /// @param posY The Y coordinates of the position to wrap. + /// @return Whether wrapping was performed or not. bool WrapPosition(int& posX, int& posY) const; - /// /// Wraps the given position Vector if it is out of bounds of this SceneLayer and wrapping is enabled on the appropriate axes. /// Does not force the position Vector within bounds if wrapping is not enabled. - /// - /// The vector coordinates of the position to wrap. - /// Whether wrapping was performed or not. + /// @param pos The vector coordinates of the position to wrap. + /// @return Whether wrapping was performed or not. bool WrapPosition(Vector& pos) const { return ForceBoundsOrWrapPosition(pos, false); } - /// /// Wraps or bounds a position coordinate if it is out of bounds of the SceneLayer, depending on the wrap settings of this SceneLayer. - /// - /// The X coordinates of the position to wrap. - /// The Y coordinates of the position to wrap. - /// Whether wrapping was performed or not. Does not report on bounding. + /// @param posX The X coordinates of the position to wrap. + /// @param posY The Y coordinates of the position to wrap. + /// @return Whether wrapping was performed or not. Does not report on bounding. bool ForceBounds(int& posX, int& posY) const; - /// /// Wraps or bounds a position coordinate if it is out of bounds of the SceneLayer, depending on the wrap settings of this SceneLayer. - /// - /// The Vector coordinates of the position to wrap. - /// Whether wrapping was performed or not. Does not report on bounding. + /// @param pos The Vector coordinates of the position to wrap. + /// @return Whether wrapping was performed or not. Does not report on bounding. bool ForceBounds(Vector& pos) const { return ForceBoundsOrWrapPosition(pos, true); } #pragma endregion #pragma region Drawing Tracking - /// /// Registers an area of the SceneLayer to be drawn upon. These areas will be cleared when ClearBitmap is called. - /// - /// The position of the left side of the area to be drawn upon. - /// The position of the top of the area to be drawn upon. - /// The position of the right side of the area to be drawn upon. - /// + /// @param left The position of the left side of the area to be drawn upon. + /// @param top The position of the top of the area to be drawn upon. + /// @param right The position of the right side of the area to be drawn upon. + /// @param bottom"The position of the bottom of the area to be drawn upon void RegisterDrawing(int left, int top, int right, int bottom); - /// /// Registers an area of the SceneLayer to be drawn upon. These areas will be cleared when ClearBitmap is called. - /// - /// The position of the center of the area to be drawn upon. - /// The radius of the area to be drawn upon. + /// @param center The position of the center of the area to be drawn upon. + /// @param radius The radius of the area to be drawn upon. void RegisterDrawing(const Vector& center, float radius); #pragma endregion #pragma region Virtual Methods - /// /// Updates the state of this SceneLayer. - /// virtual void Update() {} - /// /// Draws this SceneLayer's current scrolled position to a bitmap. - /// - /// The bitmap to draw to. - /// The box on the target bitmap to limit drawing to, with the corner of box being where the scroll position lines up. - /// Whether the offset of this SceneLayer or the passed in offset override need to be adjusted to scroll ratio. + /// @param targetBitmap The bitmap to draw to. + /// @param targetBox The box on the target bitmap to limit drawing to, with the corner of box being where the scroll position lines up. + /// @param offsetNeedsScrollRatioAdjustment Whether the offset of this SceneLayer or the passed in offset override need to be adjusted to scroll ratio. virtual void Draw(BITMAP* targetBitmap, Box& targetBox, bool offsetNeedsScrollRatioAdjustment = false); #pragma endregion @@ -300,49 +230,37 @@ namespace RTE { Vector m_ScaleFactor; //!< The scaling factor of this SceneLayer. Used for scaled drawing and adjusting scrolling ratios. Vector m_ScaledDimensions; //!< The dimensions of this SceneLayer adjusted to the scaling factor. - /// /// Initialize the scroll ratios from the scroll info. Must be done after the bitmap has been created. - /// - /// - /// + /// @param initForNetworkPlayer + /// @param player void InitScrollRatios(bool initForNetworkPlayer = false, int player = Players::NoPlayer); - /// /// Wraps or bounds a position coordinate if it is out of bounds of the SceneLayer, depending on the wrap settings of this SceneLayer. - /// - /// The Vector coordinates of the position to wrap. - /// Whether to attempt bounding or wrapping, or just wrapping. - /// Whether wrapping was performed or not. Does not report on bounding. + /// @param pos The Vector coordinates of the position to wrap. + /// @param forceBounds Whether to attempt bounding or wrapping, or just wrapping. + /// @return Whether wrapping was performed or not. Does not report on bounding. bool ForceBoundsOrWrapPosition(Vector& pos, bool forceBounds) const; #pragma region Draw Breakdown - /// /// Performs wrapped drawing of this SceneLayer's bitmap to the screen in cases where it is both wider and taller than the target bitmap. - /// - /// The bitmap to draw to. - /// The box on the target bitmap to limit drawing to, with the corner of box being where the scroll position lines up. - /// Whether to use scaled drawing routines or not. + /// @param targetBitmap The bitmap to draw to. + /// @param targetBox The box on the target bitmap to limit drawing to, with the corner of box being where the scroll position lines up. + /// @param drawScaled Whether to use scaled drawing routines or not. void DrawWrapped(BITMAP* targetBitmap, const Box& targetBox, bool drawScaled) const; - /// /// Performs tiled drawing of this SceneLayer's bitmap to the screen in cases where the target bitmap is larger in some dimension. - /// - /// The bitmap to draw to. - /// The box on the target bitmap to limit drawing to, with the corner of box being where the scroll position lines up. - /// Whether to use scaled drawing routines or not. + /// @param targetBitmap The bitmap to draw to. + /// @param targetBox The box on the target bitmap to limit drawing to, with the corner of box being where the scroll position lines up. + /// @param drawScaled Whether to use scaled drawing routines or not. void DrawTiled(BITMAP* targetBitmap, const Box& targetBox, bool drawScaled) const; #pragma endregion private: - /// /// Clears any tracked and drawn-to areas. - /// - /// Color to clear to. + /// @param clearTo Color to clear to. void ClearDrawings(BITMAP* bitmap, const std::vector& drawings, ColorKeys clearTo) const; - /// /// Clears all the member variables of this SceneLayer, effectively resetting the members of this abstraction level only. - /// void Clear(); // Disallow the use of some implicit methods. @@ -350,27 +268,21 @@ namespace RTE { void operator=(const SceneLayerImpl& rhs) = delete; }; - /// /// If we track drawings, then disallow getting non-const access to the underlying bitmap - we must draw through special functions on SceneLayer that'll track the drawings. - /// class SceneLayerTracked : public SceneLayerImpl { public: EntityAllocation(SceneLayerTracked); ClassInfoGetters; - /// /// Constructor method used to instantiate a SceneLayerTracked object in system memory. Create() should be called before using the object. - /// SceneLayerTracked() : SceneLayerImpl() {} // TODO: We shouldn't let external users access a non-const version of our bitmap. We should do all drawing to it internally, and track registering our MOID drawings internally too. // However, in the interest of time (and my own sanity), given that the old code already does this, we're not doing that yet. - /// /// Gets the BITMAP that this SceneLayer uses. - /// - /// A pointer to the BITMAP of this SceneLayer. Ownership is NOT transferred! + /// @return A pointer to the BITMAP of this SceneLayer. Ownership is NOT transferred! BITMAP* GetBitmap() const { return m_MainBitmap; } protected: @@ -383,16 +295,12 @@ namespace RTE { EntityAllocation(SceneLayer); ClassInfoGetters; - /// /// Constructor method used to instantiate a SceneLayer object in system memory. Create() should be called before using the object. - /// SceneLayer() : SceneLayerImpl() {} - /// /// Gets the BITMAP that this SceneLayer uses. - /// - /// A pointer to the BITMAP of this SceneLayer. Ownership is NOT transferred! + /// @return A pointer to the BITMAP of this SceneLayer. Ownership is NOT transferred! BITMAP* GetBitmap() const { return m_MainBitmap; } protected: diff --git a/Source/Entities/SceneObject.cpp b/Source/Entities/SceneObject.cpp index dbcb50ed8e..10a34b66cb 100644 --- a/Source/Entities/SceneObject.cpp +++ b/Source/Entities/SceneObject.cpp @@ -1,15 +1,3 @@ -////////////////////////////////////////////////////////////////////////////////////////// -// File: SceneObject.cpp -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Source file for the SceneObject class. -// Project: Retro Terrain Engine -// Author(s): Daniel Tabar -// data@datarealms.com -// http://www.datarealms.com - -////////////////////////////////////////////////////////////////////////////////////////// -// Inclusions of header files - #include "SceneObject.h" #include "PresetMan.h" #include "Matrix.h" @@ -21,12 +9,6 @@ namespace RTE { AbstractClassInfo(SceneObject, Entity); const std::string SceneObject::SOPlacer::c_ClassName = "SOPlacer"; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Clear - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears all the member variables of this SOPlacer, effectively - // resetting the members of this abstraction level only. - void SceneObject::SOPlacer::Clear() { m_pObjectReference = 0; m_Offset.Reset(); @@ -50,11 +32,6 @@ namespace RTE { } */ - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Creates a SOPlacer to be identical to another, by deep copy. - int SceneObject::SOPlacer::Create(const SOPlacer& reference) { m_pObjectReference = reference.m_pObjectReference; m_Offset = reference.m_Offset; @@ -65,14 +42,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: ReadProperty - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Reads a property value from a reader stream. If the name isn't - // recognized by this class, then ReadProperty of the parent class - // is called. If the property isn't recognized by any of the base classes, - // false is returned, and the reader's position is untouched. - int SceneObject::SOPlacer::ReadProperty(const std::string_view& propName, Reader& reader) { StartPropertyList(return Serializable::ReadProperty(propName, reader)); @@ -94,12 +63,6 @@ namespace RTE { EndPropertyList; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Save - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Saves the complete state of this SOPlacer with a Writer for - // later recreation with Create(Reader &reader); - int SceneObject::SOPlacer::Save(Writer& writer) const { Serializable::Save(writer); @@ -126,12 +89,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetPlacedCopy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes a copy of the preset instance, and applies the placement - // properties of this to it, finally returning it WITH OWNERSHIP. - SceneObject* SceneObject::SOPlacer::GetPlacedCopy(const SceneObject* pParent) const { RTEAssert(m_pObjectReference, "No Object reference to make copy from!"); @@ -169,12 +126,6 @@ namespace RTE { return pCopy; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Clear - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears all the member variables of this SceneObject, effectively - // resetting the members of this abstraction level only. - void SceneObject::Clear() { m_Pos.Reset(); m_OzValue = 0; @@ -211,11 +162,6 @@ namespace RTE { } */ - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Creates an SceneObject object to be identical to another, by deep copy. - int SceneObject::Create(const SceneObject& reference) { Entity::Create(reference); @@ -229,14 +175,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: ReadProperty - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Reads a property value from a Reader stream. If the name isn't - // recognized by this class, then ReadProperty of the parent class - // is called. If the property isn't recognized by any of the base classes, - // false is returned, and the Reader's position is untouched. - int SceneObject::ReadProperty(const std::string_view& propName, Reader& reader) { StartPropertyList(return Entity::ReadProperty(propName, reader)); @@ -257,12 +195,6 @@ namespace RTE { EndPropertyList; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Save - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Saves the complete state of this SceneObject to an output stream for - // later recreation with Create(istream &stream); - int SceneObject::Save(Writer& writer) const { Entity::Save(writer); // TODO: Make proper save system that knows not to save redundant data! @@ -283,11 +215,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destroys and resets (through Clear()) the SceneObject object. - void SceneObject::Destroy(bool notInherited) { if (!notInherited) @@ -295,22 +222,11 @@ namespace RTE { Clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetGoldValue - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the cost to purchase this item, in oz's of gold. - float SceneObject::GetGoldValue(int nativeModule, float foreignMult, float nativeMult) const { // Multiply the value of this according to whether its Tech is native or not to the specified DataModule return m_OzValue * ((m_DefinedInModule > 0 && nativeModule > 0 && m_DefinedInModule != nativeModule) ? foreignMult : nativeMult); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetGoldValueString - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets a descriptive string describing the cost to purchase this item, - // in oz's of gold. - std::string SceneObject::GetGoldValueString(int nativeModule, float foreignMult, float nativeMult) const { float subjValue = GetGoldValue(nativeModule, foreignMult, nativeMult); @@ -324,10 +240,6 @@ namespace RTE { return returnString; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: DrawTeamMark - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws team sign this terrain object belongs to. void SceneObject::DrawTeamMark(BITMAP* pTargetBitmap, const Vector& targetPos) const { // Only do HUD if on a team if (m_Team < 0) diff --git a/Source/Entities/SceneObject.h b/Source/Entities/SceneObject.h index 1ee5a2ae86..5503e53b0e 100644 --- a/Source/Entities/SceneObject.h +++ b/Source/Entities/SceneObject.h @@ -1,18 +1,11 @@ #ifndef _RTESCENEOBJECT_ #define _RTESCENEOBJECT_ -////////////////////////////////////////////////////////////////////////////////////////// -// File: SceneObject.h -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Header file for the SceneObject class. -// Project: Retro Terrain Engine -// Author(s): Daniel Tabar -// data@datarealms.com -// http://www.datarealms.com - -////////////////////////////////////////////////////////////////////////////////////////// -// Inclusions of header files, forward declarations, namespace stuff - +/// Header file for the SceneObject class. +/// @author Daniel Tabar +/// data@datarealms.com +/// http://www.datarealms.com +/// Inclusions of header files, forward declarations, namespace stuff #include "Entity.h" #include "Matrix.h" @@ -20,26 +13,16 @@ struct BITMAP; namespace RTE { - ////////////////////////////////////////////////////////////////////////////////////////// - // Abstract class: SceneObject - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: The base class shared by Both TerrainObject:s and MovableObject:s, ie - // anything that can be places in a scene. - // Parent(s): Entity. - // Class history: 8/6/2007 SceneObject created. - + /// The base class shared by Both TerrainObject:s and MovableObject:s, ie + /// anything that can be places in a scene. class SceneObject : public Entity { - ////////////////////////////////////////////////////////////////////////////////////////// - // Public member variable, method and friend function declarations - + /// Public member variable, method and friend function declarations public: SerializableOverrideMethods; ClassInfoGetters; - /// /// Enumeration for the different buyable modes of this SceneObject. - /// enum class BuyableMode { NoRestrictions, BuyMenuOnly, @@ -47,132 +30,68 @@ namespace RTE { ScriptOnly }; - ////////////////////////////////////////////////////////////////////////////////////////// - // Nested class: SOPlacer - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Acts as a small memory object that only holds a pointer to a reference - // instance and the most essential properties to eventually place a copy - // of that reference when needed. - // Parent(s): Serializable. - // Class history: 11/25/2007 SOPlacer created. - + /// Acts as a small memory object that only holds a pointer to a reference + /// instance and the most essential properties to eventually place a copy + /// of that reference when needed. class SOPlacer : public Serializable { - ////////////////////////////////////////////////////////////////////////////////////////// - // Public member variable, method and friend function declarations - + /// Public member variable, method and friend function declarations public: SerializableClassNameGetter; SerializableOverrideMethods; - ////////////////////////////////////////////////////////////////////////////////////////// - // Constructor: SOPlacer - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Constructor method used to instantiate a SOPlacer object in system - // memory. Create() should be called before using the object. - // Arguments: None. - + /// Constructor method used to instantiate a SOPlacer object in system + /// memory. Create() should be called before using the object. SOPlacer() { Clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Creates a SOPlacer to be identical to another, by deep copy. - // Arguments: A reference to the SOPlacer to deep copy. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Creates a SOPlacer to be identical to another, by deep copy. + /// @param reference A reference to the SOPlacer to deep copy. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Create(const SOPlacer& reference); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Reset - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Resets the entire Serializable, including its inherited members, to their - // default settings or values. - // Arguments: None. - // Return value: None. - + /// Resets the entire Serializable, including its inherited members, to their + /// default settings or values. void Reset() override { Clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: GetObjectReference - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the object reference to be placed. Owenership is NOT transferred! - // Arguments: None. - // Return value: A pointer to the reference object to be copied and placed. Not transferred! - + /// Gets the object reference to be placed. Owenership is NOT transferred! + /// @return A pointer to the reference object to be copied and placed. Not transferred! const SceneObject* GetObjectReference() { return m_pObjectReference; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetOffset - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the place offset from the parent's position/origin. If in a scene - // this will yield the absolute scene coordinates. - // Arguments: None. - // Return value: The offset in pixels from the parent's position where this gets spawned. - + /// Gets the place offset from the parent's position/origin. If in a scene + /// this will yield the absolute scene coordinates. + /// @return The offset in pixels from the parent's position where this gets spawned. Vector GetOffset() const { return m_Offset; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetOffset - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the place offset from the parent's position/origin. - // Arguments: New offset. - // Return value: None. - + /// Sets the place offset from the parent's position/origin. + /// @param newOffset New offset. void SetOffset(Vector newOffset) { m_Offset = newOffset; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetRotation - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the rotation angle of the object to be placed, in radians. - // Arguments: None. - // Return value: The placement rotational angle, in radians. - + /// Gets the rotation angle of the object to be placed, in radians. + /// @return The placement rotational angle, in radians. float GetRotation() const { return m_RotAngle; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetHFlipped - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets whether the placement is horizontally flipped or not. - // Arguments: None. - // Return value: The horizontal flipping of the placement. - + /// Gets whether the placement is horizontally flipped or not. + /// @return The horizontal flipping of the placement. bool GetHFlipped() const { return m_HFlipped; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetTeam - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets which team this is to be assigned to when placed. - // Arguments: None. - // Return value: The team number this is to be assigned to when placed. - + /// Gets which team this is to be assigned to when placed. + /// @return The team number this is to be assigned to when placed. int GetTeam() const { return m_Team; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetTeam - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets which team this is to be assigned to when placed. - // Arguments: The team number this is to be assigned to when placed. - // Return value: None. - + /// Sets which team this is to be assigned to when placed. + /// @param team The team number this is to be assigned to when placed. void SetTeam(int team) { m_Team = team; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetPlacedCopy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes a copy of the preset instance, and applies the placement - // properties of this to it, finally returning it WITH OWNERSHIP. - // Arguments: The parent to place as offset from. If 0 is passed, the placement - // properties will be applied as absolutes instead of relative. - // Return value: The new copy with correct placement applied. OWNERSHIP IS TRANSFERRED! - + /// Makes a copy of the preset instance, and applies the placement + /// properties of this to it, finally returning it WITH OWNERSHIP. + /// @param pParent The parent to place as offset from. If 0 is passed, the placement (default: 0) + /// properties will be applied as absolutes instead of relative. + /// @return The new copy with correct placement applied. OWNERSHIP IS TRANSFERRED! SceneObject* GetPlacedCopy(const SceneObject* pParent = 0) const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Protected member variable and method declarations - + /// Protected member variable and method declarations protected: // The pointer to the preset instance, that copies of which will be placed. Not Owned! const SceneObject* m_pObjectReference; @@ -185,345 +104,181 @@ namespace RTE { // The team of the placed object int m_Team; - ////////////////////////////////////////////////////////////////////////////////////////// - // Private member variable and method declarations - + /// Private member variable and method declarations private: static const std::string c_ClassName; //!< A string with the friendly-formatted type name of this object. - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Clear - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears all the member variables of this SOPlacer, effectively - // resetting the members of this abstraction level only. - // Arguments: None. - // Return value: None. - + /// Clears all the member variables of this SOPlacer, effectively + /// resetting the members of this abstraction level only. void Clear(); }; - ////////////////////////////////////////////////////////////////////////////////////////// - // Constructor: SceneObject - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Constructor method used to instantiate a SceneObject object in system - // memory. Create() should be called before using the object. - // Arguments: None. - + /// Constructor method used to instantiate a SceneObject object in system + /// memory. Create() should be called before using the object. SceneObject() { Clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Destructor: ~SceneObject - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destructor method used to clean up a SceneObject object before deletion - // from system memory. - // Arguments: None. - + /// Destructor method used to clean up a SceneObject object before deletion + /// from system memory. ~SceneObject() override { Destroy(true); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes the SceneObject object ready for use. - // Arguments: None. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Makes the SceneObject object ready for use. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Create() override { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Creates an SceneObject to be identical to another, by deep copy. - // Arguments: A reference to the SceneObject to deep copy. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Creates an SceneObject to be identical to another, by deep copy. + /// @param reference A reference to the SceneObject to deep copy. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Create(const SceneObject& reference); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Reset - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Resets the entire SceneObject, including its inherited members, to their - // default settings or values. - // Arguments: None. - // Return value: None. - + /// Resets the entire SceneObject, including its inherited members, to their + /// default settings or values. void Reset() override { Clear(); Entity::Reset(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Pure V. method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destroys and resets (through Clear()) the SceneObject object. - // Arguments: Whether to only destroy the members defined in this derived class, or - // to destroy all inherited members also. - // Return value: None. - + /// Destroys and resets (through Clear()) the SceneObject object. + /// @param notInherited Whether to only destroy the members defined in this derived class, or (default: false) + /// to destroy all inherited members also. void Destroy(bool notInherited = false) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: GetPos - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the absolute position of this SceneObject. - // Arguments: None. - // Return value: A Vector describing the current absolute position in pixels. - + /// Gets the absolute position of this SceneObject. + /// @return A Vector describing the current absolute position in pixels. const Vector& GetPos() const { return m_Pos; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: SetPos - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the absolute position of this SceneObject in the scene. - // Arguments: A Vector describing the current absolute position in pixels. - // Return value: None. - + /// Sets the absolute position of this SceneObject in the scene. + /// @param newPos A Vector describing the current absolute position in pixels. void SetPos(const Vector& newPos) { m_Pos = newPos; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: IsHFlipped - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns whether this is being drawn flipped horizontally (around the - // vertical axis), or not. - // Arguments: None. - // Return value: Whether flipped or not. - + /// Returns whether this is being drawn flipped horizontally (around the + /// vertical axis), or not. + /// @return Whether flipped or not. virtual bool IsHFlipped() const { return false; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: GetRotMatrix - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the current rotational Matrix of of this MovableObject. - // Arguments: None. - // Return value: The rotational Matrix of this MovableObject. - + /// Gets the current rotational Matrix of of this MovableObject. + /// @return The rotational Matrix of this MovableObject. virtual Matrix GetRotMatrix() const { return Matrix(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: GetRotAngle - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the current rotational angle of of this, in radians. - // Arguments: None. - // Return value: The rotational angle of this, in radians. - + /// Gets the current rotational angle of of this, in radians. + /// @return The rotational angle of this, in radians. virtual float GetRotAngle() const { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virutal method: SetHFlipped - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets whether this should be drawn flipped horizontally (around the - // vertical axis). - // Arguments: A bool with the new value. - // Return value: None. - + /// Sets whether this should be drawn flipped horizontally (around the + /// vertical axis). + /// @param flipped A bool with the new value. virtual void SetHFlipped(const bool flipped) {} - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: SetRotAngle - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the current absolute angle of rotation of this. - // Arguments: The new absolute angle in radians. - // Return value: None. - + /// Sets the current absolute angle of rotation of this. + /// @param newAngle The new absolute angle in radians. virtual void SetRotAngle(float newAngle) {} - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: SetTeam - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets which team this belongs to. - // Arguments: The assigned team number. - // Return value: None. - + /// Sets which team this belongs to. + /// @param team The assigned team number. virtual void SetTeam(int team) { m_Team = team; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: GetTeam - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets which team this belongs to. - // Arguments: None. - // Return value: The currently assigned team number. - + /// Gets which team this belongs to. + /// @return The currently assigned team number. int GetTeam() const { return m_Team; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: SetPlacedByPlayer - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets which player placed this object in the scene, if any. - // Arguments: The player responsible for placing this is in the scene, if any. - // Return value: None. - + /// Sets which player placed this object in the scene, if any. + /// @param player The player responsible for placing this is in the scene, if any. void SetPlacedByPlayer(int player) { m_PlacedByPlayer = player; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: GetPlacedByPlayer - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets which player placed this object in the scene, if any. - // Arguments: None. - // Return value: The player responsible for placing this is in the scene, if any. - + /// Gets which player placed this object in the scene, if any. + /// @return The player responsible for placing this is in the scene, if any. int GetPlacedByPlayer() const { return m_PlacedByPlayer; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetGoldValue - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the cost to purchase this item, in oz's of gold. - // Arguments: If this is supposed to be adjusted for a specific Tech's subjective - // value, then pass in the native DataModule ID of that tech. 0 means - // no Tech is specified and the base value is returned. - // How much to multiply the value if this happens to be a foreign Tech. - // How much to multiply the value if this happens to be a native Tech. - // Return value: The cost, in oz of gold. - + /// Gets the cost to purchase this item, in oz's of gold. + /// @param nativeModule If this is supposed to be adjusted for a specific Tech's subjective (default: 0) + /// value, then pass in the native DataModule ID of that tech. 0 means + /// no Tech is specified and the base value is returned. + /// @param foreignMult How much to multiply the value if this happens to be a foreign Tech. (default: 1.0) + /// @param nativeMult How much to multiply the value if this happens to be a native Tech. (default: 1.0) + /// @return The cost, in oz of gold. virtual float GetGoldValue(int nativeModule = 0, float foreignMult = 1.0, float nativeMult = 1.0) const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetGoldValue - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the cost to purchase this item, in oz's of gold. - // Arguments: The cost, in oz of gold. - // Return value: None. - + /// Sets the cost to purchase this item, in oz's of gold. + /// @param value The cost, in oz of gold. void SetGoldValue(float value) { m_OzValue = value; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetGoldValueOld - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: DOES THE SAME THING AS GetGoldValue, USED ONLY TO PRESERVE LUA COMPATIBILITY - + /// DOES THE SAME THING AS GetGoldValue, USED ONLY TO PRESERVE LUA COMPATIBILITY virtual float GetGoldValueOld(int nativeModule, float foreignMult) const { return GetGoldValue(nativeModule, foreignMult, 1.0); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetGoldValueString - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets a descriptive string describing the cost to purchase this item, - // in oz's of gold. - // Arguments: If this is supposed to be adjusted for a specific Tech's subjective - // value, then pass in the native DataModule ID of that tech. 0 means - // no Tech is specified and the base value is returned. - // How much to multiply the value if this happens to be a foreign Tech. - // Return value: The cost, described in a friendly to read string: "100oz", or "Free" - + /// Gets a descriptive string describing the cost to purchase this item, + /// in oz's of gold. + /// @param nativeModule If this is supposed to be adjusted for a specific Tech's subjective (default: 0) + /// value, then pass in the native DataModule ID of that tech. 0 means + /// no Tech is specified and the base value is returned. + /// @param foreignMult How much to multiply the value if this happens to be a foreign Tech. (default: 1.0) + /// @return The cost, described in a friendly to read string: "100oz", or "Free" std::string GetGoldValueString(int nativeModule = 0, float foreignMult = 1.0, float nativeMult = 1.0) const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetTotalValue - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the total liquidation value of this, including everything inside. - // Arguments: If this is supposed to be adjusted for a specific Tech's subjective - // value, then pass in the native DataModule ID of that tech. 0 means - // no Tech is specified and the base value is returned. - // How much to multiply the value if this happens to be a foreign Tech. - // Return value: The current value of this and all contained assets. - + /// Gets the total liquidation value of this, including everything inside. + /// @param nativeModule If this is supposed to be adjusted for a specific Tech's subjective (default: 0) + /// value, then pass in the native DataModule ID of that tech. 0 means + /// no Tech is specified and the base value is returned. + /// @param foreignMult How much to multiply the value if this happens to be a foreign Tech. (default: 1.0) + /// @return The current value of this and all contained assets. virtual float GetTotalValue(int nativeModule = 0, float foreignMult = 1.0, float nativeMult = 1.0) const { return GetGoldValue(nativeModule, foreignMult, nativeMult); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: IsBuyable - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Shows whether this should appear in teh buy menus at all. - // Arguments: None. - // Return value: Buyable or not. - + /// Shows whether this should appear in teh buy menus at all. + /// @return Buyable or not. bool IsBuyable() const { return m_Buyable; } - /// /// Gets the BuyableMode of this SceneObject. - /// - /// The BuyableMode of this SceneObject + /// @return The BuyableMode of this SceneObject BuyableMode GetBuyableMode() const { return m_BuyableMode; } - /// /// Gets whether this SceneObject is available only in the BuyMenu list when buyable. - /// - /// Whether this SceneObject is available only in the BuyMenu list when buyable. + /// @return Whether this SceneObject is available only in the BuyMenu list when buyable. bool IsBuyableInBuyMenuOnly() const { return m_BuyableMode == BuyableMode::BuyMenuOnly; } - /// /// Gets whether this SceneObject is available only in the ObjectPicker list when buyable. - /// - /// Whether this SceneObject is available only in the ObjectPicker list when buyable. + /// @return Whether this SceneObject is available only in the ObjectPicker list when buyable. bool IsBuyableInObjectPickerOnly() const { return m_BuyableMode == BuyableMode::ObjectPickerOnly; } - /// /// Gets whether this SceneObject is available only by lua functions like CreateRandom - /// - /// Whether this SceneObject is available only in the AI list when buyable. + /// @return Whether this SceneObject is available only in the AI list when buyable. bool IsBuyableInScriptOnly() const { return m_BuyableMode == BuyableMode::ScriptOnly; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetGraphicalIcon - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets a bitmap showing a good identifyable icon of this, for use in - // GUI lists etc. - // Arguments: None. - // Return value: A good identifyable graphical representation of this in a BITMAP, if - // available. If not, 0 is returned. Ownership is NOT TRANSFERRED! - + /// Gets a bitmap showing a good identifyable icon of this, for use in + /// GUI lists etc. + /// @return A good identifyable graphical representation of this in a BITMAP, if + /// available. If not, 0 is returned. Ownership is NOT TRANSFERRED! virtual BITMAP* GetGraphicalIcon() const { return nullptr; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: IsOnScenePoint - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Indicates whether this' current graphical representation overlaps - // a point in absolute scene coordinates. - // Arguments: The point in absolute scene coordinates. - // Return value: Whether this' graphical rep overlaps the scene point. - + /// Indicates whether this' current graphical representation overlaps + /// a point in absolute scene coordinates. + /// @param scenePoint The point in absolute scene coordinates. + /// @return Whether this' graphical rep overlaps the scene point. virtual bool IsOnScenePoint(Vector& scenePoint) const { return false; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Update - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates this SceneObject. Supposed to be done every frame. - // Arguments: None. - // Return value: None. - + /// Updates this SceneObject. Supposed to be done every frame. virtual void Update() {} - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: FullUpdate - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the full state of this object in one call. - // Arguments: None. - // Return value: None. + /// Updates the full state of this object in one call. virtual void FullUpdate() { Update(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: PostUpdate - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Function called after everything has finished updating. - // Arguments: None. - // Return value: None. + /// Function called after everything has finished updating. virtual void PostUpdate(){}; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Draw - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws this SceneObject's current graphical representation to a BITMAP of - // choice. - // Arguments: A pointer to a BITMAP to draw on. - // The absolute position of the target bitmap's upper left corner in the Scene. - // In which mode to draw in. See the DrawMode enumeration for the modes. - // Whether to not draw any extra 'ghost' items of this MovableObject, - // like indicator arrows or hovering HUD text and so on. - // Return value: None. - + /// Draws this SceneObject's current graphical representation to a BITMAP of + /// choice. + /// @param pTargetBitmap A pointer to a BITMAP to draw on. + /// @param targetPos The absolute position of the target bitmap's upper left corner in the Scene. (default: Vector()) + /// @param mode In which mode to draw in. See the DrawMode enumeration for the modes. (default: g_DrawColor) + /// @param onlyPhysical Whether to not draw any extra 'ghost' items of this MovableObject, (default: false) + /// like indicator arrows or hovering HUD text and so on. virtual void Draw(BITMAP* pTargetBitmap, const Vector& targetPos = Vector(), DrawMode mode = g_DrawColor, bool onlyPhysical = false) const = 0; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: DrawTeamMark - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws team sign this terrain object belongs to. - // Arguments: A pointer to a BITMAP to draw on. - // The absolute position of the target bitmap's upper left corner in the Scene. - // Return value: None. - + /// Draws team sign this terrain object belongs to. + /// @param pTargetBitmap A pointer to a BITMAP to draw on. + /// @param targetPos The absolute position of the target bitmap's upper left corner in the Scene. (default: Vector()) void DrawTeamMark(BITMAP* pTargetBitmap, const Vector& targetPos = Vector()) const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Protected member variable and method declarations - + /// Protected member variable and method declarations protected: // Forbidding copying SceneObject(const SceneObject& reference) = delete; @@ -545,18 +300,10 @@ namespace RTE { // The player this was placed by in edit mode int m_PlacedByPlayer; - ////////////////////////////////////////////////////////////////////////////////////////// - // Private member variable and method declarations - + /// Private member variable and method declarations private: - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Clear - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears all the member variables of this SceneObject, effectively - // resetting the members of this abstraction level only. - // Arguments: None. - // Return value: None. - + /// Clears all the member variables of this SceneObject, effectively + /// resetting the members of this abstraction level only. void Clear(); }; diff --git a/Source/Entities/SoundContainer.cpp b/Source/Entities/SoundContainer.cpp index f71b53dcb8..3d2f5c456c 100644 --- a/Source/Entities/SoundContainer.cpp +++ b/Source/Entities/SoundContainer.cpp @@ -15,8 +15,6 @@ namespace RTE { {"UI", SoundContainer::BusRouting::UI}, {"Music", SoundContainer::BusRouting::MUSIC}}; - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SoundContainer::Clear() { m_TopLevelSoundSet.Destroy(); @@ -40,8 +38,6 @@ namespace RTE { m_PitchVariation = 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int SoundContainer::Create(const SoundContainer& reference) { Entity::Create(reference); @@ -68,8 +64,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int SoundContainer::ReadProperty(const std::string_view& propName, Reader& reader) { StartPropertyList(return Entity::ReadProperty(propName, reader)); @@ -130,8 +124,6 @@ namespace RTE { EndPropertyList; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int SoundContainer::Save(Writer& writer) const { Entity::Save(writer); @@ -178,8 +170,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - float SoundContainer::GetLength(LengthOfSoundType type) const { if (!m_SoundPropertiesUpToDate) { // Todo - use a post-load fixup stage instead of lazily initializing shit everywhere... Eugh. @@ -200,8 +190,6 @@ namespace RTE { return lengthMilliseconds; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - std::vector SoundContainer::GetSelectedSoundHashes() const { std::vector soundHashes; std::vector flattenedSoundData; @@ -212,8 +200,6 @@ namespace RTE { return soundHashes; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - const SoundSet::SoundData* SoundContainer::GetSoundDataForSound(const FMOD::Sound* sound) const { std::vector flattenedSoundData; m_TopLevelSoundSet.GetFlattenedSoundData(flattenedSoundData, false); @@ -225,8 +211,6 @@ namespace RTE { return nullptr; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool SoundContainer::Play(int player) { if (HasAnySounds()) { if (IsBeingPlayed()) { @@ -241,8 +225,6 @@ namespace RTE { return false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - FMOD_RESULT SoundContainer::UpdateSoundProperties() { FMOD_RESULT result = FMOD_OK; diff --git a/Source/Entities/SoundContainer.h b/Source/Entities/SoundContainer.h index 73322533e5..753d3a36da 100644 --- a/Source/Entities/SoundContainer.h +++ b/Source/Entities/SoundContainer.h @@ -8,9 +8,7 @@ namespace RTE { class Vector; - /// /// A container for sounds that represent a specific sound effect. - /// class SoundContainer : public Entity { public: @@ -18,18 +16,14 @@ namespace RTE { SerializableOverrideMethods; ClassInfoGetters; - /// /// The FMOD channelgroup/bus this sound routes through. - /// enum BusRouting { SFX = 0, // Default diegetic bus for general game SFX. UI = 1, // Menu sounds and other things that shouldn't be affected by diegetic sound processing. MUSIC = 2 // Self-explanatory music bus. }; - /// /// How the SoundContainer should behave when it tries to play again while already playing. - /// enum SoundOverlapMode { OVERLAP = 0, RESTART = 1, @@ -37,35 +31,27 @@ namespace RTE { }; #pragma region Creation - /// /// Constructor method used to instantiate a SoundContainer object in system memory. Create() should be called before using the object. - /// SoundContainer() { Clear(); } - /// /// Copy constructor method used to instantiate a SoundContainer object identical to an already existing one. - /// - /// A reference to the SoundContainer to deep copy. + /// @param reference A reference to the SoundContainer to deep copy. SoundContainer(const SoundContainer& reference) { Clear(); Create(reference); } - /// /// Creates a SoundContainer to be identical to another, by deep copy. - /// - /// A reference to the SoundContainer to deep copy. - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @param reference A reference to the SoundContainer to deep copy. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create(const SoundContainer& reference); - /// /// Creates a SoundContainer and adds a sound, optionally setting immobility, being affected by global pitch, and bus routing. - /// - /// The path to a sound to add to the first SoundSet of this SoundContainer. - /// Whether this SoundContainer's sounds will be treated as immobile, i.e. they won't be affected by 3D sound manipulation. - /// Whether this SoundContainer's sounds' frequency will be affected by the global pitch. - /// Bus to route this sound to. - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @param soundFilePath The path to a sound to add to the first SoundSet of this SoundContainer. + /// @param immobile Whether this SoundContainer's sounds will be treated as immobile, i.e. they won't be affected by 3D sound manipulation. + /// @param affectedByGlobalPitch Whether this SoundContainer's sounds' frequency will be affected by the global pitch. + /// @param busRouting Bus to route this sound to. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create(const std::string& soundFilePath, bool immobile = false, bool affectedByGlobalPitch = true, BusRouting busRouting = BusRouting::SFX) { m_TopLevelSoundSet.AddSound(soundFilePath, true); SetImmobile(immobile); @@ -76,15 +62,11 @@ namespace RTE { #pragma endregion #pragma region Destruction - /// /// Destructor method used to clean up a SoundContainer object before deletion from system memory. - /// ~SoundContainer() override { Destroy(true); } - /// /// Destroys and resets (through Clear()) the SoundContainer object. It doesn't delete the Sound files, since they're owned by ContentFile static maps. - /// - /// Whether to only destroy the members defined in this derived class, or to destroy all inherited members also. + /// @param notInherited Whether to only destroy the members defined in this derived class, or to destroy all inherited members also. void Destroy(bool notInherited = false) override { if (!notInherited) { Entity::Destroy(); @@ -92,9 +74,7 @@ namespace RTE { Clear(); } - /// /// Resets the entire SoundContainer, including its inherited members, to their default settings or values. - /// void Reset() override { Clear(); Entity::Reset(); @@ -102,10 +82,8 @@ namespace RTE { #pragma endregion #pragma region Sound Management Getters and Setters - /// /// Shows whether this SoundContainer's top level SoundSet has any SoundData or SoundSets. - /// - /// Whether this SoundContainer has any sounds. + /// @return Whether this SoundContainer has any sounds. bool HasAnySounds() const { return m_TopLevelSoundSet.HasAnySounds(); } enum class LengthOfSoundType { @@ -113,132 +91,94 @@ namespace RTE { NextPlayed }; - /// /// Gets the length of the sound in this sound container. - /// - /// Whether to get the length of the next played sound, or the maximum length of any sound in this container. - /// The length of this sound, in ms. + /// @param type Whether to get the length of the next played sound, or the maximum length of any sound in this container. + /// @return The length of this sound, in ms. float GetLength(LengthOfSoundType type) const; - /// /// Gets a reference to the top level SoundSet of this SoundContainer, to which all SoundData and sub SoundSets belong. - /// - /// A reference to the top level SoundSet of this SoundContainer. + /// @return A reference to the top level SoundSet of this SoundContainer. SoundSet& GetTopLevelSoundSet() { return m_TopLevelSoundSet; } - /// /// Copies the passed in SoundSet reference into the top level SoundSet of this SoundContainer, effectively making that the new top level SoundSet. - /// - /// A reference to the new top level SoundSet for this SoundContainer. + /// @param newTopLevelSoundSet A reference to the new top level SoundSet for this SoundContainer. void SetTopLevelSoundSet(const SoundSet& newTopLevelSoundSet) { m_TopLevelSoundSet = newTopLevelSoundSet; m_SoundPropertiesUpToDate = false; } - /// /// Gets a vector of hashes of the sounds selected to be played next in this SoundContainer. - /// - /// The currently playing sounds hashes. + /// @return The currently playing sounds hashes. std::vector GetSelectedSoundHashes() const; - /// /// Gets the SoundData object that corresponds to the given FMOD::Sound. If the sound can't be found, it returns a null pointer. - /// - /// The FMOD::Sound to search for. - /// A pointer to the corresponding SoundData or a null pointer. + /// @param sound The FMOD::Sound to search for. + /// @return A pointer to the corresponding SoundData or a null pointer. const SoundSet::SoundData* GetSoundDataForSound(const FMOD::Sound* sound) const; - /// /// Gets the channels playing sounds from this SoundContainer. - /// - /// The channels currently being used. + /// @return The channels currently being used. std::unordered_set const* GetPlayingChannels() const { return &m_PlayingChannels; } - /// /// Indicates whether any sound in this SoundContainer is currently being played. - /// - /// Whether any sounds are playing. + /// @return Whether any sounds are playing. bool IsBeingPlayed() const { return !m_PlayingChannels.empty(); } - /// /// Adds a channel index to the SoundContainer's collection of playing channels. - /// - /// The channel index to add. + /// @param channel The channel index to add. void AddPlayingChannel(int channel) { m_PlayingChannels.insert(channel); } - /// /// Removes a channel index from the SoundContainer's collection of playing channels. - /// - /// The channel index to remove. + /// @param channel The channel index to remove. void RemovePlayingChannel(int channel) { m_PlayingChannels.erase(channel); } - /// /// Gets the SoundOverlapMode of this SoundContainer, which is used to determine how it should behave when it's told to play while already playing. - /// - /// The SoundOverlapMode of this SoundContainer. + /// @return The SoundOverlapMode of this SoundContainer. SoundOverlapMode GetSoundOverlapMode() const { return m_SoundOverlapMode; } - /// /// Sets the SoundOverlapMode of this SoundContainer, which is used to determine how it should behave when it's told to play while already playing. - /// - /// The new SoundOverlapMode this SoundContainer should use. + /// @param newSoundOverlapMode The new SoundOverlapMode this SoundContainer should use. void SetSoundOverlapMode(SoundOverlapMode newSoundOverlapMode) { m_SoundOverlapMode = newSoundOverlapMode; } #pragma endregion #pragma region Sound Property Getters and Setters - /// /// Gets the bus this sound routes to. - /// - /// The bus this sound routes to. + /// @return The bus this sound routes to. BusRouting GetBusRouting() const { return m_BusRouting; } - /// /// Sets the bus this sound routes to. - /// - /// The new bus for this sound to route to. + /// @param newBusRoute The new bus for this sound to route to. void SetBusRouting(BusRouting newBusRoute) { m_BusRouting = newBusRoute; } - /// /// Gets whether the sounds in this SoundContainer should be considered immobile, i.e. always play at the listener's position. - /// - /// Whether or not the sounds in this SoundContainer are immobile. + /// @return Whether or not the sounds in this SoundContainer are immobile. bool IsImmobile() const { return m_Immobile; } - /// /// Sets whether the sounds in this SoundContainer should be considered immobile, i.e. always play at the listener's position. Does not affect currently playing sounds. - /// - /// The new immobile setting. + /// @param immobile The new immobile setting. void SetImmobile(bool immobile) { m_Immobile = immobile; m_SoundPropertiesUpToDate = false; } - /// /// Gets the attenuation start distance of this SoundContainer. - /// - /// A float with the attenuation start distance. + /// @return A float with the attenuation start distance. float GetAttenuationStartDistance() const { return m_AttenuationStartDistance; } - /// /// Sets the attenuation start distance of this SoundContainer. Values < 0 set it to default. Does not affect currently playing sounds. - /// - /// The new attenuation start distance. + /// @param attenuationStartDistance The new attenuation start distance. void SetAttenuationStartDistance(float attenuationStartDistance) { m_AttenuationStartDistance = (attenuationStartDistance < 0) ? c_DefaultAttenuationStartDistance : attenuationStartDistance; m_SoundPropertiesUpToDate = false; } - /// /// Gets the custom pan value of this SoundContainer. - /// - /// A float with the custom pan value. + /// @return A float with the custom pan value. float GetCustomPanValue() const { return m_CustomPanValue; } - /// /// Sets the custom pan value of this SoundContainer. Clamped between -1 and 1. - /// - /// The new custom pan value. + /// @param customPanValue The new custom pan value. void SetCustomPanValue(float customPanValue) { m_CustomPanValue = std::clamp(customPanValue, -1.0f, 1.0f); if (IsBeingPlayed()) { @@ -246,78 +186,56 @@ namespace RTE { } } - /// /// Gets the panning strength multiplier of this SoundContainer. - /// - /// A float with the panning strength multiplier. + /// @return A float with the panning strength multiplier. float GetPanningStrengthMultiplier() const { return m_PanningStrengthMultiplier; } - /// /// Sets the panning strength multiplier of this SoundContainer. - /// - /// The new panning strength multiplier. + /// @param panningStrengthMultiplier The new panning strength multiplier. void SetPanningStrengthMultiplier(float panningStrengthMultiplier) { m_PanningStrengthMultiplier = panningStrengthMultiplier; m_SoundPropertiesUpToDate = false; } - /// /// Gets the looping setting of this SoundContainer. - /// - /// An int with the loop count. + /// @return An int with the loop count. int GetLoopSetting() const { return m_Loops; } - /// /// Sets the looping setting of this SoundContainer. Does not affect currently playing sounds. /// 0 means the sound is set to only play once. -1 means it loops indefinitely. - /// - /// The new loop count. + /// @param loops The new loop count. void SetLoopSetting(int loops) { m_Loops = loops; m_SoundPropertiesUpToDate = false; } - /// /// Gets whether the sounds in this SoundContainer have all had all their properties set appropriately. Used to account for issues with ordering in INI loading. - /// - /// Whether or not the sounds in this SoundContainer have their properties set appropriately. + /// @return Whether or not the sounds in this SoundContainer have their properties set appropriately. bool SoundPropertiesUpToDate() const { return m_SoundPropertiesUpToDate; } - /// /// Gets the current playback priority. - /// - /// The playback priority. + /// @return The playback priority. int GetPriority() const { return m_Priority; } - /// /// Sets the current playback priority. Higher priority (lower value) will make this more likely to make it into mixing on playback. Does not affect currently playing sounds. - /// - /// The new priority. See AudioMan::PRIORITY_* enumeration. + /// @param priority The new priority. See AudioMan::PRIORITY_* enumeration. void SetPriority(int priority) { m_Priority = std::clamp(priority, 0, 256); } - /// /// Gets whether the sounds in this SoundContainer are affected by global pitch changes or not. - /// - /// Whether or not the sounds in this SoundContainer are affected by global pitch changes. + /// @return Whether or not the sounds in this SoundContainer are affected by global pitch changes. bool IsAffectedByGlobalPitch() const { return m_AffectedByGlobalPitch; } - /// /// Sets whether the sounds in this SoundContainer are affected by global pitch changes or not. Does not affect currently playing sounds. - /// - /// The new affected by global pitch setting. + /// @param affectedByGlobalPitch The new affected by global pitch setting. void SetAffectedByGlobalPitch(bool affectedByGlobalPitch) { m_AffectedByGlobalPitch = affectedByGlobalPitch; } - /// /// Gets the position at which this SoundContainer's sound will be played. Note that its individual sounds can be offset from this. - /// - /// The position of this SoundContainer. + /// @return The position of this SoundContainer. const Vector& GetPosition() const { return m_Pos; } - /// /// Sets the position of the SoundContainer's sounds while they're playing. - /// - /// The new position to play the SoundContainer's sounds. - /// Whether this SoundContainer's attenuation setting was successful. + /// @param position The new position to play the SoundContainer's sounds. + /// @return Whether this SoundContainer's attenuation setting was successful. void SetPosition(const Vector& newPosition) { if (!m_Immobile && newPosition != m_Pos) { m_Pos = newPosition; @@ -327,16 +245,12 @@ namespace RTE { } } - /// /// Gets the volume the sounds in this SoundContainer are played at. Note that this does not factor volume changes due to the SoundContainer's position. - /// - /// The volume the sounds in this SoundContainer are played at. + /// @return The volume the sounds in this SoundContainer are played at. float GetVolume() const { return m_Volume; } - /// /// Sets the volume sounds in this SoundContainer should be played at. Note that this does not factor volume changes due to the SoundContainer's position. Does not affect currently playing sounds. - /// - /// The new volume sounds in this SoundContainer should be played at. Limited between 0 and 10. + /// @param newVolume The new volume sounds in this SoundContainer should be played at. Limited between 0 and 10. void SetVolume(float newVolume) { newVolume = std::clamp(newVolume, 0.0F, 10.0F); if (IsBeingPlayed()) { @@ -345,16 +259,12 @@ namespace RTE { m_Volume = newVolume; } - /// /// Gets the pitch the sounds in this SoundContainer are played at. Note that this does not factor in global pitch. - /// - /// The pitch the sounds in this SoundContainer are played at. + /// @return The pitch the sounds in this SoundContainer are played at. float GetPitch() const { return m_Pitch; } - /// /// Sets the pitch sounds in this SoundContainer should be played at and updates any playing instances accordingly. - /// - /// The new pitch sounds in this SoundContainer should be played at. Limited between 0.125 and 8 (8 octaves up or down). + /// @param newPitch The new pitch sounds in this SoundContainer should be played at. Limited between 0.125 and 8 (8 octaves up or down). void SetPitch(float newPitch) { m_Pitch = std::clamp(newPitch, 0.125F, 8.0F); if (IsBeingPlayed()) { @@ -362,81 +272,59 @@ namespace RTE { } } - /// /// Gets the pitch variation the sounds in this SoundContainer are played at. - /// - /// The pitch variation the sounds in this SoundContainer are played at. + /// @return The pitch variation the sounds in this SoundContainer are played at. float GetPitchVariation() const { return m_PitchVariation; } - /// /// Sets the pitch variation the sounds in this SoundContainer are played at. - /// - /// The pitch variation the sounds in this SoundContainer are played at. + /// @param newValue The pitch variation the sounds in this SoundContainer are played at. void SetPitchVariation(float newValue) { m_PitchVariation = newValue; } #pragma endregion #pragma region Playback Controls - /// /// Plays the next sound of this SoundContainer at its current position for all players. - /// - /// Whether this SoundContainer successfully started playing on any channels. + /// @return Whether this SoundContainer successfully started playing on any channels. bool Play() { return Play(-1); } - /// /// Plays the next sound of this container at its current position. - /// - /// The player to start playback of this SoundContainer's sounds for. - /// Whether there were sounds to play and they were able to be played. + /// @param player The player to start playback of this SoundContainer's sounds for. + /// @return Whether there were sounds to play and they were able to be played. bool Play(int player); - /// /// Plays the next sound of this SoundContainer at the given position for all players. - /// - /// The position at which to play the SoundContainer's sounds. - /// Whether this SoundContainer successfully started playing on any channels. + /// @param position The position at which to play the SoundContainer's sounds. + /// @return Whether this SoundContainer successfully started playing on any channels. bool Play(const Vector& position) { return Play(position, -1); } - /// /// Plays the next sound of this SoundContainer with the given attenuation for a specific player. - /// - /// The position at which to play the SoundContainer's sounds. - /// The player to start playback of this SoundContainer's sounds for. - /// Whether this SoundContainer successfully started playing on any channels. + /// @param position The position at which to play the SoundContainer's sounds. + /// @param player The player to start playback of this SoundContainer's sounds for. + /// @return Whether this SoundContainer successfully started playing on any channels. bool Play(const Vector& position, int player) { SetPosition(position); return Play(player); } - /// /// Stops playback of this SoundContainer for all players. - /// - /// Whether this SoundContainer successfully stopped playing. + /// @return Whether this SoundContainer successfully stopped playing. bool Stop() { return Stop(-1); } - /// /// Stops playback of this SoundContainer for a specific player. - /// - /// Player to stop playback of this SoundContainer for. - /// Whether this SoundContainer successfully stopped playing. + /// @param player Player to stop playback of this SoundContainer for. + /// @return Whether this SoundContainer successfully stopped playing. bool Stop(int player) { return (HasAnySounds() && IsBeingPlayed()) ? g_AudioMan.StopSoundContainerPlayingChannels(this, player) : false; } - /// /// Restarts playback of this SoundContainer for all players. - /// - /// Whether this SoundContainer successfully restarted its playback. + /// @return Whether this SoundContainer successfully restarted its playback. bool Restart() { return Restart(-1); } - /// /// Restarts playback of this SoundContainer for a specific player. - /// - /// Player to restart playback of this SoundContainer for. - /// Whether this SoundContainer successfully restarted its playback. + /// @param player Player to restart playback of this SoundContainer for. + /// @return Whether this SoundContainer successfully restarted its playback. bool Restart(int player) { return (HasAnySounds() && IsBeingPlayed()) ? g_AudioMan.StopSoundContainerPlayingChannels(this, player) && g_AudioMan.PlaySoundContainer(this, player) : false; } - /// /// Fades out playback of the SoundContainer to 0 volume. - /// - /// How long the fadeout should take. + /// @param fadeOutTime How long the fadeout should take. void FadeOut(int fadeOutTime = 1000) { if (IsBeingPlayed()) { return g_AudioMan.FadeOutSoundContainerPlayingChannels(this, fadeOutTime); @@ -445,11 +333,9 @@ namespace RTE { #pragma endregion #pragma region Miscellaneous - /// /// Updates all sound properties to match this SoundContainer's settings. /// Necessary because sounds loaded from ini seem to be used directly instead of loaded from PresetMan, so their correctness can't be guaranteed when they're played. - /// - /// The FMOD_RESULT for updating all of the SoundContainer's sounds' properties. If it's not FMOD_OK, something went wrong. + /// @return The FMOD_RESULT for updating all of the SoundContainer's sounds' properties. If it's not FMOD_OK, something went wrong. FMOD_RESULT UpdateSoundProperties(); #pragma endregion @@ -480,9 +366,7 @@ namespace RTE { float m_PitchVariation; //!< The randomized pitch variation of this SoundContainer's sounds. 1 means the sound will vary a full octave both ways. float m_Volume; //!< The current natural volume of this SoundContainer's sounds. - /// /// Clears all the member variables of this SoundContainer, effectively resetting the members of this abstraction level only. - /// void Clear(); }; } // namespace RTE diff --git a/Source/Entities/SoundSet.cpp b/Source/Entities/SoundSet.cpp index 1bdb6c999c..a61ec8968d 100644 --- a/Source/Entities/SoundSet.cpp +++ b/Source/Entities/SoundSet.cpp @@ -12,8 +12,6 @@ namespace RTE { {"forwards", SoundSelectionCycleMode::FORWARDS}, {"all", SoundSelectionCycleMode::ALL}}; - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SoundSet::Clear() { m_SoundSelectionCycleMode = SoundSelectionCycleMode::RANDOM; m_CurrentSelection = {false, -1}; @@ -22,8 +20,6 @@ namespace RTE { m_SubSoundSets.clear(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int SoundSet::Create(const SoundSet& reference) { m_SoundSelectionCycleMode = reference.m_SoundSelectionCycleMode; m_CurrentSelection = reference.m_CurrentSelection; @@ -39,8 +35,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int SoundSet::ReadProperty(const std::string_view& propName, Reader& reader) { StartPropertyList(return Serializable::ReadProperty(propName, reader)); @@ -55,8 +49,6 @@ namespace RTE { EndPropertyList; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - SoundSet::SoundData SoundSet::ReadAndGetSoundData(Reader& reader) { SoundSet::SoundData soundData; @@ -101,8 +93,6 @@ namespace RTE { return soundData; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - SoundSet::SoundSelectionCycleMode SoundSet::ReadSoundSelectionCycleMode(Reader& reader) { SoundSelectionCycleMode soundSelectionCycleModeToReturn; std::string soundSelectionCycleModeString = reader.ReadPropValue(); @@ -125,8 +115,6 @@ namespace RTE { return soundSelectionCycleModeToReturn; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int SoundSet::Save(Writer& writer) const { Serializable::Save(writer); @@ -159,8 +147,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SoundSet::SaveSoundSelectionCycleMode(Writer& writer, SoundSelectionCycleMode soundSelectionCycleMode) { auto cycleModeMapEntry = std::find_if(c_SoundSelectionCycleModeMap.begin(), c_SoundSelectionCycleModeMap.end(), [&soundSelectionCycleMode = soundSelectionCycleMode](auto element) { return element.second == soundSelectionCycleMode; }); if (cycleModeMapEntry != c_SoundSelectionCycleModeMap.end()) { @@ -170,8 +156,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SoundSet::AddSound(const std::string& soundFilePath, const Vector& offset, float minimumAudibleDistance, float attenuationStartDistance, bool abortGameForInvalidSound) { ContentFile soundFile(soundFilePath.c_str()); FMOD::Sound* soundObject = soundFile.GetAsSound(abortGameForInvalidSound, false); @@ -182,8 +166,6 @@ namespace RTE { m_SoundData.push_back({soundFile, soundObject, offset, minimumAudibleDistance, attenuationStartDistance}); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool SoundSet::RemoveSound(const std::string& soundFilePath, bool removeFromSubSoundSets) { auto soundsToRemove = std::remove_if(m_SoundData.begin(), m_SoundData.end(), [&soundFilePath](const SoundSet::SoundData& soundData) { return soundData.SoundFile.GetDataPath() == soundFilePath; }); bool anySoundsToRemove = soundsToRemove != m_SoundData.end(); @@ -198,8 +180,6 @@ namespace RTE { return anySoundsToRemove; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool SoundSet::HasAnySounds(bool includeSubSoundSets) const { bool hasAnySounds = !m_SoundData.empty(); if (!hasAnySounds && includeSubSoundSets) { @@ -213,8 +193,6 @@ namespace RTE { return hasAnySounds; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SoundSet::GetFlattenedSoundData(std::vector& flattenedSoundData, bool onlyGetSelectedSoundData) { if (!onlyGetSelectedSoundData || m_SoundSelectionCycleMode == SoundSelectionCycleMode::ALL) { for (SoundData& soundData: m_SoundData) { @@ -232,8 +210,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SoundSet::GetFlattenedSoundData(std::vector& flattenedSoundData, bool onlyGetSelectedSoundData) const { if (!onlyGetSelectedSoundData || m_SoundSelectionCycleMode == SoundSelectionCycleMode::ALL) { for (const SoundData& soundData: m_SoundData) { @@ -251,8 +227,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool SoundSet::SelectNextSounds() { if (m_SoundSelectionCycleMode == SoundSelectionCycleMode::ALL) { for (SoundSet& subSoundSet: m_SubSoundSets) { diff --git a/Source/Entities/SoundSet.h b/Source/Entities/SoundSet.h index f39f1a7e76..e6e7e7b6ab 100644 --- a/Source/Entities/SoundSet.h +++ b/Source/Entities/SoundSet.h @@ -7,27 +7,21 @@ namespace RTE { - /// /// A set of sounds, and their selection data. - /// class SoundSet : public Serializable { friend struct EntityLuaBindings; public: SerializableOverrideMethods; - /// /// How the SoundSet should choose the next sound or SoundSet to play when SelectNextSound is called. - /// enum SoundSelectionCycleMode { RANDOM = 0, FORWARDS, ALL }; - /// /// Self-contained struct defining an individual sound in a SoundSet. - /// struct SoundData { ContentFile SoundFile; FMOD::Sound* SoundObject; @@ -37,133 +31,97 @@ namespace RTE { }; #pragma region Creation - /// /// Constructor method used to instantiate a SoundSet object in system memory. Create() should be called before using the object. - /// SoundSet() { Clear(); } - /// /// Creates a SoundSet to be identical to another, by deep copy. - /// - /// A reference to the SoundSet to deep copy. - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @param reference A reference to the SoundSet to deep copy. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create(const SoundSet& reference); #pragma endregion #pragma region Destruction - /// /// Destructor method used to clean up a SoundSet object before deletion from system memory. - /// ~SoundSet() { Destroy(); } - /// /// Destroys and resets (through Clear()) the SoundSet object. - /// void Destroy() { Clear(); } #pragma endregion #pragma region INI Handling - /// /// Handles reading a SoundData from INI, loading it in as a ContentFile and into FMOD, and reading any of its subproperties. /// Does not add the created SoundData to a this SoundSet. - /// - /// A Reader lined up to the value of the property to be read. - /// SoundData for the newly read sound. + /// @param reader A Reader lined up to the value of the property to be read. + /// @return SoundData for the newly read sound. static SoundData ReadAndGetSoundData(Reader& reader); - /// /// Handles turning a SoundCelectionCycleMode from its user-friendly name in INI to its enum value, using the static SoundSelectionCycleMap. - /// - /// A Reader lined up to the value of the property to be read. - /// The appropriate SoundSelectionCycleMode for the given INI value. + /// @param reader A Reader lined up to the value of the property to be read. + /// @return The appropriate SoundSelectionCycleMode for the given INI value. static SoundSelectionCycleMode ReadSoundSelectionCycleMode(Reader& reader); - /// /// Handles writing the given SoundSelectionCycleMode out to the given Writer, using the static SoundSelectionCycleMap. - /// - /// A Writer filled in with the property to write to. - /// The SoundSelectionCycleMode to write. + /// @param writer A Writer filled in with the property to write to. + /// @param soundSelectionCycleMode The SoundSelectionCycleMode to write. static void SaveSoundSelectionCycleMode(Writer& writer, SoundSelectionCycleMode soundSelectionCycleMode); #pragma endregion #pragma region SoundData and SoundSet Addition - /// /// Adds a new sound to this SoundSet, spitting out a Lua error if it fails. The sound will have default configuration. - /// - /// A path to the new sound to add. This will be handled through PresetMan. + /// @param soundFilePath A path to the new sound to add. This will be handled through PresetMan. void AddSound(const std::string& soundFilePath) { AddSound(soundFilePath, false); } - /// /// Adds a new sound to this SoundSet, either spitting out a Lua error or aborting if it fails. The sound will have default configuration. - /// - /// A path to the new sound to add. This will be handled through PresetMan. - /// Whether to abort the game if the sound couldn't be added, or just show a console error. + /// @param soundFilePath A path to the new sound to add. This will be handled through PresetMan. + /// @param abortGameForInvalidSound Whether to abort the game if the sound couldn't be added, or just show a console error. void AddSound(const std::string& soundFilePath, bool abortGameForInvalidSound) { AddSound(soundFilePath, Vector(), 0, -1, abortGameForInvalidSound); } - /// /// Adds a new sound to this SoundSet, spitting out a Lua error if it fails. The sound will be configured based on parameters. - /// - /// A path to the new sound to add. This will be handled through PresetMan. - /// The offset position to play this sound at, where (0, 0) is no offset. - /// The minimum distance at which this sound will be audible. 0 means there is none, which is normally the case. - /// The attenuation start distance for this sound, -1 sets it to default. + /// @param soundFilePath A path to the new sound to add. This will be handled through PresetMan. + /// @param offset The offset position to play this sound at, where (0, 0) is no offset. + /// @param minimumAudibleDistance The minimum distance at which this sound will be audible. 0 means there is none, which is normally the case. + /// @param attenuationStartDistance The attenuation start distance for this sound, -1 sets it to default. void AddSound(const std::string& soundFilePath, const Vector& offset, float minimumAudibleDistance, float attenuationStartDistance) { AddSound(soundFilePath, offset, minimumAudibleDistance, attenuationStartDistance, false); } - /// /// Adds a new sound to this SoundSet, either spitting out a Lua error or aborting if it fails. The sound will be configured based on parameters. - /// - /// A path to the new sound to add. This will be handled through PresetMan. - /// The offset position to play this sound at, where (0, 0) is no offset. - /// The minimum distance at which this sound will be audible. 0 means there is none, which is normally the case. - /// The attenuation start distance for this sound, -1 sets it to default. - /// Whether to abort the game if the sound couldn't be added, or just show a console error. + /// @param soundFilePath A path to the new sound to add. This will be handled through PresetMan. + /// @param offset The offset position to play this sound at, where (0, 0) is no offset. + /// @param minimumAudibleDistance The minimum distance at which this sound will be audible. 0 means there is none, which is normally the case. + /// @param attenuationStartDistance The attenuation start distance for this sound, -1 sets it to default. + /// @param abortGameForInvalidSound Whether to abort the game if the sound couldn't be added, or just show a console error. void AddSound(const std::string& soundFilePath, const Vector& offset, float minimumAudibleDistance, float attenuationStartDistance, bool abortGameForInvalidSound); - /// /// Removes all instances of the sound with the given filepath from this SoundSet. Does not remove it from any sub-SoundSets. - /// - /// The path to the sound to be removed from this SoundSet. - /// Whether or not a sound with the given filepath was found in this SoundSet. + /// @param soundFilePath The path to the sound to be removed from this SoundSet. + /// @return Whether or not a sound with the given filepath was found in this SoundSet. bool RemoveSound(const std::string& soundFilePath) { return RemoveSound(soundFilePath, false); } - /// /// Removes all instances of the sound with the given filepath from this SoundSet, optionally removing it from all sub-SoundSets as well. - /// - /// The path to the sound to be removed from this SoundSet. - /// Whether or not to remove the sound from any sub-SoundSets as well as this SoundSet. - /// Whether or not a sound with the given filepath was found in this SoundSet or, if set to remove from sub-SoundSets, any of its sub-SoundSets. + /// @param soundFilePath The path to the sound to be removed from this SoundSet. + /// @param removeFromSubSoundSets Whether or not to remove the sound from any sub-SoundSets as well as this SoundSet. + /// @return Whether or not a sound with the given filepath was found in this SoundSet or, if set to remove from sub-SoundSets, any of its sub-SoundSets. bool RemoveSound(const std::string& soundFilePath, bool removeFromSubSoundSets); - /// /// Adds a copy of the given SoundData to this SoundSet. - /// - /// The SoundData to copy to this SoundSet. + /// @param soundDataToAdd The SoundData to copy to this SoundSet. void AddSoundData(const SoundData& soundDataToAdd) { m_SoundData.push_back(soundDataToAdd); } - /// /// Adds a copy of the passed in SoundSet as a sub SoundSet of this SoundSet. Ownership IS transferred! - /// - /// A reference to the SoundSet to be copied in as a sub SoundSet of this SoundSet. Ownership IS transferred! + /// @param soundSetToAdd A reference to the SoundSet to be copied in as a sub SoundSet of this SoundSet. Ownership IS transferred! void AddSoundSet(const SoundSet& soundSetToAdd) { m_SubSoundSets.push_back(soundSetToAdd); } #pragma endregion #pragma region Getters and Setters - /// /// Shows whether this SoundSet has any sounds in it or, optionally its SubSoundSets. - /// - /// Whether this SoundSet has any sounds, according to the conditions. + /// @return Whether this SoundSet has any sounds, according to the conditions. bool HasAnySounds(bool includeSubSoundSets = true) const; - /// /// Gets the current SoundSelectionCycleMode for this SoundSet, which is used to determine what SoundSet to select next time SelectNextSounds is called. - /// - /// The current sound selection cycle mode. + /// @return The current sound selection cycle mode. SoundSelectionCycleMode GetSoundSelectionCycleMode() const { return m_SoundSelectionCycleMode; } - /// /// Sets the SoundSelectionCycleMode for this SoundSet, which is used to determine what SoundSet to select next time SelectNextSounds is called. - /// - /// The new SoundSelectionCycleMode for this SoundSet. + /// @param newSoundSelectionCycleMOde The new SoundSelectionCycleMode for this SoundSet. void SetSoundSelectionCycleMode(SoundSelectionCycleMode newSoundSelectionCycleMode) { m_SoundSelectionCycleMode = newSoundSelectionCycleMode; if (m_SoundSelectionCycleMode == SoundSelectionCycleMode::FORWARDS) { @@ -171,40 +129,30 @@ namespace RTE { } } - /// /// Fills the passed in vector with the flattened SoundData in the SoundSet, optionally only getting currently selected SoundData. - /// - /// A reference vector of SoundData references to be filled with this SoundSet's flattened SoundData. - /// Whether to only get SoundData that is currently selected, or to get all SoundData in this SoundSet. + /// @param flattenedSoundData A reference vector of SoundData references to be filled with this SoundSet's flattened SoundData. + /// @param onlyGetSelectedSoundData Whether to only get SoundData that is currently selected, or to get all SoundData in this SoundSet. void GetFlattenedSoundData(std::vector& flattenedSoundData, bool onlyGetSelectedSoundData); - /// /// Fills the passed in vector with the flattened SoundData in the SoundSet, optionally only getting currently selected SoundData. - /// - /// A reference vector of SoundData references to be filled with this SoundSet's flattened SoundData. - /// Whether to only get SoundData that is currently selected, or to get all SoundData in this SoundSet. + /// @param flattenedSoundData A reference vector of SoundData references to be filled with this SoundSet's flattened SoundData. + /// @param onlyGetSelectedSoundData Whether to only get SoundData that is currently selected, or to get all SoundData in this SoundSet. void GetFlattenedSoundData(std::vector& flattenedSoundData, bool onlyGetSelectedSoundData) const; - /// /// Gets the vector of SubSoundSets for this SoundSet. - /// - /// The vector of SubSoundSets for this SoundSet. + /// @return The vector of SubSoundSets for this SoundSet. std::vector& GetSubSoundSets() { return m_SubSoundSets; } #pragma endregion #pragma region Miscellaneous - /// /// Selects the next sounds of this SoundSet to be played, also selecting them for sub SoundSets as appropriate. - /// - /// False if this SoundSet or any of its sub SoundSets failed to select sounds, or true if everything worked. + /// @return False if this SoundSet or any of its sub SoundSets failed to select sounds, or true if everything worked. bool SelectNextSounds(); #pragma endregion #pragma region Class Info - /// /// Gets the class name of this Serializable. - /// - /// A string with the friendly-formatted type name of this object. + /// @return A string with the friendly-formatted type name of this object. const std::string& GetClassName() const override { return m_sClassName; } #pragma endregion @@ -218,9 +166,7 @@ namespace RTE { std::vector m_SoundData; //!< The SoundData available for selection in this SoundSet. std::vector m_SubSoundSets; //!< The sub SoundSets available for selection in this SoundSet. - /// /// Clears all the member variables of this SoundSet, effectively resetting the members of this abstraction level only. - /// void Clear(); }; } // namespace RTE diff --git a/Source/Entities/TDExplosive.cpp b/Source/Entities/TDExplosive.cpp index 99a59f98e8..443f14b23b 100644 --- a/Source/Entities/TDExplosive.cpp +++ b/Source/Entities/TDExplosive.cpp @@ -4,14 +4,10 @@ namespace RTE { ConcreteClassInfo(TDExplosive, ThrownDevice, 50); - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void TDExplosive::Clear() { m_IsAnimatedManually = false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int TDExplosive::Create() { if (ThrownDevice::Create() < 0) { return -1; @@ -24,8 +20,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int TDExplosive::Create(const TDExplosive& reference) { if (ThrownDevice::Create(reference) < 0) { return -1; @@ -35,8 +29,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int TDExplosive::ReadProperty(const std::string_view& propName, Reader& reader) { StartPropertyList(return ThrownDevice::ReadProperty(propName, reader)); @@ -52,8 +44,6 @@ namespace RTE { EndPropertyList; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int TDExplosive::Save(Writer& writer) const { ThrownDevice::Save(writer); writer.NewProperty("IsAnimatedManually"); @@ -61,8 +51,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void TDExplosive::Update() { ThrownDevice::Update(); @@ -79,8 +67,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void TDExplosive::DrawHUD(BITMAP* targetBitmap, const Vector& targetPos, int whichScreen, bool playerControlled) { if (m_HUDVisible && !m_Activated) { ThrownDevice::DrawHUD(targetBitmap, targetPos, whichScreen); diff --git a/Source/Entities/TDExplosive.h b/Source/Entities/TDExplosive.h index bdc15d1e53..d18ec18b20 100644 --- a/Source/Entities/TDExplosive.h +++ b/Source/Entities/TDExplosive.h @@ -5,9 +5,7 @@ namespace RTE { - /// /// A thrown device that explodes after its trigger delay is completed after its activation. - /// class TDExplosive : public ThrownDevice { public: @@ -16,35 +14,25 @@ namespace RTE { ClassInfoGetters; #pragma region Creation - /// /// Constructor method used to instantiate a TDExplosive object in system memory. Create() should be called before using the object. - /// TDExplosive() { Clear(); } - /// /// Makes the TDExplosive object ready for use. - /// - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create() override; - /// /// Creates a TDExplosive to be identical to another, by deep copy. - /// - /// A reference to the TDExplosive to deep copy. - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @param reference A reference to the TDExplosive to deep copy. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create(const TDExplosive& reference); #pragma endregion #pragma region Destruction - /// /// Destructor method used to clean up a TDExplosive object before deletion from system memory. - /// ~TDExplosive() override { Destroy(true); } - /// /// Destroys and resets (through Clear()) the SceneLayer object. - /// - /// Whether to only destroy the members defined in this derived class, or to destroy all inherited members also. + /// @param notInherited Whether to only destroy the members defined in this derived class, or to destroy all inherited members also. void Destroy(bool notInherited = false) override { if (!notInherited) { ThrownDevice::Destroy(); @@ -52,9 +40,7 @@ namespace RTE { Clear(); } - /// /// Resets the entire TDExplosive, including its inherited members, to their default settings or values. - /// void Reset() override { Clear(); ThrownDevice::Reset(); @@ -62,32 +48,24 @@ namespace RTE { #pragma endregion #pragma region Getters and Setters - /// /// If true, then the frame will not be changed automatically during update - /// - /// Whether or not the TDExplosive's Frame will change automatically during update. + /// @return Whether or not the TDExplosive's Frame will change automatically during update. bool IsAnimatedManually() const { return m_IsAnimatedManually; } - /// /// Sets whether this TDExplosive is animated manually. - /// - /// Whether or not to animate manually. + /// @param isAnimatedManually Whether or not to animate manually. void SetAnimatedManually(bool isAnimatedManually) { m_IsAnimatedManually = isAnimatedManually; } #pragma endregion #pragma region Virtual Override Methods - /// /// Updates this MovableObject. Supposed to be done every frame. - /// void Update() override; - /// /// Draws this' current graphical HUD overlay representation to a BITMAP of choice. - /// - /// A pointer to a BITMAP to draw on. - /// The absolute position of the target bitmap's upper left corner in the Scene. - /// Which player's screen this is being drawn to. May affect what HUD elements get drawn etc. - /// Whether or not this MovableObject is currently player controlled (not applicable for TDExplosive). + /// @param targetBitmap A pointer to a BITMAP to draw on. + /// @param targetPos The absolute position of the target bitmap's upper left corner in the Scene. + /// @param whichScreen Which player's screen this is being drawn to. May affect what HUD elements get drawn etc. + /// @param playerControlled Whether or not this MovableObject is currently player controlled (not applicable for TDExplosive). void DrawHUD(BITMAP* targetBitmap, const Vector& targetPos = Vector(), int whichScreen = 0, bool playerControlled = false) override; #pragma endregion @@ -97,9 +75,7 @@ namespace RTE { bool m_IsAnimatedManually; //!< If true m_Frame is not changed during an update hence the animation is done by external Lua code. private: - /// /// Clears all the member variables of this TDExplosive, effectively resetting the members of this abstraction level only. - /// void Clear(); // Disallow the use of some implicit methods. diff --git a/Source/Entities/TerrainDebris.cpp b/Source/Entities/TerrainDebris.cpp index 5624997d9b..dee86859d6 100644 --- a/Source/Entities/TerrainDebris.cpp +++ b/Source/Entities/TerrainDebris.cpp @@ -5,8 +5,6 @@ namespace RTE { ConcreteClassInfo(TerrainDebris, Entity, 0); - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void TerrainDebris::Clear() { m_DebrisFile.Reset(); m_Bitmaps.clear(); @@ -25,8 +23,6 @@ namespace RTE { m_Density = 0.01F; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int TerrainDebris::Create() { Entity::Create(); m_DebrisFile.GetAsAnimation(m_Bitmaps, m_BitmapCount); @@ -34,8 +30,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int TerrainDebris::Create(const TerrainDebris& reference) { Entity::Create(reference); @@ -59,8 +53,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int TerrainDebris::ReadProperty(const std::string_view& propName, Reader& reader) { StartPropertyList(return Entity::ReadProperty(propName, reader)); @@ -90,8 +82,6 @@ namespace RTE { EndPropertyList; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int TerrainDebris::Save(Writer& writer) const { Entity::Save(writer); @@ -113,8 +103,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool TerrainDebris::GetPiecePlacementPosition(SLTerrain* terrain, Box& possiblePiecePosition) const { BITMAP* matBitmap = terrain->GetMaterialBitmap(); int posX = RandomNum(0, matBitmap->w); @@ -149,8 +137,6 @@ namespace RTE { return false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool TerrainDebris::MaterialPixelIsValidTarget(int materialCheckPixel, int prevMaterialCheckPixel) const { bool checkResult = true; @@ -185,8 +171,6 @@ namespace RTE { return checkResult; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void TerrainDebris::DrawToTerrain(SLTerrain* terrain, BITMAP* bitmapToDraw, const Vector& position) const { // Create a square temp bitmap that is larger than the original to avoid clipping if rotating. int dimensions = 10 + std::max(bitmapToDraw->w, bitmapToDraw->h); @@ -227,8 +211,6 @@ namespace RTE { destroy_bitmap(tempDrawBitmap); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void TerrainDebris::ScatterOnTerrain(SLTerrain* terrain) { RTEAssert(!m_Bitmaps.empty() && m_BitmapCount > 0, "No bitmaps loaded for terrain debris during TerrainDebris::ScatterOnTerrain!"); diff --git a/Source/Entities/TerrainDebris.h b/Source/Entities/TerrainDebris.h index 6f3c837ac7..33ce33d0c5 100644 --- a/Source/Entities/TerrainDebris.h +++ b/Source/Entities/TerrainDebris.h @@ -10,9 +10,7 @@ namespace RTE { class Box; class SLTerrain; - /// /// Debris objects scattered randomly throughout the terrain. - /// class TerrainDebris : public Entity { public: @@ -21,35 +19,25 @@ namespace RTE { ClassInfoGetters; #pragma region Creation - /// /// Constructor method used to instantiate a TerrainDebris object in system memory. Create() should be called before using the object. - /// TerrainDebris() { Clear(); } - /// /// Makes the TerrainDebris object ready for use. - /// - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create() override; - /// /// Creates a TerrainDebris to be identical to another, by deep copy. - /// - /// A reference to the TerrainDebris to deep copy. - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @param reference A reference to the TerrainDebris to deep copy. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create(const TerrainDebris& reference); #pragma endregion #pragma region Destruction - /// /// Destructor method used to clean up a TerrainDebris object before deletion from system memory. - /// ~TerrainDebris() override { Destroy(true); } - /// /// Destroys and resets (through Clear()) the TerrainDebris object. - /// - /// Whether to only destroy the members defined in this derived class, or to destroy all inherited members also. + /// @param notInherited Whether to only destroy the members defined in this derived class, or to destroy all inherited members also. void Destroy(bool notInherited = false) override { if (!notInherited) { Entity::Destroy(); @@ -59,17 +47,13 @@ namespace RTE { #pragma endregion #pragma region Concrete Methods - /// /// Places random pieces of this TerrainDebris's at random positions on the specified SLTerrain. - /// - /// The SLTerrain to scatter this TerrainDebris on. Ownership is NOT transferred! + /// @param terrain The SLTerrain to scatter this TerrainDebris on. Ownership is NOT transferred! void ScatterOnTerrain(SLTerrain* terrain); #pragma endregion private: - /// /// Enumeration for the different debris placement modes. - /// enum DebrisPlacementMode { NoPlacementRestrictions, OnSurfaceOnly, @@ -105,34 +89,26 @@ namespace RTE { float m_Density; //!< Approximate density of debris pieces per meter. #pragma region Debris Application Breakdown - /// /// Checks if conditions apply for a debris piece to be placed to the terrain. The actual position is returned via the passed in Box's center position. - /// - /// Pointer to the SLTerrain to check debris placement on. Ownership is NOT transferred! - /// A Box that holds the debris piece's dimensions. The center position of the Box will be modified during checking. - /// True if a valid placement position was found, which means the passed in Box's center or corner positions are good to be used as the piece's drawing position. + /// @param terrain Pointer to the SLTerrain to check debris placement on. Ownership is NOT transferred! + /// @param possiblePiecePosition A Box that holds the debris piece's dimensions. The center position of the Box will be modified during checking. + /// @return True if a valid placement position was found, which means the passed in Box's center or corner positions are good to be used as the piece's drawing position. bool GetPiecePlacementPosition(SLTerrain* terrain, Box& possiblePiecePosition) const; - /// /// Checks whether the passed in pixel color value is of target Material, and if extra conditions apply for it to be valid for placement, depending on DebrisPlacementMode. - /// - /// The pixel color value to check. - /// The previously checked pixel color value to check extra conditions with. Does not apply when DebrisPlacementMode is NoPlacementRestrictions. - /// Whether the passed in pixel color value is valid for debris placement. + /// @param materialCheckPixel The pixel color value to check. + /// @param prevMaterialCheckPixel The previously checked pixel color value to check extra conditions with. Does not apply when DebrisPlacementMode is NoPlacementRestrictions. + /// @return Whether the passed in pixel color value is valid for debris placement. bool MaterialPixelIsValidTarget(int materialCheckPixel, int prevMaterialCheckPixel) const; - /// /// Draws the debris piece bitmap on the terrain at the specified position. Performs flipping and rotating if necessary. - /// - /// Pointer to the SLTerrain to draw the debris piece on. Ownership is NOT transferred! - /// The BITMAP to draw. Ownership is NOT transferred! - /// The position to draw the debris piece on the terrain. + /// @param terrain Pointer to the SLTerrain to draw the debris piece on. Ownership is NOT transferred! + /// @param bitmapToDraw The BITMAP to draw. Ownership is NOT transferred! + /// @param position The position to draw the debris piece on the terrain. void DrawToTerrain(SLTerrain* terrain, BITMAP* bitmapToDraw, const Vector& position) const; #pragma endregion - /// /// Clears all the member variables of this TerrainDebris, effectively resetting the members of this abstraction level only. - /// void Clear(); // Disallow the use of some implicit methods. diff --git a/Source/Entities/TerrainFrosting.cpp b/Source/Entities/TerrainFrosting.cpp index a2a2807f7f..64d0747d19 100644 --- a/Source/Entities/TerrainFrosting.cpp +++ b/Source/Entities/TerrainFrosting.cpp @@ -5,8 +5,6 @@ namespace RTE { const std::string TerrainFrosting::c_ClassName = "TerrainFrosting"; - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void TerrainFrosting::Clear() { m_FrostingMaterial.Reset(); m_TargetMaterial.Reset(); @@ -15,8 +13,6 @@ namespace RTE { m_InAirOnly = true; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int TerrainFrosting::ReadProperty(const std::string_view& propName, Reader& reader) { StartPropertyList(return Serializable::ReadProperty(propName, reader)); @@ -29,8 +25,6 @@ namespace RTE { EndPropertyList; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int TerrainFrosting::Save(Writer& writer) const { Serializable::Save(writer); @@ -43,8 +37,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void TerrainFrosting::FrostTerrain(SLTerrain* terrain) const { BITMAP* frostingTexture = m_FrostingMaterial.GetFGTexture(); BITMAP* fgColorBitmap = terrain->GetFGColorBitmap(); diff --git a/Source/Entities/TerrainFrosting.h b/Source/Entities/TerrainFrosting.h index c83c2d20e2..043afade5e 100644 --- a/Source/Entities/TerrainFrosting.h +++ b/Source/Entities/TerrainFrosting.h @@ -7,9 +7,7 @@ namespace RTE { class SLTerrain; - /// /// A layer of material on top of another material on the terrain. - /// class TerrainFrosting : public Serializable { public: @@ -17,19 +15,15 @@ namespace RTE { SerializableOverrideMethods #pragma region Creation - /// /// Constructor method used to instantiate a TerrainFrosting object in system memory and make it ready for use. - /// TerrainFrosting() { Clear(); } #pragma endregion #pragma region Concrete Methods - /// /// Draws the frosting layer to the specified SLTerrain according to the read-in parameters. - /// - /// The SLTerrain to frost. Ownership is NOT transferred! + /// @param terrain The SLTerrain to frost. Ownership is NOT transferred! void FrostTerrain(SLTerrain* terrain) const; #pragma endregion @@ -42,9 +36,7 @@ namespace RTE { int m_MaxThickness; //!< The maximum height above the target Material, in pixels. bool m_InAirOnly; //!< Whether the frosting only appears where there is air (i.e. does not appear where the terrain background layer is showing). - /// /// Clears all the member variables of this TerrainFrosting, effectively resetting the members of this abstraction level only. - /// void Clear(); // Disallow the use of some implicit methods. diff --git a/Source/Entities/TerrainObject.cpp b/Source/Entities/TerrainObject.cpp index e86cfa15ae..70bf1067d4 100644 --- a/Source/Entities/TerrainObject.cpp +++ b/Source/Entities/TerrainObject.cpp @@ -6,8 +6,6 @@ namespace RTE { ConcreteClassInfo(TerrainObject, SceneObject, 0); - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void TerrainObject::Clear() { m_FGColorFile.Reset(); m_FGColorBitmap = nullptr; @@ -20,8 +18,6 @@ namespace RTE { m_ChildObjects.clear(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int TerrainObject::Create() { SceneObject::Create(); @@ -39,8 +35,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int TerrainObject::Create(const TerrainObject& reference) { SceneObject::Create(reference); @@ -59,8 +53,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int TerrainObject::ReadProperty(const std::string_view& propName, Reader& reader) { StartPropertyList(return SceneObject::ReadProperty(propName, reader)); @@ -97,8 +89,6 @@ namespace RTE { EndPropertyList; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int TerrainObject::Save(Writer& writer) const { SceneObject::Save(writer); @@ -122,8 +112,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - BITMAP* TerrainObject::GetGraphicalIcon() const { if (m_FGColorBitmap) { // Check several spots on the FG bitmap, to be sure it has parts that aren't transparent. If not, show the background layer instead. @@ -135,8 +123,6 @@ namespace RTE { return m_BGColorBitmap; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void TerrainObject::SetTeam(int team) { SceneObject::SetTeam(team); for (SceneObject::SOPlacer& childObject: m_ChildObjects) { @@ -144,8 +130,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool TerrainObject::IsOnScenePoint(Vector& scenePoint) const { // TODO: TAKE CARE OF WRAPPING Vector bitmapPos = m_Pos + m_BitmapOffset; @@ -164,8 +148,6 @@ namespace RTE { return false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool TerrainObject::PlaceOnTerrain(SLTerrain* terrain) { if (!terrain) { return false; @@ -182,8 +164,6 @@ namespace RTE { return true; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void TerrainObject::Draw(BITMAP* targetBitmap, const Vector& targetPos, DrawMode drawMode, bool onlyPhysical) const { std::array drawPos = {m_Pos + m_BitmapOffset - targetPos}; int wrapPasses = 1; @@ -244,8 +224,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void TerrainObject::DrawToTerrain(SLTerrain* terrain) { BITMAP* terrainMatBitmap = terrain->GetMaterialBitmap(); BITMAP* terrainBGBitmap = terrain->GetBGColorBitmap(); diff --git a/Source/Entities/TerrainObject.h b/Source/Entities/TerrainObject.h index 9374419f39..762bf16996 100644 --- a/Source/Entities/TerrainObject.h +++ b/Source/Entities/TerrainObject.h @@ -8,9 +8,7 @@ namespace RTE { class SLTerrain; - /// /// A feature of the terrain, which includes foreground color layer, material layer and optional background layer. - /// class TerrainObject : public SceneObject { public: @@ -19,35 +17,25 @@ namespace RTE { ClassInfoGetters; #pragma region Creation - /// /// Constructor method used to instantiate a TerrainObject object in system memory. Create() should be called before using the object. - /// TerrainObject() { Clear(); } - /// /// Makes the TerrainObject object ready for use. - /// - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create() override; - /// /// Creates a TerrainObject to be identical to another, by deep copy. - /// - /// A reference to the TerrainObject to deep copy. - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @param reference A reference to the TerrainObject to deep copy. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create(const TerrainObject& reference); #pragma endregion #pragma region Destruction - /// /// Destructor method used to clean up a TerrainObject object before deletion from system memory. - /// ~TerrainObject() override { Destroy(true); } - /// /// Destroys and resets (through Clear()) the TerrainObject object. - /// - /// Whether to only destroy the members defined in this derived class, or to destroy all inherited members also. + /// @param notInherited Whether to only destroy the members defined in this derived class, or to destroy all inherited members also. void Destroy(bool notInherited = false) override { if (!notInherited) { SceneObject::Destroy(); @@ -57,103 +45,73 @@ namespace RTE { #pragma endregion #pragma region Getters and Setters - /// /// Returns whether this TerrainObject has any foreground color data. - /// - /// Whether this TerrainOBject has any foreground color data. + /// @return Whether this TerrainOBject has any foreground color data. bool HasFGColorBitmap() const { return m_FGColorBitmap != nullptr; } - /// /// Gets the BITMAP that this TerrainObject uses for its foreground color representation. - /// - /// A pointer to the foreground color BITMAP object. Ownership is NOT transferred! + /// @return A pointer to the foreground color BITMAP object. Ownership is NOT transferred! BITMAP* GetFGColorBitmap() const { return m_FGColorBitmap; } - /// /// Returns whether this TerrainObject has any background color data. - /// - /// Whether this TerrainOBject has any background color data. + /// @return Whether this TerrainOBject has any background color data. bool HasBGColorBitmap() const { return m_BGColorBitmap != nullptr; } - /// /// Gets the BITMAP that this TerrainObject uses for its background color representation, if any. - /// - /// A pointer to the background color BITMAP object. This may be nullptr if there is no BG bitmap. Ownership is NOT transferred! + /// @return A pointer to the background color BITMAP object. This may be nullptr if there is no BG bitmap. Ownership is NOT transferred! BITMAP* GetBGColorBitmap() const { return m_BGColorBitmap; } - /// /// Returns whether this TerrainObject has any material data. - /// - /// Whether this TerrainOBject has any material data. + /// @return Whether this TerrainOBject has any material data. bool HasMaterialBitmap() const { return m_MaterialBitmap != nullptr; } - /// /// Gets the BITMAP that this TerrainObject uses for its material representation, if any. - /// - /// A pointer to the material BITMAP object. Ownership is NOT transferred! + /// @return A pointer to the material BITMAP object. Ownership is NOT transferred! BITMAP* GetMaterialBitmap() const { return m_MaterialBitmap; } - /// /// Gets the offset from the position to the upper left corner of this TerrainObject's BITMAPs. - /// - /// A Vector describing the bitmap offset, in pixels. + /// @return A Vector describing the bitmap offset, in pixels. const Vector& GetBitmapOffset() const { return m_BitmapOffset; } - /// /// Gets the width of the widest BITMAP of this TerrainObject's layers. - /// - /// The width of this TerrainObject. + /// @return The width of this TerrainObject. int GetBitmapWidth() const { return std::max({m_MaterialBitmap ? m_MaterialBitmap->w : 0, m_BGColorBitmap ? m_BGColorBitmap->w : 0, m_FGColorBitmap ? m_FGColorBitmap->w : 0}); } - /// /// Gets the height of the highest BITMAP of this TerrainObject's layers. - /// - /// The height of this TerrainObject. + /// @return The height of this TerrainObject. int GetBitmapHeight() const { return std::max({m_MaterialBitmap ? m_MaterialBitmap->h : 0, m_BGColorBitmap ? m_BGColorBitmap->h : 0, m_FGColorBitmap ? m_FGColorBitmap->h : 0}); } - /// /// Gets the list of child objects that should be placed when this TerrainObject is placed. - /// - /// A reference to the list of child objects. Ownership of the list is NOT transferred! + /// @return A reference to the list of child objects. Ownership of the list is NOT transferred! const std::vector& GetChildObjects() const { return m_ChildObjects; } - /// /// Gets a BITMAP showing a good identifiable icon of this, for use in GUI lists. - /// - /// A good identifiable graphical representation of this in a BITMAP, if available. If not, nullptr is returned. Ownership is NOT transferred! + /// @return A good identifiable graphical representation of this in a BITMAP, if available. If not, nullptr is returned. Ownership is NOT transferred! BITMAP* GetGraphicalIcon() const override; - /// /// Sets which team this TerrainObject belongs to. - /// - /// The assigned team number. + /// @param team The assigned team number. void SetTeam(int team) override; #pragma endregion #pragma region Concrete Methods - /// /// Places this TerrainObject and all its children on the specified SLTerrain. - /// - /// The SLTerrain to place this TerrainObject on. Ownership is NOT transferred! - /// Whether the object was successfully placed on the terrain. + /// @param terrain The SLTerrain to place this TerrainObject on. Ownership is NOT transferred! + /// @return Whether the object was successfully placed on the terrain. bool PlaceOnTerrain(SLTerrain* terrain); #pragma endregion #pragma region Virtual Override Methods - /// /// Indicates whether this TerrainObject's current graphical representation overlaps a point in absolute scene coordinates. - /// - /// The point in absolute scene coordinates. - /// Whether this' graphical rep overlaps the scene point. + /// @param scenePoint The point in absolute scene coordinates. + /// @return Whether this' graphical rep overlaps the scene point. bool IsOnScenePoint(Vector& scenePoint) const override; - /// /// Draws this TerrainObject's current graphical representation to a BITMAP of choice. - /// - /// A pointer to a BITMAP to draw on. - /// The absolute position of the target bitmap's upper left corner in the Scene. - /// In which mode to draw in. See the DrawMode enumeration for the modes. - /// Whether to not draw any extra 'ghost' items of this TerrainObject, like indicator arrows or hovering HUD text and so on. + /// @param targetBitmap A pointer to a BITMAP to draw on. + /// @param targetPos The absolute position of the target bitmap's upper left corner in the Scene. + /// @param drawMode In which mode to draw in. See the DrawMode enumeration for the modes. + /// @param onlyPhysical Whether to not draw any extra 'ghost' items of this TerrainObject, like indicator arrows or hovering HUD text and so on. void Draw(BITMAP* targetBitmap, const Vector& targetPos = Vector(), DrawMode drawMode = DrawMode::g_DrawColor, bool onlyPhysical = false) const override; #pragma endregion @@ -175,15 +133,11 @@ namespace RTE { std::vector m_ChildObjects; //!< The objects that are placed along with this TerrainObject on the Scene. private: - /// /// Draws this TerrainObject's graphical and material representations to the specified SLTerrain's respective layers. - /// - /// The SLTerrain to draw this TerrainObject to. Ownership is NOT transferred! + /// @param terrain The SLTerrain to draw this TerrainObject to. Ownership is NOT transferred! void DrawToTerrain(SLTerrain* terrain); - /// /// Clears all the member variables of this TerrainObject, effectively resetting the members of this abstraction level only. - /// void Clear(); // Disallow the use of some implicit methods. diff --git a/Source/Entities/ThrownDevice.cpp b/Source/Entities/ThrownDevice.cpp index e1b469230e..e9913cff91 100644 --- a/Source/Entities/ThrownDevice.cpp +++ b/Source/Entities/ThrownDevice.cpp @@ -7,8 +7,6 @@ namespace RTE { ConcreteClassInfo(ThrownDevice, HeldDevice, 50); - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ThrownDevice::Clear() { m_ActivationSound.Reset(); m_StartThrowOffset.Reset(); @@ -20,8 +18,6 @@ namespace RTE { m_StrikerLever = nullptr; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int ThrownDevice::Create() { if (HeldDevice::Create() < 0) { return -1; @@ -31,8 +27,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int ThrownDevice::Create(const ThrownDevice& reference) { HeldDevice::Create(reference); @@ -51,8 +45,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int ThrownDevice::ReadProperty(const std::string_view& propName, Reader& reader) { StartPropertyList(return HeldDevice::ReadProperty(propName, reader)); @@ -68,8 +60,6 @@ namespace RTE { EndPropertyList; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int ThrownDevice::Save(Writer& writer) const { HeldDevice::Save(writer); @@ -93,8 +83,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - float ThrownDevice::GetCalculatedMaxThrowVelIncludingArmThrowStrength() { if (m_MaxThrowVel > 0) { return m_MaxThrowVel; @@ -104,8 +92,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ThrownDevice::ResetAllTimers() { double elapsedTime = m_Activated ? m_ActivationTimer.GetElapsedSimTimeMS() : 0; HeldDevice::ResetAllTimers(); @@ -114,8 +100,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ThrownDevice::Activate() { if (!m_Activated) { m_ActivationTimer.Reset(); diff --git a/Source/Entities/ThrownDevice.h b/Source/Entities/ThrownDevice.h index 9738b68dac..3943b397f9 100644 --- a/Source/Entities/ThrownDevice.h +++ b/Source/Entities/ThrownDevice.h @@ -5,9 +5,7 @@ namespace RTE { - /// /// A device that is carried and thrown by Actors. - /// class ThrownDevice : public HeldDevice { public: @@ -16,35 +14,25 @@ namespace RTE { ClassInfoGetters; #pragma region Creation - /// /// Constructor method used to instantiate a ThrownDevice object in system memory. Create should be called before using the object. - /// ThrownDevice() { Clear(); } - /// /// Makes the ThrownDevice object ready for use. - /// - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create() override; - /// /// Creates a ThrownDevice to be identical to another, by deep copy. - /// - /// A reference to the ThrownDevice to deep copy. - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @param reference A reference to the ThrownDevice to deep copy. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create(const ThrownDevice& reference); #pragma endregion #pragma region Destruction - /// /// Destructor method used to clean up a ThrownDevice object before deletion from system memory. - /// ~ThrownDevice() override { Destroy(true); } - /// /// Destroys and resets (through Clear()) the SceneLayer object. - /// - /// Whether to only destroy the members defined in this derived class, or to destroy all inherited members also. + /// @param notInherited Whether to only destroy the members defined in this derived class, or to destroy all inherited members also. void Destroy(bool notInherited = false) override { if (!notInherited) { HeldDevice::Destroy(); @@ -52,9 +40,7 @@ namespace RTE { Clear(); } - /// /// Resets the entire ThrownDevice, including its inherited members, to their default settings or values. - /// void Reset() override { Clear(); Attachable::Reset(); @@ -62,82 +48,56 @@ namespace RTE { #pragma endregion #pragma region Getters and Setters - /// /// Gets the start throw offset of this ThrownDevice's joint relative from the parent Actor's position, if attached. - /// - /// A const reference to the current start throw parent offset. + /// @return A const reference to the current start throw parent offset. Vector GetStartThrowOffset() const { return m_StartThrowOffset; } - /// /// Sets the start throw offset for this ThrownDevice. - /// - /// The new start throw offset. + /// @param startOffset The new start throw offset. void SetStartThrowOffset(Vector startOffset) { m_StartThrowOffset = startOffset; } - /// /// Gets the end throw offset of this ThrownDevice's joint relative from the parent Actor's position, if attached. - /// - /// A const reference to the current end throw parent offset. + /// @return A const reference to the current end throw parent offset. Vector GetEndThrowOffset() const { return m_EndThrowOffset; } - /// /// Sets the end throw offset for this ThrownDevice. - /// - /// The new end throw offset. + /// @param endOffset The new end throw offset. void SetEndThrowOffset(Vector endOffset) { m_EndThrowOffset = endOffset; } - /// /// Gets the minimum throw velocity of this when thrown. - /// - /// The minimum throw velocity of this, in m/s. + /// @return The minimum throw velocity of this, in m/s. float GetMinThrowVel() const { return m_MinThrowVel; } - /// /// Sets the minimum throw velocity of this when thrown. - /// - /// The minimum throw velocity of this, in m/s. + /// @param minThrowVel The minimum throw velocity of this, in m/s. void SetMinThrowVel(float minThrowVel) { m_MinThrowVel = minThrowVel; } - /// /// Gets the maximum throw velocity of this when thrown. - /// - /// The maximum throw velocity of this, in m/s. + /// @return The maximum throw velocity of this, in m/s. float GetMaxThrowVel() const { return m_MaxThrowVel; } - /// /// Sets the maximum throw velocity of this when thrown. - /// - /// The maximum throw velocity of this, in m/s. + /// @param maxThrowVel The maximum throw velocity of this, in m/s. void SetMaxThrowVel(float maxThrowVel) { m_MaxThrowVel = maxThrowVel; } - /// /// Ugly method to deal with lua AI bullshit, by pulling the max throwvel calculation based on arm strength into here. /// If throw velocity is decided by the Arm and not by the ThrownDevice, then the mass of the ThrownDevice and the angular velocity of the root parent Actor will be taken into account. - /// - /// The max throw vel to use. + /// @return The max throw vel to use. float GetCalculatedMaxThrowVelIncludingArmThrowStrength(); - /// /// If true then the explosive will not activate until it's released. - /// - /// Whether this ThrownDevice is supposed to only activate when it's released. + /// @return Whether this ThrownDevice is supposed to only activate when it's released. bool ActivatesWhenReleased() const { return m_ActivatesWhenReleased; } #pragma endregion #pragma region Virtual Override Methods - /// /// Resets all the timers used by this (e.g. emitters, etc). This is to prevent backed up emissions from coming out all at once while this has been held dormant in an inventory. - /// void ResetAllTimers() override; - /// /// Activates this Device as long as it's not set to activate when released or it has no parent. - /// void Activate() override; - /// /// Does the calculations necessary to detect whether this ThrownDevice is at rest or not. IsAtRest() retrieves the answer. - /// void RestDetection() override { HeldDevice::RestDetection(); if (m_Activated) { @@ -160,9 +120,7 @@ namespace RTE { const MovableObject* m_StrikerLever; //!< Striker lever particle MovableObject preset instance. private: - /// /// Clears all the member variables of this ThrownDevice, effectively resetting the members of this abstraction level only. - /// void Clear(); // Disallow the use of some implicit methods. diff --git a/Source/Entities/Turret.cpp b/Source/Entities/Turret.cpp index 40c1a63915..6e2613226d 100644 --- a/Source/Entities/Turret.cpp +++ b/Source/Entities/Turret.cpp @@ -7,15 +7,11 @@ namespace RTE { ConcreteClassInfo(Turret, Attachable, 20); - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void Turret::Clear() { m_MountedDevices.clear(); m_MountedDeviceRotationOffset = 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int Turret::Create(const Turret& reference) { if (!reference.m_MountedDevices.empty()) { for (const HeldDevice* referenceMountedDevice: reference.m_MountedDevices) { @@ -30,8 +26,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void Turret::Destroy(bool notInherited) { if (!notInherited) { Attachable::Destroy(); @@ -42,8 +36,6 @@ namespace RTE { Clear(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int Turret::ReadProperty(const std::string_view& propName, Reader& reader) { StartPropertyList(return Attachable::ReadProperty(propName, reader)); @@ -54,8 +46,6 @@ namespace RTE { EndPropertyList; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int Turret::Save(Writer& writer) const { Attachable::Save(writer); @@ -69,8 +59,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void Turret::SetFirstMountedDevice(HeldDevice* newMountedDevice) { if (HasMountedDevice()) { RemoveAndDeleteAttachable(m_MountedDevices[0]); @@ -95,8 +83,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void Turret::AddMountedDevice(HeldDevice* newMountedDevice) { if (newMountedDevice == nullptr) { return; @@ -119,8 +105,6 @@ namespace RTE { newMountedDevice->SetSupportAvailable(true); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void Turret::Update() { for (HeldDevice* mountedDevice: m_MountedDevices) { mountedDevice->SetRotAngle(m_Rotation.GetRadAngle() + m_MountedDeviceRotationOffset); @@ -128,8 +112,6 @@ namespace RTE { Attachable::Update(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void Turret::Draw(BITMAP* pTargetBitmap, const Vector& targetPos, DrawMode mode, bool onlyPhysical) const { Attachable::Draw(pTargetBitmap, targetPos, mode, onlyPhysical); // TODO replace this with a relative draw order property or something that lets you organize attachable drawing so it doesn't need special hardcoding crap. Use this for ahuman limbs and arm held mo if possible. @@ -140,8 +122,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void Turret::SetParent(MOSRotating* newParent) { Attachable::SetParent(newParent); for (HeldDevice* mountedDevice: m_MountedDevices) { @@ -149,8 +129,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void Turret::RemoveMountedDevice(const HeldDevice* mountedDeviceToRemove) { std::vector::iterator mountedDeviceIterator = std::find_if(m_MountedDevices.begin(), m_MountedDevices.end(), [&mountedDeviceToRemove](const HeldDevice* mountedDevice) { return mountedDevice == mountedDeviceToRemove; diff --git a/Source/Entities/Turret.h b/Source/Entities/Turret.h index f7205ea4b7..335e5a2951 100644 --- a/Source/Entities/Turret.h +++ b/Source/Entities/Turret.h @@ -7,9 +7,7 @@ namespace RTE { class HeldDevice; - /// /// An Attachable Turret pod that can hold HeldDevices. - /// class Turret : public Attachable { public: @@ -18,34 +16,24 @@ namespace RTE { ClassInfoGetters; #pragma region Creation - /// /// Constructor method used to instantiate a Turret object in system memory. Create() should be called before using the object. - /// Turret() { Clear(); } - /// /// Creates a Turret to be identical to another, by deep copy. - /// - /// A reference to the Turret to deep copy. - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @param reference A reference to the Turret to deep copy. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create(const Turret& reference); #pragma endregion #pragma region Destruction - /// /// Destructor method used to clean up a Turret object before deletion from system memory. - /// ~Turret() override { Destroy(true); } - /// /// Destroys and resets (through Clear()) the Turret object. - /// - /// Whether to only destroy the members defined in this derived class, or to destroy all inherited members also. + /// @param notInherited Whether to only destroy the members defined in this derived class, or to destroy all inherited members also. void Destroy(bool notInherited = false) override; - /// /// Resets the entire Turret, including its inherited members, to their default settings or values. - /// void Reset() override { Clear(); Attachable::Reset(); @@ -53,73 +41,53 @@ namespace RTE { #pragma endregion #pragma region Getters and Setters - /// /// Indicates whether a HeldDevice is mounted or not. - /// - /// Whether or not a HeldDevice is mounted on this Turret. + /// @return Whether or not a HeldDevice is mounted on this Turret. bool HasMountedDevice() const { return !m_MountedDevices.empty(); } - /// /// Gets the first mounted HeldDevice of this Turret, mostly here for Lua convenience. - /// - /// A pointer to mounted HeldDevice of this Turret. Ownership is NOT transferred! + /// @return A pointer to mounted HeldDevice of this Turret. Ownership is NOT transferred! HeldDevice* GetFirstMountedDevice() const { return m_MountedDevices[0]; } - /// /// Sets the first mounted HeldDevice for this Turret, mostly here for Lua convenience. Ownership IS transferred! /// The current first mounted HeldDevice (if there is one) will be dropped and added to MovableMan. - /// - /// The new HeldDevice to use. + /// @param newMountedDevice The new HeldDevice to use. void SetFirstMountedDevice(HeldDevice* newMountedDevice); - /// /// Gets the vector of mounted HeldDevices for this Turret. - /// - /// The vector of mounted HeldDevices for this Turret. + /// @return The vector of mounted HeldDevices for this Turret. const std::vector& GetMountedDevices() const { return m_MountedDevices; } - /// /// Adds a HeldDevice to be mounted on this Turret. Ownership IS transferred! /// Will not remove any other HeldDevices mounted on this Turret. - /// - /// The new HeldDevice to be mounted on this Turret. + /// @param newMountedDevice The new HeldDevice to be mounted on this Turret. void AddMountedDevice(HeldDevice* newMountedDevice); - /// /// Gets the current rotational offset of the mounted HeldDevice from the rest of the Turret. - /// - /// The current rotational offset of the mounted HeldDevice from the rest of the Turret. + /// @return The current rotational offset of the mounted HeldDevice from the rest of the Turret. float GetMountedDeviceRotationOffset() const { return m_MountedDeviceRotationOffset; } - /// /// Sets the current rotational offset of the mounted HeldDevice from the rest of the Turret. - /// - /// The new offset angle in radians, relative from the rest of the Turret. + /// @param newOffsetAngle The new offset angle in radians, relative from the rest of the Turret. void SetMountedDeviceRotationOffset(float newOffsetAngle) { m_MountedDeviceRotationOffset = newOffsetAngle; } #pragma endregion #pragma region Override Methods - /// /// Updates this MovableObject. Supposed to be done every frame. - /// void Update() override; - /// /// Draws this Turret's current graphical representation to a BITMAP of choice. - /// - /// A pointer to a BITMAP to draw on. - /// The absolute position of the target bitmap's upper left corner in the Scene. - /// In which mode to draw in. See the DrawMode enumeration for the modes. - /// Whether to not draw any extra 'ghost' items of this MovableObject, indicator arrows or hovering HUD text and so on. + /// @param pTargetBitmap A pointer to a BITMAP to draw on. + /// @param targetPos The absolute position of the target bitmap's upper left corner in the Scene. + /// @param mode In which mode to draw in. See the DrawMode enumeration for the modes. + /// @param onlyPhysical Whether to not draw any extra 'ghost' items of this MovableObject, indicator arrows or hovering HUD text and so on. void Draw(BITMAP* pTargetBitmap, const Vector& targetPos = Vector(), DrawMode mode = g_DrawColor, bool onlyPhysical = false) const override; #pragma endregion protected: - /// /// Sets this Attachable's parent MOSRotating, and also sets its Team based on its parent and, if the Attachable is set to collide, adds/removes Atoms to its new/old parent. /// Additionally, deactivates all MountedDevices. - /// - /// A pointer to the MOSRotating to set as the new parent. Ownership is NOT transferred! + /// @param newParent A pointer to the MOSRotating to set as the new parent. Ownership is NOT transferred! void SetParent(MOSRotating* newParent) override; static Entity::ClassInfo m_sClass; //!< ClassInfo for this class. @@ -129,15 +97,11 @@ namespace RTE { std::vector m_MountedDevices; //!< Vector of pointers to the mounted HeldDevices of this Turret, if any. Owned here. float m_MountedDeviceRotationOffset; //!< The relative offset angle (in radians) of the mounted HeldDevice from this Turret's rotation. - /// /// Removes the HeldDevice from this turret's vector of mounted devices if it's in there. This releases the unique_ptr for it, leaving the caller to take care of it. - /// - /// A pointer to the mounted device to remove. + /// @param mountedDeviceToRemove A pointer to the mounted device to remove. void RemoveMountedDevice(const HeldDevice* mountedDeviceToRemove); - /// /// Clears all the member variables of this Turret, effectively resetting the members of this abstraction level only. - /// void Clear(); // Disallow the use of some implicit methods. diff --git a/Source/GUI/GUI.h b/Source/GUI/GUI.h index 29a658a810..689ebb2745 100644 --- a/Source/GUI/GUI.h +++ b/Source/GUI/GUI.h @@ -10,9 +10,7 @@ #endif #pragma region Rectangle Structure -/// /// The GUIRect structure defines a rectangle by the coordinates of its upper-left and lower-right corners. -/// struct GUIRect { long left; long top; @@ -20,14 +18,12 @@ struct GUIRect { long bottom; }; -/// /// Sets the bounds of a GUIRect. -/// -/// Pointer to the GUIRect. -/// Position of top left corner on X axis. -/// Position of top left corner on Y axis. -/// Position of bottom right corner on X axis. -/// Position of bottom right corner on Y axis. +/// @param pRect Pointer to the GUIRect. +/// @param left Position of top left corner on X axis. +/// @param top Position of top left corner on Y axis. +/// @param right Position of bottom right corner on X axis. +/// @param bottom Position of bottom right corner on Y axis. inline void SetRect(GUIRect* rect, int left, int top, int right, int bottom) { rect->left = left; rect->top = top; diff --git a/Source/GUI/GUIBanner.cpp b/Source/GUI/GUIBanner.cpp index 920dc5f902..16345d1391 100644 --- a/Source/GUI/GUIBanner.cpp +++ b/Source/GUI/GUIBanner.cpp @@ -1,15 +1,3 @@ -////////////////////////////////////////////////////////////////////////////////////////// -// File: GUIBanner.cpp -////////////////////////////////////////////////////////////////////////////////////////// -// Description: GUIBanner class -// Project: Retro Terrain Engine -// Author(s): Daniel Tabar -// data@datarealms.com -// http://www.datarealms.com - -////////////////////////////////////////////////////////////////////////////////////////// -// Inclusions of header files - #include "GUIBanner.h" #include "ContentFile.h" @@ -18,12 +6,6 @@ namespace RTE { std::map GUIBanner::m_sFontCache; std::map GUIBanner::m_sCharCapCache; - ////////////////////////////////////////////////////////////////////////////////////////// - // Constructor: GUIBanner - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Constructor method used to instantiate a GUIBanner object in system - // memory. - GUIBanner::GUIBanner() { m_pFontImage[REGULAR] = 0; m_pFontImage[BLURRED] = 0; @@ -47,11 +29,6 @@ namespace RTE { m_FrameTimer.Reset(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Create the font from an image file. - bool GUIBanner::Create(const std::string fontFilePath, const std::string fontBlurFilePath, int bitDepth) { // Package the font bitmap paths o they are more easily processed below std::string filePaths[2] = {fontFilePath, fontBlurFilePath}; @@ -175,22 +152,11 @@ namespace RTE { return true; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destroys the font data - void GUIBanner::Destroy() { m_BannerText.clear(); m_BannerChars.clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SpaceBetween - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Tells how much space, in pixels, currently exists between two flying - // characters. - int GUIBanner::SpaceBetween(const FlyingChar& first, FontMode firstMode, const FlyingChar& second, FontMode secondMode) const { if (first.m_PosX < second.m_PosX) return second.m_PosX - first.m_PosX - CalculateWidth(first.m_Character, firstMode); @@ -198,11 +164,6 @@ namespace RTE { return first.m_PosX - second.m_PosX - CalculateWidth(second.m_Character, secondMode); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ShowText - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Starts the display animation of a text string in this banner's font. - void GUIBanner::ShowText(const std::string& text, AnimMode mode, long duration, Vector targetSize, float yOnTarget, int flySpeed, int flySpacing) { m_BannerText = text; m_AnimMode = mode; @@ -272,11 +233,6 @@ namespace RTE { } */ - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Update - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the position of the flying characters of this banner. - void GUIBanner::Update() { double deltaS = m_FrameTimer.GetElapsedRealTimeS(); @@ -361,11 +317,6 @@ namespace RTE { m_FrameTimer.Reset(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Draw - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws text to a bitmap. - void GUIBanner::Draw(BITMAP* pTargetBitmap) { // Only bother drawing if things are visible at all if (m_AnimState < SHOWING || m_AnimState > HIDING) @@ -400,11 +351,6 @@ namespace RTE { } } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: CalculateWidth - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Calculates the width of a piece of text. - int GUIBanner::CalculateWidth(const std::string text, FontMode mode) const { unsigned char c; int Width = 0; @@ -438,11 +384,6 @@ namespace RTE { return Width; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: CalculateWidth - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Calculates the width of a piece of text. - int GUIBanner::CalculateWidth(const char Character, FontMode mode) const { unsigned char c = Character; if (c >= 32 && c < m_CharIndexCap) diff --git a/Source/GUI/GUIBanner.h b/Source/GUI/GUIBanner.h index b97477bcc1..d2454a9012 100644 --- a/Source/GUI/GUIBanner.h +++ b/Source/GUI/GUIBanner.h @@ -1,15 +1,10 @@ #ifndef _GUIBANNER_ #define _GUIBANNER_ -////////////////////////////////////////////////////////////////////////////////////////// -// File: GUIBanner.h -////////////////////////////////////////////////////////////////////////////////////////// -// Description: GUIBanner class -// Project: Retro Terrain Engine -// Author(s): Daniel Tabar -// data@datarealms.com -// http://www.datarealms.com - +/// GUIBanner class +/// @author Daniel Tabar +/// data@datarealms.com +/// http://www.datarealms.com #include "Vector.h" #include "Timer.h" #include "allegro.h" @@ -20,19 +15,11 @@ struct BITMAP; namespace RTE { - ////////////////////////////////////////////////////////////////////////////////////////// - // Class: GUIBanner - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: A class to handle the drawing of LARGE text banners that fly across - // the screen, grabbing the player's attention. - // Parent(s): None. - // Class history: 5/7/2011 GUIBanner Created. - + /// A class to handle the drawing of LARGE text banners that fly across + /// the screen, grabbing the player's attention. class GUIBanner { - ////////////////////////////////////////////////////////////////////////////////////////// - // Public member variable, method and friend function declarations - + /// Public member variable, method and friend function declarations public: enum FontMode { REGULAR = 0, @@ -80,151 +67,80 @@ namespace RTE { float m_Speed; }; - ////////////////////////////////////////////////////////////////////////////////////////// - // Constructor: GUIBanner - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Constructor method used to instantiate a GUIBanner object in system - // memory. - // Arguments: None. - // Return value: None. - + /// Constructor method used to instantiate a GUIBanner object in system + /// memory. GUIBanner(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Create the font from an image file. - // Arguments: Path to the font bitmap file. - // Path to the blurred font bitmap file. - // At which color bit depth to load the font files as. - // Return value: None. - + /// Create the font from an image file. + /// @param fontFilePath Path to the font bitmap file. + /// @param fontBlurFilePath Path to the blurred font bitmap file. + /// @param bitDepth At which color bit depth to load the font files as. bool Create(const std::string fontFilePath, const std::string fontBlurFilePath, int bitDepth); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destroys the font data - // Arguments: None. - // Return value: None. - + /// Destroys the font data void Destroy(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetBannerText - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the currently displayed text string. - // Arguments: None. - // Return value: The currently displayed text string. - + /// Gets the currently displayed text string. + /// @return The currently displayed text string. std::string GetBannerText() const { return m_BannerText; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetAnimState - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the current state of the overall animation of this banner. - // Arguments: None. - // Return value: The current state of the animation. - + /// Gets the current state of the overall animation of this banner. + /// @return The current state of the animation. AnimState GetAnimState() const { return m_AnimState; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: IsVisible - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Tells whether this banner is currently showing anything on screen. - // Arguments: None. - // Return value: Whether this is showing anything presently. - + /// Tells whether this banner is currently showing anything on screen. + /// @return Whether this is showing anything presently. bool IsVisible() const { return m_AnimState >= SHOWING && m_AnimState <= HIDING; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: CalculateWidth - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Calculates the width of a piece of text. - // Arguments: Text. - // Return value: None. - + /// Calculates the width of a piece of text. + /// @param Text Text. int CalculateWidth(const std::string Text, FontMode mode) const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: CalculateWidth - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Calculates the width of a piece of text. - // Arguments: Character. - // Return value: None. - + /// Calculates the width of a piece of text. + /// @param Character Character. int CalculateWidth(const char Character, FontMode mode) const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetFontHeight - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the font height. - // Arguments: None. - // Return value: The font height in pixels. - + /// Gets the font height. + /// @return The font height in pixels. int GetFontHeight() const { return m_FontHeight; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetKerning - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Get the character kerning (spacing) - // Arguments: None. - // Return value: Spacing between characters, in pixels. 1 = one empty pixel - // between chars, 0 = chars are touching. - + /// Get the character kerning (spacing) + /// @return Spacing between characters, in pixels. 1 = one empty pixel + /// between chars, 0 = chars are touching. int GetKerning() const { return m_Kerning; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetKerning - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Set the character kerning (spacing), in pixels. 1 = one empty pixel - // between chars, 0 = chars are touching. - // Arguments: The new kerning value. - // Return value: None. - + /// Set the character kerning (spacing), in pixels. 1 = one empty pixel + /// between chars, 0 = chars are touching. + /// @param newKerning The new kerning value. (default: 1) void SetKerning(int newKerning = 1) { m_Kerning = newKerning; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SpaceBetween - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Tells how much space, in pixels, currently exists between two flying - // characters. - // Arguments: The first FlyingChar. - // The font mode of the first character. - // The second FlyingChar. - // The font mode of the second character. - // Return value: The space, in pixels. - + /// Tells how much space, in pixels, currently exists between two flying + /// characters. + /// @param first The first FlyingChar. + /// @param firstMode The font mode of the first character. + /// @param second The second FlyingChar. + /// @param secondMode The font mode of the second character. + /// @return The space, in pixels. int SpaceBetween(const FlyingChar& first, FontMode firstMode, const FlyingChar& second, FontMode secondMode) const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ShowText - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Starts the display animation of a text string in this banner's font. - // This only needs to be called once per display animation. Any currently - // played animation will be interrupted and the banner restarted. - // Arguments: The text to display. - // The animation mode to display the text in. - // The duration of the animation the text is displayed in. Negative value - // means the text pauses at the display/center until HideText is called. - // The width and height of the bitmap target this will be displayed on. - // The Y position the banner should appear on the target, in normalized - // value. 0.5 = banner midline is centered on halfway down the target. - // The speed at which the characters will fly, in pixels per second. - // The spacing between the flying characters, in pixels. - // Return value: None. - + /// Starts the display animation of a text string in this banner's font. + /// This only needs to be called once per display animation. Any currently + /// played animation will be interrupted and the banner restarted. + /// @param text The text to display. + /// @param mode The animation mode to display the text in. + /// @param duration The duration of the animation the text is displayed in. Negative value + /// means the text pauses at the display/center until HideText is called. + /// @param targetSize The width and height of the bitmap target this will be displayed on. + /// @param yOnTarget The Y position the banner should appear on the target, in normalized + /// value. 0.5 = banner midline is centered on halfway down the target. + /// @param flySpeed The speed at which the characters will fly, in pixels per second. (default: 1500) + /// @param flySpacing The spacing between the flying characters, in pixels. (default: 100) void ShowText(const std::string& text, AnimMode mode, long duration, Vector targetSize, float yOnTarget, int flySpeed = 1500, int flySpacing = 100); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: HideText - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Tells the banner to animate away elegantly. Especially useful when - // a ShowText is waiting with a negative duration. - // Arguments: The speed at which the characters will fly, in pixels per second. - // The spacing between the flying characters, in pixels. - // Return value: None. - + /// Tells the banner to animate away elegantly. Especially useful when + /// a ShowText is waiting with a negative duration. + /// @param flySpeed The speed at which the characters will fly, in pixels per second. (default: 1500) + /// @param flySpacing The spacing between the flying characters, in pixels. (default: 100) void HideText(int flySpeed = 1500, int flySpacing = 100) { if (m_AnimState <= SHOW) { m_AnimState = HIDING; @@ -233,40 +149,21 @@ namespace RTE { m_FlySpacing = flySpacing; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ClearText - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Abruptly clears any text without animating it away. Resets this thing. - // Arguments: None. - // Return value: None. - + /// Abruptly clears any text without animating it away. Resets this thing. void ClearText() { m_BannerText.clear(); m_BannerChars.clear(); m_AnimState = NOTSTARTED; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Update - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the position of the flying characters of this banner. - // Arguments: None. - // Return value: None. - + /// Updates the position of the flying characters of this banner. void Update(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Draw - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws text to a bitmap. - // Arguments: The target bitmap to draw to. - // Return value: None. - + /// Draws text to a bitmap. + /// @param pTargetBitmap The target bitmap to draw to. void Draw(BITMAP* pTargetBitmap); - ////////////////////////////////////////////////////////////////////////////////////////// - // Private member variable and method declarations - + /// Private member variable and method declarations private: // Font bitmap files - not owned BITMAP* m_pFontImage[FONTMODECOUNT]; diff --git a/Source/GUI/GUIButton.cpp b/Source/GUI/GUIButton.cpp index f6a53ac61f..8b48e88c6e 100644 --- a/Source/GUI/GUIButton.cpp +++ b/Source/GUI/GUIButton.cpp @@ -5,8 +5,6 @@ using namespace RTE; -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIButton::GUIButton(GUIManager* Manager, GUIControlManager* ControlManager) : GUIControl(), GUIPanel(Manager) { m_ControlID = "BUTTON"; @@ -19,8 +17,6 @@ GUIButton::GUIButton(GUIManager* Manager, GUIControlManager* ControlManager) : m_BorderSizes = nullptr; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIButton::Create(const std::string& Name, int X, int Y, int Width, int Height) { GUIControl::Create(Name, X, Y, Width, Height); @@ -66,8 +62,6 @@ void GUIButton::Create(const std::string& Name, int X, int Y, int Width, int Hei } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIButton::Create(GUIProperties* Props) { GUIControl::Create(Props); @@ -114,8 +108,6 @@ void GUIButton::Create(GUIProperties* Props) { m_Text->SetVerticalOverflowScroll(overflowScroll); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIButton::Destroy() { // Free the drawing bitmap if (m_DrawBitmap) { @@ -125,8 +117,6 @@ void GUIButton::Destroy() { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIButton::ChangeSkin(GUISkin* Skin) { GUIControl::ChangeSkin(Skin); @@ -134,8 +124,6 @@ void GUIButton::ChangeSkin(GUISkin* Skin) { BuildBitmap(); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIButton::BuildBitmap() { // Free any old bitmap if (m_DrawBitmap) { @@ -234,8 +222,6 @@ void GUIButton::BuildBitmap() { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIButton::Draw(GUIScreen* Screen) { GUIRect Rect; int y = 0; @@ -255,8 +241,6 @@ void GUIButton::Draw(GUIScreen* Screen) { GUIPanel::Draw(Screen); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIButton::OnMouseDown(int X, int Y, int Buttons, int Modifier) { if (Buttons & MOUSE_LEFT) { SetPushed(true); @@ -267,8 +251,6 @@ void GUIButton::OnMouseDown(int X, int Y, int Buttons, int Modifier) { SetFocus(); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIButton::OnMouseUp(int X, int Y, int Buttons, int Modifier) { if (PointInside(X, Y)) { AddEvent(GUIEvent::Notification, Clicked, Buttons); @@ -289,8 +271,6 @@ void GUIButton::OnMouseUp(int X, int Y, int Buttons, int Modifier) { AddEvent(GUIEvent::Notification, UnPushed, 0); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIButton::OnMouseEnter(int X, int Y, int Buttons, int Modifier) { m_Over = true; m_Text->ActivateDeactivateOverflowScroll(true); @@ -298,8 +278,6 @@ void GUIButton::OnMouseEnter(int X, int Y, int Buttons, int Modifier) { AddEvent(GUIEvent::Notification, Focused, 0); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIButton::OnMouseLeave(int X, int Y, int Buttons, int Modifier) { m_Over = false; if (!m_GotFocus && !m_Pushed) { @@ -308,15 +286,11 @@ void GUIButton::OnMouseLeave(int X, int Y, int Buttons, int Modifier) { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIButton::OnGainFocus() { GUIPanel::OnGainFocus(); m_Text->ActivateDeactivateOverflowScroll(true); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIButton::OnLoseFocus() { GUIPanel::OnLoseFocus(); if (!m_Over && !m_Pushed) { @@ -325,8 +299,6 @@ void GUIButton::OnLoseFocus() { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIButton::OnMouseMove(int X, int Y, int Buttons, int Modifier) { if (!(Buttons & MOUSE_LEFT) || !IsCaptured()) { return; @@ -346,39 +318,27 @@ void GUIButton::OnMouseMove(int X, int Y, int Buttons, int Modifier) { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIButton::OnKeyDown(int KeyCode, int Modifier) { } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIPanel* GUIButton::GetPanel() { return this; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIButton::GetControlRect(int* X, int* Y, int* Width, int* Height) { GUIPanel::GetRect(X, Y, Width, Height); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIButton::StoreProperties() { m_Properties.AddVariable("Text", m_Text->GetText()); m_Properties.AddVariable("HorizontalOverflowScroll", m_Text->GetHorizontalOverflowScroll()); m_Properties.AddVariable("VerticalOverflowScroll", m_Text->GetVerticalOverflowScroll()); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIButton::Move(int X, int Y) { GUIPanel::SetPositionAbs(X, Y); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIButton::Resize(int Width, int Height) { // Make sure the button isn't too small Width = std::max(Width, m_MinWidth); @@ -389,8 +349,6 @@ void GUIButton::Resize(int Width, int Height) { BuildBitmap(); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIButton::SetPushed(bool pushed) { m_Pushed = pushed; if (pushed) { @@ -401,8 +359,6 @@ void GUIButton::SetPushed(bool pushed) { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIButton::SetText(const std::string_view& newText, bool noBitmapRebuild) { if (GetText() != newText) { m_Text->SetText(newText); @@ -412,14 +368,10 @@ void GUIButton::SetText(const std::string_view& newText, bool noBitmapRebuild) { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - const std::string& GUIButton::GetText() const { return m_Text->GetText(); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIButton::SetHorizontalOverflowScroll(bool newOverflowScroll) { m_Text->SetHorizontalOverflowScroll(newOverflowScroll); if (m_Text->GetHorizontalOverflowScroll()) { @@ -427,8 +379,6 @@ void GUIButton::SetHorizontalOverflowScroll(bool newOverflowScroll) { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIButton::SetVerticalOverflowScroll(bool newOverflowScroll) { m_Text->SetVerticalOverflowScroll(newOverflowScroll); if (m_Text->GetVerticalOverflowScroll()) { @@ -436,8 +386,6 @@ void GUIButton::SetVerticalOverflowScroll(bool newOverflowScroll) { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIButton::SetIcon(BITMAP* newIcon, bool noBitmapRebuild) { if (m_Icon && m_Icon->GetBitmap() != newIcon) { m_Icon->SetBitmap(newIcon); @@ -447,8 +395,6 @@ void GUIButton::SetIcon(BITMAP* newIcon, bool noBitmapRebuild) { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIButton::SetIconAndText(BITMAP* newIcon, const std::string_view& newText) { bool bitmapNeedsRebuild = (m_Icon && m_Icon->GetBitmap() != newIcon) || (m_Text && m_Text->GetText() != newText); SetIcon(newIcon, true); @@ -458,8 +404,6 @@ void GUIButton::SetIconAndText(BITMAP* newIcon, const std::string_view& newText) } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIButton::ApplyProperties(GUIProperties* Props) { GUIControl::ApplyProperties(Props); diff --git a/Source/GUI/GUIButton.h b/Source/GUI/GUIButton.h index 2111c0a9e0..5722df55dc 100644 --- a/Source/GUI/GUIButton.h +++ b/Source/GUI/GUIButton.h @@ -5,9 +5,7 @@ namespace RTE { class GUILabel; - /// /// A button control class. - /// class GUIButton : public GUIControl, public GUIPanel { public: @@ -19,236 +17,126 @@ namespace RTE { Focused } Notification; - ////////////////////////////////////////////////////////////////////////////////////////// - // Constructor: GUIButton - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Constructor method used to instantiate a GUIButton object in - // system memory. - // Arguments: GUIManager, GUIControlManager. - + /// Constructor method used to instantiate a GUIButton object in + /// system memory. + /// @param Manager GUIManager, GUIControlManager. GUIButton(GUIManager* Manager, GUIControlManager* ControlManager); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the control has been created. - // Arguments: Name, Position. - + /// Called when the control has been created. + /// @param Name Name, Position. void Create(const std::string& Name, int X, int Y, int Width = -1, int Height = -1) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the control has been destroyed. - // Arguments: None. - + /// Called when the control has been destroyed. void Destroy() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the control has been created. - // Arguments: Properties. - + /// Called when the control has been created. + /// @param Props Properties. void Create(GUIProperties* Props) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ChangeSkin - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the skin has been changed. - // Arguments: New skin pointer. - + /// Called when the skin has been changed. + /// @param Skin New skin pointer. void ChangeSkin(GUISkin* Skin) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Draw - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws the panel - // Arguments: Screen class - + /// Draws the panel + /// @param Screen Screen class void Draw(GUIScreen* Screen) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: OnMouseDown - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the mouse goes down on the panel - // Arguments: Mouse Position, Mouse Buttons, Modifier. - + /// Called when the mouse goes down on the panel + /// @param X Mouse Position, Mouse Buttons, Modifier. void OnMouseDown(int X, int Y, int Buttons, int Modifier) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: OnMouseUp - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the mouse goes up on the panel - // Arguments: Mouse Position, Mouse Buttons, Modifier. - + /// Called when the mouse goes up on the panel + /// @param X Mouse Position, Mouse Buttons, Modifier. void OnMouseUp(int X, int Y, int Buttons, int Modifier) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: OnMouseMove - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the mouse moves (over the panel, or when captured). - // Arguments: Mouse Position, Mouse Buttons, Modifier. - + /// Called when the mouse moves (over the panel, or when captured). + /// @param X Mouse Position, Mouse Buttons, Modifier. void OnMouseMove(int X, int Y, int Buttons, int Modifier) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: OnMouseEnter - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the mouse enters the panel. - // Arguments: Mouse Position, Mouse Buttons, Modifier. - + /// Called when the mouse enters the panel. + /// @param X Mouse Position, Mouse Buttons, Modifier. void OnMouseEnter(int X, int Y, int Buttons, int Modifier) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: OnMouseLeave - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the mouse leaves the panel. - // Arguments: Mouse Position, Mouse Buttons, Modifier. - + /// Called when the mouse leaves the panel. + /// @param X Mouse Position, Mouse Buttons, Modifier. void OnMouseLeave(int X, int Y, int Buttons, int Modifier) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: OnGainFocus - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the panel gains focus. - // Arguments: None. - + /// Called when the panel gains focus. void OnGainFocus() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: OnLoseFocus - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the panel looses focus. - // Arguments: None. - + /// Called when the panel looses focus. void OnLoseFocus() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual Method: OnKeyDown - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when a key goes down. - // Arguments: KeyCode, Modifier. - + /// Called when a key goes down. + /// @param KeyCode KeyCode, Modifier. void OnKeyDown(int KeyCode, int Modifier) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetPanel - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns the panel of the control. - // Arguments: None. - // Returns: 0 if the control does not have a panel, otherwise the topmost panel. - + /// Returns the panel of the control. + /// @return 0 if the control does not have a panel, otherwise the topmost panel. GUIPanel* GetPanel() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetControlID - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns a string representing the control's ID - // Arguments: None. - + /// Returns a string representing the control's ID static std::string GetControlID() { return "BUTTON"; }; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetControlRect - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the rectangle of the control. - // Arguments: Position, Size. - + /// Gets the rectangle of the control. + /// @param X Position, Size. void GetControlRect(int* X, int* Y, int* Width, int* Height) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: StoreProperties - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the control to store the values into properties. - // Arguments: None. - + /// Gets the control to store the values into properties. void StoreProperties() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Move - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the control needs to be moved. - // Arguments: New position. - + /// Called when the control needs to be moved. + /// @param X New position. void Move(int X, int Y) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Resize - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the control needs to be resized. - // Arguments: New size. - + /// Called when the control needs to be resized. + /// @param Width New size. void Resize(int Width, int Height) override; - /// /// Gets whether or not this button is currently pushed. - /// - /// Whether or not this button is currently pushed. + /// @return Whether or not this button is currently pushed. bool IsPushed() const { return m_Pushed; } - /// /// Sets whether or not this button is currently pushed. - /// - /// Whether or not this button should be pushed. + /// @param pushed Whether or not this button should be pushed. void SetPushed(bool pushed = false); - /// /// Gets whether or not this button is currently being moused over. - /// - /// Whether or not this button is currently being moused over. + /// @return Whether or not this button is currently being moused over. bool IsMousedOver() const { return m_Over; } - /// /// Gets the text of this GUIButton's GUILabel. - /// - /// The text of this GUIButton's GUILabel. + /// @return The text of this GUIButton's GUILabel. const std::string& GetText() const; - /// /// Sets the text of this GUIButton's GUILabel. - /// - /// The new text for this GUIButton's GUILabel. - /// Lets this method NOT rebuild the button bitmap, even if the icon has changed. Defaults to false and should almost always stay that way. + /// @param newText The new text for this GUIButton's GUILabel. + /// @param noBitmapRebuild Lets this method NOT rebuild the button bitmap, even if the icon has changed. Defaults to false and should almost always stay that way. void SetText(const std::string_view& newText, bool noBitmapRebuild = false); - /// /// Sets whether or not this GUIButton's text should scroll horizontally (right) when it overflows the button. - /// - /// Whether or not this GUIButton's text should scroll horizontally when it overflows. + /// @param newOverflowScroll Whether or not this GUIButton's text should scroll horizontally when it overflows. void SetHorizontalOverflowScroll(bool newOverflowScroll); - /// /// Sets whether or not this GUIButton's text should scroll vertically (down) when it overflows the button. - /// - /// Whether or not this GUIButton's text should scroll vertically when it overflows. + /// @param newOverflowScroll Whether or not this GUIButton's text should scroll vertically when it overflows. void SetVerticalOverflowScroll(bool newOverflowScroll); - /// /// Gets whether or not this GUIButton has an icon with a Bitmap. - /// bool HasIcon() const { return m_Icon->GetBitmap(); } - /// /// Sets the icon for this GUIButton. Ownership is NOT transferred. - /// - /// A pointer to the new icon BITMAP for this GUIButton. - /// Lets this method NOT rebuild the button bitmap, even if the icon has changed. Defaults to false and should almost always stay that way. + /// @param newIcon A pointer to the new icon BITMAP for this GUIButton. + /// @param noBitmapRebuild Lets this method NOT rebuild the button bitmap, even if the icon has changed. Defaults to false and should almost always stay that way. void SetIcon(BITMAP* newIcon, bool noBitmapRebuild = false); - /// /// Helper method to set both text and icon for this GUIButton at the same time. - /// - /// A pointer to the new icon BITMAP for this GUIButton. - /// The new text for this GUIButton's GUILabel. + /// @param newIcon A pointer to the new icon BITMAP for this GUIButton. + /// @param newText The new text for this GUIButton's GUILabel. void SetIconAndText(BITMAP* newIcon, const std::string_view& newText); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ApplyProperties - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Applies new properties to the control. - // Arguments: GUIProperties. - + /// Applies new properties to the control. + /// @param Props GUIProperties. void ApplyProperties(GUIProperties* Props) override; private: @@ -260,12 +148,7 @@ namespace RTE { std::unique_ptr m_Icon; std::unique_ptr m_BorderSizes; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: BuildBitmap - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Create the button bitmap to draw. - // Arguments: None. - + /// Create the button bitmap to draw. void BuildBitmap(); }; }; // namespace RTE diff --git a/Source/GUI/GUICheckbox.cpp b/Source/GUI/GUICheckbox.cpp index 6c1d623e9a..0fd5c850ac 100644 --- a/Source/GUI/GUICheckbox.cpp +++ b/Source/GUI/GUICheckbox.cpp @@ -3,8 +3,6 @@ using namespace RTE; -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUICheckbox::GUICheckbox(GUIManager* Manager, GUIControlManager* ControlManager) : GUIControl(), GUIPanel(Manager) { m_ControlID = "CHECKBOX"; @@ -14,8 +12,6 @@ GUICheckbox::GUICheckbox(GUIManager* Manager, GUIControlManager* ControlManager) m_Mouseover = false; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUICheckbox::Create(const std::string& Name, int X, int Y, int Width, int Height) { GUIControl::Create(Name, X, Y, Width, Height); @@ -45,8 +41,6 @@ void GUICheckbox::Create(const std::string& Name, int X, int Y, int Width, int H m_Height = std::max(m_Height, m_MinHeight); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUICheckbox::Create(GUIProperties* Props) { GUIControl::Create(Props); @@ -77,12 +71,8 @@ void GUICheckbox::Create(GUIProperties* Props) { Props->GetValue("Text", &m_Text); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUICheckbox::Destroy() {} -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUICheckbox::ChangeSkin(GUISkin* Skin) { GUIControl::ChangeSkin(Skin); @@ -90,8 +80,6 @@ void GUICheckbox::ChangeSkin(GUISkin* Skin) { BuildBitmap(); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUICheckbox::BuildBitmap() { std::string Filename; unsigned long ColorIndex = 0; @@ -136,8 +124,6 @@ void GUICheckbox::BuildBitmap() { SetRect(&m_ImageRects[3], Values[0], Values[1], Values[0] + Values[2], Values[1] + Values[3]); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUICheckbox::Draw(GUIScreen* Screen) { if (!m_Image) { return; @@ -184,8 +170,6 @@ void GUICheckbox::Draw(GUIScreen* Screen) { GUIPanel::Draw(Screen); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUICheckbox::OnMouseDown(int X, int Y, int Buttons, int Modifier) { if (Buttons & MOUSE_LEFT) { // Push the checkbox down @@ -196,8 +180,6 @@ void GUICheckbox::OnMouseDown(int X, int Y, int Buttons, int Modifier) { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUICheckbox::OnMouseUp(int X, int Y, int Buttons, int Modifier) { ReleaseMouse(); @@ -214,32 +196,22 @@ void GUICheckbox::OnMouseUp(int X, int Y, int Buttons, int Modifier) { AddEvent(GUIEvent::Notification, UnPushed, 0); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUICheckbox::OnMouseEnter(int X, int Y, int Buttons, int Modifier) { m_Mouseover = true; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUICheckbox::OnMouseLeave(int X, int Y, int Buttons, int Modifier) { m_Mouseover = false; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIPanel* GUICheckbox::GetPanel() { return this; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUICheckbox::Move(int X, int Y) { SetPositionAbs(X, Y); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUICheckbox::Resize(int Width, int Height) { // Make sure the control isn't too small Width = std::max(Width, m_MinWidth); @@ -250,14 +222,10 @@ void GUICheckbox::Resize(int Width, int Height) { BuildBitmap(); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUICheckbox::GetControlRect(int* X, int* Y, int* Width, int* Height) { GUIPanel::GetRect(X, Y, Width, Height); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUICheckbox::StoreProperties() { if (m_Check == Unchecked) { m_Properties.AddVariable("Checked", "Unchecked"); @@ -269,32 +237,22 @@ void GUICheckbox::StoreProperties() { m_Properties.AddVariable("Text", m_Text); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUICheckbox::SetText(const std::string& Text) { m_Text = Text; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - std::string GUICheckbox::GetText() const { return m_Text; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUICheckbox::SetCheck(int Check) { m_Check = Check; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int GUICheckbox::GetCheck() const { return m_Check; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUICheckbox::ApplyProperties(GUIProperties* Props) { GUIControl::ApplyProperties(Props); diff --git a/Source/GUI/GUICheckbox.h b/Source/GUI/GUICheckbox.h index 086f2d1588..ce109a1e35 100644 --- a/Source/GUI/GUICheckbox.h +++ b/Source/GUI/GUICheckbox.h @@ -3,9 +3,7 @@ namespace RTE { - /// /// A checkbox control class. - /// class GUICheckbox : public GUIControl, public GUIPanel { public: @@ -23,174 +21,84 @@ namespace RTE { Changed, } Notification; - ////////////////////////////////////////////////////////////////////////////////////////// - // Constructor: GUICheckbox - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Constructor method used to instantiate a GUICheckbox object in - // system memory. - // Arguments: GUIManager, GUIControlManager. - + /// Constructor method used to instantiate a GUICheckbox object in + /// system memory. + /// @param Manager GUIManager, GUIControlManager. GUICheckbox(GUIManager* Manager, GUIControlManager* ControlManager); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the control has been created. - // Arguments: Name, Position. - + /// Called when the control has been created. + /// @param Name Name, Position. void Create(const std::string& Name, int X, int Y, int Width = -1, int Height = -1) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the control has been created. - // Arguments: Properties. - + /// Called when the control has been created. + /// @param Props Properties. void Create(GUIProperties* Props) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the control has been destroyed. - // Arguments: None. - + /// Called when the control has been destroyed. void Destroy() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ChangeSkin - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the skin has been changed. - // Arguments: New skin pointer. - + /// Called when the skin has been changed. + /// @param Skin New skin pointer. void ChangeSkin(GUISkin* Skin) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Draw - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws the panel - // Arguments: Screen class - + /// Draws the panel + /// @param Screen Screen class void Draw(GUIScreen* Screen) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: OnMouseDown - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the mouse goes down on the panel - // Arguments: Mouse Position, Mouse Buttons, Modifier. - + /// Called when the mouse goes down on the panel + /// @param X Mouse Position, Mouse Buttons, Modifier. void OnMouseDown(int X, int Y, int Buttons, int Modifier) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: OnMouseUp - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the mouse goes up on the panel - // Arguments: Mouse Position, Mouse Buttons, Modifier. - + /// Called when the mouse goes up on the panel + /// @param X Mouse Position, Mouse Buttons, Modifier. void OnMouseUp(int X, int Y, int Buttons, int Modifier) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: OnMouseEnter - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the mouse enters the panel. - // Arguments: Mouse Position, Mouse Buttons, Modifier. - + /// Called when the mouse enters the panel. + /// @param X Mouse Position, Mouse Buttons, Modifier. void OnMouseEnter(int X, int Y, int Buttons, int Modifier) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: OnMouseLeave - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the mouse leaves the panel. - // Arguments: Mouse Position, Mouse Buttons, Modifier. - + /// Called when the mouse leaves the panel. + /// @param X Mouse Position, Mouse Buttons, Modifier. void OnMouseLeave(int X, int Y, int Buttons, int Modifier) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetPanel - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns the panel of the control. - // Arguments: None. - // Returns: 0 if the control does not have a panel, otherwise the topmost panel. - + /// Returns the panel of the control. + /// @return 0 if the control does not have a panel, otherwise the topmost panel. GUIPanel* GetPanel() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetControlID - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns a string representing the control's ID - // Arguments: None. - + /// Returns a string representing the control's ID static std::string GetControlID() { return "CHECKBOX"; }; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Move - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the control needs to be moved. - // Arguments: New position. - + /// Called when the control needs to be moved. + /// @param X New position. void Move(int X, int Y) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Resize - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the control needs to be resized. - // Arguments: New size. - + /// Called when the control needs to be resized. + /// @param Width New size. void Resize(int Width, int Height) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetControlRect - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the rectangle of the control. - // Arguments: Position, Size. - + /// Gets the rectangle of the control. + /// @param X Position, Size. void GetControlRect(int* X, int* Y, int* Width, int* Height) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: StoreProperties - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the control to store the values into properties. - // Arguments: None. - + /// Gets the control to store the values into properties. void StoreProperties() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetText - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the text. - // Arguments: Text. - + /// Sets the text. + /// @param Text Text. void SetText(const std::string& Text); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetText - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the text. - // Arguments: None. - + /// Gets the text. std::string GetText() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetCheck - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the check state. - // Arguments: Check state. - + /// Sets the check state. + /// @param Check Check state. void SetCheck(int Check); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetCheck - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the check state. - // Arguments: None. - + /// Gets the check state. int GetCheck() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ApplyProperties - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Applies new properties to the control. - // Arguments: GUIProperties. - + /// Applies new properties to the control. + /// @param Props GUIProperties. void ApplyProperties(GUIProperties* Props) override; private: @@ -201,12 +109,7 @@ namespace RTE { std::string m_Text; int m_Mouseover; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: BuildBitmap - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Create the checkbox bitmap to draw. - // Arguments: None. - + /// Create the checkbox bitmap to draw. void BuildBitmap(); }; }; // namespace RTE diff --git a/Source/GUI/GUICollectionBox.cpp b/Source/GUI/GUICollectionBox.cpp index d1631aac2e..6cbb33a90c 100644 --- a/Source/GUI/GUICollectionBox.cpp +++ b/Source/GUI/GUICollectionBox.cpp @@ -3,8 +3,6 @@ using namespace RTE; -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUICollectionBox::GUICollectionBox(GUIManager* Manager, GUIControlManager* ControlManager) : GUIControl(), GUIPanel(Manager) { m_ControlID = "COLLECTIONBOX"; @@ -18,8 +16,6 @@ GUICollectionBox::GUICollectionBox(GUIManager* Manager, GUIControlManager* Contr m_IsContainer = true; // We are a container } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUICollectionBox::Create(const std::string& Name, int X, int Y, int Width, int Height) { GUIControl::Create(Name, X, Y, Width, Height); @@ -49,8 +45,6 @@ void GUICollectionBox::Create(const std::string& Name, int X, int Y, int Width, m_Height = std::max(m_Height, m_MinHeight); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUICollectionBox::Create(GUIProperties* Props) { GUIControl::Create(Props); @@ -83,15 +77,11 @@ void GUICollectionBox::Create(GUIProperties* Props) { Props->GetValue("DrawColor", &m_DrawColor); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUICollectionBox::Destroy() { delete m_Background; delete m_DrawBitmap; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUICollectionBox::ChangeSkin(GUISkin* Skin) { GUIControl::ChangeSkin(Skin); @@ -99,8 +89,6 @@ void GUICollectionBox::ChangeSkin(GUISkin* Skin) { BuildBitmap(); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUICollectionBox::BuildBitmap() { // Free any old bitmap delete m_DrawBitmap; @@ -112,8 +100,6 @@ void GUICollectionBox::BuildBitmap() { m_Skin->BuildStandardRect(m_DrawBitmap, "CollectionBox_Panel", 0, 0, m_Width, m_Height); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUICollectionBox::Draw(GUIScreen* Screen) { if (m_DrawBackground) { if (m_DrawType == Color) { @@ -140,34 +126,24 @@ void GUICollectionBox::Draw(GUIScreen* Screen) { GUIPanel::Draw(Screen); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUICollectionBox::OnMouseDown(int X, int Y, int Buttons, int Modifier) { CaptureMouse(); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUICollectionBox::OnMouseUp(int X, int Y, int Buttons, int Modifier) { ReleaseMouse(); AddEvent(GUIEvent::Notification, Clicked, Buttons); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUICollectionBox::OnMouseMove(int X, int Y, int Buttons, int Modifier) { AddEvent(GUIEvent::Notification, MouseMove, Buttons); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIPanel* GUICollectionBox::GetPanel() { return this; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUICollectionBox::Move(int X, int Y) { int DX = X - m_X; int DY = Y - m_Y; @@ -189,8 +165,6 @@ void GUICollectionBox::Move(int X, int Y) { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUICollectionBox::Resize(int Width, int Height) { int OldWidth = m_Width; int OldHeight = m_Height; @@ -242,14 +216,10 @@ void GUICollectionBox::Resize(int Width, int Height) { BuildBitmap(); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUICollectionBox::GetControlRect(int* X, int* Y, int* Width, int* Height) { GUIPanel::GetRect(X, Y, Width, Height); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUICollectionBox::SetDrawImage(GUIBitmap* Bitmap) { // Free any old bitmap delete m_DrawBitmap; @@ -257,34 +227,24 @@ void GUICollectionBox::SetDrawImage(GUIBitmap* Bitmap) { m_DrawBitmap = Bitmap; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUICollectionBox::SetDrawBackground(bool DrawBack) { m_DrawBackground = DrawBack; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUICollectionBox::SetDrawType(int Type) { m_DrawType = Type; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUICollectionBox::SetDrawColor(unsigned long Color) { m_DrawColor = Color; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUICollectionBox::StoreProperties() { m_Properties.AddVariable("DrawBackground", m_DrawBackground); m_Properties.AddVariable("DrawType", m_DrawType == Color ? "Color" : "Image"); m_Properties.AddVariable("DrawColor", (int)m_DrawColor); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUICollectionBox::ApplyProperties(GUIProperties* Props) { GUIControl::ApplyProperties(Props); diff --git a/Source/GUI/GUICollectionBox.h b/Source/GUI/GUICollectionBox.h index 184711f14b..001356cd64 100644 --- a/Source/GUI/GUICollectionBox.h +++ b/Source/GUI/GUICollectionBox.h @@ -3,9 +3,7 @@ namespace RTE { - /// /// A collection box control class that contains child controls. - /// class GUICollectionBox : public GUIControl, public GUIPanel { public: @@ -22,199 +20,97 @@ namespace RTE { Panel } DrawType; - ////////////////////////////////////////////////////////////////////////////////////////// - // Constructor: GUICollectionBox - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Constructor method used to instantiate a GUICollectionBox object in - // system memory. - // Arguments: GUIManager, GUIControlManager. - + /// Constructor method used to instantiate a GUICollectionBox object in + /// system memory. + /// @param Manager GUIManager, GUIControlManager. GUICollectionBox(GUIManager* Manager, GUIControlManager* ControlManager); - ////////////////////////////////////////////////////////////////////////////////////////// - // Destructor: ~GUICollectionBox - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destructor method used to clean up this before deletion from memory. - // Arguments: None. - + /// Destructor method used to clean up this before deletion from memory. ~GUICollectionBox() { Destroy(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the control has been created. - // Arguments: Name, Position. - + /// Called when the control has been created. + /// @param Name Name, Position. void Create(const std::string& Name, int X, int Y, int Width = -1, int Height = -1) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the control has been created. - // Arguments: Properties. - + /// Called when the control has been created. + /// @param Props Properties. void Create(GUIProperties* Props) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destroys and frees this' allocated data - // Arguments: None. - + /// Destroys and frees this' allocated data void Destroy() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ChangeSkin - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the skin has been changed. - // Arguments: New skin pointer. - + /// Called when the skin has been changed. + /// @param Skin New skin pointer. void ChangeSkin(GUISkin* Skin) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Draw - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws the panel - // Arguments: Screen class - + /// Draws the panel + /// @param Screen Screen class void Draw(GUIScreen* Screen) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: OnMouseDown - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the mouse goes down on the panel - // Arguments: Mouse Position, Mouse Buttons, Modifier. - + /// Called when the mouse goes down on the panel + /// @param X Mouse Position, Mouse Buttons, Modifier. void OnMouseDown(int X, int Y, int Buttons, int Modifier) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: OnMouseUp - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the mouse goes up on the panel - // Arguments: Mouse Position, Mouse Buttons, Modifier. - + /// Called when the mouse goes up on the panel + /// @param X Mouse Position, Mouse Buttons, Modifier. void OnMouseUp(int X, int Y, int Buttons, int Modifier) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: OnMouseMove - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the mouse moves (over the panel, or when captured). - // Arguments: Mouse Position, Mouse Buttons, Modifier. - + /// Called when the mouse moves (over the panel, or when captured). + /// @param X Mouse Position, Mouse Buttons, Modifier. void OnMouseMove(int X, int Y, int Buttons, int Modifier) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Move - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the control needs to be moved. - // Arguments: New position. - + /// Called when the control needs to be moved. + /// @param X New position. void Move(int X, int Y) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Resize - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the control needs to be resized. - // Arguments: New size. - + /// Called when the control needs to be resized. + /// @param Width New size. void Resize(int Width, int Height) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetControlRect - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the rectangle of the control. - // Arguments: Position, Size. - + /// Gets the rectangle of the control. + /// @param X Position, Size. void GetControlRect(int* X, int* Y, int* Width, int* Height) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetPanel - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns the panel of the control. - // Arguments: None. - // Returns: 0 if the control does not have a panel, otherwise the topmost panel. - + /// Returns the panel of the control. + /// @return 0 if the control does not have a panel, otherwise the topmost panel. GUIPanel* GetPanel() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetControlID - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns a string representing the control's ID - // Arguments: None. - + /// Returns a string representing the control's ID static std::string GetControlID() { return "COLLECTIONBOX"; }; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: StoreProperties - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the control to store the values into properties. - // Arguments: None. - + /// Gets the control to store the values into properties. void StoreProperties() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetDrawImage - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the drawing image bitmap to draw - // Arguments: Bitmap, ownership IS transferred! - + /// Sets the drawing image bitmap to draw + /// @param Bitmap Bitmap, ownership IS transferred! void SetDrawImage(GUIBitmap* Bitmap); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetDrawImage - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the drawing image bitmap that is being drawn - // Arguments: Bitmap, ownership IS NOT transferred! - + /// Gets the drawing image bitmap that is being drawn + /// @param Bitmap, ownership IS NOT transferred! GUIBitmap* GetDrawImage() { return m_DrawBitmap; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetDrawBackground - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets whether to draw the background. - // Arguments: Draw. - + /// Sets whether to draw the background. + /// @param DrawBack Draw. void SetDrawBackground(bool DrawBack); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetDrawType - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the drawing type. - // Arguments: Type. - + /// Sets the drawing type. + /// @param Type Type. void SetDrawType(int Type); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetDrawType - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the current drawing type. - // Arguments: None. - // Returns: Type. - + /// Gets the current drawing type. + /// @return Type. int GetDrawType() const { return m_DrawType; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetDrawColor - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the drawing color. - // Arguments: Color. - + /// Sets the drawing color. + /// @param Color Color. void SetDrawColor(unsigned long Color); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetDrawColor - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the drawing color. - // Returns: Color. - + /// Gets the drawing color. + /// @return Color. unsigned long GetDrawColor() const { return m_DrawColor; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ApplyProperties - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Applies new properties to the control. - // Arguments: GUIProperties. - + /// Applies new properties to the control. + /// @param Props GUIProperties. void ApplyProperties(GUIProperties* Props) override; private: @@ -225,12 +121,7 @@ namespace RTE { unsigned long m_DrawColor; GUIBitmap* m_DrawBitmap; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: BuildBitmap - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Create the button bitmap to draw. - // Arguments: None. - + /// Create the button bitmap to draw. void BuildBitmap(); }; }; // namespace RTE diff --git a/Source/GUI/GUIComboBox.cpp b/Source/GUI/GUIComboBox.cpp index 02ed8f2555..4aafb65121 100644 --- a/Source/GUI/GUIComboBox.cpp +++ b/Source/GUI/GUIComboBox.cpp @@ -3,8 +3,6 @@ using namespace RTE; -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIComboBox::GUIComboBox(GUIManager* Manager, GUIControlManager* ControlManager) : GUIControl(), GUIPanel(Manager) { m_ControlID = "COMBOBOX"; @@ -25,8 +23,6 @@ GUIComboBox::GUIComboBox(GUIManager* Manager, GUIControlManager* ControlManager) m_Button = new GUIComboBoxButton(Manager); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIComboBox::Create(const std::string& Name, int X, int Y, int Width, int Height) { GUIControl::Create(Name, X, Y, Width, Height); @@ -74,8 +70,6 @@ void GUIComboBox::Create(const std::string& Name, int X, int Y, int Width, int H GUIPanel::AddChild(m_Button); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIComboBox::Create(GUIProperties* Props) { GUIControl::Create(Props); @@ -125,8 +119,6 @@ void GUIComboBox::Create(GUIProperties* Props) { m_TextPanel->SetLocked((m_DropDownStyle == DropDownList)); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIComboBox::Destroy() { // Free the panels if (m_ListPanel) { @@ -150,8 +142,6 @@ void GUIComboBox::Destroy() { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIComboBox::Activate() { m_TextPanel->SetPositionAbs(m_X, m_Y); @@ -165,8 +155,6 @@ void GUIComboBox::Activate() { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIComboBox::ChangeSkin(GUISkin* Skin) { GUIControl::ChangeSkin(Skin); @@ -193,8 +181,6 @@ void GUIComboBox::ChangeSkin(GUISkin* Skin) { m_Button->ChangeSkin(Skin); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIComboBox::Draw(GUIScreen* Screen) { // Draw the background m_DrawBitmap->Draw(Screen->GetBitmap(), m_X, m_Y, nullptr); @@ -207,14 +193,10 @@ void GUIComboBox::Draw(GUIScreen* Screen) { GUIPanel::Draw(Screen); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIPanel* GUIComboBox::GetPanel() { return this; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIComboBox::ReceiveSignal(GUIPanel* Source, int Code, int Data) { assert(Source); @@ -316,41 +298,29 @@ void GUIComboBox::ReceiveSignal(GUIPanel* Source, int Code, int Data) { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIComboBox::BeginUpdate() { m_ListPanel->BeginUpdate(); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIComboBox::EndUpdate() { m_ListPanel->EndUpdate(); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIComboBox::AddItem(const std::string& Name, const std::string& ExtraText, GUIBitmap* pBitmap, const Entity* pEntity) { m_ListPanel->AddItem(Name, ExtraText, pBitmap, pEntity); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIComboBox::ClearList() { m_TextPanel->SetText(""); m_ListPanel->ClearList(); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIComboBox::Move(int X, int Y) { GUIPanel::SetPositionAbs(X, Y); m_ListPanel->SetPositionAbs(m_X, m_Y + m_Height); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIComboBox::Resize(int Width, int Height) { // Make sure the textbox isn't too small Width = std::max(Width, m_MinWidth); @@ -371,14 +341,10 @@ void GUIComboBox::Resize(int Width, int Height) { ChangeSkin(m_Skin); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIComboBox::GetControlRect(int* X, int* Y, int* Width, int* Height) { GUIPanel::GetRect(X, Y, Width, Height); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIComboBox::DeleteItem(int Index) { m_ListPanel->DeleteItem(Index); @@ -396,20 +362,14 @@ void GUIComboBox::DeleteItem(int Index) { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int GUIComboBox::GetCount() { return m_ListPanel->GetItemList()->size(); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int GUIComboBox::GetSelectedIndex() { return m_ListPanel->GetSelectedIndex(); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIComboBox::SetSelectedIndex(int Index) { m_ListPanel->SetSelectedIndex(Index); m_OldSelection = Index; @@ -420,8 +380,6 @@ void GUIComboBox::SetSelectedIndex(int Index) { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool GUIComboBox::RollbackSelection() { // Restore the previous selection if (m_OldSelection >= 0 && m_OldSelection < m_ListPanel->GetItemList()->size() && m_OldSelection != m_ListPanel->GetSelectedIndex()) { @@ -436,14 +394,10 @@ bool GUIComboBox::RollbackSelection() { return false; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIListPanel::Item* GUIComboBox::GetItem(int Index) { return m_ListPanel->GetItem(Index); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIComboBox::SetDropHeight(int Drop) { m_DropHeight = Drop; m_DropHeight = std::max(m_DropHeight, 20); @@ -452,8 +406,6 @@ void GUIComboBox::SetDropHeight(int Drop) { m_ListPanel->SetSize(m_Width, m_DropHeight); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIComboBox::StoreProperties() { m_Properties.AddVariable("DropHeight", m_DropHeight); if (m_DropDownStyle == DropDownList) { @@ -463,8 +415,6 @@ void GUIComboBox::StoreProperties() { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIComboBox::SetDropDownStyle(int Style) { if (Style == DropDown || Style == DropDownList) { m_DropDownStyle = Style; @@ -473,14 +423,10 @@ void GUIComboBox::SetDropDownStyle(int Style) { m_TextPanel->SetLocked(m_DropDownStyle == DropDownList); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int GUIComboBox::GetDropDownStyle() const { return m_DropDownStyle; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIComboBox::SetVisible(bool Visible) { _SetVisible(Visible); if (!Visible && m_ListPanel) { @@ -488,14 +434,10 @@ void GUIComboBox::SetVisible(bool Visible) { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool GUIComboBox::GetVisible() { return _GetVisible(); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIComboBox::SetEnabled(bool Enabled) { _SetEnabled(Enabled); if (m_ListPanel) { @@ -503,14 +445,10 @@ void GUIComboBox::SetEnabled(bool Enabled) { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool GUIComboBox::GetEnabled() { return _GetEnabled(); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - std::string GUIComboBox::GetText() { if (m_DropDownStyle != DropDown) { return ""; @@ -521,16 +459,12 @@ std::string GUIComboBox::GetText() { return ""; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIComboBox::SetText(const std::string& Text) { if (m_DropDownStyle == DropDown && m_TextPanel) { m_TextPanel->SetText(Text); } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIComboBox::ApplyProperties(GUIProperties* Props) { GUIControl::ApplyProperties(Props); @@ -550,16 +484,12 @@ void GUIComboBox::ApplyProperties(GUIProperties* Props) { ChangeSkin(m_Skin); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIComboBoxButton::GUIComboBoxButton(GUIManager* Manager) : GUIPanel(Manager) { m_DrawBitmap = nullptr; m_Pushed = false; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIComboBoxButton::ChangeSkin(GUISkin* Skin) { // Free any old bitmap if (m_DrawBitmap) { @@ -599,8 +529,6 @@ void GUIComboBoxButton::ChangeSkin(GUISkin* Skin) { Arrow->DrawTrans(m_DrawBitmap, (m_Width / 2) - (Values[2] / 2) + 1, m_Height + (m_Height / 2) - (Values[3] / 2) + 1, &Rect); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIComboBoxButton::Draw(GUIScreen* Screen) { GUIRect Rect; SetRect(&Rect, 0, m_Pushed ? m_Height : 0, m_Width, m_Pushed ? m_Height * 2 : m_Height); @@ -608,8 +536,6 @@ void GUIComboBoxButton::Draw(GUIScreen* Screen) { m_DrawBitmap->Draw(Screen->GetBitmap(), m_X, m_Y, &Rect); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIComboBoxButton::Create(int X, int Y, int Width, int Height) { m_X = X; m_Y = Y; @@ -617,8 +543,6 @@ void GUIComboBoxButton::Create(int X, int Y, int Width, int Height) { m_Height = Height; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIComboBoxButton::OnMouseDown(int X, int Y, int Buttons, int Modifier) { if (Buttons & MOUSE_LEFT) { m_Pushed = true; @@ -626,20 +550,14 @@ void GUIComboBoxButton::OnMouseDown(int X, int Y, int Buttons, int Modifier) { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIComboBoxButton::OnMouseUp(int X, int Y, int Buttons, int Modifier) { m_Pushed = false; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIComboBoxButton::SetPushed(bool Pushed) { m_Pushed = Pushed; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIComboBoxButton::Destroy() { // Free the drawing bitmap if (m_DrawBitmap) { diff --git a/Source/GUI/GUIComboBox.h b/Source/GUI/GUIComboBox.h index 9b8dba0871..30b9ca71aa 100644 --- a/Source/GUI/GUIComboBox.h +++ b/Source/GUI/GUIComboBox.h @@ -8,14 +8,10 @@ namespace RTE { class GUIComboBoxButton; - /// /// A ComboBox control class. - /// class GUIComboBox : public GUIControl, public GUIPanel { - ////////////////////////////////////////////////////////////////////////////////////////// - // Public member variable, method and friend function declarations - + /// Public member variable, method and friend function declarations public: // Notifications enum { @@ -29,324 +25,151 @@ namespace RTE { DropDownList, } DropDownStyles; - ////////////////////////////////////////////////////////////////////////////////////////// - // Constructor: GUIComboBox - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Constructor method used to instantiate a GUIComboBox object in - // system memory. - // Arguments: GUIManager, GUIControlManager. - + /// Constructor method used to instantiate a GUIComboBox object in + /// system memory. + /// @param Manager GUIManager, GUIControlManager. GUIComboBox(GUIManager* Manager, GUIControlManager* ControlManager); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the control has been created. - // Arguments: Name, Position. - + /// Called when the control has been created. + /// @param Name Name, Position. void Create(const std::string& Name, int X, int Y, int Width = -1, int Height = -1) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the control has been created. - // Arguments: Properties. - + /// Called when the control has been created. + /// @param Props Properties. void Create(GUIProperties* Props) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the control has been destroyed. - // Arguments: None. - + /// Called when the control has been destroyed. void Destroy() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Activate - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the control is activated and ready for use. - // Arguments: None. - + /// Called when the control is activated and ready for use. void Activate() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ChangeSkin - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the skin has been changed. - // Arguments: New skin pointer. - + /// Called when the skin has been changed. + /// @param Skin New skin pointer. void ChangeSkin(GUISkin* Skin) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Draw - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws the panel - // Arguments: Screen class - + /// Draws the panel + /// @param Screen Screen class void Draw(GUIScreen* Screen) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetPanel - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns the panel of the control. - // Arguments: None. - // Returns: 0 if the control does not have a panel, otherwise the topmost panel. - + /// Returns the panel of the control. + /// @return 0 if the control does not have a panel, otherwise the topmost panel. GUIPanel* GetPanel() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetListPanel - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns the ListPanel component of the control. - // Arguments: None. - // Returns: The ListPanel component of this ComboBox. - + /// Returns the ListPanel component of the control. + /// @return The ListPanel component of this ComboBox. GUIListPanel* GetListPanel() { return m_ListPanel; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetControlID - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns a string representing the control's ID - // Arguments: None. - + /// Returns a string representing the control's ID static std::string GetControlID() { return "COMBOBOX"; }; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ReceiveSignal - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when receiving a signal. - // Arguments: Signal source, Signal code, Signal data. - + /// Called when receiving a signal. + /// @param Source Signal source, Signal code, Signal data. void ReceiveSignal(GUIPanel* Source, int Code, int Data) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: BeginUpdate - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Locks the control from updating every time a new item is added. - // Arguments: None. - + /// Locks the control from updating every time a new item is added. void BeginUpdate(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: EndUpdate - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: UnLocks the control from updating every time a new item is added. - // Will automatically update the control. - // Arguments: None. - + /// UnLocks the control from updating every time a new item is added. + /// Will automatically update the control. void EndUpdate(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Move - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the control needs to be moved. - // Arguments: New position. - + /// Called when the control needs to be moved. + /// @param X New position. void Move(int X, int Y) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Resize - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the control needs to be resized. - // Arguments: New size. - + /// Called when the control needs to be resized. + /// @param Width New size. void Resize(int Width, int Height) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetControlRect - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the rectangle of the control. - // Arguments: Position, Size. - + /// Gets the rectangle of the control. + /// @param X Position, Size. void GetControlRect(int* X, int* Y, int* Width, int* Height) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: AddItem - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Add an item to the list. - // Arguments: Name, Extra text, bitmap to show in the list, extra entity data - + /// Add an item to the list. + /// @param Name Name, Extra text, bitmap to show in the list, extra entity data void AddItem(const std::string& Name, const std::string& ExtraText = "", GUIBitmap* pBitmap = nullptr, const Entity* pEntity = nullptr); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: DeleteItem - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Delete an item from the list. - // Arguments: Item Index. - + /// Delete an item from the list. + /// @param Index Item Index. void DeleteItem(int Index); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ClearList - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears the list. - // Arguments: None. - + /// Clears the list. void ClearList(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetCount - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Get the item count. - // Arguments: None. - + /// Get the item count. int GetCount(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetSelectedIndex - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Get the index of the selected item. - // Arguments: None. - + /// Get the index of the selected item. int GetSelectedIndex(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetOldSelectionIndex - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Get the index of the previously selected item before the selection is - // made. - // Arguments: None. - + /// Get the index of the previously selected item before the selection is + /// made. int GetOldSelectionIndex() const { return m_OldSelection; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetSelectedIndex - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the index of the selected item. - // Arguments: None. - + /// Sets the index of the selected item. void SetSelectedIndex(int Index); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: RollbackSelection - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Rolls back the selection to the previous selected item. - // Arguments: None. - // Returns: Whether the rollback worked and was performed. - + /// Rolls back the selection to the previous selected item. + /// @return Whether the rollback worked and was performed. bool RollbackSelection(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetItem - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns the Item structure at the index. - // Arguments: Index. - // Returns: Pointer to the item structure. 0 if the index was invalid. - + /// Returns the Item structure at the index. + /// @param Index Index. + /// @return Pointer to the item structure. 0 if the index was invalid. GUIListPanel::Item* GetItem(int Index); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetSelectedItem - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns the Item structure at the currently selected index. - // Arguments: Index. - // Returns: Pointer to the item structure. 0 if nothing valid is selected. - + /// Returns the Item structure at the currently selected index. + /// @param GetItem(GetSelectedIndex() Index. + /// @return Pointer to the item structure. 0 if nothing valid is selected. GUIListPanel::Item* GetSelectedItem() { return GetItem(GetSelectedIndex()); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetDropHeight - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the drop height of the list. - // Arguments: Height. - + /// Sets the drop height of the list. + /// @param Drop Height. void SetDropHeight(int Drop); - /// /// Gets the drop height of the list. - /// - /// The drop height of the list. + /// @return The drop height of the list. int GetDropHeight() const { return m_DropHeight; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: StoreProperties - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the control to store the values into properties. - // Arguments: None. - + /// Gets the control to store the values into properties. void StoreProperties() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetDropDownStyle - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the drop down style of the combo box. - // Arguments: Style. - + /// Sets the drop down style of the combo box. + /// @param Style Style. void SetDropDownStyle(int Style); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetDropDownStyle - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the drop down style of the combo box. - // Arguments: None. - + /// Gets the drop down style of the combo box. int GetDropDownStyle() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetVisible - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the visibility of the control. - // Arguments: Visible. - + /// Sets the visibility of the control. + /// @param Visible Visible. void SetVisible(bool Visible) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetVisible - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the visibility of the control. - // Arguments: None. - + /// Gets the visibility of the control. bool GetVisible() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetEnabled - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the enabled state of the control. - // Arguments: Enabled. - + /// Sets the enabled state of the control. + /// @param Enabled Enabled. void SetEnabled(bool Enabled) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetEnabled - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the enabled state of the control. - // Arguments: None. - + /// Gets the enabled state of the control. bool GetEnabled() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetText - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets text (only if style is DropDown). - // Arguments: None. - // Returns: Text. Returns empty string is style is not DropDown. - + /// Gets text (only if style is DropDown). + /// @return Text. Returns empty string is style is not DropDown. std::string GetText(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetText - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets text (only if style is DropDown). - // Arguments: Text. - + /// Sets text (only if style is DropDown). + /// @param Text Text. void SetText(const std::string& Text); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ApplyProperties - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Applies new properties to the control. - // Arguments: GUIProperties. - + /// Applies new properties to the control. + /// @param Props GUIProperties. void ApplyProperties(GUIProperties* Props) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: IsDropped - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Shows whether the list is currently dropped down or not. - // Arguments: None. - // Returns: Whether this is currently dropped down and showing the list. - + /// Shows whether the list is currently dropped down or not. + /// @return Whether this is currently dropped down and showing the list. bool IsDropped() { return m_ListPanel->_GetVisible(); } private: @@ -362,9 +185,7 @@ namespace RTE { GUIComboBoxButton* m_Button; }; - /// /// A ComboBoxButton control class. - /// class GUIComboBoxButton : public GUIPanel { public: @@ -373,69 +194,36 @@ namespace RTE { Clicked } Signals; - ////////////////////////////////////////////////////////////////////////////////////////// - // Constructor: GUIComboBoxButton - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Constructor method used to instantiate a GUIComboBoxButton object in - // system memory. - // Arguments: GUIManager. - + /// Constructor method used to instantiate a GUIComboBoxButton object in + /// system memory. + /// @param Manager GUIManager. explicit GUIComboBoxButton(GUIManager* Manager); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ChangeSkin - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the skin has been changed. - // Arguments: New skin pointer. - + /// Called when the skin has been changed. + /// @param Skin New skin pointer. void ChangeSkin(GUISkin* Skin); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Draw - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws the panel - // Arguments: Screen class - + /// Draws the panel + /// @param Screen Screen class void Draw(GUIScreen* Screen) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Create the panel. - // Arguments: Position, Size. - + /// Create the panel. + /// @param X Position, Size. void Create(int X, int Y, int Width, int Height); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destroys the button. - // Arguments: None. - + /// Destroys the button. void Destroy(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: OnMouseDown - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the mouse goes down on the panel - // Arguments: Mouse Position, Mouse Buttons, Modifier. - + /// Called when the mouse goes down on the panel + /// @param X Mouse Position, Mouse Buttons, Modifier. void OnMouseDown(int X, int Y, int Buttons, int Modifier) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: OnMouseUp - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the mouse goes up on the panel - // Arguments: Mouse Position, Mouse Buttons, Modifier. - + /// Called when the mouse goes up on the panel + /// @param X Mouse Position, Mouse Buttons, Modifier. void OnMouseUp(int X, int Y, int Buttons, int Modifier) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetPushed - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the pushed state of the button. - // Arguments: Pushed. - + /// Sets the pushed state of the button. + /// @param Pushed Pushed. void SetPushed(bool Pushed); private: diff --git a/Source/GUI/GUIControl.cpp b/Source/GUI/GUIControl.cpp index 59eec68991..b9fa0cbe74 100644 --- a/Source/GUI/GUIControl.cpp +++ b/Source/GUI/GUIControl.cpp @@ -2,8 +2,6 @@ using namespace RTE; -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIControl::GUIControl() { m_Skin = nullptr; m_SkinPreset = 1; @@ -13,8 +11,6 @@ GUIControl::GUIControl() { m_IsContainer = false; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIControl::Create(const std::string& Name, int X, int Y, int Width, int Height) { m_Properties.Clear(); m_Properties.AddVariable("Name", Name); @@ -22,8 +18,6 @@ void GUIControl::Create(const std::string& Name, int X, int Y, int Width, int He m_Properties.AddVariable("ToolTip", ""); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIControl::Create(GUIProperties* Props) { assert(Props); @@ -35,28 +29,18 @@ void GUIControl::Create(GUIProperties* Props) { m_Properties.Update(Props); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIControl::Destroy() {} -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIControl::Activate() {} -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIControl::ChangeSkin(GUISkin* Skin) { m_Skin = Skin; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIControl::AddEvent(int Type, int Msg, int Data) { m_ControlManager->AddEvent(new GUIEvent(this, Type, Msg, Data)); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - std::string GUIControl::GetName() { std::string Name; m_Properties.GetValue("Name", &Name); @@ -64,8 +48,6 @@ std::string GUIControl::GetName() { return Name; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - std::string GUIControl::GetToolTip() { std::string tip; m_Properties.GetValue("ToolTip", &tip); @@ -73,20 +55,14 @@ std::string GUIControl::GetToolTip() { return tip; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - std::string GUIControl::GetID() const { return m_ControlID; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIPanel* GUIControl::GetPanel() { return nullptr; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIControl::AddChild(GUIControl* Control) { assert(Control); @@ -99,14 +75,10 @@ void GUIControl::AddChild(GUIControl* Control) { m_ControlChildren.push_back(Control); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - std::vector* GUIControl::GetChildren() { return &m_ControlChildren; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool GUIControl::Save(GUIWriter* W) { std::string OutString = ""; std::string Name; @@ -150,16 +122,10 @@ bool GUIControl::Save(GUIWriter* W) { return true; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIControl::Move(int X, int Y) {} -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIControl::Resize(int Width, int Height) {} -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIControl::GetControlRect(int* X, int* Y, int* Width, int* Height) { // Zero the values for controls that don't override this if (X) { @@ -176,8 +142,6 @@ void GUIControl::GetControlRect(int* X, int* Y, int* Width, int* Height) { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int GUIControl::GetAnchor() { int Anchor = 0; std::string Value[4]; @@ -210,12 +174,8 @@ int GUIControl::GetAnchor() { return Anchor; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIControl::StoreProperties() {} -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIControl::SetVisible(bool Visible) { // Default method is the grab the main panel and directly set its state. Controls that use multiple panels on the same layer will need to override this function GUIPanel* Panel = GetPanel(); @@ -224,8 +184,6 @@ void GUIControl::SetVisible(bool Visible) { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool GUIControl::GetVisible() { // See SetVisible() comment GUIPanel* Panel = GetPanel(); @@ -235,8 +193,6 @@ bool GUIControl::GetVisible() { return false; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIControl::SetEnabled(bool Enabled) { // See SetVisible() comment GUIPanel* Panel = GetPanel(); @@ -245,8 +201,6 @@ void GUIControl::SetEnabled(bool Enabled) { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool GUIControl::GetEnabled() { // See SetVisible() comment GUIPanel* Panel = GetPanel(); @@ -257,20 +211,14 @@ bool GUIControl::GetEnabled() { return false; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIControl* GUIControl::GetParent() { return m_ControlParent; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIProperties* GUIControl::GetProperties() { return &m_Properties; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIControl::ApplyProperties(GUIProperties* Props) { assert(Props); @@ -305,14 +253,10 @@ void GUIControl::ApplyProperties(GUIProperties* Props) { Resize(Width, Height); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool GUIControl::IsContainer() { return m_IsContainer; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIControl::RemoveChild(const std::string Name) { // Note: We do NOT free the children because they are still linked in through their panels. This merely removes the control from the list. // This will cause a small memory leak, but this is only designed for the GUI Editor and is a bit of a hack. @@ -327,8 +271,6 @@ void GUIControl::RemoveChild(const std::string Name) { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIControl::RemoveChildren() { // Note: We do NOT free the children because they are still linked in through their panels. This merely removes the control from the list. // This will cause a small memory leak, but this is only designed for the GUI Editor and is a bit of a hack. diff --git a/Source/GUI/GUIControl.h b/Source/GUI/GUIControl.h index 616942429e..d08699966a 100644 --- a/Source/GUI/GUIControl.h +++ b/Source/GUI/GUIControl.h @@ -7,9 +7,7 @@ namespace RTE { class GUIControlManager; - /// /// A base class inherited by all controls. - /// class GUIControl { public: @@ -21,247 +19,111 @@ namespace RTE { Anchor_Bottom = 0x08 } Anchor; - ////////////////////////////////////////////////////////////////////////////////////////// - // Constructor: GUIControl - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Constructor method used to instantiate a GUIControl object in - // system memory. - // Arguments: None. - + /// Constructor method used to instantiate a GUIControl object in + /// system memory. GUIControl(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual Method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the control has been created. - // Arguments: Name, Position, Size - + /// Called when the control has been created. + /// @param Name Name, Position, Size virtual void Create(const std::string& Name, int X, int Y, int Width = -1, int Height = -1); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual Method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the control has been created. - // Arguments: Properties. - + /// Called when the control has been created. + /// @param Props Properties. virtual void Create(GUIProperties* Props); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual Method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the control has been destroyed. - // Arguments: None. - + /// Called when the control has been destroyed. virtual void Destroy(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual Method: Activate - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the control is activated and ready for use. - // Arguments: None. - + /// Called when the control is activated and ready for use. virtual void Activate(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual Method: ChangeSkin - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the skin has been changed. - // Arguments: New skin pointer. - + /// Called when the skin has been changed. + /// @param Skin New skin pointer. virtual void ChangeSkin(GUISkin* Skin); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: AddEvent - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Add a new event to the queue. - // Arguments: Type, Message, Data. - + /// Add a new event to the queue. + /// @param Type Type, Message, Data. void AddEvent(int Type, int Msg, int Data); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetName - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the control's name. - // Arguments: None. - + /// Gets the control's name. std::string GetName(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetToolTip - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the control's tooltip string. - // Arguments: The new ToolTip for this. - + /// Sets the control's tooltip string. + /// @param m_Properties.SetValue("ToolTip" The new ToolTip for this. void SetToolTip(const std::string& tip) { m_Properties.SetValue("ToolTip", tip); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetToolTip - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the control's tooltip string. - // Arguments: None. - + /// Gets the control's tooltip string. std::string GetToolTip(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetID - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns a string representing the control's ID - // Arguments: None. - + /// Returns a string representing the control's ID std::string GetID() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetAnchor - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns the anchor flags. - // Arguments: None. - + /// Returns the anchor flags. int GetAnchor(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: AddChild - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Adds a child to this control - // Arguments: Control. - + /// Adds a child to this control + /// @param Control Control. void AddChild(GUIControl* Control); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetChildren - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the children lst - // Arguments: None. - + /// Gets the children lst std::vector* GetChildren(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual Method: GetPanel - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns the panel of the control. - // Arguments: None. - // Returns: 0 if the control does not have a panel, otherwise the topmost panel. - + /// Returns the panel of the control. + /// @return 0 if the control does not have a panel, otherwise the topmost panel. virtual GUIPanel* GetPanel(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Save - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Saves the control properties. - // Arguments: Writer. - // Returns: True if sucessful - + /// Saves the control properties. + /// @param W Writer. + /// @return True if sucessful bool Save(GUIWriter* W); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual Method: StoreProperties - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the control to store the values into properties. - // Arguments: None. - + /// Gets the control to store the values into properties. virtual void StoreProperties(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual Method: Move - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the control needs to be moved. - // Arguments: New position. - + /// Called when the control needs to be moved. + /// @param X New position. virtual void Move(int X, int Y); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual Method: Resize - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the control needs to be resized. - // Arguments: New size. - + /// Called when the control needs to be resized. + /// @param Width New size. virtual void Resize(int Width, int Height); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual Method: GetControlRect - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the rectangle of the control. - // Arguments: Position, Size. - + /// Gets the rectangle of the control. + /// @param X Position, Size. virtual void GetControlRect(int* X, int* Y, int* Width, int* Height); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual Method: SetVisible - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the visibility of the control. - // Arguments: Visible. - + /// Sets the visibility of the control. + /// @param Visible Visible. virtual void SetVisible(bool Visible); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual Method: GetVisible - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the visibility of the control. - // Arguments: None. - + /// Gets the visibility of the control. virtual bool GetVisible(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual Method: SetEnabled - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the enabled state of the control. - // Arguments: Enabled. - + /// Sets the enabled state of the control. + /// @param Enabled Enabled. virtual void SetEnabled(bool Enabled); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual Method: GetEnabled - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the enabled state of the control. - // Arguments: None. - + /// Gets the enabled state of the control. virtual bool GetEnabled(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetParent - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the parent of this control. - // Arguments: None. - + /// Gets the parent of this control. GUIControl* GetParent(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetProperties - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the control properties. - // Arguments: None. - + /// Gets the control properties. GUIProperties* GetProperties(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual Method: ApplyProperties - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Applies new properties to the control. - // Arguments: GUIProperties. - + /// Applies new properties to the control. + /// @param Props GUIProperties. virtual void ApplyProperties(GUIProperties* Props); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ApplyProperties - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns the IsContainer value. - // Arguments: None. - + /// Returns the IsContainer value. bool IsContainer(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: RemoveChild - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Removes a child based on name. - // Arguments: Child Name. - + /// Removes a child based on name. + /// @param Name Child Name. void RemoveChild(const std::string Name); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: RemoveChildren - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Removes all the children. - // Arguments: None. - + /// Removes all the children. void RemoveChildren(); protected: diff --git a/Source/GUI/GUIControlFactory.cpp b/Source/GUI/GUIControlFactory.cpp index 81345990ee..7b78dea479 100644 --- a/Source/GUI/GUIControlFactory.cpp +++ b/Source/GUI/GUIControlFactory.cpp @@ -16,8 +16,6 @@ using namespace RTE; -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIControl* GUIControlFactory::CreateControl(GUIManager* Manager, GUIControlManager* ControlManager, const std::string& ControlName) { // Button if (ControlName.compare(GUIButton::GetControlID()) == 0) { diff --git a/Source/GUI/GUIControlFactory.h b/Source/GUI/GUIControlFactory.h index 7b88ad585d..67f87af7c4 100644 --- a/Source/GUI/GUIControlFactory.h +++ b/Source/GUI/GUIControlFactory.h @@ -3,18 +3,12 @@ namespace RTE { - /// /// A class used to create the different controls based on name. - /// class GUIControlFactory { public: - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: CreateControl - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Method used for creating controls - // Arguments: Control Type Name. - + /// Method used for creating controls + /// @param Manager Control Type Name. static GUIControl* CreateControl(GUIManager* Manager, GUIControlManager* ControlManager, const std::string& ControlName); }; }; // namespace RTE diff --git a/Source/GUI/GUIControlManager.cpp b/Source/GUI/GUIControlManager.cpp index c7e80cb319..98aebcf0d2 100644 --- a/Source/GUI/GUIControlManager.cpp +++ b/Source/GUI/GUIControlManager.cpp @@ -3,8 +3,6 @@ using namespace RTE; -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIControlManager::GUIControlManager() { m_Screen = nullptr; m_Input = nullptr; @@ -16,8 +14,6 @@ GUIControlManager::GUIControlManager() { m_CursorType = Pointer; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool GUIControlManager::Create(GUIScreen* Screen, GUIInput* Input, const std::string& SkinDir, const std::string& SkinFilename) { assert(Screen && Input); @@ -45,8 +41,6 @@ bool GUIControlManager::Create(GUIScreen* Screen, GUIInput* Input, const std::st return true; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIControlManager::Destroy() { // Free the skin if (m_Skin) { @@ -65,8 +59,6 @@ void GUIControlManager::Destroy() { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIControlManager::Clear() { std::vector::iterator it; @@ -93,8 +85,6 @@ void GUIControlManager::Clear() { m_EventQueue.clear(); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIControlManager::ChangeSkin(const std::string& SkinDir, const std::string& SkinFilename) { std::vector::iterator it; @@ -109,8 +99,6 @@ void GUIControlManager::ChangeSkin(const std::string& SkinDir, const std::string } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIControl* GUIControlManager::AddControl(const std::string& Name, const std::string& Type, GUIControl* Parent, int X, int Y, int Width, int Height) { // Skip if we already have a control of this name if (GetControl(Name)) { @@ -145,8 +133,6 @@ GUIControl* GUIControlManager::AddControl(const std::string& Name, const std::st return Control; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIControl* GUIControlManager::AddControl(GUIProperties* Property) { assert(Property); @@ -195,8 +181,6 @@ GUIControl* GUIControlManager::AddControl(GUIProperties* Property) { return Control; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIControl* GUIControlManager::GetControl(const std::string& Name) { std::vector::iterator it; @@ -211,14 +195,10 @@ GUIControl* GUIControlManager::GetControl(const std::string& Name) { return nullptr; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - std::vector* GUIControlManager::GetControlList() { return &m_ControlList; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIControl* GUIControlManager::GetControlUnderPoint(int pointX, int pointY, GUIControl* pParent, int depth) { // Default to the root object if no parent specified if (!pParent) { @@ -266,8 +246,6 @@ GUIControl* GUIControlManager::GetControlUnderPoint(int pointX, int pointY, GUIC return pParent == m_ControlList.front() ? nullptr : pParent; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIControlManager::RemoveControl(const std::string& Name, bool RemoveFromParent) { // NOTE: We can't simply remove it because some controls need to remove extra panels and it's silly to add 'remove' to every control to remove their extra panels (ie. Combobox). // Signals and stuff are also linked in so we just remove the controls from the list and not from memory. @@ -294,8 +272,6 @@ void GUIControlManager::RemoveControl(const std::string& Name, bool RemoveFromPa } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIControlManager::Update(bool ignoreKeyboardEvents) { // Clear the event queue m_EventQueue.clear(); @@ -304,20 +280,14 @@ void GUIControlManager::Update(bool ignoreKeyboardEvents) { m_GUIManager->Update(ignoreKeyboardEvents); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIControlManager::Draw() { m_GUIManager->Draw(m_Screen); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIControlManager::Draw(GUIScreen* pScreen) { m_GUIManager->Draw(pScreen); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIControlManager::DrawMouse(GUIScreen* guiScreen) { int MouseX; int MouseY; @@ -343,8 +313,6 @@ void GUIControlManager::DrawMouse(GUIScreen* guiScreen) { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool GUIControlManager::GetEvent(GUIEvent* Event) { if (Event && !m_EventQueue.empty()) { @@ -363,8 +331,6 @@ bool GUIControlManager::GetEvent(GUIEvent* Event) { return false; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIControlManager::AddEvent(GUIEvent* Event) { // Add the event to the queue if (Event) { @@ -372,14 +338,10 @@ void GUIControlManager::AddEvent(GUIEvent* Event) { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIControlManager::SetCursor(int CursorType) { m_CursorType = CursorType; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool GUIControlManager::Save(const std::string& Filename) { GUIWriter W; if (W.Create(Filename) != 0) { @@ -392,8 +354,6 @@ bool GUIControlManager::Save(const std::string& Filename) { return Result; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool GUIControlManager::Save(GUIWriter* W) { assert(W); @@ -410,8 +370,6 @@ bool GUIControlManager::Save(GUIWriter* W) { return true; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool GUIControlManager::Load(const std::string& Filename, bool keepOld) { GUIReader reader; const std::string pathFile = g_PresetMan.GetFullModulePath(Filename); diff --git a/Source/GUI/GUIControlManager.h b/Source/GUI/GUIControlManager.h index 4bd4224b20..f47532b0ff 100644 --- a/Source/GUI/GUIControlManager.h +++ b/Source/GUI/GUIControlManager.h @@ -6,9 +6,7 @@ namespace RTE { - /// /// A class used to manage the GUI as a whole and provide the interface between the GUI and the rest of the system. - /// class GUIControlManager { friend class GUIControl; @@ -20,232 +18,124 @@ namespace RTE { HorSize } CursorType; - ////////////////////////////////////////////////////////////////////////////////////////// - // Constructor: GUIControlmanager - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Constructor method used to instantiate a GUIControlManager object in - // system memory. - // Arguments: None. - + /// Constructor method used to instantiate a GUIControlManager object in + /// system memory. GUIControlManager(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Destructor: GUIControlmanager - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destructor method used to clean up a GUIControlManager object in - // system memory. - // Arguments: None. - + /// Destructor method used to clean up a GUIControlManager object in + /// system memory. ~GUIControlManager() { Destroy(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Creates the data for the control manager - // Arguments: Screen and Input Interfaces, Skin directory - + /// Creates the data for the control manager + /// @param Screen Screen and Input Interfaces, Skin directory bool Create(GUIScreen* Screen, GUIInput* Input, const std::string& SkinDir, const std::string& SkinFilename = "skin.ini"); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Frees all the allocated resources. - // Arguments: None. - + /// Frees all the allocated resources. void Destroy(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Clear - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears all the controls. - // Arguments: None. - + /// Clears all the controls. void Clear(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ChangeSkin - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Changes the skin of the controls. - // Arguments: Skin directory. - + /// Changes the skin of the controls. + /// @param SkinDir Skin directory. void ChangeSkin(const std::string& SkinDir, const std::string& SkinFilename = "skin.ini"); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetSkin - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the Skin object currently in use. - // Arguments: None. - // Returns: A pointer to the currently used skin. Please don't mess it up. - + /// Gets the Skin object currently in use. + /// @return A pointer to the currently used skin. Please don't mess it up. GUISkin* GetSkin() { return m_Skin; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Update - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the GUI every frame - // Arguments: Whether keyboard events should be ignored or not. Used to avoid conflicts when custom keyboard handling for GUI elements is preset. - + /// Updates the GUI every frame + /// @param ignoreKeyboardEvents Whether keyboard events should be ignored or not. Used to avoid conflicts when custom keyboard handling for GUI elements is preset. (default: false) void Update(bool ignoreKeyboardEvents = false); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Draw - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws the GUI to the back buffer. - // Arguments: None. - + /// Draws the GUI to the back buffer. void Draw(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Draw - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws the GUI to the back buffer. - // Arguments: The GUIScreen to draw to, overriding the one passed in on construction - + /// Draws the GUI to the back buffer. + /// @param pScreen The GUIScreen to draw to, overriding the one passed in on construction void Draw(GUIScreen* pScreen); - /// /// Draws the mouse to the backbuffer. - /// - /// The GUIScreen to draw to, overriding the one passed in on construction. + /// @param pScreen The GUIScreen to draw to, overriding the one passed in on construction. void DrawMouse(GUIScreen* guiScreen = nullptr); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: EnableMouse - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Enables and disables the mouse completely for this. - // Arguments: Enable? - + /// Enables and disables the mouse completely for this. + /// @param enable Enable? (default: true) { m_GUIManager->EnableMouse(enable) void EnableMouse(bool enable = true) { m_GUIManager->EnableMouse(enable); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetPosOnScreen - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the absolute position of this entire GUI on the screen. This is - // useful if the UI's are being drawn in a different area of the screen - // than the top left corner. This will adjust the mouse input to match - // the offset screen location. - // Arguments: The position. - + /// Sets the absolute position of this entire GUI on the screen. This is + /// useful if the UI's are being drawn in a different area of the screen + /// than the top left corner. This will adjust the mouse input to match + /// the offset screen location. + /// @param screenPosX The position. void SetPosOnScreen(int screenPosX, int screenPosY) { m_Input->SetMouseOffset(-screenPosX, -screenPosY); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetManager - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the control manager - // Arguments: Name. - // Returns: The manager, ownership is NOT transferred! - + /// Gets the control manager + /// @param Name. + /// @return The manager, ownership is NOT transferred! GUIManager* GetManager() { return m_GUIManager; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: AddControl - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Manually creates a control. - // Arguments: Name, Type, Position, Size, Parent. - // Returns: GUIControl class created. 0 if not created. - + /// Manually creates a control. + /// @param Name Name, Type, Position, Size, Parent. + /// @return GUIControl class created. 0 if not created. GUIControl* AddControl(const std::string& Name, const std::string& Type, GUIControl* Parent, int X, int Y, int Width, int Height); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: AddControl - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Manually creates a control. - // Arguments: Properties. - // Returns: GUIControl class created. 0 if not created. - + /// Manually creates a control. + /// @param Property Properties. + /// @return GUIControl class created. 0 if not created. GUIControl* AddControl(GUIProperties* Property); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetControl - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets a control - // Arguments: Name. - // Returns: GUIControl class, or 0 if not found. - + /// Gets a control + /// @param Name Name. + /// @return GUIControl class, or 0 if not found. GUIControl* GetControl(const std::string& Name); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetControlList - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the control list - // Arguments: None. - // Returns: vector Pointer. - + /// Gets the control list + /// @return vector Pointer. std::vector* GetControlList(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetControlUnderPoint - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Checks if a control is under a specific point - // Arguments: The absolute point coordinates to check under. - // Parent to check under. Pass null to default to the root control. - // How many levels of children under the parent to look at. If negative, - // goes as far as it can. - // Returns: GUIControl. NULL if no control under the point - + /// Checks if a control is under a specific point + /// @param pointX The absolute point coordinates to check under. + /// @param pointY Parent to check under. Pass null to default to the root control. + /// @param pParent How many levels of children under the parent to look at. If negative, (default: nullptr) + /// goes as far as it can. + /// @param depth Returns: GUIControl. NULL if no control under the point (default: -1) GUIControl* GetControlUnderPoint(int pointX, int pointY, GUIControl* pParent = nullptr, int depth = -1); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: RemoveControl - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Removes a control by name - // Arguments: Name, RemoveFromParent. - // Returns: None. - + /// Removes a control by name + /// @param Name Name, RemoveFromParent. void RemoveControl(const std::string& Name, bool RemoveFromParent); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetEvent - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets an event from the queue. - // Arguments: Pointer to variable receiving the Event. - // Returns: Returns true when an event was grabbed. - // Returns false when there was no more events in the queue - // OR the Event pointer is 0. - + /// Gets an event from the queue. + /// @param Event Pointer to variable receiving the Event. + /// @return Returns true when an event was grabbed. + /// Returns false when there was no more events in the queue + /// OR the Event pointer is 0. bool GetEvent(GUIEvent* Event); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetCursor - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the cursor type. - // Arguments: Cursor type. - + /// Sets the cursor type. + /// @param CursorType Cursor type. void SetCursor(int CursorType); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Save - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Saves the layout to a file. - // Arguments: Filename. - // Returns: True if successful. - + /// Saves the layout to a file. + /// @param Filename Filename. + /// @return True if successful. bool Save(const std::string& Filename); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Save - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Saves the layout to a Writer class. - // Arguments: Writer class. - // Returns: True if successful. - + /// Saves the layout to a Writer class. + /// @param W Writer class. + /// @return True if successful. bool Save(GUIWriter* W); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Load - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Loads the layout from a file. - // Arguments: Filename. - // Whether to NOT clear out the manager, but just add the controls loaded - // to the existing layout. - // Returns: True if successful. - + /// Loads the layout from a file. + /// @param Filename Filename. + /// @param keepOld Whether to NOT clear out the manager, but just add the controls loaded (default: false) + /// to the existing layout. + /// @return True if successful. bool Load(const std::string& Filename, bool keepOld = false); - /// /// Gets the GUIScreen that this GUIControlManager is drawing itself to. - /// - /// Pointer to the GUIScreen that this GUIControlManager is drawing itself to. + /// @return Pointer to the GUIScreen that this GUIControlManager is drawing itself to. GUIScreen* GetScreen() const { return m_Screen; } private: @@ -259,12 +149,8 @@ namespace RTE { int m_CursorType; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: AddEvent - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Add a new event to the queue. - // Arguments: Event point. - + /// Add a new event to the queue. + /// @param Event Event point. void AddEvent(GUIEvent* Event); }; }; // namespace RTE diff --git a/Source/GUI/GUIEvent.cpp b/Source/GUI/GUIEvent.cpp index 1a3904694c..4e3162875c 100644 --- a/Source/GUI/GUIEvent.cpp +++ b/Source/GUI/GUIEvent.cpp @@ -2,8 +2,6 @@ using namespace RTE; -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIEvent::GUIEvent() { m_Control = nullptr; m_Type = 0; @@ -11,8 +9,6 @@ GUIEvent::GUIEvent() { m_Data = 0; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIEvent::GUIEvent(GUIControl* Control, int Type, int Msg, int Data) { assert(Control); m_Control = Control; @@ -21,26 +17,18 @@ GUIEvent::GUIEvent(GUIControl* Control, int Type, int Msg, int Data) { m_Data = Data; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int GUIEvent::GetType() const { return m_Type; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIControl* GUIEvent::GetControl() { return m_Control; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int GUIEvent::GetMsg() const { return m_Msg; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int GUIEvent::GetData() const { return m_Data; } diff --git a/Source/GUI/GUIEvent.h b/Source/GUI/GUIEvent.h index 9024698407..4ec8ba5674 100644 --- a/Source/GUI/GUIEvent.h +++ b/Source/GUI/GUIEvent.h @@ -3,9 +3,7 @@ namespace RTE { - /// /// A class to hold event information. - /// class GUIEvent { public: @@ -15,54 +13,25 @@ namespace RTE { Notification } EventType; - ////////////////////////////////////////////////////////////////////////////////////////// - // Constructor: GUIEvent - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Constructor method used to instantiate a GUIEvent object in system - // memory. - // Arguments: None. - + /// Constructor method used to instantiate a GUIEvent object in system + /// memory. GUIEvent(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Constructor: GUIEvent - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Constructor method used to instantiate a GUIEvent object in system - // memory. - // Arguments: Control, Event type, Msg, Data. - + /// Constructor method used to instantiate a GUIEvent object in system + /// memory. + /// @param Control Control, Event type, Msg, Data. GUIEvent(GUIControl* Control, int Type, int Msg, int Data); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetType - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the event type - // Arguments: None. - + /// Gets the event type int GetType() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetMsg - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the msg. - // Arguments: None. - + /// Gets the msg. int GetMsg() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetData - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the data. - // Arguments: None. - + /// Gets the data. int GetData() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetControl - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the event control. - // Arguments: None. - + /// Gets the event control. GUIControl* GetControl(); private: diff --git a/Source/GUI/GUIFont.cpp b/Source/GUI/GUIFont.cpp index f30e0de072..6a77a70d56 100644 --- a/Source/GUI/GUIFont.cpp +++ b/Source/GUI/GUIFont.cpp @@ -2,8 +2,6 @@ using namespace RTE; -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIFont::GUIFont(const std::string& Name) { m_Screen = nullptr; m_Font = nullptr; @@ -20,8 +18,6 @@ GUIFont::GUIFont(const std::string& Name) { m_CharIndexCap = 256; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool GUIFont::Load(GUIScreen* Screen, const std::string& Filename) { assert(Screen); @@ -107,8 +103,6 @@ bool GUIFont::Load(GUIScreen* Screen, const std::string& Filename) { return true; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIFont::Draw(GUIBitmap* Bitmap, int X, int Y, const std::string& Text, unsigned long Shadow) { unsigned char c; GUIRect Rect; @@ -163,8 +157,6 @@ void GUIFont::Draw(GUIBitmap* Bitmap, int X, int Y, const std::string& Text, uns } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIFont::DrawAligned(GUIBitmap* Bitmap, int X, int Y, const std::string& Text, int HAlign, int VAlign, int MaxWidth, unsigned long Shadow) { std::string TextLine = Text; int lineStartPos = 0; @@ -245,8 +237,6 @@ void GUIFont::DrawAligned(GUIBitmap* Bitmap, int X, int Y, const std::string& Te } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIFont::SetColor(unsigned long Color) { // Only check the change if the color is different if (Color != m_CurrentColor) { @@ -262,8 +252,6 @@ void GUIFont::SetColor(unsigned long Color) { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int GUIFont::CalculateWidth(const std::string& Text) { unsigned char c; int Width = 0; @@ -300,8 +288,6 @@ int GUIFont::CalculateWidth(const std::string& Text) { return WidestLine; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int GUIFont::CalculateWidth(const char Character) { if (Character >= 32 && Character < m_CharIndexCap) { return m_Characters[Character].m_Width + m_Kerning; @@ -309,8 +295,6 @@ int GUIFont::CalculateWidth(const char Character) { return 0; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int GUIFont::CalculateHeight(const std::string& Text, int MaxWidth) { if (Text.empty()) { return 0; @@ -353,8 +337,6 @@ int GUIFont::CalculateHeight(const std::string& Text, int MaxWidth) { return Height; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIFont::CacheColor(unsigned long Color) { // Make sure we haven't already cached this color and it isn't a 0 color if (GetFontColor(Color) != nullptr || !Color) { @@ -391,8 +373,6 @@ void GUIFont::CacheColor(unsigned long Color) { m_ColorCache.push_back(FC); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIFont::FontColor* GUIFont::GetFontColor(unsigned long Color) { std::vector::iterator it; FontColor* F = nullptr; @@ -408,26 +388,18 @@ GUIFont::FontColor* GUIFont::GetFontColor(unsigned long Color) { return nullptr; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int GUIFont::GetFontHeight() const { return m_FontHeight; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - std::string GUIFont::GetName() const { return m_Name; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int GUIFont::GetKerning() const { return m_Kerning; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIFont::Destroy() { if (m_Font) { m_Font->Destroy(); diff --git a/Source/GUI/GUIFont.h b/Source/GUI/GUIFont.h index 94383c0fde..05af264b19 100644 --- a/Source/GUI/GUIFont.h +++ b/Source/GUI/GUIFont.h @@ -3,9 +3,7 @@ namespace RTE { - /// /// A class to handle the drawing of text. - /// class GUIFont { public: @@ -36,127 +34,61 @@ namespace RTE { GUIBitmap* m_Bitmap; } FontColor; - ////////////////////////////////////////////////////////////////////////////////////////// - // Constructor: GUIFont - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Constructor method used to instantiate a GUIFont object in system - // memory. - // Arguments: None. - + /// Constructor method used to instantiate a GUIFont object in system + /// memory. explicit GUIFont(const std::string& Name); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Load - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Loads the font from an image file. - // Arguments: Screen class, Filename of image. - + /// Loads the font from an image file. + /// @param Screen Screen class, Filename of image. bool Load(GUIScreen* Screen, const std::string& Filename); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: CacheColor - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Pre-Calculates the font using a specific color. - // Arguments: Color. - + /// Pre-Calculates the font using a specific color. + /// @param Color Color. void CacheColor(unsigned long Color); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetFontColor - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Finds a font color structure from the cache. - // Arguments: Color. - + /// Finds a font color structure from the cache. + /// @param Color Color. FontColor* GetFontColor(unsigned long Color); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Draw - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws text to a bitmap. - // Arguments: Bitmap, Position, Text, Color, Drop-shadow, 0 = none. - + /// Draws text to a bitmap. + /// @param Bitmap Bitmap, Position, Text, Color, Drop-shadow, 0 = none. void Draw(GUIBitmap* Bitmap, int X, int Y, const std::string& Text, unsigned long Shadow = 0); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: DrawAligned - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws text to a bitmap aligned. - // Arguments: Bitmap, Position, Text. - + /// Draws text to a bitmap aligned. + /// @param Bitmap Bitmap, Position, Text. void DrawAligned(GUIBitmap* Bitmap, int X, int Y, const std::string& Text, int HAlign, int VAlign = Top, int maxWidth = 0, unsigned long Shadow = 0); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetColor - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the current color. - // Arguments: Color. - + /// Sets the current color. + /// @param Color Color. void SetColor(unsigned long Color); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: CalculateWidth - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Calculates the width of a piece of text. - // Arguments: Text. - + /// Calculates the width of a piece of text. + /// @param Text Text. int CalculateWidth(const std::string& Text); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: CalculateWidth - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Calculates the width of a piece of text. - // Arguments: Character. - + /// Calculates the width of a piece of text. + /// @param Character Character. int CalculateWidth(const char Character); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: CalculateHeight - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Calculates the height of a piece of text, if it's wrapped within a - // max width. - // Arguments: Text, and the max width. If 0, no wrapping is done. - + /// Calculates the height of a piece of text, if it's wrapped within a + /// max width. + /// @param Text Text, and the max width. If 0, no wrapping is done. int CalculateHeight(const std::string& Text, int MaxWidth = 0); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetFontHeight - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the font height. - // Arguments: None. - + /// Gets the font height. int GetFontHeight() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetName - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the name of the font - // Arguments: None. - + /// Gets the name of the font std::string GetName() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destroys the font data - // Arguments: None. - + /// Destroys the font data void Destroy(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetKerning - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Get the character kerning (spacing) - // Arguments: None. - + /// Get the character kerning (spacing) int GetKerning() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetKerning - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Set the character kerning (spacing), in pixels. 1 = one empty pixel - // between chars, 0 = chars are touching. - // Arguments: None. - + /// Set the character kerning (spacing), in pixels. 1 = one empty pixel + /// between chars, 0 = chars are touching. void SetKerning(int newKerning = 1) { m_Kerning = newKerning; } private: diff --git a/Source/GUI/GUIInput.cpp b/Source/GUI/GUIInput.cpp index bac777c994..0326cc1df0 100644 --- a/Source/GUI/GUIInput.cpp +++ b/Source/GUI/GUIInput.cpp @@ -2,8 +2,6 @@ using namespace RTE; -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool GUIInput::m_OverrideInput = false; int GUIInput::m_NetworkMouseButtonsEvents[4][3] = {{-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}}; @@ -13,8 +11,6 @@ int GUIInput::m_PrevNetworkMouseButtonsStates[4][3] = {{-1, -1, -1}, {-1, -1, -1 int GUIInput::m_NetworkMouseX[4] = {0, 0, 0, 0}; int GUIInput::m_NetworkMouseY[4] = {0, 0, 0, 0}; -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIInput::GUIInput(int whichPlayer, bool keyJoyMouseCursor) { // Clear all the states memset(m_KeyboardBuffer, 0, sizeof(unsigned char) * KEYBOARD_BUFFER_SIZE); @@ -44,32 +40,22 @@ GUIInput::GUIInput(int whichPlayer, bool keyJoyMouseCursor) { m_MouseWheelChange = 0; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIInput::Destroy() {} -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIInput::GetKeyboard(unsigned char* Buffer) const { if (Buffer) { memcpy(Buffer, m_KeyboardBuffer, sizeof(unsigned char) * KEYBOARD_BUFFER_SIZE); } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - unsigned char GUIInput::GetAsciiState(unsigned char ascii) const { return m_KeyboardBuffer[ascii]; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - unsigned char GUIInput::GetScanCodeState(unsigned char scancode) const { return m_ScanCodeState[scancode]; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIInput::GetMouseButtons(int* Buttons, int* States) const { if (!m_OverrideInput) { if (Buttons) { @@ -97,8 +83,6 @@ void GUIInput::GetMouseButtons(int* Buttons, int* States) const { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIInput::SetNetworkMouseButton(int whichPlayer, int state1, int state2, int state3) { if (whichPlayer >= 0 && whichPlayer < 4) { m_OverrideInput = true; @@ -113,8 +97,6 @@ void GUIInput::SetNetworkMouseButton(int whichPlayer, int state1, int state2, in } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIInput::GetMousePosition(int* X, int* Y) const { if (m_OverrideInput) { if (m_Player >= 0 && m_Player < 4) { @@ -142,8 +124,6 @@ void GUIInput::GetMousePosition(int* X, int* Y) const { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIInput::SetNetworkMouseMovement(int whichPlayer, int x, int y) { if (whichPlayer >= 0 && whichPlayer < 4) { m_OverrideInput = true; @@ -152,14 +132,10 @@ void GUIInput::SetNetworkMouseMovement(int whichPlayer, int x, int y) { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIInput::Update() { // Do nothing } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int GUIInput::GetModifier() const { return m_Modifier; } diff --git a/Source/GUI/GUIInput.h b/Source/GUI/GUIInput.h index 9327132844..f74e6d15a8 100644 --- a/Source/GUI/GUIInput.h +++ b/Source/GUI/GUIInput.h @@ -3,9 +3,7 @@ namespace RTE { - /// /// An interface class inherited by the different types of input methods. - /// class GUIInput { public: @@ -51,68 +49,42 @@ namespace RTE { Key_PageDown = 0x0000009A } Keys; - ////////////////////////////////////////////////////////////////////////////////////////// - // Constructor: GUIInput - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Constructor method used to instantiate a GUIInput object in system - // memory. - // Arguments: Whether the keyboard and joysticks also can control the mouse cursor. - + /// Constructor method used to instantiate a GUIInput object in system + /// memory. + /// @param whichPlayer Whether the keyboard and joysticks also can control the mouse cursor. GUIInput(int whichPlayer, bool keyJoyMouseCursor = false); virtual ~GUIInput() { Destroy(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual Method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destroy the screen - // Arguments: None. - + /// Destroy the screen virtual void Destroy(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetMouseOffset - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the offset for the mouse input to be adjusted by. This should - // be used when the GUI is being drawn somewhere else on the screen than - // the upper left corner. These values should be from the GUI to the upper - // left corner. - // Arguments: The new offset. - + /// Sets the offset for the mouse input to be adjusted by. This should + /// be used when the GUI is being drawn somewhere else on the screen than + /// the upper left corner. These values should be from the GUI to the upper + /// left corner. + /// @param mouseOffsetX The new offset. void SetMouseOffset(int mouseOffsetX, int mouseOffsetY) { m_MouseOffsetX = mouseOffsetX; m_MouseOffsetY = mouseOffsetY; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetMouseOffset - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the offset for the mouse input to be adjusted by. This should - // These values should be from the GUI to the upper of the screen. - // left corner. - // Arguments: The new offset. - + /// Sets the offset for the mouse input to be adjusted by. This should + /// These values should be from the GUI to the upper of the screen. + /// left corner. + /// @param mouseOffsetX The new offset. void GetMouseOffset(int& mouseOffsetX, int& mouseOffsetY) const { mouseOffsetX = m_MouseOffsetX; mouseOffsetY = m_MouseOffsetY; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual Method: Update - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the Input. - // Arguments: None. - + /// Updates the Input. virtual void Update(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetKeyboard - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Copies the keyboard buffer into an array. The keyboard buffer is - // ordered by ascii code and each entry contains a GUInput::Event enum - // state. - // Arguments: Buffer array. - + /// Copies the keyboard buffer into an array. The keyboard buffer is + /// ordered by ascii code and each entry contains a GUInput::Event enum + /// state. + /// @param Buffer Buffer array. void GetKeyboard(unsigned char* Buffer) const; unsigned char GetAsciiState(unsigned char ascii) const; @@ -124,46 +96,29 @@ namespace RTE { return !m_TextInput.empty(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetMouseButtons - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Copies the mouse button states into an array - // Arguments: State array. - + /// Copies the mouse button states into an array + /// @param Events State array. void GetMouseButtons(int* Events, int* States) const; static void SetNetworkMouseButton(int whichPlayer, int state1, int state2, int state3); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetMousePosition - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the mouse position - // Arguments: Pointers to store the X and Y coordinates in - + /// Gets the mouse position + /// @param X Pointers to store the X and Y coordinates in void GetMousePosition(int* X, int* Y) const; static void SetNetworkMouseMovement(int whichPlayer, int x, int y); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetModifier - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the key modifiers. - // Arguments: None. - + /// Gets the key modifiers. int GetModifier() const; - /// /// This function returns how much the mouse scroll wheel has moved. Positive integer is scroll up, negative is scroll down. - /// - /// Mouse scroll wheel movement in integer value. + /// @return Mouse scroll wheel movement in integer value. int GetMouseWheelChange() const { return m_MouseWheelChange; } - /// /// Sets whether the keyboard and joysticks also control the mouse. - /// - /// Whether the keyboard and joysticks also control the mouse or not. + /// @param enableKeyJoyMouseCursor Whether the keyboard and joysticks also control the mouse or not. void SetKeyJoyMouseCursor(bool enableKeyJoyMouseCursor) { m_KeyJoyMouseCursor = enableKeyJoyMouseCursor; } protected: diff --git a/Source/GUI/GUIInterface.h b/Source/GUI/GUIInterface.h index 6651320f10..711f9229de 100644 --- a/Source/GUI/GUIInterface.h +++ b/Source/GUI/GUIInterface.h @@ -8,166 +8,122 @@ struct BITMAP; namespace RTE { #pragma region GUIBitmap - /// /// An interface class inherited by the different types of bitmap methods. - /// class GUIBitmap { public: #pragma region Creation - /// /// Constructor method used to instantiate a GUIBitmap object in system memory. - /// GUIBitmap() = default; #pragma endregion #pragma region Destruction - /// /// Destructor method used to clean up a GUIBitmap object before deletion from system memory. - /// virtual ~GUIBitmap() = default; - /// /// Destroys and resets the GUIBitmap object. - /// virtual void Destroy() = 0; #pragma endregion #pragma region Getters and Setters - /// /// Gets the path to the data file this GUIBitmap uses. - /// - /// >Path to the data file this GUIBitmap uses. + /// @return >Path to the data file this GUIBitmap uses. virtual std::string GetDataPath() const = 0; - /// /// Gets the underlying BITMAP of this GUIBitmap. - /// - /// The underlying BITMAP of this GUIBitmap. + /// @return The underlying BITMAP of this GUIBitmap. virtual BITMAP* GetBitmap() const = 0; - /// /// Sets the underlying BITMAP for this GUIBitmap. - /// - /// A pointer to the new BITMAP for this GUIBitmap. + /// @param newBitmap A pointer to the new BITMAP for this GUIBitmap. virtual void SetBitmap(BITMAP* newBitmap) = 0; - /// /// Gets the width of the bitmap. - /// - /// The width of the bitmap. + /// @return The width of the bitmap. virtual int GetWidth() const = 0; - /// /// Gets the height of the bitmap. - /// - /// The height of the bitmap. + /// @return The height of the bitmap. virtual int GetHeight() const = 0; - /// /// Gets the number of bits per pixel color depth of the bitmap. - /// - /// The color depth of the bitmap. + /// @return The color depth of the bitmap. virtual int GetColorDepth() const = 0; - /// /// Gets the color of a pixel at a specific point on the bitmap. - /// - /// X position on bitmap. - /// Y position on bitmap. - /// The color of the pixel at the specified point. + /// @param posX X position on bitmap. + /// @param posY Y position on bitmap. + /// @return The color of the pixel at the specified point. virtual unsigned long GetPixel(int posX, int posY) const = 0; - /// /// Sets the color of a pixel at a specific point on the bitmap. - /// - /// X position on bitmap. - /// Y position on bitmap. - /// The color to set the pixel to. + /// @param posX X position on bitmap. + /// @param posY Y position on bitmap. + /// @param pixelColor The color to set the pixel to. virtual void SetPixel(int posX, int posY, unsigned long pixelColor) = 0; - /// /// Sets the color key (mask color) of the bitmap to the color of the pixel in the upper right corner of the bitmap. - /// virtual void SetColorKey() {} - /// /// Sets the color key (mask color) of the bitmap. - /// - /// Color key (mask color). + /// @param colorKey Color key (mask color). virtual void SetColorKey(unsigned long colorKey) {} #pragma endregion #pragma region Clipping - /// /// Gets the clipping rectangle of the bitmap. - /// - /// Pointer to a GUIRect to fill out. + /// @param clippingRect Pointer to a GUIRect to fill out. virtual void GetClipRect(GUIRect* clippingRect) const = 0; - /// /// Sets the clipping rectangle of the bitmap. - /// - /// Pointer to a GUIRect to use as the clipping rectangle, or nullptr for no clipping. + /// @param clippingRect Pointer to a GUIRect to use as the clipping rectangle, or nullptr for no clipping. virtual void SetClipRect(GUIRect* clippingRect) = 0; - /// /// Sets the clipping rectangle of the specified bitmap as the intersection of its current clipping rectangle and the rectangle described by the passed-in GUIRect. - /// - /// Rectangle pointer. + /// @param rect Rectangle pointer. virtual void AddClipRect(GUIRect* rect) = 0; #pragma endregion #pragma region Drawing - /// /// Draw a section of this bitmap onto another bitmap. - /// - /// Bitmap to draw onto. - /// Destination X position. - /// Destination Y position. - /// Source bitmap position and size rectangle. + /// @param destBitmap Bitmap to draw onto. + /// @param destX Destination X position. + /// @param destY Destination Y position. + /// @param srcPosAndSizeRect Source bitmap position and size rectangle. virtual void Draw(GUIBitmap* destBitmap, int destX, int destY, GUIRect* srcPosAndSizeRect) = 0; - /// /// Draw a section of this bitmap onto another bitmap ignoring color-keyed pixels. - /// - /// Bitmap to draw onto. - /// Destination X position. - /// Destination Y position. - /// Source bitmap position and size rectangle. + /// @param destBitmap Bitmap to draw onto. + /// @param destX Destination X position. + /// @param destY Destination Y position. + /// @param srcPosAndSizeRect Source bitmap position and size rectangle. virtual void DrawTrans(GUIBitmap* destBitmap, int destX, int destY, GUIRect* srcPosAndSizeRect) = 0; - /// /// Draw this bitmap scaled onto another bitmap ignoring color-keyed pixels. - /// - /// Bitmap to draw onto. - /// Destination X position. - /// Destination Y position. - /// Target width of the bitmap. - /// Target height of the bitmap. + /// @param destBitmap Bitmap to draw onto. + /// @param destX Destination X position. + /// @param destY Destination Y position. + /// @param width Target width of the bitmap. + /// @param height Target height of the bitmap. virtual void DrawTransScaled(GUIBitmap* destBitmap, int destX, int destY, int width, int height) = 0; #pragma endregion #pragma region Primitive Drawing - /// /// Draws a line on this bitmap. - /// - /// Start position on X axis. - /// Start position on Y axis. - /// End position on X axis. - /// End position on Y axis. - /// Color to draw this line with. + /// @param x1 Start position on X axis. + /// @param y1 Start position on Y axis. + /// @param x2 End position on X axis. + /// @param y2 End position on Y axis. + /// @param color Color to draw this line with. virtual void DrawLine(int x1, int y1, int x2, int y2, unsigned long color) = 0; - /// /// Draws a rectangle on this bitmap. - /// - /// Position on X axis. - /// Position on Y axis. - /// Width of rectangle. - /// Height of rectangle. - /// Color to draw this rectangle with. - /// Whether to fill the rectangle with the set color or not. + /// @param posX Position on X axis. + /// @param posY Position on Y axis. + /// @param width Width of rectangle. + /// @param height Height of rectangle. + /// @param color Color to draw this rectangle with. + /// @param filled Whether to fill the rectangle with the set color or not. virtual void DrawRectangle(int posX, int posY, int width, int height, unsigned long color, bool filled) = 0; #pragma endregion @@ -177,79 +133,59 @@ namespace RTE { #pragma endregion #pragma region GUIScreen - /// /// An interface class inherited by the different types of graphics methods. - /// class GUIScreen { public: #pragma region Creation - /// /// Constructor method used to instantiate a GUIScreen object in system memory. - /// GUIScreen() = default; - /// /// Creates a bitmap from a file. - /// - /// File name to create bitmap from. - /// Pointer to the created bitmap. + /// @param fileName File name to create bitmap from. + /// @return Pointer to the created bitmap. virtual GUIBitmap* CreateBitmap(const std::string& fileName) = 0; - /// /// Creates an empty bitmap. - /// - /// Bitmap width. - /// Bitmap height. - /// Pointer to the created bitmap. + /// @param width Bitmap width. + /// @param height Bitmap height. + /// @return Pointer to the created bitmap. virtual GUIBitmap* CreateBitmap(int width, int height) = 0; #pragma endregion #pragma region Destruction - /// /// Destructor method used to clean up a GUIScreen object before deletion from system memory. - /// virtual ~GUIScreen() = default; - /// /// Destroys and resets the GUIScreen object. - /// virtual void Destroy() = 0; #pragma endregion #pragma region Getters - /// /// Gets the bitmap representing the screen. - /// - /// Pointer to the bitmap representing the screen. + /// @return Pointer to the bitmap representing the screen. virtual GUIBitmap* GetBitmap() const = 0; #pragma endregion #pragma region Pure Virtual Methods - /// /// Draws a bitmap onto the back buffer. - /// - /// The bitmap to draw to this AllegroScreen. - /// Destination X position - /// Destination Y position - /// Source bitmap position and size rectangle. + /// @param guiBitmap The bitmap to draw to this AllegroScreen. + /// @param destX Destination X position + /// @param destY Destination Y position + /// @param srcPosAndSizeRect Source bitmap position and size rectangle. virtual void DrawBitmap(GUIBitmap* guiBitmap, int destX, int destY, GUIRect* srcPosAndSizeRect) = 0; - /// /// Draws a bitmap onto the back buffer ignoring color-keyed pixels. - /// - /// The bitmap to draw to this AllegroScreen. - /// Destination X position - /// Destination Y position - /// Source bitmap position and size rectangle. + /// @param guiBitmap The bitmap to draw to this AllegroScreen. + /// @param destX Destination X position + /// @param destY Destination Y position + /// @param srcPosAndSizeRect Source bitmap position and size rectangle. virtual void DrawBitmapTrans(GUIBitmap* guiBitmap, int destX, int destY, GUIRect* srcPosAndSizeRect) = 0; - /// /// Converts an 8bit palette index to a valid pixel format color. - /// - /// Color value in any bit depth. Will be converted to the format specified. - /// An optional target color depth that will determine what format the color should be converted to. If this is 0, then the current video color depth will be used as target. - /// The converted color. + /// @param color Color value in any bit depth. Will be converted to the format specified. + /// @param targetColorDepth An optional target color depth that will determine what format the color should be converted to. If this is 0, then the current video color depth will be used as target. + /// @return The converted color. virtual unsigned long ConvertColor(unsigned long color, int targetColorDepth = 0) = 0; #pragma endregion diff --git a/Source/GUI/GUILabel.cpp b/Source/GUI/GUILabel.cpp index 96e9b8e6c5..cf659b413d 100644 --- a/Source/GUI/GUILabel.cpp +++ b/Source/GUI/GUILabel.cpp @@ -3,8 +3,6 @@ using namespace RTE; -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUILabel::GUILabel(GUIManager* Manager, GUIControlManager* ControlManager) : GUIControl(), GUIPanel(Manager) { m_ControlID = "LABEL"; @@ -20,8 +18,6 @@ GUILabel::GUILabel(GUIManager* Manager, GUIControlManager* ControlManager) : m_OverflowScrollTimer = Timer(); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUILabel::Create(const std::string& Name, int X, int Y, int Width, int Height) { GUIControl::Create(Name, X, Y, Width, Height); @@ -51,8 +47,6 @@ void GUILabel::Create(const std::string& Name, int X, int Y, int Width, int Heig m_Height = std::max(m_Height, m_MinHeight); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUILabel::Create(GUIProperties* Props) { GUIControl::Create(Props); @@ -101,8 +95,6 @@ void GUILabel::Create(GUIProperties* Props) { Props->GetValue("VerticalOverflowScroll", &m_VerticalOverflowScroll); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUILabel::ChangeSkin(GUISkin* Skin) { GUIControl::ChangeSkin(Skin); @@ -118,15 +110,11 @@ void GUILabel::ChangeSkin(GUISkin* Skin) { m_Font->CacheColor(m_FontColor); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUILabel::Draw(GUIScreen* Screen) { Draw(Screen->GetBitmap()); GUIPanel::Draw(Screen); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUILabel::Draw(GUIBitmap* Bitmap, bool overwiteFontColorAndKerning) { // Setup the clipping Bitmap->AddClipRect(GetRect()); @@ -212,8 +200,6 @@ void GUILabel::Draw(GUIBitmap* Bitmap, bool overwiteFontColorAndKerning) { Bitmap->SetClipRect(nullptr); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUILabel::OnMouseDown(int X, int Y, int Buttons, int Modifier) { if (Buttons & MOUSE_LEFT) { CaptureMouse(); @@ -221,8 +207,6 @@ void GUILabel::OnMouseDown(int X, int Y, int Buttons, int Modifier) { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUILabel::OnMouseUp(int X, int Y, int Buttons, int Modifier) { // If the mouse is over the button, add the clicked notification to the event queue if (PointInside(X, Y) && (Buttons & MOUSE_LEFT) && IsCaptured()) { @@ -232,20 +216,14 @@ void GUILabel::OnMouseUp(int X, int Y, int Buttons, int Modifier) { ReleaseMouse(); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIPanel* GUILabel::GetPanel() { return this; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUILabel::Move(int X, int Y) { GUIPanel::SetPositionAbs(X, Y); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUILabel::Resize(int Width, int Height) { // Make sure the control isn't too small Width = std::max(Width, m_MinWidth); @@ -254,8 +232,6 @@ void GUILabel::Resize(int Width, int Height) { GUIPanel::SetSize(Width, Height); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int GUILabel::ResizeHeightToFit() { int newHeight = m_Font->CalculateHeight(m_Text, m_Width); GUIPanel::SetSize(m_Width, newHeight); @@ -263,20 +239,14 @@ int GUILabel::ResizeHeightToFit() { return newHeight; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUILabel::GetControlRect(int* X, int* Y, int* Width, int* Height) { GUIPanel::GetRect(X, Y, Width, Height); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int GUILabel::GetTextHeight() { return m_Font->CalculateHeight(m_Text, m_Width); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUILabel::SetHorizontalOverflowScroll(bool newOverflowScroll) { m_HorizontalOverflowScroll = newOverflowScroll; if (m_HorizontalOverflowScroll) { @@ -286,8 +256,6 @@ void GUILabel::SetHorizontalOverflowScroll(bool newOverflowScroll) { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUILabel::SetVerticalOverflowScroll(bool newOverflowScroll) { m_VerticalOverflowScroll = newOverflowScroll; if (m_VerticalOverflowScroll) { @@ -297,8 +265,6 @@ void GUILabel::SetVerticalOverflowScroll(bool newOverflowScroll) { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUILabel::ActivateDeactivateOverflowScroll(bool activateScroll) { if (OverflowScrollIsEnabled() && activateScroll != OverflowScrollIsActivated()) { m_OverflowScrollState = activateScroll ? OverflowScrollState::WaitAtStart : OverflowScrollState::Deactivated; @@ -306,8 +272,6 @@ void GUILabel::ActivateDeactivateOverflowScroll(bool activateScroll) { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUILabel::StoreProperties() { m_Properties.AddVariable("Text", m_Text); @@ -329,8 +293,6 @@ void GUILabel::StoreProperties() { m_Properties.AddVariable("VerticalOverflowScroll", m_VerticalOverflowScroll); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUILabel::ApplyProperties(GUIProperties* Props) { GUIControl::ApplyProperties(Props); diff --git a/Source/GUI/GUILabel.h b/Source/GUI/GUILabel.h index fe2daa4c04..573e704b39 100644 --- a/Source/GUI/GUILabel.h +++ b/Source/GUI/GUILabel.h @@ -7,9 +7,7 @@ namespace RTE { - /// /// A label control class. - /// class GUILabel : public GUIControl, public GUIPanel { public: @@ -25,234 +23,123 @@ namespace RTE { WaitAtEnd }; - ////////////////////////////////////////////////////////////////////////////////////////// - // Constructor: GUILabel - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Constructor method used to instantiate a GUILabel object in - // system memory. - // Arguments: GUIManager, GUIControlManager. - + /// Constructor method used to instantiate a GUILabel object in + /// system memory. + /// @param Manager GUIManager, GUIControlManager. GUILabel(GUIManager* Manager, GUIControlManager* ControlManager); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the control has been created. - // Arguments: Name, Position. - + /// Called when the control has been created. + /// @param Name Name, Position. void Create(const std::string& Name, int X, int Y, int Width = -1, int Height = -1) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the control has been created. - // Arguments: Properties. - + /// Called when the control has been created. + /// @param Props Properties. void Create(GUIProperties* Props) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ChangeSkin - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the skin has been changed. - // Arguments: New skin pointer. - + /// Called when the skin has been changed. + /// @param Skin New skin pointer. void ChangeSkin(GUISkin* Skin) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Draw - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws the panel - // Arguments: Screen class - + /// Draws the panel + /// @param Screen Screen class void Draw(GUIScreen* Screen) override; - /// /// Draws the Label to the given GUIBitmap. - /// - /// The GUIBitmap to draw the label to. - /// Whether to overwrite the font's color and kerning with the stored values. Defaults to true, which is usually what you want. + /// @param Bitmap The GUIBitmap to draw the label to. + /// @param overwiteFontColorAndKerning Whether to overwrite the font's color and kerning with the stored values. Defaults to true, which is usually what you want. void Draw(GUIBitmap* Bitmap, bool overwiteFontColorAndKerning = true); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: OnMouseDown - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the mouse goes down on the panel - // Arguments: Mouse Position, Mouse Buttons, Modifier. - + /// Called when the mouse goes down on the panel + /// @param X Mouse Position, Mouse Buttons, Modifier. void OnMouseDown(int X, int Y, int Buttons, int Modifier) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: OnMouseUp - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the mouse goes up on the panel - // Arguments: Mouse Position, Mouse Buttons, Modifier. - + /// Called when the mouse goes up on the panel + /// @param X Mouse Position, Mouse Buttons, Modifier. void OnMouseUp(int X, int Y, int Buttons, int Modifier) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetPanel - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns the panel of the control. - // Arguments: None. - // Returns: 0 if the control does not have a panel, otherwise the topmost panel. - + /// Returns the panel of the control. + /// @return 0 if the control does not have a panel, otherwise the topmost panel. GUIPanel* GetPanel() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetControlID - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns a string representing the control's ID - // Arguments: None. - + /// Returns a string representing the control's ID static std::string GetControlID() { return "LABEL"; }; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Move - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the control needs to be moved. - // Arguments: New position. - + /// Called when the control needs to be moved. + /// @param X New position. void Move(int X, int Y) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Resize - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the control needs to be resized. - // Arguments: New size. - + /// Called when the control needs to be resized. + /// @param Width New size. void Resize(int Width, int Height) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ResizeHeightToFit - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Resize the height of the label to fit the amount of text it has to - // display. - // Arguments: None. - // Returns: The new height in pixels. - + /// Resize the height of the label to fit the amount of text it has to + /// display. + /// @return The new height in pixels. int ResizeHeightToFit(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetControlRect - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the rectangle of the control. - // Arguments: Position, Size. - + /// Gets the rectangle of the control. + /// @param X Position, Size. void GetControlRect(int* X, int* Y, int* Width, int* Height) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetText - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the text of the label. - // Arguments: text. - + /// Sets the text of the label. + /// @param text. void SetText(const std::string_view& text) { m_Text = text; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetText - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the text of the label. - // Arguments: None. - + /// Gets the text of the label. const std::string& GetText() const { return m_Text; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetTextHeight - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Shows how tall the current text is with the current width and font etc. - // Arguments: None. - // Returns: The text height, in pixels - + /// Shows how tall the current text is with the current width and font etc. + /// @return The text height, in pixels int GetTextHeight(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetHAlignment - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the horizontal alignment of the text of this label. - // Arguments: The desired alignment. - + /// Sets the horizontal alignment of the text of this label. + /// @param HAlignment The desired alignment. (default: GUIFont::Left) void SetHAlignment(int HAlignment = GUIFont::Left) { m_HAlignment = HAlignment; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetVAlignment - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the vertical alignment of the text of this label. - // Arguments: The desired alignment. - + /// Sets the vertical alignment of the text of this label. + /// @param VAlignment The desired alignment. (default: GUIFont::Top) void SetVAlignment(int VAlignment = GUIFont::Top) { m_VAlignment = VAlignment; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetHAlignment - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the horizontal alignment of the text of this label. - // Arguments: None. - + /// Gets the horizontal alignment of the text of this label. int GetHAlignment() const { return m_HAlignment; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetVAlignment - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the vertical alignment of the text of this label. - // Arguments: The desired alignment. - + /// Gets the vertical alignment of the text of this label. + /// @param The desired alignment. int GetVAlignment() const { return m_VAlignment; } - /// /// Gets whether or not this GUILabel should scroll horizontally (right) when it overflows. - /// - /// Whether or not this GUILabel should scroll horizontally when it overflows. + /// @return Whether or not this GUILabel should scroll horizontally when it overflows. bool GetHorizontalOverflowScroll() const { return m_HorizontalOverflowScroll; } - /// /// Sets whether or not this GUILabel should scroll horizontally (right) when it overflows. Mutually exclusive with horizontal overflow scrolling. - /// - /// Whether or not this GUILabel should scroll horizontally when it overflows. + /// @param newOverflowScroll Whether or not this GUILabel should scroll horizontally when it overflows. void SetHorizontalOverflowScroll(bool newOverflowScroll); - /// /// Gets whether or not this GUILabel should scroll vertically (down) when it overflows. - /// - /// Whether or not this GUILabel should scroll vertically when it overflows. + /// @return Whether or not this GUILabel should scroll vertically when it overflows. bool GetVerticalOverflowScroll() const { return m_VerticalOverflowScroll; } - /// /// Sets whether or not this GUILabel should scroll vertically (down) when it overflows. Mutually exclusive with horizontal overflow scrolling. - /// - /// Whether or not this GUILabel should scroll vertically when it overflows. + /// @param newOverflowScroll Whether or not this GUILabel should scroll vertically when it overflows. void SetVerticalOverflowScroll(bool newOverflowScroll); - /// /// Gets whether or not horizontal or vertical overflow scrolling is turned on. - /// - /// Whether or not horizontal or vertical overflow scrolling is turned on. + /// @return Whether or not horizontal or vertical overflow scrolling is turned on. bool OverflowScrollIsEnabled() const { return m_HorizontalOverflowScroll || m_VerticalOverflowScroll; } - /// /// Gets whether or not horizontal/vertical scrolling is happening. - /// - /// Whether or not horizontal/vertical scrolling is happening. + /// @return Whether or not horizontal/vertical scrolling is happening. bool OverflowScrollIsActivated() const { return OverflowScrollIsEnabled() && m_OverflowScrollState != OverflowScrollState::Deactivated; } - /// /// Sets whether or not horizontal/vertical scrolling should be happening. When it's deactivated, text will instantly go back to un-scrolled. - /// - /// Whether the overflow scrolling should activate (true) or deactivate (false). + /// @param activateScroll Whether the overflow scrolling should activate (true) or deactivate (false). void ActivateDeactivateOverflowScroll(bool activateScroll); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: StoreProperties - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the control to store the values into properties. - // Arguments: None. - + /// Gets the control to store the values into properties. void StoreProperties() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ApplyProperties - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Applies new properties to the control. - // Arguments: GUIProperties. - + /// Applies new properties to the control. + /// @param Props GUIProperties. void ApplyProperties(GUIProperties* Props) override; private: diff --git a/Source/GUI/GUIListBox.cpp b/Source/GUI/GUIListBox.cpp index bea873ea24..092095f935 100644 --- a/Source/GUI/GUIListBox.cpp +++ b/Source/GUI/GUIListBox.cpp @@ -3,16 +3,12 @@ using namespace RTE; -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIListBox::GUIListBox(GUIManager* Manager, GUIControlManager* ControlManager) : GUIControl(), GUIListPanel(Manager) { m_ControlID = "LISTBOX"; m_ControlManager = ControlManager; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIListBox::Create(const std::string& Name, int X, int Y, int Width, int Height) { GUIControl::Create(Name, X, Y, Width, Height); @@ -41,8 +37,6 @@ void GUIListBox::Create(const std::string& Name, int X, int Y, int Width, int He GUIListPanel::Create(X, Y, w, h); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIListBox::Create(GUIProperties* Props) { GUIControl::Create(Props); @@ -69,26 +63,18 @@ void GUIListBox::Create(GUIProperties* Props) { SetMultiSelect(Multi); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIListBox::Destroy() { GUIListPanel::Destroy(); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIListBox::ChangeSkin(GUISkin* Skin) { GUIListPanel::ChangeSkin(Skin); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIListBox::Move(int X, int Y) { SetPositionAbs(X, Y); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIListBox::Resize(int Width, int Height) { // Make sure the listbox isn't too small Width = std::max(Width, m_MinWidth); @@ -97,26 +83,18 @@ void GUIListBox::Resize(int Width, int Height) { SetSize(Width, Height); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIPanel* GUIListBox::GetPanel() { return this; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIListBox::GetControlRect(int* X, int* Y, int* Width, int* Height) { GUIListPanel::GetRect(X, Y, Width, Height); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIListBox::StoreProperties() { m_Properties.AddVariable("MultiSelect", GetMultiSelect()); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIListBox::ReceiveSignal(GUIPanel* Source, int Code, int Data) { if (Source->GetPanelID() == GetPanelID()) { if (Code == GUIListPanel::MouseMove) { @@ -143,8 +121,6 @@ void GUIListBox::ReceiveSignal(GUIPanel* Source, int Code, int Data) { GUIListPanel::ReceiveSignal(Source, Code, Data); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIListBox::ApplyProperties(GUIProperties* Props) { GUIControl::ApplyProperties(Props); diff --git a/Source/GUI/GUIListBox.h b/Source/GUI/GUIListBox.h index e771887dc3..49fbe4db47 100644 --- a/Source/GUI/GUIListBox.h +++ b/Source/GUI/GUIListBox.h @@ -5,116 +5,58 @@ namespace RTE { - /// /// A ListBox control class. - /// class GUIListBox : public GUIControl, public GUIListPanel { public: - ////////////////////////////////////////////////////////////////////////////////////////// - // Constructor: GUIListBox - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Constructor method used to instantiate a GUIListBox object in - // system memory. - // Arguments: GUIManager, GUIControlManager. - + /// Constructor method used to instantiate a GUIListBox object in + /// system memory. + /// @param Manager GUIManager, GUIControlManager. GUIListBox(GUIManager* Manager, GUIControlManager* ControlManager); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the control has been created. - // Arguments: Name, Position. - + /// Called when the control has been created. + /// @param Name Name, Position. void Create(const std::string& Name, int X, int Y, int Width = -1, int Height = -1) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the control has been destroyed. - // Arguments: None. - + /// Called when the control has been destroyed. void Destroy() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the control has been created. - // Arguments: Properties. - + /// Called when the control has been created. + /// @param Props Properties. void Create(GUIProperties* Props) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ChangeSkin - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the skin has been changed. - // Arguments: New skin pointer. - + /// Called when the skin has been changed. + /// @param Skin New skin pointer. void ChangeSkin(GUISkin* Skin) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetPanel - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns the panel of the control. - // Arguments: None. - // Returns: 0 if the control does not have a panel, otherwise the topmost panel. - + /// Returns the panel of the control. + /// @return 0 if the control does not have a panel, otherwise the topmost panel. GUIPanel* GetPanel() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetControlID - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns a string representing the control's ID - // Arguments: None. - + /// Returns a string representing the control's ID static std::string GetControlID() { return "LISTBOX"; }; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Move - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the control needs to be moved. - // Arguments: New position. - + /// Called when the control needs to be moved. + /// @param X New position. void Move(int X, int Y) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Resize - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the control needs to be resized. - // Arguments: New size. - + /// Called when the control needs to be resized. + /// @param Width New size. void Resize(int Width, int Height) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetControlRect - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the rectangle of the control. - // Arguments: Position, Size. - + /// Gets the rectangle of the control. + /// @param X Position, Size. void GetControlRect(int* X, int* Y, int* Width, int* Height) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: StoreProperties - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the control to store the values into properties. - // Arguments: None. - + /// Gets the control to store the values into properties. void StoreProperties() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ReceiveSignal - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when receiving a signal. - // Arguments: Signal source, Signal code, Signal data. - + /// Called when receiving a signal. + /// @param Source Signal source, Signal code, Signal data. void ReceiveSignal(GUIPanel* Source, int Code, int Data) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ApplyProperties - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Applies new properties to the control. - // Arguments: GUIProperties. - + /// Applies new properties to the control. + /// @param Props GUIProperties. void ApplyProperties(GUIProperties* Props) override; private: diff --git a/Source/GUI/GUIListPanel.cpp b/Source/GUI/GUIListPanel.cpp index 25df8db1d9..10550a70a6 100644 --- a/Source/GUI/GUIListPanel.cpp +++ b/Source/GUI/GUIListPanel.cpp @@ -5,8 +5,6 @@ using namespace RTE; #define RIGHTTEXTWIDTH 36 -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIListPanel::GUIListPanel(GUIManager* Manager) : GUIPanel(Manager) { m_BaseBitmap = nullptr; @@ -36,8 +34,6 @@ GUIListPanel::GUIListPanel(GUIManager* Manager) : m_MouseScroll = false; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIListPanel::GUIListPanel() : GUIPanel() { m_BaseBitmap = nullptr; @@ -67,8 +63,6 @@ GUIListPanel::GUIListPanel() : m_MouseScroll = false; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIListPanel::Create(int X, int Y, int Width, int Height) { m_X = X; m_Y = Y; @@ -98,8 +92,6 @@ void GUIListPanel::Create(int X, int Y, int Width, int Height) { AddChild(m_VertScroll); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIListPanel::Destroy() { // Destroy the items std::vector::iterator it; @@ -148,8 +140,6 @@ void GUIListPanel::Destroy() { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIListPanel::ClearList() { // Destroy the items std::vector::iterator it; @@ -172,8 +162,6 @@ void GUIListPanel::ClearList() { BuildBitmap(false, true); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIListPanel::AddItem(const std::string& Name, const std::string& rightText, GUIBitmap* pBitmap, const Entity* pEntity, const int extraIndex, const int offsetX) { Item* I = new Item; I->m_Name = Name; @@ -201,8 +189,6 @@ void GUIListPanel::AddItem(const std::string& Name, const std::string& rightText BuildBitmap(false, true); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIListPanel::ChangeSkin(GUISkin* Skin) { assert(Skin); @@ -219,8 +205,6 @@ void GUIListPanel::ChangeSkin(GUISkin* Skin) { BuildBitmap(true, true); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIListPanel::BuildBitmap(bool UpdateBase, bool UpdateText) { // Gotta update the text if updating the base if (UpdateBase) @@ -291,8 +275,6 @@ void GUIListPanel::BuildBitmap(bool UpdateBase, bool UpdateText) { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIListPanel::BuildDrawBitmap() { // Draw the items std::vector::iterator it; @@ -410,8 +392,6 @@ void GUIListPanel::BuildDrawBitmap() { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIListPanel::Draw(GUIScreen* Screen) { // Draw the base m_DrawBitmap->Draw(Screen->GetBitmap(), m_X, m_Y, nullptr); @@ -420,8 +400,6 @@ void GUIListPanel::Draw(GUIScreen* Screen) { GUIPanel::Draw(Screen); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIListPanel::OnMouseDown(int X, int Y, int Buttons, int Modifier) { m_ExternalCapture = IsCaptured(); @@ -447,8 +425,6 @@ void GUIListPanel::OnMouseDown(int X, int Y, int Buttons, int Modifier) { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIListPanel::OnMouseWheelChange(int x, int y, int modifier, int mouseWheelChange) { if (!m_MouseScroll) { return; @@ -461,8 +437,6 @@ void GUIListPanel::OnMouseWheelChange(int x, int y, int modifier, int mouseWheel } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIListPanel::SelectItem(int X, int Y, int Modifier) { std::vector::iterator it; bool Shift = Modifier & MODI_SHIFT; @@ -582,8 +556,6 @@ void GUIListPanel::SelectItem(int X, int Y, int Modifier) { BuildBitmap(false, true); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIListPanel::OnMouseUp(int X, int Y, int Buttons, int Modifier) { if (m_CapturedVert) { m_VertScroll->OnMouseUp(X, Y, Buttons, Modifier); @@ -598,8 +570,6 @@ void GUIListPanel::OnMouseUp(int X, int Y, int Buttons, int Modifier) { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIListPanel::OnMouseMove(int X, int Y, int Buttons, int Modifier) { if (m_CapturedVert) { m_VertScroll->OnMouseMove(X, Y, Buttons, Modifier); @@ -614,34 +584,24 @@ void GUIListPanel::OnMouseMove(int X, int Y, int Buttons, int Modifier) { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIListPanel::OnMouseEnter(int X, int Y, int Buttons, int Modifier) { SendSignal(MouseEnter, Buttons); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIListPanel::OnMouseLeave(int X, int Y, int Buttons, int Modifier) { SendSignal(MouseLeave, Buttons); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIListPanel::OnDoubleClick(int X, int Y, int Buttons, int Modifier) { if (PointInside(X, Y)) { SendSignal(DoubleClick, Buttons); } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIListPanel::BeginUpdate() { m_UpdateLocked = true; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIListPanel::EndUpdate() { m_UpdateLocked = false; @@ -649,8 +609,6 @@ void GUIListPanel::EndUpdate() { ChangeSkin(m_Skin); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIListPanel::ScrollToItem(Item* pItem) { if (pItem && m_VertScroll->_GetVisible()) { int stackHeight = GetStackHeight(pItem); @@ -666,8 +624,6 @@ void GUIListPanel::ScrollToItem(Item* pItem) { BuildBitmap(false, true); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIListPanel::ScrollUp() { const int sensitivity = 80; if (m_VertScroll->_GetVisible()) { @@ -676,8 +632,6 @@ void GUIListPanel::ScrollUp() { BuildBitmap(false, true); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIListPanel::ScrollDown() { const int sensitivity = 80; if (m_VertScroll->_GetVisible()) { @@ -692,8 +646,6 @@ void GUIListPanel::ScrollDown() { BuildBitmap(false, true); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIListPanel::ScrollTo(int position) { if (m_VertScroll->_GetVisible()) { m_VertScroll->SetValue(position); @@ -710,8 +662,6 @@ void GUIListPanel::ScrollTo(int position) { BuildBitmap(false, true); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIListPanel::ScrollToSelected() { if (!m_SelectedList.empty()) { ScrollToItem(*(m_SelectedList.begin())); @@ -719,15 +669,11 @@ void GUIListPanel::ScrollToSelected() { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIListPanel::ScrollToTop() { m_VertScroll->SetValue(0); BuildBitmap(false, true); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIListPanel::ScrollToBottom() { if (m_Items.empty()) { m_VertScroll->SetValue(0); @@ -737,20 +683,14 @@ void GUIListPanel::ScrollToBottom() { BuildBitmap(false, true); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIListPanel::SetSelectionScrollingLoop(bool scrollLoop) { m_LoopSelectionScroll = scrollLoop; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIListPanel::SetMouseScrolling(bool mouseScroll) { m_MouseScroll = mouseScroll; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIListPanel::ScrollBarScrolling(int mouseWheelChange) { int newValue = 0; Item* lastItem = GetItem(GetItemList()->size() - 1); @@ -771,8 +711,6 @@ void GUIListPanel::ScrollBarScrolling(int mouseWheelChange) { BuildBitmap(false, true); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIListPanel::SelectionListScrolling(int scrollDir) { std::size_t itemListSize = GetItemList()->size(); if (!itemListSize || !scrollDir) { @@ -795,8 +733,6 @@ void GUIListPanel::SelectionListScrolling(int scrollDir) { SetSelectedIndex(newItemIndex); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIListPanel::AdjustScrollbars() { // If the update is locked, don't update the scrollbars if (m_UpdateLocked) { @@ -888,8 +824,6 @@ void GUIListPanel::AdjustScrollbars() { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIListPanel::OnKeyPress(int KeyCode, int Modifier) { if (m_LastSelected < 0) { return; @@ -960,14 +894,10 @@ void GUIListPanel::OnKeyPress(int KeyCode, int Modifier) { BuildBitmap(false, true); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIListPanel::OnKeyDown(int KeyCode, int Modifier) { SendSignal(KeyDown, KeyCode); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool GUIListPanel::PointInsideList(int X, int Y) { bool inside = PointInside(X, Y); // Exclude the scrollbars if we are meant to @@ -977,24 +907,18 @@ bool GUIListPanel::PointInsideList(int X, int Y) { return inside; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIListPanel::OnGainFocus() { GUIPanel::OnGainFocus(); BuildBitmap(false, true); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIListPanel::OnLoseFocus() { GUIPanel::OnLoseFocus(); BuildBitmap(false, true); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIListPanel::ReceiveSignal(GUIPanel* Source, int Code, int Data) { // ChangeValue signal from scrollpanels? assert(Source); @@ -1020,8 +944,6 @@ void GUIListPanel::ReceiveSignal(GUIPanel* Source, int Code, int Data) { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIListPanel::SetMultiSelect(bool MultiSelect) { m_MultiSelect = MultiSelect; @@ -1031,14 +953,10 @@ void GUIListPanel::SetMultiSelect(bool MultiSelect) { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool GUIListPanel::GetMultiSelect() const { return m_MultiSelect; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIListPanel::SetHotTracking(bool HotTrack) { m_HotTracking = HotTrack; @@ -1048,8 +966,6 @@ void GUIListPanel::SetHotTracking(bool HotTrack) { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIListPanel::Item* GUIListPanel::GetSelected() { // Nothing in the list if (m_SelectedList.empty()) { @@ -1059,20 +975,14 @@ GUIListPanel::Item* GUIListPanel::GetSelected() { return m_SelectedList.at(0); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - std::vector* GUIListPanel::GetSelectionList() { return &m_SelectedList; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - std::vector* GUIListPanel::GetItemList() { return &m_Items; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIListPanel::Item* GUIListPanel::GetItem(int Index) { if (Index >= 0 && Index < m_Items.size()) { return m_Items.at(Index); @@ -1080,8 +990,6 @@ GUIListPanel::Item* GUIListPanel::GetItem(int Index) { return 0; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIListPanel::Item* GUIListPanel::GetItem(int X, int Y) { int Height = m_Height; if (m_HorzScroll->_GetVisible()) { @@ -1110,8 +1018,6 @@ GUIListPanel::Item* GUIListPanel::GetItem(int X, int Y) { return 0; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int GUIListPanel::GetItemHeight(Item* pItem) { int height = 0; @@ -1140,8 +1046,6 @@ int GUIListPanel::GetItemHeight(Item* pItem) { return height; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int GUIListPanel::GetStackHeight(Item* pItem) { int height = 0; @@ -1154,8 +1058,6 @@ int GUIListPanel::GetStackHeight(Item* pItem) { return height; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIListPanel::SetItemValues(int Index, Item& item) { if (Index >= 0 && Index < m_Items.size()) { *(m_Items.at(Index)) = item; @@ -1163,8 +1065,6 @@ void GUIListPanel::SetItemValues(int Index, Item& item) { BuildBitmap(false, true); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int GUIListPanel::GetSelectedIndex() { // Nothing in the list if (m_SelectedList.empty()) { @@ -1176,8 +1076,6 @@ int GUIListPanel::GetSelectedIndex() { return I->m_ID; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIListPanel::SetSelectedIndex(int Index) { // Clear the old selection std::vector::iterator it; @@ -1203,8 +1101,6 @@ void GUIListPanel::SetSelectedIndex(int Index) { BuildBitmap(false, true); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIListPanel::DeleteItem(int Index) { if (Index >= 0 && Index < m_Items.size()) { const Item* I = m_Items.at(Index); @@ -1241,8 +1137,6 @@ void GUIListPanel::DeleteItem(int Index) { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIListPanel::SetSize(int Width, int Height) { GUIPanel::SetSize(Width, Height); @@ -1259,8 +1153,6 @@ void GUIListPanel::SetSize(int Width, int Height) { BuildBitmap(true, true); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIListPanel::SetPositionAbs(int X, int Y) { GUIPanel::SetPositionAbs(X, Y); @@ -1272,8 +1164,6 @@ void GUIListPanel::SetPositionAbs(int X, int Y) { AdjustScrollbars(); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIListPanel::EnableScrollbars(bool Horizontal, bool Vertical) { m_HorzScrollEnabled = Horizontal; m_VertScrollEnabled = Vertical; diff --git a/Source/GUI/GUIListPanel.h b/Source/GUI/GUIListPanel.h index d5cc21c786..93a82ccfd1 100644 --- a/Source/GUI/GUIListPanel.h +++ b/Source/GUI/GUIListPanel.h @@ -8,9 +8,7 @@ namespace RTE { class Entity; - /// /// A listbox panel class used for controls requiring a listbox. - /// class GUIListPanel : public GUIPanel { public: @@ -54,444 +52,229 @@ namespace RTE { } }; - ////////////////////////////////////////////////////////////////////////////////////////// - // Constructor: GUIListPanel - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Constructor method used to instantiate a GUIListPanel object in - // system memory. - // Arguments: GUIManager. - + /// Constructor method used to instantiate a GUIListPanel object in + /// system memory. + /// @param Manager GUIManager. GUIListPanel(GUIManager* Manager); - ////////////////////////////////////////////////////////////////////////////////////////// - // Constructor: GUIListPanel - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Constructor method used to instantiate a GUIListPanel object in - // system memory. - // Arguments: None. - + /// Constructor method used to instantiate a GUIListPanel object in + /// system memory. GUIListPanel(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Create the listpanel - // Arguments: Position, Size. - + /// Create the listpanel + /// @param X Position, Size. void Create(int X, int Y, int Width, int Height); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the panel has been destroyed. - // Arguments: None. - + /// Called when the panel has been destroyed. void Destroy(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: AddItem - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Add an item to the list. - // Arguments: Name, extraText, Text which will be displayed right-justified in the item. - // a Bitmap object pointer alternatively pointing to a bitmap to display - // in the list. Ownership IS transferred! - // An Extra menu-specific index that this item may be associated with. - // Object instance associated with the item. Ownership is NOT TRANSFERRED! - + /// Add an item to the list. + /// @param Name Name, extraText, Text which will be displayed right-justified in the item. + /// a Bitmap object pointer alternatively pointing to a bitmap to display + /// in the list. Ownership IS transferred! + /// @param rightText An Extra menu-specific index that this item may be associated with. (default: "") + /// @param pBitmap Object instance associated with the item. Ownership is NOT TRANSFERRED! (default: nullptr) void AddItem(const std::string& Name, const std::string& rightText = "", GUIBitmap* pBitmap = nullptr, const Entity* pEntity = 0, const int extraIndex = -1, const int offsetX = 0); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ClearList - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears the list. - // Arguments: None. - + /// Clears the list. void ClearList(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ChangeSkin - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the skin has been changed. - // Arguments: New skin pointer. - + /// Called when the skin has been changed. + /// @param Skin New skin pointer. void ChangeSkin(GUISkin* Skin); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Draw - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws the panel - // Arguments: Screen class - + /// Draws the panel + /// @param Screen Screen class void Draw(GUIScreen* Screen) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: OnMouseDown - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the mouse goes down on the panel - // Arguments: Mouse Position, Mouse Buttons, Modifier. - + /// Called when the mouse goes down on the panel + /// @param X Mouse Position, Mouse Buttons, Modifier. void OnMouseDown(int X, int Y, int Buttons, int Modifier) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: OnMouseUp - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the mouse goes up on the panel - // Arguments: Mouse Position, Mouse Buttons, Modifier. - + /// Called when the mouse goes up on the panel + /// @param X Mouse Position, Mouse Buttons, Modifier. void OnMouseUp(int X, int Y, int Buttons, int Modifier) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: OnMouseMove - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the mouse moves (over the panel, or when captured). - // Arguments: Mouse Position, Mouse Buttons, Modifier. - + /// Called when the mouse moves (over the panel, or when captured). + /// @param X Mouse Position, Mouse Buttons, Modifier. void OnMouseMove(int X, int Y, int Buttons, int Modifier) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: OnMouseEnter - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the mouse enters the panel - // Arguments: Mouse Position, Mouse Buttons, Modifier. - + /// Called when the mouse enters the panel + /// @param X Mouse Position, Mouse Buttons, Modifier. void OnMouseEnter(int X, int Y, int Buttons, int Modifier) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: OnMouseLeave - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the mouse leaves the panel - // Arguments: Mouse Position, Mouse Buttons, Modifier. - + /// Called when the mouse leaves the panel + /// @param X Mouse Position, Mouse Buttons, Modifier. void OnMouseLeave(int X, int Y, int Buttons, int Modifier) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: OnDoubleClick - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the mouse has double-clicked on the pane. - // Arguments: Mouse Position, Mouse Buttons, Modifier. - + /// Called when the mouse has double-clicked on the pane. + /// @param X Mouse Position, Mouse Buttons, Modifier. void OnDoubleClick(int X, int Y, int Buttons, int Modifier) override; - /// /// Called when the mouse scroll wheel is moved. - /// - /// Mouse X position. - /// Mouse Y position. - /// Activated modifier buttons. - /// The amount of wheel movement. Positive is scroll up, negative is scroll down. + /// @param x Mouse X position. + /// @param y Mouse Y position. + /// @param modifier Activated modifier buttons. + /// @param mouseWheelChange The amount of wheel movement. Positive is scroll up, negative is scroll down. void OnMouseWheelChange(int x, int y, int modifier, int mouseWheelChange) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: OnKeyPress - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when a key is pressed (OnDown & repeating). - // Arguments: KeyCode, Modifier. - + /// Called when a key is pressed (OnDown & repeating). + /// @param KeyCode KeyCode, Modifier. void OnKeyPress(int KeyCode, int Modifier) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: OnKeyDown - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when a key goes down. - // Arguments: KeyCode, Modifier. - + /// Called when a key goes down. + /// @param KeyCode KeyCode, Modifier. void OnKeyDown(int KeyCode, int Modifier) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: PointInsideList - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Checks if a point is inside the panel, but not on the scrollbars if - // they are visible - // Arguments: X, Y Coordinates of point - // Return value: A boolean of the check result - + /// Checks if a point is inside the panel, but not on the scrollbars if + /// they are visible + /// @param X X, Y Coordinates of point + /// @return A boolean of the check result bool PointInsideList(int X, int Y); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual Method: OnGainFocus - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the panel gains focus. - // Arguments: None. - + /// Called when the panel gains focus. void OnGainFocus() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual Method: OnLoseFocus - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the panel looses focus. - // Arguments: None. - + /// Called when the panel looses focus. void OnLoseFocus() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ReceiveSignal - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when receiving a signal. - // Arguments: Signal source, Signal code, Signal data. - + /// Called when receiving a signal. + /// @param Source Signal source, Signal code, Signal data. void ReceiveSignal(GUIPanel* Source, int Code, int Data) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: BeginUpdate - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Locks the control from updating every time a new item is added. - // Arguments: None. - + /// Locks the control from updating every time a new item is added. void BeginUpdate(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: EndUpdate - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: UnLocks the control from updating every time a new item is added. - // Will automatically update the control. - // Arguments: None. - + /// UnLocks the control from updating every time a new item is added. + /// Will automatically update the control. void EndUpdate(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetMultiSelect - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the multi-selection value. - // Arguments: MultiSelect - + /// Sets the multi-selection value. + /// @param MultiSelect MultiSelect void SetMultiSelect(bool MultiSelect); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetMultiSelect - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the multi-selection value. - // Arguments: None. - + /// Gets the multi-selection value. bool GetMultiSelect() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetHotTracking - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the hot tracking value. - // Arguments: HotTrack. - + /// Sets the hot tracking value. + /// @param HotTrack HotTrack. void SetHotTracking(bool HotTrack); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetSelected - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the selected (or first in the selected list) item. - // Arguments: None. - + /// Gets the selected (or first in the selected list) item. Item* GetSelected(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetItemList - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the item list. - // Arguments: None. - + /// Gets the item list. std::vector* GetItemList(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetItem - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets an item at the index. - // Arguments: Index. - + /// Gets an item at the index. + /// @param Index Index. Item* GetItem(int Index); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetItem - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets an item at a specific absolute screen coordinate, if any. - // Arguments: The absolute screen coordinates to get the item from. - + /// Gets an item at a specific absolute screen coordinate, if any. + /// @param X The absolute screen coordinates to get the item from. Item* GetItem(int X, int Y); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetItemHeight - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the drawing height of the item passed in. - // Arguments: Pointer to the Item to get the height of. Ownership is NOT transferred! - + /// Gets the drawing height of the item passed in. + /// @param pItem Pointer to the Item to get the height of. Ownership is NOT transferred! int GetItemHeight(Item* pItem); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetStackHeight - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the height, in pixels, of the stack of items up to a specific one. - // E.g. If the specified one is the first (top) in the list, 0 is returned. - // If the second one is specified, the height of the first is returned. - // If the third is specified, the sum of the first and second items' heights - // is returned. If 0 is passed, the entire stack's height is returned. - // Arguments: Pointer to the Item to get the height up to. Ownership is NOT transferred! - // If 0 is passed, the entire stack's height is returned. - + /// Gets the height, in pixels, of the stack of items up to a specific one. + /// E.g. If the specified one is the first (top) in the list, 0 is returned. + /// If the second one is specified, the height of the first is returned. + /// If the third is specified, the sum of the first and second items' heights + /// is returned. If 0 is passed, the entire stack's height is returned. + /// @param pItem Pointer to the Item to get the height up to. Ownership is NOT transferred! (default: nullptr) + /// If 0 is passed, the entire stack's height is returned. int GetStackHeight(Item* pItem = nullptr); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetScrollVerticalValue - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the scroll value, in pixels, of the vertical axis. - // Arguments: The scroll value in pixels. - + /// Gets the scroll value, in pixels, of the vertical axis. + /// @param m_VertScroll->GetValue( The scroll value in pixels. int GetScrollVerticalValue() const { return m_VertScroll->GetValue(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetItemValues - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the values of a specific Item. - // Arguments: Index and Item reference. - + /// Sets the values of a specific Item. + /// @param Index Index and Item reference. void SetItemValues(int Index, Item& item); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetSelectedIndex - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the selected (or first in the selected list) index. - // Arguments: None. - // Returns: Index, or -1 if there is no items selected. - + /// Gets the selected (or first in the selected list) index. + /// @return Index, or -1 if there is no items selected. int GetSelectedIndex(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetSelectedIndex - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Selects the item at the index. - // Arguments: Index. - + /// Selects the item at the index. + /// @param Index Index. void SetSelectedIndex(int Index); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetAlternateDrawMode - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Selects this to draw its items differently, with lines instead of - // rectangles, etc - // Arguments: The new mode setting. - + /// Selects this to draw its items differently, with lines instead of + /// rectangles, etc + /// @param enableAltDrawMode The new mode setting. (default: true) void SetAlternateDrawMode(bool enableAltDrawMode = true) { m_AlternateDrawMode = enableAltDrawMode; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetSelectionList - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the selection list. - // Arguments: None. - + /// Gets the selection list. std::vector* GetSelectionList(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: DeleteItem - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Deletes an item at the index. - // Arguments: Index. - + /// Deletes an item at the index. + /// @param Index Index. void DeleteItem(int Index); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetSize - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Adjusts the size of the panel. - // Arguments: Width, Height. - + /// Adjusts the size of the panel. + /// @param Width Width, Height. void SetSize(int Width, int Height) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetPositionAbs - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Adjusts the position of the panel. - // Arguments: X, Y. - + /// Adjusts the position of the panel. + /// @param X X, Y. void SetPositionAbs(int X, int Y); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: EnableScrollbars - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the enabled state of both scrollbars. - // Arguments: Horz, Vert - + /// Sets the enabled state of both scrollbars. + /// @param Horizontal Horz, Vert void EnableScrollbars(bool Horizontal, bool Vertical); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ScrollToItem - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Adjusts the vertical scrollbar to show the specific item in the list. - // Arguments: The item you want to show. - + /// Adjusts the vertical scrollbar to show the specific item in the list. + /// @param pItem The item you want to show. void ScrollToItem(Item* pItem); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ScrollToSelected - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Adjusts the vertical scrollbar to show the first selected item in the - // list. - // Arguments: None. - + /// Adjusts the vertical scrollbar to show the first selected item in the + /// list. void ScrollToSelected(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ScrollToTop - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Adjusts the vertical scrollbar to show the top of the list - // Arguments: None. - + /// Adjusts the vertical scrollbar to show the top of the list void ScrollToTop(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ScrollToBottom - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Adjusts the vertical scrollbar to show the bottom of the list - // Arguments: None. - + /// Adjusts the vertical scrollbar to show the bottom of the list void ScrollToBottom(); - /// /// Scrolls the GUIListPanel up. - /// void ScrollUp(); - /// /// Scrolls the GUIListPanel down. - /// void ScrollDown(); - /// /// Scrolls the the GUIListPanel to a specific position - /// - /// The position to scroll to. + /// @param position The position to scroll to. void ScrollTo(int position); - /// /// Sets whether the scroll panel scrolls in a loop or not. - /// - /// True to scroll in a loop, false to scroll with edge stopping. + /// @param scrollLoop True to scroll in a loop, false to scroll with edge stopping. void SetSelectionScrollingLoop(bool scrollLoop); - /// /// Sets whether the list panel can be scrolled with the mouse scroll wheel. - /// - /// True to enable scrolling, false to disable. + /// @param mouseScroll True to enable scrolling, false to disable. void SetMouseScrolling(bool mouseScroll); - /// /// Sets the thickness (width on vertical, height on horizontal) of the ListPanel's scroll bars and adjusts them to the new thickness. - /// - /// The new scroll bar thickness, in pixels. + /// @param newThickness The new scroll bar thickness, in pixels. void SetScrollBarThickness(int newThickness) { m_ScrollBarThickness = newThickness; AdjustScrollbars(); } - /// /// Sets the padding around the ListPanel's scrollbars and adjusts them to the new padding. Used to better size and position scrollbars within panel bounds, allowing to not overdraw on panel borders. - /// - /// The new scrollbar padding, in pixels. + /// @param newPadding The new scrollbar padding, in pixels. void SetScrollBarPadding(int newPadding) { m_ScrollBarPadding = newPadding; AdjustScrollbars(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: BuildBitmap - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Build the bitmap. - // Arguments: UpdateBase, UpdateText. - + /// Build the bitmap. + /// @param UpdateBase UpdateBase, UpdateText. void BuildBitmap(bool UpdateBase, bool UpdateText); private: @@ -528,40 +311,22 @@ namespace RTE { unsigned long m_SelectedColorIndex; unsigned long m_UnselectedColorIndex; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: BuildDrawBitmap - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Build the drawing bitmap. - // Arguments: None. - + /// Build the drawing bitmap. void BuildDrawBitmap(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: AdjustScrollbars - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Adjusts the scrollbars. - // Arguments: None. - + /// Adjusts the scrollbars. void AdjustScrollbars(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SelectItem - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Selects an item based on mouse position. - // Arguments: Mouse Position, Modifier. - + /// Selects an item based on mouse position. + /// @param X Mouse Position, Modifier. void SelectItem(int X, int Y, int Modifier); - /// /// Perform list scrolling through the scrollbar. - /// - /// Amount and direction of scrolling. Positive to scroll up, negative to scroll down. + /// @param MouseWheelChange Amount and direction of scrolling. Positive to scroll up, negative to scroll down. void ScrollBarScrolling(int mouseWheelChange); - /// /// Perform list scrolling by changing the currently selected list item. - /// - /// Amount and direction of scrolling. Positive to scroll up, negative to scroll down. + /// @param MouseWheelChange Amount and direction of scrolling. Positive to scroll up, negative to scroll down. void SelectionListScrolling(int mouseWheelChange); }; }; // namespace RTE diff --git a/Source/GUI/GUIManager.cpp b/Source/GUI/GUIManager.cpp index 97195ec318..b4d2016c7b 100644 --- a/Source/GUI/GUIManager.cpp +++ b/Source/GUI/GUIManager.cpp @@ -3,8 +3,6 @@ using namespace RTE; -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIManager::GUIManager(GUIInput* input) { m_Input = input; m_MouseEnabled = true; @@ -23,15 +21,11 @@ GUIManager::GUIManager(GUIInput* input) { m_pTimer = new Timer(); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIManager::~GUIManager() { delete m_pTimer; m_pTimer = nullptr; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIManager::Clear() { m_PanelList.clear(); m_CapturedPanel = nullptr; @@ -50,8 +44,6 @@ void GUIManager::Clear() { m_LastMouseDown[2] = -99999.0F; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIManager::AddPanel(GUIPanel* panel) { if (panel) { int Z = 0; @@ -70,8 +62,6 @@ void GUIManager::AddPanel(GUIPanel* panel) { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIManager::Update(bool ignoreKeyboardEvents) { m_Input->Update(); @@ -272,8 +262,6 @@ void GUIManager::Update(bool ignoreKeyboardEvents) { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIManager::Draw(GUIScreen* Screen) { // Go through drawing panels that are invalid std::vector::iterator it; @@ -288,8 +276,6 @@ void GUIManager::Draw(GUIScreen* Screen) { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIManager::CaptureMouse(GUIPanel* Panel) { assert(Panel); @@ -301,8 +287,6 @@ void GUIManager::CaptureMouse(GUIPanel* Panel) { m_CapturedPanel->SetCaptureState(true); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIManager::ReleaseMouse() { if (m_CapturedPanel) { m_CapturedPanel->SetCaptureState(false); @@ -311,8 +295,6 @@ void GUIManager::ReleaseMouse() { m_CapturedPanel = nullptr; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIPanel* GUIManager::FindBottomPanel(int X, int Y) { std::vector::iterator it; @@ -329,8 +311,6 @@ GUIPanel* GUIManager::FindBottomPanel(int X, int Y) { return nullptr; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIPanel* GUIManager::FindTopPanel(int X, int Y) { std::vector::reverse_iterator it; @@ -347,14 +327,10 @@ GUIPanel* GUIManager::FindTopPanel(int X, int Y) { return nullptr; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int GUIManager::GetPanelID() { return m_UniqueIDCount++; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool GUIManager::MouseInRect(const GUIRect* Rect, int X, int Y) { if (!Rect) { return false; @@ -365,8 +341,6 @@ bool GUIManager::MouseInRect(const GUIRect* Rect, int X, int Y) { return false; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIManager::TrackMouseHover(GUIPanel* Pan, bool Enabled, int Delay) { assert(Pan); m_HoverTrack = Enabled; @@ -376,8 +350,6 @@ void GUIManager::TrackMouseHover(GUIPanel* Pan, bool Enabled, int Delay) { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIManager::SetFocus(GUIPanel* Pan) { // Send the LoseFocus event to the old panel (if there is one) if (m_FocusPanel) { diff --git a/Source/GUI/GUIManager.h b/Source/GUI/GUIManager.h index 31c5a81e30..91a2273b3b 100644 --- a/Source/GUI/GUIManager.h +++ b/Source/GUI/GUIManager.h @@ -5,115 +5,56 @@ namespace RTE { class Timer; - /// /// The main manager that handles all the panels and inputs. - /// class GUIManager { public: - ////////////////////////////////////////////////////////////////////////////////////////// - // Constructor: GUIManager - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Constructor method used to instantiate a GUIManager object in system - // memory. - // Arguments: Input Interface - + /// Constructor method used to instantiate a GUIManager object in system + /// memory. + /// @param input Input Interface explicit GUIManager(GUIInput* input); - ////////////////////////////////////////////////////////////////////////////////////////// - // Destructor: GUIManager - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destructor method used to clean up a GUIManager object. - // Arguments: None. - + /// Destructor method used to clean up a GUIManager object. ~GUIManager(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Clear - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears the manager. - // Arguments: None. - + /// Clears the manager. void Clear(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: AddPanel - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Adds a panel to the list. - // Arguments: Pointer to a panel. - + /// Adds a panel to the list. + /// @param panel Pointer to a panel. void AddPanel(GUIPanel* panel); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Update - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the GUI. - // Arguments: Whether keyboard events should be ignored or not. Used to avoid conflicts when custom keyboard handling for GUI elements is preset. - + /// Updates the GUI. + /// @param ignoreKeyboardEvents Whether keyboard events should be ignored or not. Used to avoid conflicts when custom keyboard handling for GUI elements is preset. (default: false) void Update(bool ignoreKeyboardEvents = false); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Draw - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draw all the panels - // Arguments: Screen. - + /// Draw all the panels + /// @param Screen Screen. void Draw(GUIScreen* Screen); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: EnableMouse - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Enables and disables the mouse completely for this. - // Arguments: Enable? - + /// Enables and disables the mouse completely for this. + /// @param enable Enable? (default: true) void EnableMouse(bool enable = true) { m_MouseEnabled = enable; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: CaptureMouse - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets up capturing a mouse for a panel. - // Arguments: Panel. - + /// Sets up capturing a mouse for a panel. + /// @param Panel Panel. void CaptureMouse(GUIPanel* Panel); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ReleaseMouse - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Releases a mouse capture. - // Arguments: None. - + /// Releases a mouse capture. void ReleaseMouse(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetPanelID - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets a unique ID for a panel. - // Arguments: None. - + /// Gets a unique ID for a panel. int GetPanelID(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetInputController - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the input controller object - // Arguments: None. - + /// Gets the input controller object GUIInput* GetInputController() { return m_Input; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: TrackMouseHover - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets up the manager to enable/disable hover tracking of this panel - // Arguments: Panel, Enabled, Delay (milliseconds) - + /// Sets up the manager to enable/disable hover tracking of this panel + /// @param Pan Panel, Enabled, Delay (milliseconds) void TrackMouseHover(GUIPanel* Pan, bool Enabled, int Delay); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetFocus - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Give focus to a panel. - // Arguments: Panel. - + /// Give focus to a panel. + /// @param Pan Panel. void SetFocus(GUIPanel* Pan); private: @@ -142,30 +83,18 @@ namespace RTE { Timer* m_pTimer; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: FindBottomPanel - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Goes through the panel list and selects the bottommost - // ('first', render wise) panel on a specific point. - // Arguments: Mouse Position. - + /// Goes through the panel list and selects the bottommost + /// ('first', render wise) panel on a specific point. + /// @param X Mouse Position. GUIPanel* FindBottomPanel(int X, int Y); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: FindTopPanel - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Goes through the panel list and selects the topmost ('last', render - // wise) panel on a specific point. - // Arguments: Mouse Position. - + /// Goes through the panel list and selects the topmost ('last', render + /// wise) panel on a specific point. + /// @param X Mouse Position. GUIPanel* FindTopPanel(int X, int Y); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: MouseInRect - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Checks if the mouse point is inside a rectangle. - // Arguments: Rectangle, Mouse position. - + /// Checks if the mouse point is inside a rectangle. + /// @param Rect Rectangle, Mouse position. bool MouseInRect(const GUIRect* Rect, int X, int Y); }; }; // namespace RTE diff --git a/Source/GUI/GUIPanel.cpp b/Source/GUI/GUIPanel.cpp index 6bde68721f..9c4e013d5b 100644 --- a/Source/GUI/GUIPanel.cpp +++ b/Source/GUI/GUIPanel.cpp @@ -2,8 +2,6 @@ using namespace RTE; -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIPanel::GUIPanel(GUIManager* Manager) { Clear(); m_Manager = Manager; @@ -13,14 +11,10 @@ GUIPanel::GUIPanel(GUIManager* Manager) { m_FontKerning = 1; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIPanel::GUIPanel() { Clear(); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIPanel::Clear() { m_X = 0; m_Y = 0; @@ -46,8 +40,6 @@ void GUIPanel::Clear() { m_FontKerning = 1; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIPanel::Setup(GUIManager* manager, int ZPos) { m_Manager = manager; m_ZPos = ZPos; @@ -67,8 +59,6 @@ void GUIPanel::Setup(GUIManager* manager, int ZPos) { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIPanel::AddChild(GUIPanel* child, bool convertToAbsolutePos) { if (child) { // Convert the child's coordinates into absolute coordinates @@ -101,8 +91,6 @@ void GUIPanel::AddChild(GUIPanel* child, bool convertToAbsolutePos) { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIPanel::RemoveChild(const GUIPanel* pChild) { // Note: We do NOT free the children because they are still linked in through their controls. This merely removes the panel from the list. // This will cause a small memory leak, but this is only designed for the GUI Editor and is a bit of a hack @@ -116,8 +104,6 @@ void GUIPanel::RemoveChild(const GUIPanel* pChild) { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIPanel::LoadProperties(GUIProperties* Props) { assert(Props); @@ -130,20 +116,14 @@ void GUIPanel::LoadProperties(GUIProperties* Props) { Props->GetValue("Enabled", &m_Enabled); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIPanel::Invalidate() { m_ValidRegion = false; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool GUIPanel::IsValid() const { return m_ValidRegion; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIPanel::Draw(GUIScreen* Screen) { // Validate this panel m_ValidRegion = true; @@ -171,76 +151,44 @@ void GUIPanel::Draw(GUIScreen* Screen) { Screen->GetBitmap()->SetClipRect(nullptr); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIPanel::OnMouseDown(int X, int Y, int Buttons, int Modifier) {} -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIPanel::OnMouseUp(int X, int Y, int Buttons, int Modifier) {} -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIPanel::OnDoubleClick(int X, int Y, int Buttons, int Modifier) {} -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIPanel::OnMouseMove(int X, int Y, int Buttons, int Modifier) {} -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIPanel::OnMouseEnter(int X, int Y, int Buttons, int Modifier) {} -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIPanel::OnMouseLeave(int X, int Y, int Buttons, int Modifier) {} -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIPanel::OnMouseHover(int X, int Y, int Buttons, int Modifier) {} -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIPanel::OnKeyDown(int KeyCode, int Modifier) {} -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIPanel::OnKeyUp(int KeyCode, int Modifier) {} -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIPanel::OnKeyPress(int KeyCode, int Modifier) {} -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIPanel::OnTextInput(std::string_view inputText) {} -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIPanel::OnGainFocus() { m_GotFocus = true; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIPanel::OnLoseFocus() { m_GotFocus = false; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIPanel::CaptureMouse() { m_Manager->CaptureMouse(this); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIPanel::ReleaseMouse() { m_Manager->ReleaseMouse(); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIPanel* GUIPanel::BottomPanelUnderPoint(int x, int y) { if (!PointInside(x, y)) { return nullptr; @@ -266,8 +214,6 @@ GUIPanel* GUIPanel::BottomPanelUnderPoint(int x, int y) { return this; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIPanel* GUIPanel::TopPanelUnderPoint(int x, int y) { if (!PointInside(x, y)) { return nullptr; @@ -294,8 +240,6 @@ GUIPanel* GUIPanel::TopPanelUnderPoint(int x, int y) { return this; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool GUIPanel::PointInside(int X, int Y) { // Can't be inside an invisible panel if (!m_Visible) { @@ -311,15 +255,11 @@ bool GUIPanel::PointInside(int X, int Y) { return true; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIPanel::SetSize(int Width, int Height) { m_Width = Width; m_Height = Height; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIPanel::SetPositionAbs(int X, int Y, bool moveChildren) { int DX = X - m_X; int DY = Y - m_Y; @@ -337,8 +277,6 @@ void GUIPanel::SetPositionAbs(int X, int Y, bool moveChildren) { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIPanel::SetPositionRel(int X, int Y) { X += m_Parent->GetXPos(); Y += m_Parent->GetYPos(); @@ -357,8 +295,6 @@ void GUIPanel::SetPositionRel(int X, int Y) { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIPanel::MoveRelative(int dX, int dY) { m_X += dX; m_Y += dY; @@ -371,8 +307,6 @@ void GUIPanel::MoveRelative(int dX, int dY) { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIPanel::CenterInParent(bool centerX, bool centerY) { int newRelX = m_X - m_Parent->GetXPos(); int newRelY = m_Y - m_Parent->GetYPos(); @@ -387,52 +321,36 @@ void GUIPanel::CenterInParent(bool centerX, bool centerY) { SetPositionRel(newRelX, newRelY); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIPanel::_SetVisible(bool Visible) { m_Visible = Visible; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool GUIPanel::_GetVisible() const { return m_Visible; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIPanel::_SetEnabled(bool Enabled) { m_Enabled = Enabled; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool GUIPanel::_GetEnabled() const { return m_Enabled; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int GUIPanel::GetWidth() const { return m_Width; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int GUIPanel::GetHeight() const { return m_Height; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIRect* GUIPanel::GetRect() { SetRect(&m_Rect, m_X, m_Y, m_X + m_Width, m_Y + m_Height); return &m_Rect; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIPanel::GetRect(int* X, int* Y, int* Width, int* Height) const { if (X) { *X = m_X; @@ -448,88 +366,60 @@ void GUIPanel::GetRect(int* X, int* Y, int* Width, int* Height) const { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int GUIPanel::GetPanelID() const { return m_ID; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIPanel::TrackMouseHover(bool Enabled, int Delay) { m_Manager->TrackMouseHover(this, Enabled, Delay); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIPanel::SetFocus() { m_Manager->SetFocus(this); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool GUIPanel::HasFocus() const { return m_GotFocus; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIPanel::SetCaptureState(bool Captured) { m_Captured = Captured; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool GUIPanel::IsCaptured() const { return m_Captured; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool GUIPanel::IsEnabled() const { return m_Enabled; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIPanel::SendSignal(int Code, int Data) { if (m_SignalTarget) { m_SignalTarget->ReceiveSignal(this, Code, Data); } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIPanel::ReceiveSignal(GUIPanel* Source, int Code, int Data) {} -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIPanel::SetSignalTarget(GUIPanel* Target) { if (Target) { m_SignalTarget = Target; } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIPanel* GUIPanel::GetParentPanel() { return m_Parent; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIPanel::SetZPos(int Z) { m_ZPos = Z; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int GUIPanel::GetZPos() const { return m_ZPos; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIPanel::ChangeZPosition(int Type) { // If we don't have a parent, get the manager to alter the Z Position if (!m_Parent) { @@ -541,8 +431,6 @@ void GUIPanel::ChangeZPosition(int Type) { m_Parent->_ChangeZ(this, Type); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIPanel::_ChangeZ(GUIPanel* Child, int Type) { assert(Child); @@ -590,8 +478,6 @@ void GUIPanel::_ChangeZ(GUIPanel* Child, int Type) { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - std::string GUIPanel::ToString() { std::string OutString = ""; @@ -614,8 +500,6 @@ std::string GUIPanel::ToString() { return OutString; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIPanel::BuildProperties(GUIProperties* Prop) { assert(Prop); @@ -636,8 +520,6 @@ void GUIPanel::BuildProperties(GUIProperties* Prop) { Prop->AddVariable("Enabled", m_Enabled); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - std::string GUIPanel::WriteValue(const std::string& Name, int Value) { char buf[32]; @@ -651,8 +533,6 @@ std::string GUIPanel::WriteValue(const std::string& Name, int Value) { return OutString; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - std::string GUIPanel::WriteValue(const std::string& Name, bool Value) { std::string OutString = Name; OutString += " = "; @@ -662,8 +542,6 @@ std::string GUIPanel::WriteValue(const std::string& Name, bool Value) { return OutString; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIPanel::_ApplyProperties(GUIProperties* Props) { assert(Props); diff --git a/Source/GUI/GUIPanel.h b/Source/GUI/GUIPanel.h index 73136196ef..62cc7d98f5 100644 --- a/Source/GUI/GUIPanel.h +++ b/Source/GUI/GUIPanel.h @@ -6,9 +6,7 @@ namespace RTE { class GUIPanel; class GUIManager; - /// /// A rectangle 'window' in the GUI that recieves mouse and keyboard events. - /// class GUIPanel { public: @@ -35,499 +33,234 @@ namespace RTE { BottomMost, } ZChange; - ////////////////////////////////////////////////////////////////////////////////////////// - // Constructor: GUIPanel - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Constructor method used to instantiate a GUIPanel object in system - // memory. - // Arguments: Manager. - + /// Constructor method used to instantiate a GUIPanel object in system + /// memory. + /// @param Manager Manager. explicit GUIPanel(GUIManager* Manager); - ////////////////////////////////////////////////////////////////////////////////////////// - // Constructor: GUIPanel - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Constructor method used to instantiate a GUIPanel object in system - // memory. - // Arguments: None. - + /// Constructor method used to instantiate a GUIPanel object in system + /// memory. GUIPanel(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Clear - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears all the settings. - // Arguments: None. - + /// Clears all the settings. void Clear(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: BottomPanelUnderPoint - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Recursively goes down the tree to check the last panel under a point - // Arguments: X, Y Coordinates of point - // Return value: A pointer to the panel. 0 if no panel is under the point - + /// Recursively goes down the tree to check the last panel under a point + /// @param x X, Y Coordinates of point + /// @return A pointer to the panel. 0 if no panel is under the point GUIPanel* BottomPanelUnderPoint(int x, int y); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: TopPanelUnderPoint - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Recursively goes up the tree from to check the first panel under a point - // Arguments: X, Y Coordinates of point - // Return value: A pointer to the panel. 0 if no panel is under the point - + /// Recursively goes up the tree from to check the first panel under a point + /// @param x X, Y Coordinates of point + /// @return A pointer to the panel. 0 if no panel is under the point GUIPanel* TopPanelUnderPoint(int x, int y); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: AddChild - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Adds a child to this panel - // Arguments: Pointer to the panel to add - + /// Adds a child to this panel + /// @param child Pointer to the panel to add void AddChild(GUIPanel* child, bool convertToAbsolutePos = true); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: RemoveChild - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Removes a child based on name. - // Arguments: Child Name. - + /// Removes a child based on name. + /// @param pChild Child Name. void RemoveChild(const GUIPanel* pChild); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Setup - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets up the panel for use with the manager. - // Arguments: Pointer to the manager to use, ZPosition. - + /// Sets up the panel for use with the manager. + /// @param manager Pointer to the manager to use, ZPosition. void Setup(GUIManager* manager, int ZPos); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: LoadProperties - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Loads the base data from a properties page - // Arguments: Pointer to the properties class - + /// Loads the base data from a properties page + /// @param Props Pointer to the properties class void LoadProperties(GUIProperties* Props); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Invalidate - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Invalidates the panel - // Arguments: None. - + /// Invalidates the panel void Invalidate(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: IsValid - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Checks if the panel is valid - // Arguments: None. - + /// Checks if the panel is valid bool IsValid() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual Method: Draw - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws the panel - // Arguments: Screen class - + /// Draws the panel + /// @param Screen Screen class virtual void Draw(GUIScreen* Screen); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual Method: OnMouseDown - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the mouse goes down on the panel - // Arguments: Mouse Position, Mouse Buttons, Modifier. - + /// Called when the mouse goes down on the panel + /// @param X Mouse Position, Mouse Buttons, Modifier. virtual void OnMouseDown(int X, int Y, int Buttons, int Modifier); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual Method: OnMouseUp - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the mouse goes up on the panel - // Arguments: Mouse Position, Mouse Buttons, Modifier. - + /// Called when the mouse goes up on the panel + /// @param X Mouse Position, Mouse Buttons, Modifier. virtual void OnMouseUp(int X, int Y, int Buttons, int Modifier); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual Method: OnDoubleClick - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the mouse has double-clicked on the pane. - // Arguments: Mouse Position, Mouse Buttons, Modifier. - + /// Called when the mouse has double-clicked on the pane. + /// @param X Mouse Position, Mouse Buttons, Modifier. virtual void OnDoubleClick(int X, int Y, int Buttons, int Modifier); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual Method: OnMouseMove - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the mouse moves (over the panel, or when captured). - // Arguments: Mouse Position, Mouse Buttons, Modifier. - + /// Called when the mouse moves (over the panel, or when captured). + /// @param X Mouse Position, Mouse Buttons, Modifier. virtual void OnMouseMove(int X, int Y, int Buttons, int Modifier); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual Method: OnMouseEnter - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the mouse enters the panel. - // Arguments: Mouse Position, Mouse Buttons, Modifier. - + /// Called when the mouse enters the panel. + /// @param X Mouse Position, Mouse Buttons, Modifier. virtual void OnMouseEnter(int X, int Y, int Buttons, int Modifier); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual Method: OnMouseLeave - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the mouse leaves the panel. - // Arguments: Mouse Position, Mouse Buttons, Modifier. - + /// Called when the mouse leaves the panel. + /// @param X Mouse Position, Mouse Buttons, Modifier. virtual void OnMouseLeave(int X, int Y, int Buttons, int Modifier); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual Method: OnMouseHover - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the mouse is hovering over the panel (has to be enabled) - // Arguments: Mouse Position, Mouse Buttons, Modifier. - + /// Called when the mouse is hovering over the panel (has to be enabled) + /// @param X Mouse Position, Mouse Buttons, Modifier. virtual void OnMouseHover(int X, int Y, int Buttons, int Modifier); - /// /// Called when the mouse scroll wheel is moved. - /// - /// Mouse X position. - /// Mouse Y position. - /// Activated modifier buttons. - /// The amount of wheel movement. Positive is scroll up, negative is scroll down. + /// @param x Mouse X position. + /// @param y Mouse Y position. + /// @param modifier Activated modifier buttons. + /// @param mouseWheelChange The amount of wheel movement. Positive is scroll up, negative is scroll down. virtual void OnMouseWheelChange(int x, int y, int modifier, int mouseWheelChange){}; - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual Method: OnKeyDown - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when a key goes down. - // Arguments: KeyCode, Modifier. - + /// Called when a key goes down. + /// @param KeyCode KeyCode, Modifier. virtual void OnKeyDown(int KeyCode, int Modifier); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual Method: OnKeyUp - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when a key goes up. - // Arguments: KeyCode, Modifier. - + /// Called when a key goes up. + /// @param KeyCode KeyCode, Modifier. virtual void OnKeyUp(int KeyCode, int Modifier); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual Method: OnKeyPress - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when a key is pressed (OnDown & repeating). - // Arguments: KeyCode, Modifier. - + /// Called when a key is pressed (OnDown & repeating). + /// @param KeyCode KeyCode, Modifier. virtual void OnKeyPress(int KeyCode, int Modifier); - /// /// Called when text input is received. - /// - /// The input text being received. + /// @param inputText The input text being received. virtual void OnTextInput(std::string_view inputText); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual Method: OnGainFocus - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the panel gains focus. - // Arguments: None. - + /// Called when the panel gains focus. virtual void OnGainFocus(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual Method: OnLoseFocus - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the panel looses focus. - // Arguments: None. - + /// Called when the panel looses focus. virtual void OnLoseFocus(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual Method: SetSize - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Adjusts the size of the panel. - // Arguments: Width, Height. - + /// Adjusts the size of the panel. + /// @param Width Width, Height. virtual void SetSize(int Width, int Height); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual Method: SetPositionAbs - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Adjusts the absolute position of the panel. - // Arguments: X, Y, and whether to move the children too - + /// Adjusts the absolute position of the panel. + /// @param X X, Y, and whether to move the children too virtual void SetPositionAbs(int X, int Y, bool moveChildren = true); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual Method: SetPositionRel - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the position of the panel, relative to its parent. - // Arguments: X, Y. - + /// Sets the position of the panel, relative to its parent. + /// @param X X, Y. virtual void SetPositionRel(int X, int Y); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual Method: MoveRelative - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Moves the position of the panel by a relative amount. - // Arguments: X, Y, relative. - + /// Moves the position of the panel by a relative amount. + /// @param dX X, Y, relative. virtual void MoveRelative(int dX, int dY); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual Method: CenterInParent - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Centers this in its parent, taking this' dimensions into consideration. - // Arguments: Which axes to center. - + /// Centers this in its parent, taking this' dimensions into consideration. + /// @param centerX Which axes to center. virtual void CenterInParent(bool centerX, bool centerY); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual Method: ReceiveSignal - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when receiving a signal. - // Arguments: Signal source, Signal code, Signal data. - + /// Called when receiving a signal. + /// @param Source Signal source, Signal code, Signal data. virtual void ReceiveSignal(GUIPanel* Source, int Code, int Data); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: CaptureMouse - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Captures the mouse. - // Arguments: None. - + /// Captures the mouse. void CaptureMouse(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ReleaseMouse - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Releases the mouse. - // Arguments: None. - + /// Releases the mouse. void ReleaseMouse(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual Method: SetFont - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the font this panel will be using - // Arguments: The new font, ownership is NOT transferred! - + /// Sets the font this panel will be using + /// @param pFont The new font, ownership is NOT transferred! virtual void SetFont(GUIFont* pFont) { m_Font = pFont; m_ValidRegion = false; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: _SetVisible - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the visibility of the panel. - // Arguments: Visible. - + /// Sets the visibility of the panel. + /// @param Visible Visible. void _SetVisible(bool Visible); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: _GetVisible - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the visibility of the panel. - // Arguments: None. - + /// Gets the visibility of the panel. bool _GetVisible() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: _SetEnabled - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the enabled state of the panel. - // Arguments: Enabled. - + /// Sets the enabled state of the panel. + /// @param Enabled Enabled. void _SetEnabled(bool Enabled); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: _GetEnabled - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the enabled state of the panel. - // Arguments: None. - + /// Gets the enabled state of the panel. bool _GetEnabled() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetWidth - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the width of the panel. - // Arguments: None. - + /// Gets the width of the panel. int GetWidth() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetHeight - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the height of the panel. - // Arguments: None. - + /// Gets the height of the panel. int GetHeight() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetXPos - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the x position of the panel - // Arguments: None. - + /// Gets the x position of the panel int GetXPos() const { return m_X; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetYPos - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the y position of the panel - // Arguments: None. - + /// Gets the y position of the panel int GetYPos() const { return m_Y; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetRelXPos - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the x position of the panel, relative to its parent - // Arguments: None. - + /// Gets the x position of the panel, relative to its parent int GetRelXPos() const { return m_X - m_Parent->GetXPos(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetRelYPos - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the y position of the panel, relative to its parent - // Arguments: None. - + /// Gets the y position of the panel, relative to its parent int GetRelYPos() const { return m_Y - m_Parent->GetYPos(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetRect - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the rectangle of the panel. - // Arguments: None. - + /// Gets the rectangle of the panel. GUIRect* GetRect(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetRect - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the rectangle of the panel. - // Arguments: X, Y, Width, Height - + /// Gets the rectangle of the panel. + /// @param X X, Y, Width, Height void GetRect(int* X, int* Y, int* Width, int* Height) const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetParentPanel - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the parent of this panel. - // Arguments: None. - + /// Gets the parent of this panel. GUIPanel* GetParentPanel(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetPanelID - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the panel's ID. - // Arguments: None. - + /// Gets the panel's ID. int GetPanelID() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetCaptureState - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the panel's captured state. - // Arguments: Captured. - + /// Sets the panel's captured state. + /// @param Captured Captured. void SetCaptureState(bool Captured); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: IsCaptured - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the panel's captured state. - // Arguments: None. - + /// Gets the panel's captured state. bool IsCaptured() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: IsEnabled - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the panel's enabled state. - // Arguments: None. - + /// Gets the panel's enabled state. bool IsEnabled() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetSignalTarget - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the target panel to receive signals. - // Arguments: Target panel. - + /// Sets the target panel to receive signals. + /// @param Target Target panel. void SetSignalTarget(GUIPanel* Target); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: PointInside - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Checks if a point is inside the panel - // Arguments: X, Y Coordinates of point - // Return value: A boolean of the check result - + /// Checks if a point is inside the panel + /// @param X X, Y Coordinates of point + /// @return A boolean of the check result virtual bool PointInside(int X, int Y); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetFocus - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the focus of this panel. - // Arguments: None. - + /// Sets the focus of this panel. void SetFocus(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: HasFocus - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the focus value of the panel. - // Arguments: None. - + /// Gets the focus value of the panel. bool HasFocus() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetZPos - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the Z index of the panel. - // Arguments: ZPos. - + /// Sets the Z index of the panel. + /// @param Z ZPos. void SetZPos(int Z); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetZPos - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the Z index of the panel. - // Arguments: None. - + /// Gets the Z index of the panel. int GetZPos() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ChangeZPosition - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Changes the Z Position of the panel. - // Arguments: Change type. - + /// Changes the Z Position of the panel. + /// @param Type Change type. void ChangeZPosition(int Type); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ToString - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Convert the properties in the panel to a string. - // Arguments: None. - + /// Convert the properties in the panel to a string. std::string ToString(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: BuildProperties - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Adds this panels properties to a properties class. - // Arguments: GUIProperties. - + /// Adds this panels properties to a properties class. + /// @param Prop GUIProperties. void BuildProperties(GUIProperties* Prop); protected: @@ -548,52 +281,28 @@ namespace RTE { unsigned long m_FontShadow; int m_FontKerning; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SendSignal - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sends a signal to the target. - // Arguments: Signal code, Data. - + /// Sends a signal to the target. + /// @param Code Signal code, Data. void SendSignal(int Code, int Data); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: TrackMouseHover - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets up the manager to enable/disable hover tracking of this panel - // Arguments: Enabled, Delay (milliseconds) - + /// Sets up the manager to enable/disable hover tracking of this panel + /// @param Enabled Enabled, Delay (milliseconds) void TrackMouseHover(bool Enabled, int Delay); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: _ChangeZ - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Changes the Z position of a child panel. - // Arguments: Child panel, Change type. - + /// Changes the Z position of a child panel. + /// @param Child Child panel, Change type. void _ChangeZ(GUIPanel* Child, int Type); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: WriteValue - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Writes a single value to string. - // Arguments: Value name, Value. - + /// Writes a single value to string. + /// @param Name Value name, Value. std::string WriteValue(const std::string& Name, int Value); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: WriteValue - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Writes a single value to string. - // Arguments: Value name, Value. - + /// Writes a single value to string. + /// @param Name Value name, Value. std::string WriteValue(const std::string& Name, bool Value); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: _ApplyProperties - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Applies new properties to the panel. - // Arguments: GUIProperties. - + /// Applies new properties to the panel. + /// @param Props GUIProperties. void _ApplyProperties(GUIProperties* Props); private: diff --git a/Source/GUI/GUIProgressBar.cpp b/Source/GUI/GUIProgressBar.cpp index 70ce7566cc..ae57766c69 100644 --- a/Source/GUI/GUIProgressBar.cpp +++ b/Source/GUI/GUIProgressBar.cpp @@ -3,8 +3,6 @@ using namespace RTE; -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIProgressBar::GUIProgressBar(GUIManager* Manager, GUIControlManager* ControlManager) : GUIControl(), GUIPanel(Manager) { m_ControlID = "PROGRESSBAR"; @@ -17,8 +15,6 @@ GUIProgressBar::GUIProgressBar(GUIManager* Manager, GUIControlManager* ControlMa m_Maximum = 100; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIProgressBar::Create(const std::string& Name, int X, int Y, int Width, int Height) { GUIControl::Create(Name, X, Y, Width, Height); @@ -48,8 +44,6 @@ void GUIProgressBar::Create(const std::string& Name, int X, int Y, int Width, in m_Height = std::max(m_Height, m_MinHeight); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIProgressBar::Create(GUIProperties* Props) { GUIControl::Create(Props); @@ -77,8 +71,6 @@ void GUIProgressBar::Create(GUIProperties* Props) { m_Value = std::min(m_Value, m_Maximum); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIProgressBar::Destroy() { // Destroy the drawing bitmap if (m_DrawBitmap) { @@ -95,8 +87,6 @@ void GUIProgressBar::Destroy() { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIProgressBar::ChangeSkin(GUISkin* Skin) { GUIControl::ChangeSkin(Skin); @@ -104,8 +94,6 @@ void GUIProgressBar::ChangeSkin(GUISkin* Skin) { BuildBitmap(); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIProgressBar::BuildBitmap() { // Free any old bitmaps if (m_DrawBitmap) { @@ -163,8 +151,6 @@ void GUIProgressBar::BuildBitmap() { m_Skin->GetValue("ProgressBar_Indicator", "Spacing", &m_Spacing); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIProgressBar::Draw(GUIScreen* Screen) { // Draw the base Screen->DrawBitmap(m_DrawBitmap, m_X, m_Y, nullptr); @@ -201,14 +187,10 @@ void GUIProgressBar::Draw(GUIScreen* Screen) { GUIPanel::Draw(Screen); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIProgressBar::OnMouseDown(int X, int Y, int Buttons, int Modifier) { CaptureMouse(); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIProgressBar::OnMouseUp(int X, int Y, int Buttons, int Modifier) { ReleaseMouse(); if (PointInside(X, Y)) { @@ -216,24 +198,16 @@ void GUIProgressBar::OnMouseUp(int X, int Y, int Buttons, int Modifier) { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIProgressBar::OnMouseMove(int X, int Y, int Buttons, int Modifier) {} -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIPanel* GUIProgressBar::GetPanel() { return this; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIProgressBar::Move(int X, int Y) { GUIPanel::SetPositionAbs(X, Y); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIProgressBar::Resize(int Width, int Height) { // Make sure the control isn't too small Width = std::max(Width, m_MinWidth); @@ -245,22 +219,16 @@ void GUIProgressBar::Resize(int Width, int Height) { BuildBitmap(); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIProgressBar::GetControlRect(int* X, int* Y, int* Width, int* Height) { GUIPanel::GetRect(X, Y, Width, Height); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIProgressBar::StoreProperties() { m_Properties.AddVariable("Minimum", m_Minimum); m_Properties.AddVariable("Maximum", m_Maximum); m_Properties.AddVariable("Value", m_Value); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIProgressBar::SetValue(int Value) { int OldValue = m_Value; m_Value = Value; @@ -275,38 +243,26 @@ void GUIProgressBar::SetValue(int Value) { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int GUIProgressBar::GetValue() const { return m_Value; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIProgressBar::SetMinimum(int Minimum) { m_Minimum = Minimum; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int GUIProgressBar::GetMinimum() const { return m_Minimum; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIProgressBar::SetMaximum(int Maximum) { m_Maximum = Maximum; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int GUIProgressBar::GetMaximum() const { return m_Maximum; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIProgressBar::ApplyProperties(GUIProperties* Props) { GUIControl::ApplyProperties(Props); diff --git a/Source/GUI/GUIProgressBar.h b/Source/GUI/GUIProgressBar.h index 2781454489..249cc354a1 100644 --- a/Source/GUI/GUIProgressBar.h +++ b/Source/GUI/GUIProgressBar.h @@ -3,9 +3,7 @@ namespace RTE { - /// /// A progressbar control class. - /// class GUIProgressBar : public GUIControl, public GUIPanel { public: @@ -15,182 +13,87 @@ namespace RTE { Changed } Notification; - ////////////////////////////////////////////////////////////////////////////////////////// - // Constructor: GUIProgressBar - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Constructor method used to instantiate a GUIProgressBar object in - // system memory. - // Arguments: GUIManager, GUIControlManager. - + /// Constructor method used to instantiate a GUIProgressBar object in + /// system memory. + /// @param Manager GUIManager, GUIControlManager. GUIProgressBar(GUIManager* Manager, GUIControlManager* ControlManager); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the control has been created. - // Arguments: Name, Position. - + /// Called when the control has been created. + /// @param Name Name, Position. void Create(const std::string& Name, int X, int Y, int Width = -1, int Height = -1) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the control has been created. - // Arguments: Properties. - + /// Called when the control has been created. + /// @param Props Properties. void Create(GUIProperties* Props) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the control has been destroyed. - // Arguments: None. - + /// Called when the control has been destroyed. void Destroy() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ChangeSkin - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the skin has been changed. - // Arguments: New skin pointer. - + /// Called when the skin has been changed. + /// @param Skin New skin pointer. void ChangeSkin(GUISkin* Skin) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Draw - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws the panel - // Arguments: Screen class - + /// Draws the panel + /// @param Screen Screen class void Draw(GUIScreen* Screen) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: OnMouseDown - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the mouse goes down on the panel - // Arguments: Mouse Position, Mouse Buttons, Modifier. - + /// Called when the mouse goes down on the panel + /// @param X Mouse Position, Mouse Buttons, Modifier. void OnMouseDown(int X, int Y, int Buttons, int Modifier) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: OnMouseUp - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the mouse goes up on the panel - // Arguments: Mouse Position, Mouse Buttons, Modifier. - + /// Called when the mouse goes up on the panel + /// @param X Mouse Position, Mouse Buttons, Modifier. void OnMouseUp(int X, int Y, int Buttons, int Modifier) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: OnMouseMove - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the mouse moves (over the panel, or when captured). - // Arguments: Mouse Position, Mouse Buttons, Modifier. - + /// Called when the mouse moves (over the panel, or when captured). + /// @param X Mouse Position, Mouse Buttons, Modifier. void OnMouseMove(int X, int Y, int Buttons, int Modifier) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetPanel - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns the panel of the control. - // Arguments: None. - // Returns: 0 if the control does not have a panel, otherwise the topmost panel. - + /// Returns the panel of the control. + /// @return 0 if the control does not have a panel, otherwise the topmost panel. GUIPanel* GetPanel() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetControlID - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns a string representing the control's ID - // Arguments: None. - + /// Returns a string representing the control's ID static std::string GetControlID() { return "PROGRESSBAR"; }; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Move - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the control needs to be moved. - // Arguments: New position. - + /// Called when the control needs to be moved. + /// @param X New position. void Move(int X, int Y) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Resize - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the control needs to be resized. - // Arguments: New size. - + /// Called when the control needs to be resized. + /// @param Width New size. void Resize(int Width, int Height) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetControlRect - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the rectangle of the control. - // Arguments: Position, Size. - + /// Gets the rectangle of the control. + /// @param X Position, Size. void GetControlRect(int* X, int* Y, int* Width, int* Height) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: StoreProperties - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the control to store the values into properties. - // Arguments: None. - + /// Gets the control to store the values into properties. void StoreProperties() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetValue - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the value. - // Arguments: Value. - + /// Sets the value. + /// @param Value Value. void SetValue(int Value); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetValue - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the value. - // Arguments: None. - + /// Gets the value. int GetValue() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetMinimum - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the minimum. - // Arguments: Minimum. - + /// Sets the minimum. + /// @param Minimum Minimum. void SetMinimum(int Minimum); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetMinimum - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the minimum. - // Arguments: None. - + /// Gets the minimum. int GetMinimum() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetMaximum - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the maximum. - // Arguments: Maximum. - + /// Sets the maximum. + /// @param Maximum Maximum. void SetMaximum(int Maximum); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetMaximum - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the maximum. - // Arguments: None. - + /// Gets the maximum. int GetMaximum() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ApplyProperties - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Applies new properties to the control. - // Arguments: GUIProperties. - + /// Applies new properties to the control. + /// @param Props GUIProperties. void ApplyProperties(GUIProperties* Props) override; private: @@ -202,12 +105,7 @@ namespace RTE { int m_Value; int m_Spacing; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: BuildBitmap - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Create the progressbar bitmap to draw. - // Arguments: None. - + /// Create the progressbar bitmap to draw. void BuildBitmap(); }; }; // namespace RTE diff --git a/Source/GUI/GUIProperties.cpp b/Source/GUI/GUIProperties.cpp index 622320d54a..a05add064f 100644 --- a/Source/GUI/GUIProperties.cpp +++ b/Source/GUI/GUIProperties.cpp @@ -2,28 +2,20 @@ using namespace RTE; -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIProperties::GUIProperties(const std::string& Name) { m_Name = Name; m_VariableList.clear(); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIProperties::GUIProperties() { m_Name = ""; m_VariableList.clear(); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIProperties::~GUIProperties() { Clear(); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIProperties::Clear() { // Free the list std::vector::iterator it; @@ -37,8 +29,6 @@ void GUIProperties::Clear() { m_VariableList.clear(); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIProperties::AddVariable(const std::string& Variable, const std::string& Value) { // If this property already exists, just update it std::string Val; @@ -55,16 +45,12 @@ void GUIProperties::AddVariable(const std::string& Variable, const std::string& m_VariableList.push_back(Prop); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIProperties::AddVariable(const std::string& Variable, char* Value) { std::string Val = Value; AddVariable(Variable, Val); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIProperties::AddVariable(const std::string& Variable, int Value) { char buf[32]; std::snprintf(buf, sizeof(buf), "%i", Value); @@ -72,15 +58,11 @@ void GUIProperties::AddVariable(const std::string& Variable, int Value) { AddVariable(Variable, Val); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIProperties::AddVariable(const std::string& Variable, bool Value) { std::string Val = Value ? "True" : "False"; AddVariable(Variable, Val); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool GUIProperties::SetValue(const std::string& Variable, const std::string& Value) { // Find the property std::vector::iterator it; @@ -99,8 +81,6 @@ bool GUIProperties::SetValue(const std::string& Variable, const std::string& Val return false; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool GUIProperties::SetValue(const std::string& Variable, int Value) { char buf[64]; std::snprintf(buf, sizeof(buf), "%i", Value); @@ -108,8 +88,6 @@ bool GUIProperties::SetValue(const std::string& Variable, int Value) { return SetValue(Variable, buf); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIProperties::Update(GUIProperties* Props, bool Add) { assert(Props); @@ -125,8 +103,6 @@ void GUIProperties::Update(GUIProperties* Props, bool Add) { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool GUIProperties::GetValue(const std::string& Variable, std::string* Value) { // Find the property std::vector::iterator it; @@ -145,8 +121,6 @@ bool GUIProperties::GetValue(const std::string& Variable, std::string* Value) { return false; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int GUIProperties::GetValue(const std::string& Variable, std::string* Array, int MaxArraySize) { assert(Array); @@ -177,8 +151,6 @@ int GUIProperties::GetValue(const std::string& Variable, std::string* Array, int return count; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int GUIProperties::GetValue(const std::string& Variable, int* Array, int MaxArraySize) { assert(Array); @@ -209,8 +181,6 @@ int GUIProperties::GetValue(const std::string& Variable, int* Array, int MaxArra return count; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool GUIProperties::GetValue(const std::string& Variable, int* Value) { assert(Value); @@ -226,8 +196,6 @@ bool GUIProperties::GetValue(const std::string& Variable, int* Value) { return true; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool GUIProperties::GetValue(const std::string& Variable, unsigned long* Value) { assert(Value); @@ -243,8 +211,6 @@ bool GUIProperties::GetValue(const std::string& Variable, unsigned long* Value) return true; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool GUIProperties::GetValue(const std::string& Variable, bool* Value) { assert(Value); @@ -266,14 +232,10 @@ bool GUIProperties::GetValue(const std::string& Variable, bool* Value) { return true; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - std::string GUIProperties::GetName() const { return m_Name; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - std::string GUIProperties::ToString() { std::string OutString = ""; @@ -290,14 +252,10 @@ std::string GUIProperties::ToString() { return OutString; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int GUIProperties::GetCount() const { return m_VariableList.size(); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool GUIProperties::GetVariable(int Index, std::string* Name, std::string* Value) { // Check for a bad index if (Index < 0 || Index >= m_VariableList.size()) { @@ -315,8 +273,6 @@ bool GUIProperties::GetVariable(int Index, std::string* Name, std::string* Value return true; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool GUIProperties::SetVariable(int Index, const std::string& Name, const std::string& Value) { // Check for a bad index if (Index < 0 || Index >= m_VariableList.size()) { @@ -329,8 +285,6 @@ bool GUIProperties::SetVariable(int Index, const std::string& Name, const std::s return true; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIProperties::Sort(bool Ascending) { // Simple bubble sort diff --git a/Source/GUI/GUIProperties.h b/Source/GUI/GUIProperties.h index e5af9ea1b8..1e68052fa6 100644 --- a/Source/GUI/GUIProperties.h +++ b/Source/GUI/GUIProperties.h @@ -3,196 +3,99 @@ namespace RTE { - /// /// A class containing properties for controls and skins. - /// class GUIProperties { public: - ////////////////////////////////////////////////////////////////////////////////////////// - // Constructor: GUIProperties - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Constructor method used to instantiate a GUIProperties object in - // system memory. - // Arguments: Name of section. - + /// Constructor method used to instantiate a GUIProperties object in + /// system memory. + /// @param Name Name of section. explicit GUIProperties(const std::string& Name); - ////////////////////////////////////////////////////////////////////////////////////////// - // Constructor: GUIProperties - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Constructor method used to instantiate a GUIProperties object in - // system memory. - // Arguments: None. - + /// Constructor method used to instantiate a GUIProperties object in + /// system memory. GUIProperties(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Destructor: GUIProperties - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destructor method used to free a GUIProperties object in system - // memory. - // Arguments: None. - + /// Destructor method used to free a GUIProperties object in system + /// memory. ~GUIProperties(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Clear - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears the properties. - // Arguments: None. - + /// Clears the properties. void Clear(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: AddVariable - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Adds a new variable to the properties - // Arguments: Variable, Value - + /// Adds a new variable to the properties + /// @param Variable Variable, Value void AddVariable(const std::string& Variable, const std::string& Value); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: AddVariable - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Adds a new variable to the properties - // Arguments: Variable, Value - + /// Adds a new variable to the properties + /// @param Variable Variable, Value void AddVariable(const std::string& Variable, char* Value); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: AddVariable - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Adds a new variable to the properties - // Arguments: Variable, Value - + /// Adds a new variable to the properties + /// @param Variable Variable, Value void AddVariable(const std::string& Variable, int Value); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: AddVariable - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Adds a new variable to the properties - // Arguments: Variable, Value - + /// Adds a new variable to the properties + /// @param Variable Variable, Value void AddVariable(const std::string& Variable, bool Value); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetValue - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Changes the value of a property. - // Arguments: Variable, Value - // Returns: True if the variable was set. Otherwise false. - + /// Changes the value of a property. + /// @param Variable Variable, Value + /// @return True if the variable was set. Otherwise false. bool SetValue(const std::string& Variable, const std::string& Value); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetValue - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Changes the value of a property. - // Arguments: Variable, Value - // Returns: True if the variable was set. Otherwise false. - + /// Changes the value of a property. + /// @param Variable Variable, Value + /// @return True if the variable was set. Otherwise false. bool SetValue(const std::string& Variable, int Value); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Update - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the properties with properties from another instance. - // Arguments: Pointer to a Properties class, whether to add variables. - + /// Updates the properties with properties from another instance. + /// @param Props Pointer to a Properties class, whether to add variables. void Update(GUIProperties* Props, bool Add = false); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetValue - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets a string value - // Arguments: Variable, String pointer - + /// Gets a string value + /// @param Variable Variable, String pointer bool GetValue(const std::string& Variable, std::string* Value); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetValue - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets a string array of values - // Arguments: Variable, String array, max size of array - // Returns: Number of elements read - + /// Gets a string array of values + /// @param Variable Variable, String array, max size of array + /// @return Number of elements read int GetValue(const std::string& Variable, std::string* Array, int MaxArraySize); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetValue - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets an integer array of values - // Arguments: Variable, Integer array, max size of array - // Returns: Number of elements read - + /// Gets an integer array of values + /// @param Variable Variable, Integer array, max size of array + /// @return Number of elements read int GetValue(const std::string& Variable, int* Array, int MaxArraySize); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetValue - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets a single interger - // Arguments: Variable, Integer pointer - + /// Gets a single interger + /// @param Variable Variable, Integer pointer bool GetValue(const std::string& Variable, int* Value); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetValue - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets a single unsigned interger - // Arguments: Variable, Unsigned Integer pointer - + /// Gets a single unsigned interger + /// @param Variable Variable, Unsigned Integer pointer bool GetValue(const std::string& Variable, unsigned long* Value); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetValue - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets a boolean value - // Arguments: Variable, Boolean pointer - + /// Gets a boolean value + /// @param Variable Variable, Boolean pointer bool GetValue(const std::string& Variable, bool* Value); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetName - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the property name - + /// Gets the property name std::string GetName() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ToString - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Converts the properties to a string - + /// Converts the properties to a string std::string ToString(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetCount - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the variable count in the properties - + /// Gets the variable count in the properties int GetCount() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetVariable - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets a variable based on index - + /// Gets a variable based on index bool GetVariable(int Index, std::string* Name, std::string* Value); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetVariable - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets a variable based on index - + /// Sets a variable based on index bool SetVariable(int Index, const std::string& Name, const std::string& Value); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Sort - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sorts the list by variable name - // Arguments: True for ascending, False for descending - + /// Sorts the list by variable name + /// @param Ascending True for ascending, False for descending void Sort(bool Ascending); private: diff --git a/Source/GUI/GUIPropertyPage.cpp b/Source/GUI/GUIPropertyPage.cpp index f26d85ff13..5717ae68d2 100644 --- a/Source/GUI/GUIPropertyPage.cpp +++ b/Source/GUI/GUIPropertyPage.cpp @@ -3,8 +3,6 @@ using namespace RTE; -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIPropertyPage::GUIPropertyPage(GUIManager* Manager, GUIControlManager* ControlManager) : GUIControl(), GUIPanel(Manager) { m_ControlID = "PROPERTYPAGE"; @@ -18,8 +16,6 @@ GUIPropertyPage::GUIPropertyPage(GUIManager* Manager, GUIControlManager* Control m_TextPanelList.clear(); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIPropertyPage::Create(const std::string& Name, int X, int Y, int Width, int Height) { GUIControl::Create(Name, X, Y, Width, Height); @@ -74,8 +70,6 @@ void GUIPropertyPage::Create(const std::string& Name, int X, int Y, int Width, i } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIPropertyPage::Create(GUIProperties* Props) { GUIControl::Create(Props); @@ -120,8 +114,6 @@ void GUIPropertyPage::Create(GUIProperties* Props) { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIPropertyPage::Destroy() { // Free the drawing bitmap if (m_DrawBitmap) { @@ -138,8 +130,6 @@ void GUIPropertyPage::Destroy() { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIPropertyPage::ChangeSkin(GUISkin* Skin) { GUIControl::ChangeSkin(Skin); @@ -152,8 +142,6 @@ void GUIPropertyPage::ChangeSkin(GUISkin* Skin) { BuildBitmap(); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIPropertyPage::BuildBitmap() { // Free any old bitmap if (m_DrawBitmap) { @@ -185,8 +173,6 @@ void GUIPropertyPage::BuildBitmap() { m_LineColor = m_Skin->ConvertColor(m_LineColor, m_DrawBitmap->GetColorDepth()); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIPropertyPage::Draw(GUIScreen* Screen) { if (m_DrawBitmap) { m_DrawBitmap->Draw(Screen->GetBitmap(), m_X, m_Y, nullptr); @@ -219,8 +205,6 @@ void GUIPropertyPage::Draw(GUIScreen* Screen) { GUIPanel::Draw(Screen); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIPropertyPage::OnMouseDown(int X, int Y, int Buttons, int Modifier) { if (Buttons & MOUSE_LEFT) { // Push the button down @@ -232,48 +216,32 @@ void GUIPropertyPage::OnMouseDown(int X, int Y, int Buttons, int Modifier) { SetFocus(); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIPropertyPage::OnMouseUp(int X, int Y, int Buttons, int Modifier) {} -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIPropertyPage::OnMouseEnter(int X, int Y, int Buttons, int Modifier) { } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIPropertyPage::OnMouseLeave(int X, int Y, int Buttons, int Modifier) { } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIPropertyPage::OnMouseMove(int X, int Y, int Buttons, int Modifier) { if (!(Buttons & MOUSE_LEFT) || !IsCaptured()) { return; } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIPanel* GUIPropertyPage::GetPanel() { return this; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIPropertyPage::GetControlRect(int* X, int* Y, int* Width, int* Height) { GUIPanel::GetRect(X, Y, Width, Height); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIPropertyPage::Move(int X, int Y) { GUIPanel::SetPositionAbs(X, Y); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIPropertyPage::Resize(int Width, int Height) { // Make sure the control isn't too small Width = std::max(Width, m_MinWidth); @@ -286,14 +254,10 @@ void GUIPropertyPage::Resize(int Width, int Height) { BuildBitmap(); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIPropertyPage::StoreProperties() { // Note: This is for saving the control, not related directly to our control type } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIPropertyPage::SetPropertyValues(GUIProperties* Props) { m_PageValues.Clear(); m_PageValues.Update(Props, true); @@ -315,14 +279,10 @@ void GUIPropertyPage::SetPropertyValues(GUIProperties* Props) { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIProperties* GUIPropertyPage::GetPropertyValues() { return &m_PageValues; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIPropertyPage::ReceiveSignal(GUIPanel* Source, int Code, int Data) { assert(Source); @@ -353,8 +313,6 @@ void GUIPropertyPage::ReceiveSignal(GUIPanel* Source, int Code, int Data) { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool GUIPropertyPage::InvokeUpdate() { bool Changed = false; @@ -377,8 +335,6 @@ bool GUIPropertyPage::InvokeUpdate() { return Changed; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIPropertyPage::ClearValues() { m_PageValues.Clear(); @@ -390,8 +346,6 @@ void GUIPropertyPage::ClearValues() { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool GUIPropertyPage::HasTextFocus() { std::vector::iterator it; for (it = m_TextPanelList.begin(); it != m_TextPanelList.end(); it++) { diff --git a/Source/GUI/GUIPropertyPage.h b/Source/GUI/GUIPropertyPage.h index 8e1b32d853..de589b5a33 100644 --- a/Source/GUI/GUIPropertyPage.h +++ b/Source/GUI/GUIPropertyPage.h @@ -6,9 +6,7 @@ namespace RTE { - /// /// A property page control class. - /// class GUIPropertyPage : public GUIControl, public GUIPanel { public: @@ -18,191 +16,91 @@ namespace RTE { Enter // A text panel has lost focus or the enter key was hit } Notification; - ////////////////////////////////////////////////////////////////////////////////////////// - // Constructor: GUIPropertyPage - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Constructor method used to instantiate a GUIPropertyPage object in - // system memory. - // Arguments: GUIManager, GUIControlManager. - + /// Constructor method used to instantiate a GUIPropertyPage object in + /// system memory. + /// @param Manager GUIManager, GUIControlManager. GUIPropertyPage(GUIManager* Manager, GUIControlManager* ControlManager); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the control has been created. - // Arguments: Name, Position. - + /// Called when the control has been created. + /// @param Name Name, Position. void Create(const std::string& Name, int X, int Y, int Width = -1, int Height = -1) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the control has been destroyed. - // Arguments: None. - + /// Called when the control has been destroyed. void Destroy() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the control has been created. - // Arguments: Properties. - + /// Called when the control has been created. + /// @param Props Properties. void Create(GUIProperties* Props) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ChangeSkin - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the skin has been changed. - // Arguments: New skin pointer. - + /// Called when the skin has been changed. + /// @param Skin New skin pointer. void ChangeSkin(GUISkin* Skin) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Draw - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws the panel - // Arguments: Screen class - + /// Draws the panel + /// @param Screen Screen class void Draw(GUIScreen* Screen) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: OnMouseDown - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the mouse goes down on the panel - // Arguments: Mouse Position, Mouse Buttons, Modifier. - + /// Called when the mouse goes down on the panel + /// @param X Mouse Position, Mouse Buttons, Modifier. void OnMouseDown(int X, int Y, int Buttons, int Modifier) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: OnMouseUp - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the mouse goes up on the panel - // Arguments: Mouse Position, Mouse Buttons, Modifier. - + /// Called when the mouse goes up on the panel + /// @param X Mouse Position, Mouse Buttons, Modifier. void OnMouseUp(int X, int Y, int Buttons, int Modifier) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: OnMouseMove - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the mouse moves (over the panel, or when captured). - // Arguments: Mouse Position, Mouse Buttons, Modifier. - + /// Called when the mouse moves (over the panel, or when captured). + /// @param X Mouse Position, Mouse Buttons, Modifier. void OnMouseMove(int X, int Y, int Buttons, int Modifier) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: OnMouseEnter - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the mouse enters the panel. - // Arguments: Mouse Position, Mouse Buttons, Modifier. - + /// Called when the mouse enters the panel. + /// @param X Mouse Position, Mouse Buttons, Modifier. void OnMouseEnter(int X, int Y, int Buttons, int Modifier) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: OnMouseLeave - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the mouse leaves the panel. - // Arguments: Mouse Position, Mouse Buttons, Modifier. - + /// Called when the mouse leaves the panel. + /// @param X Mouse Position, Mouse Buttons, Modifier. void OnMouseLeave(int X, int Y, int Buttons, int Modifier) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetPanel - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns the panel of the control. - // Arguments: None. - // Returns: 0 if the control does not have a panel, otherwise the topmost panel. - + /// Returns the panel of the control. + /// @return 0 if the control does not have a panel, otherwise the topmost panel. GUIPanel* GetPanel() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetControlID - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns a string representing the control's ID - // Arguments: None. - + /// Returns a string representing the control's ID static std::string GetControlID() { return "PROPERTYPAGE"; }; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetControlRect - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the rectangle of the control. - // Arguments: Position, Size. - + /// Gets the rectangle of the control. + /// @param X Position, Size. void GetControlRect(int* X, int* Y, int* Width, int* Height) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: StoreProperties - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the control to store the values into properties. - // Arguments: None. - + /// Gets the control to store the values into properties. void StoreProperties() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Move - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the control needs to be moved. - // Arguments: New position. - + /// Called when the control needs to be moved. + /// @param X New position. void Move(int X, int Y) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Resize - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the control needs to be resized. - // Arguments: New size. - + /// Called when the control needs to be resized. + /// @param Width New size. void Resize(int Width, int Height) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetPropertyValues - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Refreshes the page with new variables & values. - // Arguments: GUIProperties. - + /// Refreshes the page with new variables & values. + /// @param Props GUIProperties. void SetPropertyValues(GUIProperties* Props); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetPropertyValues - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the properties in the page. - // Arguments: None. - + /// Gets the properties in the page. GUIProperties* GetPropertyValues(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ReceiveSignal - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when receiving a signal. - // Arguments: Signal source, Signal code, Signal data. - + /// Called when receiving a signal. + /// @param Source Signal source, Signal code, Signal data. void ReceiveSignal(GUIPanel* Source, int Code, int Data) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ClearValues - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears the property page values. - // Arguments: None. - + /// Clears the property page values. void ClearValues(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: InvokeUpdate - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Invokes an explicit update on text panels to property page. - // Arguments: None. - // Returns: Boolean whether or not any values have changed. - + /// Invokes an explicit update on text panels to property page. + /// @return Boolean whether or not any values have changed. bool InvokeUpdate(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: HasTextFocus - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Checks if any of the visible text panels have focus. - // Arguments: None. - + /// Checks if any of the visible text panels have focus. bool HasTextFocus(); private: @@ -213,12 +111,7 @@ namespace RTE { std::vector m_TextPanelList; GUIScrollPanel* m_VertScroll; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: BuildBitmap - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Create the property page bitmap to draw. - // Arguments: None. - + /// Create the property page bitmap to draw. void BuildBitmap(); }; }; // namespace RTE diff --git a/Source/GUI/GUIRadioButton.cpp b/Source/GUI/GUIRadioButton.cpp index 605ac2872a..226d4af6be 100644 --- a/Source/GUI/GUIRadioButton.cpp +++ b/Source/GUI/GUIRadioButton.cpp @@ -3,8 +3,6 @@ using namespace RTE; -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIRadioButton::GUIRadioButton(GUIManager* Manager, GUIControlManager* ControlManager) : GUIControl(), GUIPanel(Manager) { m_ControlID = "RADIOBUTTON"; @@ -17,8 +15,6 @@ GUIRadioButton::GUIRadioButton(GUIManager* Manager, GUIControlManager* ControlMa m_Text = ""; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIRadioButton::Create(const std::string& Name, int X, int Y, int Width, int Height) { GUIControl::Create(Name, X, Y, Width, Height); @@ -48,8 +44,6 @@ void GUIRadioButton::Create(const std::string& Name, int X, int Y, int Width, in m_Height = std::max(m_Height, m_MinHeight); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIRadioButton::Create(GUIProperties* Props) { GUIControl::Create(Props); @@ -73,8 +67,6 @@ void GUIRadioButton::Create(GUIProperties* Props) { Props->GetValue("Checked", &m_Checked); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIRadioButton::ChangeSkin(GUISkin* Skin) { GUIControl::ChangeSkin(Skin); @@ -82,8 +74,6 @@ void GUIRadioButton::ChangeSkin(GUISkin* Skin) { BuildBitmap(); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIRadioButton::BuildBitmap() { std::string Filename; unsigned long ColorIndex = 0; @@ -129,8 +119,6 @@ void GUIRadioButton::BuildBitmap() { SetRect(&m_ImageRects[3], Values[0], Values[1], Values[0] + Values[2], Values[1] + Values[3]); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIRadioButton::Draw(GUIScreen* Screen) { if (!m_Image) { return; @@ -179,8 +167,6 @@ void GUIRadioButton::Draw(GUIScreen* Screen) { GUIPanel::Draw(Screen); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIRadioButton::OnMouseDown(int X, int Y, int Buttons, int Modifier) { if (Buttons & MOUSE_LEFT) { // Push the checkbox down @@ -191,8 +177,6 @@ void GUIRadioButton::OnMouseDown(int X, int Y, int Buttons, int Modifier) { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIRadioButton::OnMouseUp(int X, int Y, int Buttons, int Modifier) { ReleaseMouse(); @@ -204,32 +188,22 @@ void GUIRadioButton::OnMouseUp(int X, int Y, int Buttons, int Modifier) { AddEvent(GUIEvent::Notification, UnPushed, 0); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIRadioButton::OnMouseEnter(int X, int Y, int Buttons, int Modifier) { m_Mouseover = true; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIRadioButton::OnMouseLeave(int X, int Y, int Buttons, int Modifier) { m_Mouseover = false; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIPanel* GUIRadioButton::GetPanel() { return this; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIRadioButton::Move(int X, int Y) { GUIPanel::SetPositionAbs(X, Y); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIRadioButton::Resize(int Width, int Height) { // Make sure the control isn't too small Width = std::max(Width, m_MinWidth); @@ -241,21 +215,15 @@ void GUIRadioButton::Resize(int Width, int Height) { BuildBitmap(); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIRadioButton::GetControlRect(int* X, int* Y, int* Width, int* Height) { GUIPanel::GetRect(X, Y, Width, Height); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIRadioButton::StoreProperties() { m_Properties.AddVariable("Text", m_Text); m_Properties.AddVariable("Checked", m_Checked); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIRadioButton::SetCheck(bool Check) { // Nothing to do if already in the same state if (m_Checked == Check) { @@ -294,26 +262,18 @@ void GUIRadioButton::SetCheck(bool Check) { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool GUIRadioButton::GetCheck() const { return m_Checked; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIRadioButton::SetText(const std::string& Text) { m_Text = Text; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - std::string GUIRadioButton::GetText() const { return m_Text; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIRadioButton::ApplyProperties(GUIProperties* Props) { GUIControl::ApplyProperties(Props); diff --git a/Source/GUI/GUIRadioButton.h b/Source/GUI/GUIRadioButton.h index 1d4bc69f55..212834f733 100644 --- a/Source/GUI/GUIRadioButton.h +++ b/Source/GUI/GUIRadioButton.h @@ -3,9 +3,7 @@ namespace RTE { - /// /// A radiobutton control class. - /// class GUIRadioButton : public GUIControl, public GUIPanel { public: @@ -16,166 +14,81 @@ namespace RTE { Changed, } Notification; - ////////////////////////////////////////////////////////////////////////////////////////// - // Constructor: GUIRadioButton - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Constructor method used to instantiate a GUIRadioButton object in - // system memory. - // Arguments: GUIManager, GUIControlManager. - + /// Constructor method used to instantiate a GUIRadioButton object in + /// system memory. + /// @param Manager GUIManager, GUIControlManager. GUIRadioButton(GUIManager* Manager, GUIControlManager* ControlManager); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the control has been created. - // Arguments: Name, Position. - + /// Called when the control has been created. + /// @param Name Name, Position. void Create(const std::string& Name, int X, int Y, int Width = -1, int Height = -1) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the control has been created. - // Arguments: Properties. - + /// Called when the control has been created. + /// @param Props Properties. void Create(GUIProperties* Props) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ChangeSkin - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the skin has been changed. - // Arguments: New skin pointer. - + /// Called when the skin has been changed. + /// @param Skin New skin pointer. void ChangeSkin(GUISkin* Skin) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Draw - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws the panel - // Arguments: Screen class - + /// Draws the panel + /// @param Screen Screen class void Draw(GUIScreen* Screen) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: OnMouseDown - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the mouse goes down on the panel - // Arguments: Mouse Position, Mouse Buttons, Modifier. - + /// Called when the mouse goes down on the panel + /// @param X Mouse Position, Mouse Buttons, Modifier. void OnMouseDown(int X, int Y, int Buttons, int Modifier) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: OnMouseUp - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the mouse goes up on the panel - // Arguments: Mouse Position, Mouse Buttons, Modifier. - + /// Called when the mouse goes up on the panel + /// @param X Mouse Position, Mouse Buttons, Modifier. void OnMouseUp(int X, int Y, int Buttons, int Modifier) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: OnMouseEnter - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the mouse enters the panel. - // Arguments: Mouse Position, Mouse Buttons, Modifier. - + /// Called when the mouse enters the panel. + /// @param X Mouse Position, Mouse Buttons, Modifier. void OnMouseEnter(int X, int Y, int Buttons, int Modifier) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: OnMouseLeave - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the mouse leaves the panel. - // Arguments: Mouse Position, Mouse Buttons, Modifier. - + /// Called when the mouse leaves the panel. + /// @param X Mouse Position, Mouse Buttons, Modifier. void OnMouseLeave(int X, int Y, int Buttons, int Modifier) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetPanel - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns the panel of the control. - // Arguments: None. - // Returns: 0 if the control does not have a panel, otherwise the topmost panel. - + /// Returns the panel of the control. + /// @return 0 if the control does not have a panel, otherwise the topmost panel. GUIPanel* GetPanel() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetControlID - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns a string representing the control's ID - // Arguments: None. - + /// Returns a string representing the control's ID static std::string GetControlID() { return "RADIOBUTTON"; }; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Move - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the control needs to be moved. - // Arguments: New position. - + /// Called when the control needs to be moved. + /// @param X New position. void Move(int X, int Y) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Resize - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the control needs to be resized. - // Arguments: New size. - + /// Called when the control needs to be resized. + /// @param Width New size. void Resize(int Width, int Height) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetControlRect - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the rectangle of the control. - // Arguments: Position, Size. - + /// Gets the rectangle of the control. + /// @param X Position, Size. void GetControlRect(int* X, int* Y, int* Width, int* Height) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: StoreProperties - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the control to store the values into properties. - // Arguments: None. - + /// Gets the control to store the values into properties. void StoreProperties() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetCheck - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the check state. - // Arguments: State. - + /// Sets the check state. + /// @param Check State. void SetCheck(bool Check); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetCheck - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the check state. - // Arguments: None. - + /// Gets the check state. bool GetCheck() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetText - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the text. - // Arguments: Text. - + /// Sets the text. + /// @param Text Text. void SetText(const std::string& Text); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetText - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the text. - // Arguments: None. - + /// Gets the text. std::string GetText() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ApplyProperties - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Applies new properties to the control. - // Arguments: GUIProperties. - + /// Applies new properties to the control. + /// @param Props GUIProperties. void ApplyProperties(GUIProperties* Props) override; private: @@ -186,12 +99,7 @@ namespace RTE { int m_Mouseover; std::string m_Text; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: BuildBitmap - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Create the checkbox bitmap to draw. - // Arguments: None. - + /// Create the checkbox bitmap to draw. void BuildBitmap(); }; }; // namespace RTE diff --git a/Source/GUI/GUIReader.cpp b/Source/GUI/GUIReader.cpp index 4b26e02f38..e7f5eb49ff 100644 --- a/Source/GUI/GUIReader.cpp +++ b/Source/GUI/GUIReader.cpp @@ -3,13 +3,9 @@ namespace RTE { - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIReader::StreamInfo::StreamInfo(std::ifstream* stream, const std::string& filePath, int currentLine, int prevIndent) : Stream(stream), FilePath(filePath), CurrentLine(currentLine), PreviousIndent(prevIndent) {} - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIReader::Clear() { m_Stream = nullptr; m_FilePath.clear(); @@ -23,14 +19,10 @@ namespace RTE { m_SkipIncludes = false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIReader::GUIReader() { Clear(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int GUIReader::Create(const std::string& fileName) { m_FilePath = std::filesystem::path(fileName).generic_string(); @@ -44,38 +36,26 @@ namespace RTE { return m_Stream->good() ? 0 : -1; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - std::istream* GUIReader::GetStream() const { return m_Stream.get(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - std::string GUIReader::GetCurrentFilePath() const { return m_FilePath; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - std::string GUIReader::GetCurrentFileLine() const { return std::to_string(m_CurrentLine); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool GUIReader::GetSkipIncludes() const { return m_SkipIncludes; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIReader::SetSkipIncludes(bool skip) { m_SkipIncludes = skip; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - std::string GUIReader::ReadLine() { DiscardEmptySpace(); @@ -105,8 +85,6 @@ namespace RTE { return TrimString(retString); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - std::string GUIReader::ReadPropName() { DiscardEmptySpace(); @@ -153,8 +131,6 @@ namespace RTE { return retString; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - std::string GUIReader::ReadPropValue() { std::string fullLine = ReadLine(); size_t valuePos = fullLine.find_first_of('='); @@ -162,8 +138,6 @@ namespace RTE { return TrimString(propValue); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool GUIReader::NextProperty() { if (!DiscardEmptySpace() || m_EndOfStreams) { return false; @@ -177,8 +151,6 @@ namespace RTE { return true; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - std::string GUIReader::TrimString(const std::string& stringToTrim) const { if (stringToTrim.empty()) { return ""; @@ -189,8 +161,6 @@ namespace RTE { return stringToTrim.substr(start, (end - start + 1)); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool GUIReader::DiscardEmptySpace() { char peek; int indent = 0; @@ -269,20 +239,14 @@ namespace RTE { return true; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool GUIReader::ReaderOK() const { return m_Stream.get() && !m_Stream->fail() && m_Stream->is_open(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIReader::ReportError(const std::string& errorDesc) const { GUIAbort(errorDesc + "\nError happened in " + m_FilePath + " at line " + std::to_string(m_CurrentLine) + "!"); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool GUIReader::StartIncludeFile() { // Get the file path from the current stream before pushing it into the StreamStack, otherwise we can't open a new stream after releasing it because we can't read. std::string includeFilePath = std::filesystem::path(ReadPropValue()).generic_string(); @@ -315,8 +279,6 @@ namespace RTE { return true; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool GUIReader::EndIncludeFile() { if (m_StreamStack.empty()) { m_EndOfStreams = true; @@ -339,24 +301,18 @@ namespace RTE { return true; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIReader& GUIReader::operator>>(bool& var) { DiscardEmptySpace(); *m_Stream >> var; return *this; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIReader& GUIReader::operator>>(char& var) { DiscardEmptySpace(); *m_Stream >> var; return *this; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIReader& GUIReader::operator>>(unsigned char& var) { DiscardEmptySpace(); int temp; @@ -365,56 +321,42 @@ namespace RTE { return *this; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIReader& GUIReader::operator>>(short& var) { DiscardEmptySpace(); *m_Stream >> var; return *this; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIReader& GUIReader::operator>>(unsigned short& var) { DiscardEmptySpace(); *m_Stream >> var; return *this; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIReader& GUIReader::operator>>(int& var) { DiscardEmptySpace(); *m_Stream >> var; return *this; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIReader& GUIReader::operator>>(unsigned int& var) { DiscardEmptySpace(); *m_Stream >> var; return *this; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIReader& GUIReader::operator>>(long& var) { DiscardEmptySpace(); *m_Stream >> var; return *this; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIReader& GUIReader::operator>>(unsigned long& var) { DiscardEmptySpace(); *m_Stream >> var; return *this; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // Yeah, this is dumb - read as double and cast. // This is because, for whatever fucking reason, iostream can save out floats at a precision that it's then unable to read... GUIReader& GUIReader::operator>>(float& var) { @@ -425,16 +367,12 @@ namespace RTE { return *this; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIReader& GUIReader::operator>>(double& var) { DiscardEmptySpace(); *m_Stream >> var; return *this; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIReader& GUIReader::operator>>(std::string& var) { var.assign(ReadLine()); return *this; diff --git a/Source/GUI/GUIReader.h b/Source/GUI/GUIReader.h index 579ed6ddd3..091de0c449 100644 --- a/Source/GUI/GUIReader.h +++ b/Source/GUI/GUIReader.h @@ -3,119 +3,85 @@ namespace RTE { - /// /// Reads GUI objects from std::istreams. - /// class GUIReader { public: #pragma region Creation - /// /// Constructor method used to instantiate a GUIReader object in system memory. Create() should be called before using the object. - /// GUIReader(); - /// /// Makes the GUIReader object ready for use. - /// - /// Path to the file to open for reading. If the file doesn't exist the stream will fail to open. - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @param fileName Path to the file to open for reading. If the file doesn't exist the stream will fail to open. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create(const std::string& fileName); #pragma endregion #pragma region Getters and Setters - /// /// Gets a pointer to the istream of this reader. - /// - /// A pointer to the istream object for this reader. + /// @return A pointer to the istream object for this reader. std::istream* GetStream() const; - /// /// Gets the path of the current file this reader is reading from. - /// - /// A string with the path, relative from the working directory. + /// @return A string with the path, relative from the working directory. std::string GetCurrentFilePath() const; - /// /// Gets the line of the current file line this reader is reading from. - /// - /// A string with the line number that will be read from next. + /// @return A string with the line number that will be read from next. std::string GetCurrentFileLine() const; - /// /// Returns true if reader was told to skip InlcudeFile statements - /// - /// Returns whether reader was told to skip included files. + /// @return Returns whether reader was told to skip included files. bool GetSkipIncludes() const; - /// /// Set whether this reader should skip included files. - /// - /// - /// The whitespace-trimmed std::string that will hold the next property's name. + /// @return The whitespace-trimmed std::string that will hold the next property's name. std::string ReadPropName(); - /// /// Reads the next property value from the context object GUIReader's stream after eating all whitespace including newlines up till the first newline char. /// Basically gets anything after the last "=" and up to the next newline after that. - /// - /// The whitespace-trimmed std::string that will hold the next property value. + /// @return The whitespace-trimmed std::string that will hold the next property value. std::string ReadPropValue(); - /// /// Lines up the reader with the next property of the current object. - /// - /// Whether there are any more properties to be read by the current object. + /// @return Whether there are any more properties to be read by the current object. bool NextProperty(); - /// /// Takes out whitespace from the beginning and the end of a string. - /// - /// String to remove whitespace from. - /// The string that was passed in, sans whitespace in the front and end. + /// @param stringToTrim String to remove whitespace from. + /// @return The string that was passed in, sans whitespace in the front and end. std::string TrimString(const std::string& stringToTrim) const; - /// /// Discards all whitespace, newlines and comment lines (which start with '//') so that the next thing to be read will be actual data. - /// - /// Whether there is more data to read from the file streams after this eat. + /// @return Whether there is more data to read from the file streams after this eat. bool DiscardEmptySpace(); #pragma endregion #pragma region Reader Status - /// /// Shows whether this is still OK to read from. If file isn't present, etc, this will return false. - /// - /// Whether this GUIReader's stream is OK or not. + /// @return Whether this GUIReader's stream is OK or not. bool ReaderOK() const; - /// /// Makes an error message box pop up for the user that tells them something went wrong with the reading, and where. - /// - /// The message describing what's wrong. + /// @param errorDesc The message describing what's wrong. void ReportError(const std::string& errorDesc) const; #pragma endregion #pragma region Operator Overloads - /// /// Stream extraction operator overloads for all the elemental types. - /// - /// A reference to the variable that will be filled by the extracted data. - /// A GUIReader reference for further use in an expression. + /// @param var A reference to the variable that will be filled by the extracted data. + /// @return A GUIReader reference for further use in an expression. GUIReader& operator>>(bool& var); GUIReader& operator>>(char& var); GUIReader& operator>>(unsigned char& var); @@ -131,13 +97,9 @@ namespace RTE { #pragma endregion protected: - /// /// A struct containing information from the currently used stream. - /// struct StreamInfo { - /// /// Constructor method used to instantiate a StreamInfo object in system memory. - /// StreamInfo(std::ifstream* stream, const std::string& filePath, int currentLine, int prevIndent); // NOTE: These members are owned by the reader that owns this struct, so are not deleted when this is destroyed. @@ -161,32 +123,24 @@ namespace RTE { int m_CurrentLine; //!< The line number the stream is on. bool m_SkipIncludes; //!< Indicates whether reader should skip included files. - /// /// When NextProperty() has returned false, indicating that there were no more properties to read on that object, /// this is incremented until it matches -m_IndentDifference, and then NextProperty will start returning true again. - /// int m_ObjectEndings; private: #pragma region Reading Operations - /// /// When ReadPropName encounters the property name "IncludeFile", it will automatically call this function to get started reading on that file. /// This will create a new stream to the include file. - /// - /// Whether the include file was found and opened ok or not. + /// @return Whether the include file was found and opened ok or not. bool StartIncludeFile(); - /// /// This should be called when end-of-file is detected in an included file stream. /// It will destroy the current stream pop the top stream off the stream stack to resume reading from it instead. - /// - /// Whether there were any stream on the stack to resume. + /// @return Whether there were any stream on the stack to resume. bool EndIncludeFile(); #pragma endregion - /// /// Clears all the member variables of this GUIReader, effectively resetting the members of this abstraction level only. - /// void Clear(); // Disallow the use of some implicit methods. diff --git a/Source/GUI/GUIScrollPanel.cpp b/Source/GUI/GUIScrollPanel.cpp index e6f9dcf6b0..d8c2d1b4a7 100644 --- a/Source/GUI/GUIScrollPanel.cpp +++ b/Source/GUI/GUIScrollPanel.cpp @@ -3,8 +3,6 @@ using namespace RTE; -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIScrollPanel::GUIScrollPanel(GUIManager* Manager) : GUIPanel(Manager) { m_Skin = nullptr; @@ -20,8 +18,6 @@ GUIScrollPanel::GUIScrollPanel(GUIManager* Manager) : m_ValueResolution = 1; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIScrollPanel::GUIScrollPanel() : GUIPanel() { m_Skin = nullptr; @@ -37,8 +33,6 @@ GUIScrollPanel::GUIScrollPanel() : m_ValueResolution = 1; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIScrollPanel::Create(int X, int Y, int Width, int Height) { m_X = X; m_Y = Y; @@ -56,8 +50,6 @@ void GUIScrollPanel::Create(int X, int Y, int Width, int Height) { m_ValueResolution = 1; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIScrollPanel::Destroy() { // Destroy the three bitmaps for (int i = 0; i < 3; i++) { @@ -69,8 +61,6 @@ void GUIScrollPanel::Destroy() { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIScrollPanel::LoadProps(GUIProperties* Props) { assert(Props); @@ -92,8 +82,6 @@ void GUIScrollPanel::LoadProps(GUIProperties* Props) { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIScrollPanel::ChangeSkin(GUISkin* Skin) { assert(Skin); @@ -103,8 +91,6 @@ void GUIScrollPanel::ChangeSkin(GUISkin* Skin) { BuildBitmap(true, true); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIScrollPanel::BuildBitmap(bool UpdateSize, bool UpdateKnob) { // It is normal if this function is called but the skin has not been set so we just ignore the call if the skin has not been set if (!m_Skin) { @@ -194,8 +180,6 @@ void GUIScrollPanel::BuildBitmap(bool UpdateSize, bool UpdateKnob) { m_RebuildKnob = false; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIScrollPanel::BuildButton(const std::string& ArrowName, int Y, int Width, int Height) { // Create the buttons m_Skin->BuildStandardRect(m_DrawBitmap[ButtonStates], "ScrollButton_Up", 0, Y, Width, Height); @@ -228,8 +212,6 @@ void GUIScrollPanel::BuildButton(const std::string& ArrowName, int Y, int Width, Arrow->DrawTrans(m_DrawBitmap[ButtonStates], Width + (Width / 2) - (Values[2] / 2) + 1, Y + (Height / 2) - (Values[3] / 2) + 1, &Rect); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIScrollPanel::BuildBackground() { std::string Filename; m_Skin->GetValue("ScrollBackground", "Filename", &Filename); @@ -252,16 +234,12 @@ void GUIScrollPanel::BuildBackground() { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIScrollPanel::BuildKnob(const std::string& Section, int X, int Y, int Width, int Height) { if (m_DrawBitmap[KnobStates]) { m_Skin->BuildStandardRect(m_DrawBitmap[KnobStates], Section, X, Y, Width, Height); } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIScrollPanel::SetMinimum(int Min) { m_Minimum = Min; m_Minimum = std::min(m_Minimum, m_Maximum); @@ -270,8 +248,6 @@ void GUIScrollPanel::SetMinimum(int Min) { m_RebuildKnob = true; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIScrollPanel::SetMaximum(int Max) { m_Maximum = Max; m_Maximum = std::max(m_Maximum, m_Minimum); @@ -280,15 +256,11 @@ void GUIScrollPanel::SetMaximum(int Max) { m_RebuildKnob = true; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIScrollPanel::SetValue(int Value) { m_Value = std::clamp(Value, m_Minimum, m_Maximum); CalculateKnob(); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIScrollPanel::SetPageSize(int PageSize) { m_PageSize = PageSize; m_PageSize = std::max(m_PageSize, 1); @@ -297,8 +269,6 @@ void GUIScrollPanel::SetPageSize(int PageSize) { m_RebuildKnob = true; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIScrollPanel::SetOrientation(int Orientation) { m_Orientation = Orientation; @@ -307,27 +277,19 @@ void GUIScrollPanel::SetOrientation(int Orientation) { m_RebuildSize = true; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int GUIScrollPanel::GetValue() const { return m_Value; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int GUIScrollPanel::GetPageSize() const { return m_PageSize; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIScrollPanel::SetSmallChange(int SmallChange) { m_SmallChange = SmallChange; m_SmallChange = std::max(m_SmallChange, 0); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIScrollPanel::Draw(GUIScreen* Screen) { GUIRect Rect; @@ -380,8 +342,6 @@ void GUIScrollPanel::Draw(GUIScreen* Screen) { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIScrollPanel::OnMouseDown(int X, int Y, int Buttons, int Modifier) { m_ButtonPushed[0] = m_ButtonPushed[1] = false; m_GrabbedKnob = false; @@ -490,8 +450,6 @@ void GUIScrollPanel::OnMouseDown(int X, int Y, int Buttons, int Modifier) { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIScrollPanel::OnMouseUp(int X, int Y, int Buttons, int Modifier) { // No more grabs m_ButtonPushed[0] = m_ButtonPushed[1] = false; @@ -501,8 +459,6 @@ void GUIScrollPanel::OnMouseUp(int X, int Y, int Buttons, int Modifier) { SendSignal(Release, Buttons); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIScrollPanel::OnMouseMove(int X, int Y, int Buttons, int Modifier) { int KnobTop = 0; int MoveLength = 1; @@ -549,8 +505,6 @@ void GUIScrollPanel::OnMouseMove(int X, int Y, int Buttons, int Modifier) { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIScrollPanel::OnMouseHover(int X, int Y, int Buttons, int Modifier) { // Ignore if the left mouse button is not down if (!(Buttons & MOUSE_LEFT)) { @@ -634,8 +588,6 @@ void GUIScrollPanel::OnMouseHover(int X, int Y, int Buttons, int Modifier) { TrackMouseHover(true, 50); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIScrollPanel::SetSize(int Width, int Height) { // If there is no change in size, ignore the call if (m_Width == Width && m_Height == Height) { @@ -648,8 +600,6 @@ void GUIScrollPanel::SetSize(int Width, int Height) { m_RebuildSize = true; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIScrollPanel::CalculateKnob() { int MoveLength = 1; @@ -691,8 +641,6 @@ void GUIScrollPanel::CalculateKnob() { m_KnobPosition = std::min(m_KnobPosition, MoveLength - m_KnobLength); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIScrollPanel::AdjustValue(int Delta) { int OldValue = m_Value; @@ -710,8 +658,6 @@ void GUIScrollPanel::AdjustValue(int Delta) { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIScrollPanel::SaveProps(GUIProperties* Props) const { assert(Props); @@ -723,32 +669,22 @@ void GUIScrollPanel::SaveProps(GUIProperties* Props) const { Props->AddVariable("SmallChange", m_SmallChange); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int GUIScrollPanel::GetMinimum() const { return m_Minimum; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int GUIScrollPanel::GetMaximum() const { return m_Maximum; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int GUIScrollPanel::GetOrientation() const { return m_Orientation; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int GUIScrollPanel::GetSmallChange() const { return m_SmallChange; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int GUIScrollPanel::GetValueResolution() const { return m_ValueResolution; } diff --git a/Source/GUI/GUIScrollPanel.h b/Source/GUI/GUIScrollPanel.h index 1d2899375a..a61f67a4b1 100644 --- a/Source/GUI/GUIScrollPanel.h +++ b/Source/GUI/GUIScrollPanel.h @@ -3,9 +3,7 @@ namespace RTE { - /// /// A scrollbar panel class used for controls requiring a scrollbar. - /// class GUIScrollPanel : public GUIPanel { public: @@ -29,221 +27,106 @@ namespace RTE { Release }; - ////////////////////////////////////////////////////////////////////////////////////////// - // Constructor: GUIScrollPanel - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Constructor method used to instantiate a GUIScrollPanel object in - // system memory. - // Arguments: GUIManager. - + /// Constructor method used to instantiate a GUIScrollPanel object in + /// system memory. + /// @param Manager GUIManager. explicit GUIScrollPanel(GUIManager* Manager); - ////////////////////////////////////////////////////////////////////////////////////////// - // Constructor: GUIScrollPanel - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Constructor method used to instantiate a GUIScrollPanel object in - // system memory. - // Arguments: None. - + /// Constructor method used to instantiate a GUIScrollPanel object in + /// system memory. GUIScrollPanel(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Create the scrollpanel - // Arguments: Position, Size. - + /// Create the scrollpanel + /// @param X Position, Size. void Create(int X, int Y, int Width, int Height); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the panel has been destroyed. - // Arguments: None. - + /// Called when the panel has been destroyed. void Destroy(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ChangeSkin - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the skin has been changed. - // Arguments: New skin pointer. - + /// Called when the skin has been changed. + /// @param Skin New skin pointer. void ChangeSkin(GUISkin* Skin); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Draw - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws the panel - // Arguments: Screen class - + /// Draws the panel + /// @param Screen Screen class void Draw(GUIScreen* Screen) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: OnMouseDown - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the mouse goes down on the panel - // Arguments: Mouse Position, Mouse Buttons, Modifier. - + /// Called when the mouse goes down on the panel + /// @param X Mouse Position, Mouse Buttons, Modifier. void OnMouseDown(int X, int Y, int Buttons, int Modifier) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: OnMouseUp - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the mouse goes up on the panel - // Arguments: Mouse Position, Mouse Buttons, Modifier. - + /// Called when the mouse goes up on the panel + /// @param X Mouse Position, Mouse Buttons, Modifier. void OnMouseUp(int X, int Y, int Buttons, int Modifier) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: OnMouseMove - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the mouse moves (over the panel, or when captured). - // Arguments: Mouse Position, Mouse Buttons, Modifier. - + /// Called when the mouse moves (over the panel, or when captured). + /// @param X Mouse Position, Mouse Buttons, Modifier. void OnMouseMove(int X, int Y, int Buttons, int Modifier) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: OnMouseHover - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the mouse is hovering over the panel (has to be enabled) - // Arguments: Mouse Position, Mouse Buttons, Modifier. - + /// Called when the mouse is hovering over the panel (has to be enabled) + /// @param X Mouse Position, Mouse Buttons, Modifier. void OnMouseHover(int X, int Y, int Buttons, int Modifier) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Resize - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Adjusts the size of the panel. - // Arguments: Width, Height. - + /// Adjusts the size of the panel. + /// @param Width Width, Height. void SetSize(int Width, int Height); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetMinimum - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the minimum value for the scrollpanel - // Arguments: Minimum value. - + /// Sets the minimum value for the scrollpanel + /// @param Min Minimum value. void SetMinimum(int Min); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetMinimum - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the minimum value for the scrollpanel - // Arguments: None. - + /// Gets the minimum value for the scrollpanel int GetMinimum() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetMaximum - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the maximum value for the scrollpanel - // Arguments: Maximum value. - + /// Sets the maximum value for the scrollpanel + /// @param Max Maximum value. void SetMaximum(int Max); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetMaximum - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the maximum value for the scrollpanel - // Arguments: None. - + /// Gets the maximum value for the scrollpanel int GetMaximum() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetValue - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the current value for the scrollpanel - // Arguments: Value. - + /// Sets the current value for the scrollpanel + /// @param Value Value. void SetValue(int Value); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetValue - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the current value of the scrollpanel. - // Arguments: None. - + /// Gets the current value of the scrollpanel. int GetValue() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetPageSize - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the page size value for the scrollpanel. - // Arguments: PageSize. - + /// Sets the page size value for the scrollpanel. + /// @param PageSize PageSize. void SetPageSize(int PageSize); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetPageSize - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the size of the page. - // Arguments: None. - + /// Gets the size of the page. int GetPageSize() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetOrientation - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the orientation of the scrollpanel. - // Arguments: Orientation. - + /// Sets the orientation of the scrollpanel. + /// @param Orientation Orientation. void SetOrientation(int Orientation); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetOrientation - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the orientation of the scrollpanel. - // Arguments: None. - + /// Gets the orientation of the scrollpanel. int GetOrientation() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetSmallChange - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the small change value. - // Arguments: SmallChange. - + /// Sets the small change value. + /// @param SmallChange SmallChange. void SetSmallChange(int SmallChange); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetSmallChange - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the small change value. - // Arguments: None. - + /// Gets the small change value. int GetSmallChange() const; - /// /// Gets the value resolution for this scroll panel. - /// - /// The value resolution + /// @return The value resolution int GetValueResolution() const; protected: - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: LoadProps - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Load values from a property class. - // Arguments: Properties. - + /// Load values from a property class. + /// @param Props Properties. void LoadProps(GUIProperties* Props); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SaveProps - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Save values to a property class. - // Arguments: Properties. - + /// Save values to a property class. + /// @param Props Properties. void SaveProps(GUIProperties* Props) const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: BuildBitmap - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Build the bitmap. - // Arguments: None. - + /// Build the bitmap. void BuildBitmap(bool UpdateSize, bool UpdateKnob); private: @@ -272,44 +155,21 @@ namespace RTE { int m_GrabbedSide; int m_ValueResolution; //!< How much the value increases/decreases on each mouse wheel change when scrolling. - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: BuildButton - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Build a button. - // Arguments: ArrowName, Width, Height. - + /// Build a button. + /// @param ArrowName ArrowName, Width, Height. void BuildButton(const std::string& ArrowName, int Y, int Width, int Height); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: BuildBackground - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Build the background. - // Arguments: None. - + /// Build the background. void BuildBackground(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: BuildKnob - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Build the knob. - // Arguments: None. - + /// Build the knob. void BuildKnob(const std::string& Section, int X, int Y, int Width, int Height); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: CalculateKnob - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Calculate the knob size and position. - // Arguments: None. - + /// Calculate the knob size and position. void CalculateKnob(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: AdjustValue - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Adjusts the value. - // Arguments: Delta movement. - + /// Adjusts the value. + /// @param Delta Delta movement. void AdjustValue(int Delta); }; }; // namespace RTE diff --git a/Source/GUI/GUIScrollbar.cpp b/Source/GUI/GUIScrollbar.cpp index 3f4ba3f82f..a202f53d3e 100644 --- a/Source/GUI/GUIScrollbar.cpp +++ b/Source/GUI/GUIScrollbar.cpp @@ -3,16 +3,12 @@ using namespace RTE; -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIScrollbar::GUIScrollbar(GUIManager* Manager, GUIControlManager* ControlManager) : GUIControl(), GUIScrollPanel(Manager) { m_ControlID = "SCROLLBAR"; m_ControlManager = ControlManager; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIScrollbar::Create(const std::string& Name, int X, int Y, int Width, int Height) { GUIControl::Create(Name, X, Y, Width, Height); @@ -42,8 +38,6 @@ void GUIScrollbar::Create(const std::string& Name, int X, int Y, int Width, int GUIScrollPanel::Create(X, Y, w, h); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIScrollbar::Create(GUIProperties* Props) { GUIControl::Create(Props); @@ -67,26 +61,18 @@ void GUIScrollbar::Create(GUIProperties* Props) { GUIScrollPanel::LoadProps(Props); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIScrollbar::Destroy() { GUIScrollPanel::Destroy(); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIScrollbar::ChangeSkin(GUISkin* Skin) { GUIScrollPanel::ChangeSkin(Skin); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIPanel* GUIScrollbar::GetPanel() { return this; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIScrollbar::ReceiveSignal(GUIPanel* Source, int Code, int Data) { assert(Source); @@ -96,8 +82,6 @@ void GUIScrollbar::ReceiveSignal(GUIPanel* Source, int Code, int Data) { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIScrollbar::OnMouseDown(int X, int Y, int Buttons, int Modifier) { // Capture the mouse CaptureMouse(); @@ -105,8 +89,6 @@ void GUIScrollbar::OnMouseDown(int X, int Y, int Buttons, int Modifier) { GUIScrollPanel::OnMouseDown(X, Y, Buttons, Modifier); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIScrollbar::OnMouseUp(int X, int Y, int Buttons, int Modifier) { // Release the mouse ReleaseMouse(); @@ -114,8 +96,6 @@ void GUIScrollbar::OnMouseUp(int X, int Y, int Buttons, int Modifier) { GUIScrollPanel::OnMouseUp(X, Y, Buttons, Modifier); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIScrollbar::OnMouseWheelChange(int x, int y, int modifier, int mouseWheelChange) { int oldValue = GetValue(); int newValue = std::clamp(oldValue - (GetValueResolution() * ((mouseWheelChange > 0) ? 1 : -1)), GetMinimum(), GetMaximum() - GetPageSize()); @@ -125,14 +105,10 @@ void GUIScrollbar::OnMouseWheelChange(int x, int y, int modifier, int mouseWheel } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIScrollbar::Move(int X, int Y) { GUIScrollPanel::SetPositionAbs(X, Y); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIScrollbar::Resize(int Width, int Height) { // Make sure the control isn't too small Width = std::max(Width, m_MinWidth); @@ -141,20 +117,14 @@ void GUIScrollbar::Resize(int Width, int Height) { GUIScrollPanel::SetSize(Width, Height); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIScrollbar::GetControlRect(int* X, int* Y, int* Width, int* Height) { GUIScrollPanel::GetRect(X, Y, Width, Height); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIScrollbar::StoreProperties() { GUIScrollPanel::SaveProps(&m_Properties); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIScrollbar::ApplyProperties(GUIProperties* Props) { GUIControl::ApplyProperties(Props); diff --git a/Source/GUI/GUIScrollbar.h b/Source/GUI/GUIScrollbar.h index e9efa3cbdc..b58eae8d44 100644 --- a/Source/GUI/GUIScrollbar.h +++ b/Source/GUI/GUIScrollbar.h @@ -5,9 +5,7 @@ namespace RTE { - /// /// A Scrollbar control class. - /// class GUIScrollbar : public GUIControl, public GUIScrollPanel { public: @@ -17,135 +15,69 @@ namespace RTE { } Notifications; - ////////////////////////////////////////////////////////////////////////////////////////// - // Constructor: GUIScrollbar - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Constructor method used to instantiate a GUIScrollbar object in - // system memory. - // Arguments: GUIManager, GUIControlManager. - + /// Constructor method used to instantiate a GUIScrollbar object in + /// system memory. + /// @param Manager GUIManager, GUIControlManager. GUIScrollbar(GUIManager* Manager, GUIControlManager* ControlManager); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the control has been created. - // Arguments: Name, Position. - + /// Called when the control has been created. + /// @param Name Name, Position. void Create(const std::string& Name, int X, int Y, int Width = -1, int Height = -1) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the control has been created. - // Arguments: Properties. - + /// Called when the control has been created. + /// @param Props Properties. void Create(GUIProperties* Props) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the control has been destroyed. - // Arguments: None. - + /// Called when the control has been destroyed. void Destroy() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ChangeSkin - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the skin has been changed. - // Arguments: New skin pointer. - + /// Called when the skin has been changed. + /// @param Skin New skin pointer. void ChangeSkin(GUISkin* Skin) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: OnMouseDown - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the mouse goes down on the panel - // Arguments: Mouse Position, Mouse Buttons, Modifier. - + /// Called when the mouse goes down on the panel + /// @param X Mouse Position, Mouse Buttons, Modifier. void OnMouseDown(int X, int Y, int Buttons, int Modifier) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: OnMouseUp - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the mouse goes up on the panel - // Arguments: Mouse Position, Mouse Buttons, Modifier. - + /// Called when the mouse goes up on the panel + /// @param X Mouse Position, Mouse Buttons, Modifier. void OnMouseUp(int X, int Y, int Buttons, int Modifier) override; - /// /// Called when the mouse scroll wheel is moved. - /// - /// Mouse X position. - /// Mouse Y position. - /// Activated modifier buttons. - /// The amount of wheel movement. Positive is scroll up, negative is scroll down. + /// @param x Mouse X position. + /// @param y Mouse Y position. + /// @param modifier Activated modifier buttons. + /// @param mouseWheelChange The amount of wheel movement. Positive is scroll up, negative is scroll down. void OnMouseWheelChange(int x, int y, int modifier, int mouseWheelChange) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetPanel - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns the panel of the control. - // Arguments: None. - // Returns: 0 if the control does not have a panel, otherwise the topmost panel. - + /// Returns the panel of the control. + /// @return 0 if the control does not have a panel, otherwise the topmost panel. GUIPanel* GetPanel() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetControlID - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns a string representing the control's ID - // Arguments: None. - + /// Returns a string representing the control's ID static std::string GetControlID() { return "SCROLLBAR"; }; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ReceiveSignal - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when receiving a signal. - // Arguments: Signal source, Signal code, Signal data. - + /// Called when receiving a signal. + /// @param Source Signal source, Signal code, Signal data. void ReceiveSignal(GUIPanel* Source, int Code, int Data) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Move - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the control needs to be moved. - // Arguments: New position. - + /// Called when the control needs to be moved. + /// @param X New position. void Move(int X, int Y) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Resize - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the control needs to be resized. - // Arguments: New size. - + /// Called when the control needs to be resized. + /// @param Width New size. void Resize(int Width, int Height) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetControlRect - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the rectangle of the control. - // Arguments: Position, Size. - + /// Gets the rectangle of the control. + /// @param X Position, Size. void GetControlRect(int* X, int* Y, int* Width, int* Height) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: StoreProperties - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the control to store the values into properties. - // Arguments: None. - + /// Gets the control to store the values into properties. void StoreProperties() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ApplyProperties - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Applies new properties to the control. - // Arguments: GUIProperties. - + /// Applies new properties to the control. + /// @param Props GUIProperties. void ApplyProperties(GUIProperties* Props) override; private: diff --git a/Source/GUI/GUISkin.cpp b/Source/GUI/GUISkin.cpp index 00ff282c2d..dbb6c3944b 100644 --- a/Source/GUI/GUISkin.cpp +++ b/Source/GUI/GUISkin.cpp @@ -4,8 +4,6 @@ using namespace RTE; -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUISkin::GUISkin(GUIScreen* Screen) { m_Screen = Screen; m_FontCache.clear(); @@ -17,14 +15,10 @@ GUISkin::GUISkin(GUIScreen* Screen) { Clear(); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUISkin::~GUISkin() { Destroy(); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUISkin::Clear() { m_PropList.clear(); m_ImageCache.clear(); @@ -32,8 +26,6 @@ void GUISkin::Clear() { m_Directory = ""; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool GUISkin::Load(const std::string& directory, const std::string& fileName) { // Destroy any previous instances Destroy(); @@ -98,8 +90,6 @@ bool GUISkin::Load(const std::string& directory, const std::string& fileName) { return true; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool GUISkin::GetValue(const std::string& Section, const std::string& Variable, std::string* Value) { std::vector::iterator it; @@ -116,8 +106,6 @@ bool GUISkin::GetValue(const std::string& Section, const std::string& Variable, return false; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int GUISkin::GetValue(const std::string& Section, const std::string& Variable, int* Array, int MaxArraySize) { std::vector::iterator it; @@ -134,8 +122,6 @@ int GUISkin::GetValue(const std::string& Section, const std::string& Variable, i return false; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool GUISkin::GetValue(const std::string& Section, const std::string& Variable, int* Value) { std::vector::iterator it; @@ -152,8 +138,6 @@ bool GUISkin::GetValue(const std::string& Section, const std::string& Variable, return false; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool GUISkin::GetValue(const std::string& Section, const std::string& Variable, unsigned long* Value) { std::vector::iterator it; @@ -170,8 +154,6 @@ bool GUISkin::GetValue(const std::string& Section, const std::string& Variable, return false; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUISkin::Destroy() { std::vector::iterator it; @@ -213,14 +195,10 @@ void GUISkin::Destroy() { m_ImageCache.clear(); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIBitmap* GUISkin::CreateBitmap(int Width, int Height) { return m_Screen->CreateBitmap(Width, Height); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIBitmap* GUISkin::CreateBitmap(const std::string& Filename) { // Add the filename onto the current directory std::string File = m_Directory + Filename; @@ -246,8 +224,6 @@ GUIBitmap* GUISkin::CreateBitmap(const std::string& Filename) { return Bitmap; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIFont* GUISkin::GetFont(const std::string& Name) { // Check if the font is already in the list std::vector::iterator it; @@ -271,8 +247,6 @@ GUIFont* GUISkin::GetFont(const std::string& Name) { return Font; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIBitmap* GUISkin::LoadMousePointer(const std::string& Section) { std::string File; int ColorKey; @@ -291,8 +265,6 @@ GUIBitmap* GUISkin::LoadMousePointer(const std::string& Section) { return Bitmap; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUISkin::DrawMouse(int Image, int X, int Y, GUIScreen* guiScreenOverride) { assert(Image >= 0 && Image <= 2); @@ -303,8 +275,6 @@ void GUISkin::DrawMouse(int Image, int X, int Y, GUIScreen* guiScreenOverride) { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUISkin::BuildStandardRect(GUIBitmap* Dest, const std::string& Section, int X, int Y, int Width, int Height, bool buildBG, bool buildFrame, GUIRect* borderSizes) { // Note: For a control to use a 'Standard Rect' it must use the 8 side names, a filler name and a filename property. @@ -401,8 +371,6 @@ void GUISkin::BuildStandardRect(GUIBitmap* Dest, const std::string& Section, int } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - unsigned long GUISkin::ConvertColor(unsigned long color, int targetDepth) { return m_Screen->ConvertColor(color, targetDepth); } diff --git a/Source/GUI/GUISkin.h b/Source/GUI/GUISkin.h index 24e07e0c7b..38b2bcf8f7 100644 --- a/Source/GUI/GUISkin.h +++ b/Source/GUI/GUISkin.h @@ -3,139 +3,75 @@ namespace RTE { - /// /// Skin class used for the controls to get skin details. - /// class GUISkin { public: - ////////////////////////////////////////////////////////////////////////////////////////// - // Constructor: GUISkin - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Constructor method used to instantiate a GUISkin object in system - // memory. - // Arguments: GUIScreen Interface. - + /// Constructor method used to instantiate a GUISkin object in system + /// memory. + /// @param Screen GUIScreen Interface. explicit GUISkin(GUIScreen* Screen); - ////////////////////////////////////////////////////////////////////////////////////////// - // Destructor: GUISkin - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destructor method used to free a GUISkin object in system - // memory. - // Arguments: None. - + /// Destructor method used to free a GUISkin object in system + /// memory. ~GUISkin(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Load - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Loads a skin for a directory - // Arguments: Skin directory and the file within to use - + /// Loads a skin for a directory + /// @param directory Skin directory and the file within to use bool Load(const std::string& directory, const std::string& fileName = "skin.ini"); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Clear - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears all the data - // Arguments: None. - + /// Clears all the data void Clear(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Frees the allocated data. - // Arguments: None. - + /// Frees the allocated data. void Destroy(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetValue - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets a string value - // Arguments: Section, Variable, String pointer - + /// Gets a string value + /// @param Section Section, Variable, String pointer bool GetValue(const std::string& Section, const std::string& Variable, std::string* Value); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetValue - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets an integer array of values - // Arguments: Section, Variable, Integer array, max size of array - // Returns: Number of elements read - + /// Gets an integer array of values + /// @param Section Section, Variable, Integer array, max size of array + /// @return Number of elements read int GetValue(const std::string& Section, const std::string& Variable, int* Array, int MaxArraySize); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetValue - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets a single integer value. - // Arguments: Section, Variable, Integer pointer - + /// Gets a single integer value. + /// @param Section Section, Variable, Integer pointer bool GetValue(const std::string& Section, const std::string& Variable, int* Value); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetValue - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets a single unsigned integer value. - // Arguments: Section, Variable, Unsigned Integer pointer - + /// Gets a single unsigned integer value. + /// @param Section Section, Variable, Unsigned Integer pointer bool GetValue(const std::string& Section, const std::string& Variable, unsigned long* Value); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: CreateBitmap - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Creates a blank bitmap. - // Arguments: Width, Height. - + /// Creates a blank bitmap. + /// @param Width Width, Height. GUIBitmap* CreateBitmap(int Width, int Height); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: CreateBitmap - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Creates a bitmap from a filename. - // Arguments: Filename. - + /// Creates a bitmap from a filename. + /// @param Filename Filename. GUIBitmap* CreateBitmap(const std::string& Filename); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetFont - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets a cached copy of a font. Ownership is NOT transferred! - // Arguments: None. - + /// Gets a cached copy of a font. Ownership is NOT transferred! GUIFont* GetFont(const std::string& Name); - /// /// Draws the mouse onto the screen. - /// - /// Mouse image ID. - /// Horizontal position on the screen. - /// Vertical position on the screen. - /// The GUIScreen to draw to, overriding the one passed in on construction. + /// @param Image Mouse image ID. + /// @param X Horizontal position on the screen. + /// @param Y Vertical position on the screen. + /// @param pScreen The GUIScreen to draw to, overriding the one passed in on construction. void DrawMouse(int Image, int X, int Y, GUIScreen* guiScreenOverride = nullptr); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: BuildStandardRect - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Builds a bitmap from a standard skin property section. - // Arguments: Destination bitmap, Section name, Position, Size. Whether to draw the - // background and frame, a GUIRect to be filled in with the border sizes of the four sides of the built standard rect. - + /// Builds a bitmap from a standard skin property section. + /// @param Dest Destination bitmap, Section name, Position, Size. Whether to draw the + /// background and frame, a GUIRect to be filled in with the border sizes of the four sides of the built standard rect. void BuildStandardRect(GUIBitmap* Dest, const std::string& Section, int X, int Y, int Width, int Height, bool buildBG = true, bool buildFrame = true, GUIRect* borderSizes = nullptr); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ConvertColor - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Converts an 8bit palette index to a valid pixel format. - // Primarily used for development in windowed mode. - // Arguments: Color value in any bit depth. Will be converted to the format specified. - // An optional target color depth that will determine what format the color - // should be converted to. If this is 0, then the current video color depth - // will be used as target. - + /// Converts an 8bit palette index to a valid pixel format. + /// Primarily used for development in windowed mode. + /// @param color Color value in any bit depth. Will be converted to the format specified. + /// @param targetDepth An optional target color depth that will determine what format the color (default: 0) + /// should be converted to. If this is 0, then the current video color depth + /// will be used as target. unsigned long ConvertColor(unsigned long color, int targetDepth = 0); private: @@ -147,12 +83,8 @@ namespace RTE { std::vector m_ImageCache; std::vector m_FontCache; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: LoadMousePointer - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Loads a mouse pointer image & details - // Arguments: Section name. - + /// Loads a mouse pointer image & details + /// @param Section Section name. GUIBitmap* LoadMousePointer(const std::string& Section); }; }; // namespace RTE diff --git a/Source/GUI/GUISlider.cpp b/Source/GUI/GUISlider.cpp index ea6b7e069a..3859519242 100644 --- a/Source/GUI/GUISlider.cpp +++ b/Source/GUI/GUISlider.cpp @@ -3,8 +3,6 @@ using namespace RTE; -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUISlider::GUISlider(GUIManager* Manager, GUIControlManager* ControlManager) : GUIControl(), GUIPanel(Manager) { m_ControlID = "SLIDER"; @@ -22,8 +20,6 @@ GUISlider::GUISlider(GUIManager* Manager, GUIControlManager* ControlManager) : m_ValueResolution = 1; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUISlider::Create(const std::string& Name, int X, int Y, int Width, int Height) { GUIControl::Create(Name, X, Y, Width, Height); @@ -52,8 +48,6 @@ void GUISlider::Create(const std::string& Name, int X, int Y, int Width, int Hei CalculateKnob(); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUISlider::Create(GUIProperties* Props) { GUIControl::Create(Props); @@ -101,8 +95,6 @@ void GUISlider::Create(GUIProperties* Props) { CalculateKnob(); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUISlider::Destroy() { // Destroy the draw bitmap if (m_DrawBitmap) { @@ -119,8 +111,6 @@ void GUISlider::Destroy() { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUISlider::ChangeSkin(GUISkin* Skin) { GUIControl::ChangeSkin(Skin); @@ -128,8 +118,6 @@ void GUISlider::ChangeSkin(GUISkin* Skin) { BuildBitmap(); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUISlider::BuildBitmap() { // Free any old bitmaps if (m_DrawBitmap) { @@ -188,8 +176,6 @@ void GUISlider::BuildBitmap() { CalculateKnob(); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUISlider::BuildLine(const std::string& Section, GUIBitmap* SrcImage) { int Values[4]; GUIRect Rect; @@ -235,8 +221,6 @@ void GUISlider::BuildLine(const std::string& Section, GUIBitmap* SrcImage) { SrcImage->Draw(m_DrawBitmap, X, Y, &Rect); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUISlider::Draw(GUIScreen* Screen) { int X = 0; int Y = 0; @@ -269,8 +253,6 @@ void GUISlider::Draw(GUIScreen* Screen) { GUIPanel::Draw(Screen); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUISlider::OnMouseDown(int X, int Y, int Buttons, int Modifier) { CaptureMouse(); SetFocus(); @@ -319,8 +301,6 @@ void GUISlider::OnMouseDown(int X, int Y, int Buttons, int Modifier) { AddEvent(GUIEvent::Notification, Clicked, 0); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUISlider::OnMouseUp(int X, int Y, int Buttons, int Modifier) { ReleaseMouse(); @@ -334,8 +314,6 @@ void GUISlider::OnMouseUp(int X, int Y, int Buttons, int Modifier) { AddEvent(GUIEvent::Notification, Clicked, 0); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUISlider::OnMouseMove(int X, int Y, int Buttons, int Modifier) { int MousePos = X; int KnobTop = 0; @@ -389,8 +367,6 @@ void GUISlider::OnMouseMove(int X, int Y, int Buttons, int Modifier) { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUISlider::OnMouseWheelChange(int x, int y, int modifier, int mouseWheelChange) { m_OldValue = m_Value; @@ -406,14 +382,10 @@ void GUISlider::OnMouseWheelChange(int x, int y, int modifier, int mouseWheelCha } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIPanel* GUISlider::GetPanel() { return this; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUISlider::CalculateKnob() { if (!m_KnobImage) { return; @@ -428,14 +400,10 @@ void GUISlider::CalculateKnob() { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUISlider::Move(int X, int Y) { GUIPanel::SetPositionAbs(X, Y); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUISlider::Resize(int Width, int Height) { // Make sure the control isn't too small Width = std::max(Width, m_MinWidth); @@ -447,42 +415,30 @@ void GUISlider::Resize(int Width, int Height) { BuildBitmap(); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUISlider::GetControlRect(int* X, int* Y, int* Width, int* Height) { GUIPanel::GetRect(X, Y, Width, Height); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUISlider::SetOrientation(int Orientation) { m_Orientation = Orientation; BuildBitmap(); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int GUISlider::GetOrientation() const { return m_Orientation; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUISlider::SetTickDirection(int TickDir) { m_TickDirection = TickDir; BuildBitmap(); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int GUISlider::GetTickDirection() const { return m_TickDirection; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUISlider::SetMinimum(int Minimum) { if (Minimum != m_Minimum) { m_Minimum = Minimum; @@ -493,14 +449,10 @@ void GUISlider::SetMinimum(int Minimum) { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int GUISlider::GetMinimum() const { return m_Minimum; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUISlider::SetMaximum(int Maximum) { if (Maximum != m_Maximum) { m_Maximum = Maximum; @@ -511,14 +463,10 @@ void GUISlider::SetMaximum(int Maximum) { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int GUISlider::GetMaximum() const { return m_Maximum; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUISlider::SetValue(int Value) { int OldValue = m_Value; @@ -530,14 +478,10 @@ void GUISlider::SetValue(int Value) { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int GUISlider::GetValue() const { return m_Value; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUISlider::StoreProperties() { m_Properties.AddVariable("Value", m_Value); m_Properties.AddVariable("Minimum", m_Minimum); @@ -546,8 +490,6 @@ void GUISlider::StoreProperties() { m_Properties.AddVariable("TickDirection", m_TickDirection == TopLeft ? "TopLeft" : "BottomRight"); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUISlider::ApplyProperties(GUIProperties* Props) { GUIControl::ApplyProperties(Props); @@ -578,8 +520,6 @@ void GUISlider::ApplyProperties(GUIProperties* Props) { BuildBitmap(); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUISlider::SetValueResolution(int valueRes) { if (valueRes >= 1 && valueRes <= m_Maximum - m_Minimum) { m_ValueResolution = valueRes; diff --git a/Source/GUI/GUISlider.h b/Source/GUI/GUISlider.h index 0a478372d6..ec7d3003a0 100644 --- a/Source/GUI/GUISlider.h +++ b/Source/GUI/GUISlider.h @@ -3,9 +3,7 @@ namespace RTE { - /// /// A slider control class. - /// class GUISlider : public GUIControl, public GUIPanel { public: @@ -27,229 +25,112 @@ namespace RTE { Clicked } Notification; - ////////////////////////////////////////////////////////////////////////////////////////// - // Constructor: GUISlider - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Constructor method used to instantiate a GUISlider object in - // system memory. - // Arguments: GUIManager, GUIControlManager. - + /// Constructor method used to instantiate a GUISlider object in + /// system memory. + /// @param Manager GUIManager, GUIControlManager. GUISlider(GUIManager* Manager, GUIControlManager* ControlManager); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the control has been created. - // Arguments: Name, Position. - + /// Called when the control has been created. + /// @param Name Name, Position. void Create(const std::string& Name, int X, int Y, int Width = -1, int Height = -1) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the control has been created. - // Arguments: Properties. - + /// Called when the control has been created. + /// @param Props Properties. void Create(GUIProperties* Props) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the control has been destroyed. - // Arguments: None. - + /// Called when the control has been destroyed. void Destroy() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ChangeSkin - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the skin has been changed. - // Arguments: New skin pointer. - + /// Called when the skin has been changed. + /// @param Skin New skin pointer. void ChangeSkin(GUISkin* Skin) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Draw - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws the panel - // Arguments: Screen class - + /// Draws the panel + /// @param Screen Screen class void Draw(GUIScreen* Screen) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: OnMouseDown - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the mouse goes down on the panel - // Arguments: Mouse Position, Mouse Buttons, Modifier. - + /// Called when the mouse goes down on the panel + /// @param X Mouse Position, Mouse Buttons, Modifier. void OnMouseDown(int X, int Y, int Buttons, int Modifier) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: OnMouseUp - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the mouse goes up on the panel - // Arguments: Mouse Position, Mouse Buttons, Modifier. - + /// Called when the mouse goes up on the panel + /// @param X Mouse Position, Mouse Buttons, Modifier. void OnMouseUp(int X, int Y, int Buttons, int Modifier) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: OnMouseMove - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the mouse moves (over the panel, or when captured). - // Arguments: Mouse Position, Mouse Buttons, Modifier. - + /// Called when the mouse moves (over the panel, or when captured). + /// @param X Mouse Position, Mouse Buttons, Modifier. void OnMouseMove(int X, int Y, int Buttons, int Modifier) override; - /// /// Called when the mouse scroll wheel is moved. - /// - /// Mouse X position. - /// Mouse Y position. - /// Activated modifier buttons. - /// The amount of wheel movement. Positive is scroll up, negative is scroll down. + /// @param x Mouse X position. + /// @param y Mouse Y position. + /// @param modifier Activated modifier buttons. + /// @param mouseWheelChange The amount of wheel movement. Positive is scroll up, negative is scroll down. void OnMouseWheelChange(int x, int y, int modifier, int mouseWheelChange) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetPanel - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns the panel of the control. - // Arguments: None. - // Returns: 0 if the control does not have a panel, otherwise the topmost panel. - + /// Returns the panel of the control. + /// @return 0 if the control does not have a panel, otherwise the topmost panel. GUIPanel* GetPanel() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetControlID - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns a string representing the control's ID - // Arguments: None. - + /// Returns a string representing the control's ID static std::string GetControlID() { return "SLIDER"; }; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Move - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the control needs to be moved. - // Arguments: New position. - + /// Called when the control needs to be moved. + /// @param X New position. void Move(int X, int Y) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Resize - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the control needs to be resized. - // Arguments: New size. - + /// Called when the control needs to be resized. + /// @param Width New size. void Resize(int Width, int Height) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetControlRect - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the rectangle of the control. - // Arguments: Position, Size. - + /// Gets the rectangle of the control. + /// @param X Position, Size. void GetControlRect(int* X, int* Y, int* Width, int* Height) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetOrientation - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the orientation of the slider. - // Arguments: Orientation. - + /// Sets the orientation of the slider. + /// @param Orientation Orientation. void SetOrientation(int Orientation); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetOrientation - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the orientation of the slider. - // Arguments: None. - + /// Gets the orientation of the slider. int GetOrientation() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetTickDirection - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the direction of the ticks. - // Arguments: TickDir. - + /// Sets the direction of the ticks. + /// @param TickDir TickDir. void SetTickDirection(int TickDir); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetTickDirection - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the direction of the ticks. - // Arguments: None. - + /// Gets the direction of the ticks. int GetTickDirection() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetMinimum - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the minimum value. - // Arguments: Minimum. - + /// Sets the minimum value. + /// @param Minimum Minimum. void SetMinimum(int Minimum); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetMinimum - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the minimum value. - // Arguments: None. - + /// Gets the minimum value. int GetMinimum() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetMaximum - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the maximum value. - // Arguments: Maximum. - + /// Sets the maximum value. + /// @param Maximum Maximum. void SetMaximum(int Maximum); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetMaximum - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the maximum value. - // Arguments: None. - + /// Gets the maximum value. int GetMaximum() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetValue - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the value. - // Arguments: Value. - + /// Sets the value. + /// @param Value Value. void SetValue(int Value); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetValue - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the value. - // Arguments: None. - + /// Gets the value. int GetValue() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: StoreProperties - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the control to store the values into properties. - // Arguments: None. - + /// Gets the control to store the values into properties. void StoreProperties() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ApplyProperties - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Applies new properties to the control. - // Arguments: GUIProperties. - + /// Applies new properties to the control. + /// @param Props GUIProperties. void ApplyProperties(GUIProperties* Props) override; - /// /// Sets the value resolution for this slider. - /// - /// The new value resolution + /// @param valueRes The new value resolution void SetValueResolution(int valueRes); private: @@ -272,28 +153,14 @@ namespace RTE { int m_EndThickness; int m_OldValue; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: BuildBitmap - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Create the slider bitmap to draw. - // Arguments: None. - + /// Create the slider bitmap to draw. void BuildBitmap(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: BuildLine - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Builds the background line for the slider - // Arguments: Section, SrcImage. - + /// Builds the background line for the slider + /// @param Section Section, SrcImage. void BuildLine(const std::string& Section, GUIBitmap* SrcImage); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: CalculateKnob - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Calculates the knob position and size. - // Arguments: None. - + /// Calculates the knob position and size. void CalculateKnob(); }; }; // namespace RTE diff --git a/Source/GUI/GUISound.cpp b/Source/GUI/GUISound.cpp index 5974129870..12166535b6 100644 --- a/Source/GUI/GUISound.cpp +++ b/Source/GUI/GUISound.cpp @@ -2,8 +2,6 @@ namespace RTE { - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUISound::Clear() { m_SplashSound.Reset(); m_EnterMenuSound.Reset(); @@ -34,8 +32,6 @@ namespace RTE { m_PlacementGravel.Reset(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUISound::Initialize() { // Interface sounds should not be pitched to reinforce the appearance of time decoupling between simulation and UI. diff --git a/Source/GUI/GUISound.h b/Source/GUI/GUISound.h index 2a94a04391..8ab0dae1cb 100644 --- a/Source/GUI/GUISound.h +++ b/Source/GUI/GUISound.h @@ -8,197 +8,133 @@ namespace RTE { - /// /// The singleton loader for all GUI sound effects. - /// class GUISound : public Singleton { public: #pragma region Creation - /// /// Constructor method used to instantiate a GUISound object in system memory. Create() should be called before using the object. - /// GUISound() { Clear(); } - /// /// Creates all the GUI sound effects with Sound::Create and their additional samples with Sound::AddSample and makes the GUISound object ready for use. - /// void Initialize(); #pragma endregion #pragma region Destruction - /// /// Destroys and resets (through Clear()) the GUISound object. - /// void Destroy() { Clear(); } - /// /// Destructor method used to clean up a GUISound object before deletion from system memory. - /// ~GUISound() { Destroy(); } #pragma endregion #pragma region Getters - /// /// Gets juicy logo signature jingle Sound. - /// - /// Juicy logo signature jingle Sound. + /// @return Juicy logo signature jingle Sound. SoundContainer* SplashSound() { return &m_SplashSound; } - /// /// Gets SoundContainer for enabling menu. - /// - /// SoundContainer for enabling menu. + /// @return SoundContainer for enabling menu. SoundContainer* EnterMenuSound() { return &m_EnterMenuSound; } - /// /// Gets SoundContainer for disabling menu. - /// - /// SoundContainer for disabling menu. + /// @return SoundContainer for disabling menu. SoundContainer* ExitMenuSound() { return &m_ExitMenuSound; } - /// /// Gets SoundContainer for changing focus. - /// - /// SoundContainer for changing focus. + /// @return SoundContainer for changing focus. SoundContainer* FocusChangeSound() { return &m_FocusChangeSound; } - /// /// Gets SoundContainer for selecting items in list, etc. - /// - /// SoundContainer for selecting items in list, etc. + /// @return SoundContainer for selecting items in list, etc. SoundContainer* SelectionChangeSound() { return &m_SelectionChangeSound; } - /// /// Gets SoundContainer for adding or deleting items in list. - /// - /// SoundContainer for adding or deleting items in list. + /// @return SoundContainer for adding or deleting items in list. SoundContainer* ItemChangeSound() { return &m_ItemChangeSound; } - /// /// Gets SoundContainer for button press. - /// - /// SoundContainer for button press. + /// @return SoundContainer for button press. SoundContainer* ButtonPressSound() { return &m_ButtonPressSound; } - /// /// Gets SoundContainer for button press of going back button. - /// - /// SoundContainer for button press of going back button. + /// @return SoundContainer for button press of going back button. SoundContainer* BackButtonPressSound() { return &m_BackButtonPressSound; } - /// /// Gets SoundContainer for confirming a selection. - /// - /// SoundContainer for confirming a selection. + /// @return SoundContainer for confirming a selection. SoundContainer* ConfirmSound() { return &m_ConfirmSound; } - /// /// Gets SoundContainer for erroneous input. - /// - /// SoundContainer for erroneous input. + /// @return SoundContainer for erroneous input. SoundContainer* UserErrorSound() { return &m_UserErrorSound; } - /// /// Gets SoundContainer for testing volume when adjusting volume sliders. - /// - /// SoundContainer for testing volume when adjusting volume sliders. + /// @return SoundContainer for testing volume when adjusting volume sliders. SoundContainer* TestSound() { return &m_TestSound; } - /// /// Gets SoundContainer for opening pie menu. - /// - /// SoundContainer for opening pie menu. + /// @return SoundContainer for opening pie menu. SoundContainer* PieMenuEnterSound() { return &m_PieMenuEnterSound; } - /// /// Gets SoundContainer for closing pie menu. - /// - /// SoundContainer for closing pie menu. + /// @return SoundContainer for closing pie menu. SoundContainer* PieMenuExitSound() { return &m_PieMenuExitSound; } - /// /// Gets SoundContainer for when PieMenu hover arrow appears or changes slice. - /// - /// SoundContainer for when PieMenu hover arrow appears or changes slice. + /// @return SoundContainer for when PieMenu hover arrow appears or changes slice. SoundContainer* HoverChangeSound() { return &m_HoverChangeSound; } - /// /// Gets SoundContainer for when PieMenu hover arrow appears or changes to a disabled slice. - /// - /// SoundContainer for when PieMenu hover arrow appears or changes to a disabled slice. + /// @return SoundContainer for when PieMenu hover arrow appears or changes to a disabled slice. SoundContainer* HoverDisabledSound() { return &m_HoverDisabledSound; } - /// /// Gets SoundContainer for picking a valid PieMenu slice. - /// - /// SoundContainer for picking a valid PieMenu slice. + /// @return SoundContainer for picking a valid PieMenu slice. SoundContainer* SlicePickedSound() { return &m_SlicePickedSound; } - /// /// Gets SoundContainer for erroneous input in PieMenu. - /// - /// SoundContainer for erroneous input in PieMenu. + /// @return SoundContainer for erroneous input in PieMenu. SoundContainer* DisabledPickedSound() { return &m_DisabledPickedSound; } - /// /// Gets SoundContainer for when the funds of a team changes. - /// - /// SoundContainer for when the funds of a team changes. + /// @return SoundContainer for when the funds of a team changes. SoundContainer* FundsChangedSound() { return &m_FundsChangedSound; } - /// /// Gets SoundContainer for switching between regular (non-brain) actors. - /// - /// SoundContainer for switching between regular (non-brain) actors. + /// @return SoundContainer for switching between regular (non-brain) actors. SoundContainer* ActorSwitchSound() { return &m_ActorSwitchSound; } - /// /// Gets SoundContainer for switching to the brain shortcut. - /// - /// SoundContainer for switching to the brain shortcut. + /// @return SoundContainer for switching to the brain shortcut. SoundContainer* BrainSwitchSound() { return &m_BrainSwitchSound; } - /// /// Gets SoundContainer when camera is traveling between actors. - /// - /// SoundContainer when camera is traveling between actors. + /// @return SoundContainer when camera is traveling between actors. SoundContainer* CameraTravelSound() { return &m_CameraTravelSound; } - /// /// Gets SoundContainer for making an area focus. - /// - /// SoundContainer for making an area focus. + /// @return SoundContainer for making an area focus. SoundContainer* AreaPickedSound() { return &m_AreaPickedSound; } - /// /// Gets SoundContainer for making an object focus. - /// - /// SoundContainer for making an object focus. + /// @return SoundContainer for making an object focus. SoundContainer* ObjectPickedSound() { return &m_ObjectPickedSound; } - /// /// Gets SoundContainer for making a purchase. - /// - /// SoundContainer for making a purchase. + /// @return SoundContainer for making a purchase. SoundContainer* PurchaseMadeSound() { return &m_PurchaseMadeSound; } - /// /// Gets SoundContainer for placement of object to scene. - /// - /// SoundContainer for placement of object to scene. + /// @return SoundContainer for placement of object to scene. SoundContainer* PlacementBlip() { return &m_PlacementBlip; } - /// /// Gets SoundContainer for placement of object to scene. - /// - /// SoundContainer for placement of object to scene. + /// @return SoundContainer for placement of object to scene. SoundContainer* PlacementThud() { return &m_PlacementThud; } - /// /// Gets SoundContainer for gravely placement of object to scene. - /// - /// SoundContainer for gravely placement of object to scene. + /// @return SoundContainer for gravely placement of object to scene. SoundContainer* PlacementGravel() { return &m_PlacementGravel; } #pragma endregion @@ -242,9 +178,7 @@ namespace RTE { SoundContainer m_PlacementThud; //! SoundContainer for placement of object to scene. SoundContainer m_PlacementGravel; //! SoundContainer for gravely placement of object to scene. - /// /// Clears all the member variables of this GUISound, effectively resetting the members of this abstraction level only. - /// void Clear(); }; } // namespace RTE diff --git a/Source/GUI/GUITab.cpp b/Source/GUI/GUITab.cpp index 411ad986f5..f3debbeac0 100644 --- a/Source/GUI/GUITab.cpp +++ b/Source/GUI/GUITab.cpp @@ -3,8 +3,6 @@ using namespace RTE; -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUITab::GUITab(GUIManager* Manager, GUIControlManager* ControlManager) : GUIControl(), GUIPanel(Manager) { m_ControlID = "TAB"; @@ -17,8 +15,6 @@ GUITab::GUITab(GUIManager* Manager, GUIControlManager* ControlManager) : m_Text = ""; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUITab::Create(const std::string& Name, int X, int Y, int Width, int Height) { GUIControl::Create(Name, X, Y, Width, Height); @@ -48,8 +44,6 @@ void GUITab::Create(const std::string& Name, int X, int Y, int Width, int Height m_Height = std::max(m_Height, m_MinHeight); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUITab::Create(GUIProperties* Props) { GUIControl::Create(Props); @@ -73,8 +67,6 @@ void GUITab::Create(GUIProperties* Props) { Props->GetValue("Checked", &m_Selected); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUITab::ChangeSkin(GUISkin* Skin) { GUIControl::ChangeSkin(Skin); @@ -82,8 +74,6 @@ void GUITab::ChangeSkin(GUISkin* Skin) { BuildBitmap(); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUITab::BuildBitmap() { std::string Filename; unsigned long ColorIndex = 0; @@ -130,8 +120,6 @@ void GUITab::BuildBitmap() { SetRect(&m_ImageRects[3], Values[0], Values[1], Values[0] + Values[2], Values[1] + Values[3]); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUITab::Draw(GUIScreen* Screen) { if (!m_Image) { return; @@ -182,8 +170,6 @@ void GUITab::Draw(GUIScreen* Screen) { GUIPanel::Draw(Screen); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUITab::OnMouseDown(int X, int Y, int Buttons, int Modifier) { if (Buttons & MOUSE_LEFT) { // Push the checkbox down @@ -194,8 +180,6 @@ void GUITab::OnMouseDown(int X, int Y, int Buttons, int Modifier) { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUITab::OnMouseUp(int X, int Y, int Buttons, int Modifier) { ReleaseMouse(); @@ -207,33 +191,23 @@ void GUITab::OnMouseUp(int X, int Y, int Buttons, int Modifier) { AddEvent(GUIEvent::Notification, UnPushed, 0); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUITab::OnMouseEnter(int X, int Y, int Buttons, int Modifier) { m_Mouseover = true; AddEvent(GUIEvent::Notification, Hovered, 0); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUITab::OnMouseLeave(int X, int Y, int Buttons, int Modifier) { m_Mouseover = false; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIPanel* GUITab::GetPanel() { return this; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUITab::Move(int X, int Y) { GUIPanel::SetPositionAbs(X, Y); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUITab::Resize(int Width, int Height) { // Make sure the control isn't too small Width = std::max(Width, m_MinWidth); @@ -245,21 +219,15 @@ void GUITab::Resize(int Width, int Height) { BuildBitmap(); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUITab::GetControlRect(int* X, int* Y, int* Width, int* Height) { GUIPanel::GetRect(X, Y, Width, Height); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUITab::StoreProperties() { m_Properties.AddVariable("Text", m_Text); m_Properties.AddVariable("Selected", m_Selected); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUITab::SetCheck(bool Check) { // Nothing to do if already in the same state if (m_Selected == Check) { @@ -296,26 +264,18 @@ void GUITab::SetCheck(bool Check) { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool GUITab::GetCheck() const { return m_Selected; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUITab::SetText(const std::string& Text) { m_Text = Text; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - std::string GUITab::GetText() const { return m_Text; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUITab::ApplyProperties(GUIProperties* Props) { GUIControl::ApplyProperties(Props); diff --git a/Source/GUI/GUITab.h b/Source/GUI/GUITab.h index ce44aa25e2..0a96d97599 100644 --- a/Source/GUI/GUITab.h +++ b/Source/GUI/GUITab.h @@ -3,9 +3,7 @@ namespace RTE { - /// /// A tab control class. - /// class GUITab : public GUIControl, public GUIPanel { public: @@ -17,166 +15,81 @@ namespace RTE { Changed, } Notification; - ////////////////////////////////////////////////////////////////////////////////////////// - // Constructor: GUITab - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Constructor method used to instantiate a GUITab object in - // system memory. - // Arguments: GUIManager, GUIControlManager. - + /// Constructor method used to instantiate a GUITab object in + /// system memory. + /// @param Manager GUIManager, GUIControlManager. GUITab(GUIManager* Manager, GUIControlManager* ControlManager); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the control has been created. - // Arguments: Name, Position. - + /// Called when the control has been created. + /// @param Name Name, Position. void Create(const std::string& Name, int X, int Y, int Width = -1, int Height = -1) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the control has been created. - // Arguments: Properties. - + /// Called when the control has been created. + /// @param Props Properties. void Create(GUIProperties* Props) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ChangeSkin - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the skin has been changed. - // Arguments: New skin pointer. - + /// Called when the skin has been changed. + /// @param Skin New skin pointer. void ChangeSkin(GUISkin* Skin) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Draw - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws the panel - // Arguments: Screen class - + /// Draws the panel + /// @param Screen Screen class void Draw(GUIScreen* Screen) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: OnMouseDown - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the mouse goes down on the panel - // Arguments: Mouse Position, Mouse Buttons, Modifier. - + /// Called when the mouse goes down on the panel + /// @param X Mouse Position, Mouse Buttons, Modifier. void OnMouseDown(int X, int Y, int Buttons, int Modifier) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: OnMouseUp - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the mouse goes up on the panel - // Arguments: Mouse Position, Mouse Buttons, Modifier. - + /// Called when the mouse goes up on the panel + /// @param X Mouse Position, Mouse Buttons, Modifier. void OnMouseUp(int X, int Y, int Buttons, int Modifier) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: OnMouseEnter - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the mouse enters the panel. - // Arguments: Mouse Position, Mouse Buttons, Modifier. - + /// Called when the mouse enters the panel. + /// @param X Mouse Position, Mouse Buttons, Modifier. void OnMouseEnter(int X, int Y, int Buttons, int Modifier) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: OnMouseLeave - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the mouse leaves the panel. - // Arguments: Mouse Position, Mouse Buttons, Modifier. - + /// Called when the mouse leaves the panel. + /// @param X Mouse Position, Mouse Buttons, Modifier. void OnMouseLeave(int X, int Y, int Buttons, int Modifier) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetPanel - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns the panel of the control. - // Arguments: None. - // Returns: 0 if the control does not have a panel, otherwise the topmost panel. - + /// Returns the panel of the control. + /// @return 0 if the control does not have a panel, otherwise the topmost panel. GUIPanel* GetPanel() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetControlID - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns a string representing the control's ID - // Arguments: None. - + /// Returns a string representing the control's ID static std::string GetControlID() { return "TAB"; }; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Move - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the control needs to be moved. - // Arguments: New position. - + /// Called when the control needs to be moved. + /// @param X New position. void Move(int X, int Y) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Resize - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the control needs to be resized. - // Arguments: New size. - + /// Called when the control needs to be resized. + /// @param Width New size. void Resize(int Width, int Height) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetControlRect - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the rectangle of the control. - // Arguments: Position, Size. - + /// Gets the rectangle of the control. + /// @param X Position, Size. void GetControlRect(int* X, int* Y, int* Width, int* Height) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: StoreProperties - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the control to store the values into properties. - // Arguments: None. - + /// Gets the control to store the values into properties. void StoreProperties() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetCheck - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the check state. - // Arguments: State. - + /// Sets the check state. + /// @param Check State. void SetCheck(bool Check); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetCheck - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the check state. - // Arguments: None. - + /// Gets the check state. bool GetCheck() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetText - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the text. - // Arguments: Text. - + /// Sets the text. + /// @param Text Text. void SetText(const std::string& Text); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetText - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the text. - // Arguments: None. - + /// Gets the text. std::string GetText() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ApplyProperties - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Applies new properties to the control. - // Arguments: GUIProperties. - + /// Applies new properties to the control. + /// @param Props GUIProperties. void ApplyProperties(GUIProperties* Props) override; private: @@ -187,12 +100,7 @@ namespace RTE { int m_Mouseover; std::string m_Text; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: BuildBitmap - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Create the checkbox bitmap to draw. - // Arguments: None. - + /// Create the checkbox bitmap to draw. void BuildBitmap(); }; }; // namespace RTE diff --git a/Source/GUI/GUITextBox.cpp b/Source/GUI/GUITextBox.cpp index f5e0a83e68..d6d14b7ca0 100644 --- a/Source/GUI/GUITextBox.cpp +++ b/Source/GUI/GUITextBox.cpp @@ -3,8 +3,6 @@ using namespace RTE; -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUITextBox::GUITextBox(GUIManager* Manager, GUIControlManager* ControlManager) : GUIControl(), GUITextPanel(Manager) { m_ControlID = "TEXTBOX"; @@ -14,8 +12,6 @@ GUITextBox::GUITextBox(GUIManager* Manager, GUIControlManager* ControlManager) : m_VAlignment = GUIFont::Top; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUITextBox::Create(const std::string& Name, int X, int Y, int Width, int Height) { GUIControl::Create(Name, X, Y, Width, Height); @@ -40,8 +36,6 @@ void GUITextBox::Create(const std::string& Name, int X, int Y, int Width, int He GUITextPanel::Create(X, Y, w, h); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUITextBox::Create(GUIProperties* Props) { GUIControl::Create(Props); @@ -86,8 +80,6 @@ void GUITextBox::Create(GUIProperties* Props) { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUITextBox::Destroy() { // Destroy the draw bitmap if (m_DrawBitmap) { @@ -97,8 +89,6 @@ void GUITextBox::Destroy() { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUITextBox::ChangeSkin(GUISkin* Skin) { GUIControl::ChangeSkin(Skin); @@ -119,8 +109,6 @@ void GUITextBox::ChangeSkin(GUISkin* Skin) { GUITextPanel::ChangeSkin(Skin); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUITextBox::Draw(GUIScreen* Screen) { // Draw the background m_DrawBitmap->Draw(Screen->GetBitmap(), m_X, m_Y, nullptr); @@ -128,20 +116,14 @@ void GUITextBox::Draw(GUIScreen* Screen) { GUITextPanel::Draw(Screen); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIPanel* GUITextBox::GetPanel() { return this; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUITextBox::Move(int X, int Y) { GUITextPanel::SetPositionAbs(X, Y); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUITextBox::Resize(int Width, int Height) { // Make sure the control isn't too small Width = std::max(Width, m_MinWidth); @@ -153,14 +135,10 @@ void GUITextBox::Resize(int Width, int Height) { ChangeSkin(m_Skin); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUITextBox::GetControlRect(int* X, int* Y, int* Width, int* Height) { GUITextPanel::GetRect(X, Y, Width, Height); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUITextBox::ReceiveSignal(GUIPanel* Source, int Code, int Data) { // Clicked if (Code == GUITextPanel::Clicked) { @@ -178,8 +156,6 @@ void GUITextBox::ReceiveSignal(GUIPanel* Source, int Code, int Data) { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUITextBox::ApplyProperties(GUIProperties* Props) { GUIControl::ApplyProperties(Props); diff --git a/Source/GUI/GUITextBox.h b/Source/GUI/GUITextBox.h index 1aead6dd86..1ac341fd80 100644 --- a/Source/GUI/GUITextBox.h +++ b/Source/GUI/GUITextBox.h @@ -5,9 +5,7 @@ namespace RTE { - /// /// A TextBox control class. - /// class GUITextBox : public GUIControl, public GUITextPanel { public: @@ -18,110 +16,55 @@ namespace RTE { Enter } Notification; - ////////////////////////////////////////////////////////////////////////////////////////// - // Constructor: GUITextBox - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Constructor method used to instantiate a GUITextBox object in - // system memory. - // Arguments: GUIManager, GUIControlManager. - + /// Constructor method used to instantiate a GUITextBox object in + /// system memory. + /// @param Manager GUIManager, GUIControlManager. GUITextBox(GUIManager* Manager, GUIControlManager* ControlManager); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the control has been created. - // Arguments: Name, Position. - + /// Called when the control has been created. + /// @param Name Name, Position. void Create(const std::string& Name, int X, int Y, int Width = -1, int Height = -1) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the control has been created. - // Arguments: Properties. - + /// Called when the control has been created. + /// @param Props Properties. void Create(GUIProperties* Props) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the control has been destroyed. - // Arguments: None. - + /// Called when the control has been destroyed. void Destroy() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ChangeSkin - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the skin has been changed. - // Arguments: New skin pointer. - + /// Called when the skin has been changed. + /// @param Skin New skin pointer. void ChangeSkin(GUISkin* Skin) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Draw - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws the panel - // Arguments: Screen class - + /// Draws the panel + /// @param Screen Screen class void Draw(GUIScreen* Screen) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetPanel - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns the panel of the control. - // Arguments: None. - // Returns: 0 if the control does not have a panel, otherwise the topmost panel. - + /// Returns the panel of the control. + /// @return 0 if the control does not have a panel, otherwise the topmost panel. GUIPanel* GetPanel() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetControlID - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns a string representing the control's ID - // Arguments: None. - + /// Returns a string representing the control's ID static std::string GetControlID() { return "TEXTBOX"; }; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Move - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the control needs to be moved. - // Arguments: New position. - + /// Called when the control needs to be moved. + /// @param X New position. void Move(int X, int Y) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Resize - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the control needs to be resized. - // Arguments: New size. - + /// Called when the control needs to be resized. + /// @param Width New size. void Resize(int Width, int Height) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetControlRect - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the rectangle of the control. - // Arguments: Position, Size. - + /// Gets the rectangle of the control. + /// @param X Position, Size. void GetControlRect(int* X, int* Y, int* Width, int* Height) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ReceiveSignal - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when receiving a signal. - // Arguments: Signal source, Signal code, Signal data. - + /// Called when receiving a signal. + /// @param Source Signal source, Signal code, Signal data. void ReceiveSignal(GUIPanel* Source, int Code, int Data) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ApplyProperties - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Applies new properties to the control. - // Arguments: GUIProperties. - + /// Applies new properties to the control. + /// @param Props GUIProperties. void ApplyProperties(GUIProperties* Props) override; private: diff --git a/Source/GUI/GUITextPanel.cpp b/Source/GUI/GUITextPanel.cpp index f34b85ea7a..ae761c5655 100644 --- a/Source/GUI/GUITextPanel.cpp +++ b/Source/GUI/GUITextPanel.cpp @@ -3,8 +3,6 @@ using namespace RTE; -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUITextPanel::GUITextPanel(GUIManager* Manager) : GUIPanel(Manager) { m_Font = nullptr; @@ -29,8 +27,6 @@ GUITextPanel::GUITextPanel(GUIManager* Manager) : // TODO: Both constructors use a common clear function?? Same with other panels -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUITextPanel::GUITextPanel() : GUIPanel() { m_Font = nullptr; @@ -54,8 +50,6 @@ GUITextPanel::GUITextPanel() : m_MaxNumericValue = 0; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUITextPanel::Create(int X, int Y, int Width, int Height) { m_X = X; m_Y = Y; @@ -65,8 +59,6 @@ void GUITextPanel::Create(int X, int Y, int Width, int Height) { assert(m_Manager); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUITextPanel::ChangeSkin(GUISkin* Skin) { // Load the font std::string Filename; @@ -95,8 +87,6 @@ void GUITextPanel::ChangeSkin(GUISkin* Skin) { m_CursorColor = Skin->ConvertColor(m_CursorColor); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUITextPanel::Draw(GUIScreen* Screen) { if (!m_Font) return; @@ -148,8 +138,6 @@ void GUITextPanel::Draw(GUIScreen* Screen) { Screen->GetBitmap()->SetClipRect(nullptr); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUITextPanel::OnKeyPress(int KeyCode, int Modifier) { // TODO: Figure out what the "performance bitching" is. // Condition here to stop the compiler bitching about performance @@ -289,8 +277,6 @@ void GUITextPanel::OnKeyPress(int KeyCode, int Modifier) { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUITextPanel::OnTextInput(std::string_view inputText) { int minValidKeyCode = 32; int maxValidKeyCode = 126; @@ -319,8 +305,6 @@ void GUITextPanel::OnTextInput(std::string_view inputText) { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUITextPanel::OnMouseDown(int X, int Y, int Buttons, int Modifier) { SendSignal(MouseDown, Buttons); @@ -364,8 +348,6 @@ void GUITextPanel::OnMouseDown(int X, int Y, int Buttons, int Modifier) { UpdateText(false, false); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUITextPanel::OnMouseMove(int X, int Y, int Buttons, int Modifier) { if (!(Buttons & MOUSE_LEFT) || !IsCaptured()) { return; @@ -392,15 +374,11 @@ void GUITextPanel::OnMouseMove(int X, int Y, int Buttons, int Modifier) { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUITextPanel::OnMouseUp(int X, int Y, int Buttons, int Modifier) { ReleaseMouse(); SendSignal(Clicked, Buttons); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUITextPanel::UpdateText(bool Typing, bool DoIncrement) { if (!m_Font) { return; @@ -443,8 +421,6 @@ void GUITextPanel::UpdateText(bool Typing, bool DoIncrement) { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUITextPanel::DoSelection(int Start, int End) { // Start a selection if (!m_GotSelection) { @@ -479,8 +455,6 @@ void GUITextPanel::DoSelection(int Start, int End) { m_SelectionWidth = std::min(m_SelectionWidth, m_Width); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int RTE::GUITextPanel::GetStartOfNextCharacterGroup(const std::string_view& stringToCheck, int currentIndex) const { auto isNormalCharacter = [](char charToCheck) { return (std::isalnum(charToCheck) || charToCheck == '_'); @@ -501,8 +475,6 @@ int RTE::GUITextPanel::GetStartOfNextCharacterGroup(const std::string_view& stri return std::distance(stringToCheck.cbegin(), currentIterator); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int RTE::GUITextPanel::GetStartOfPreviousCharacterGroup(const std::string_view& stringToCheck, int currentIndex) const { auto isNormalCharacter = [](char charToCheck) { return (std::isalnum(charToCheck) || charToCheck == '_'); @@ -525,8 +497,6 @@ int RTE::GUITextPanel::GetStartOfPreviousCharacterGroup(const std::string_view& return std::distance(stringToCheck.cbegin(), currentIterator.base()); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUITextPanel::RemoveSelectionText() { if (!m_GotSelection) { return; @@ -547,8 +517,6 @@ void GUITextPanel::RemoveSelectionText() { m_GotSelection = false; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUITextPanel::SetCursorPos(int cursorPos) { m_GotSelection = false; @@ -564,8 +532,6 @@ void GUITextPanel::SetCursorPos(int cursorPos) { UpdateText(); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - std::string GUITextPanel::GetSelectionText() const { if (!m_GotSelection) { return ""; @@ -579,8 +545,6 @@ std::string GUITextPanel::GetSelectionText() const { return m_Text.substr(Start, End - Start); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUITextPanel::SetText(const std::string& Text) { m_Text = Text; @@ -597,15 +561,11 @@ void GUITextPanel::SetText(const std::string& Text) { SendSignal(Changed, 0); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUITextPanel::SetRightText(const std::string& rightText) { m_RightText = rightText; SendSignal(Changed, 0); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUITextPanel::SetSelection(int Start, int End) { if (m_Locked) { return; @@ -618,8 +578,6 @@ void GUITextPanel::SetSelection(int Start, int End) { UpdateText(false, false); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int GUITextPanel::GetSelectionStart() const { // No selection? if (!m_GotSelection) { @@ -629,8 +587,6 @@ int GUITextPanel::GetSelectionStart() const { return m_StartSelection; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int GUITextPanel::GetSelectionEnd() const { if (!m_GotSelection) { return -1; @@ -638,14 +594,10 @@ int GUITextPanel::GetSelectionEnd() const { return m_EndSelection; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUITextPanel::ClearSelection() { m_GotSelection = false; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUITextPanel::SetLocked(bool Locked) { m_Locked = Locked; @@ -655,8 +607,6 @@ void GUITextPanel::SetLocked(bool Locked) { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool GUITextPanel::GetLocked() const { return m_Locked; } diff --git a/Source/GUI/GUITextPanel.h b/Source/GUI/GUITextPanel.h index dbd42a31d0..fb2a9e7738 100644 --- a/Source/GUI/GUITextPanel.h +++ b/Source/GUI/GUITextPanel.h @@ -3,9 +3,7 @@ namespace RTE { - /// /// A text panel class. - /// class GUITextPanel : public GUIPanel { public: @@ -17,204 +15,101 @@ namespace RTE { Enter } Signals; - ////////////////////////////////////////////////////////////////////////////////////////// - // Constructor: GUITextPanel - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Constructor method used to instantiate a GUITextPanel object in - // system memory. - // Arguments: GUIManager. - + /// Constructor method used to instantiate a GUITextPanel object in + /// system memory. + /// @param Manager GUIManager. explicit GUITextPanel(GUIManager* Manager); - ////////////////////////////////////////////////////////////////////////////////////////// - // Constructor: GUITextPanel - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Constructor method used to instantiate a GUITextPanel object in - // system memory. - // Arguments: None. - + /// Constructor method used to instantiate a GUITextPanel object in + /// system memory. GUITextPanel(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Create the panel. - // Arguments: Position, Size. - + /// Create the panel. + /// @param X Position, Size. void Create(int X, int Y, int Width, int Height); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ChangeSkin - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the skin has been changed. - // Arguments: New skin pointer. - + /// Called when the skin has been changed. + /// @param Skin New skin pointer. void ChangeSkin(GUISkin* Skin); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Draw - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws the panel - // Arguments: Screen class - + /// Draws the panel + /// @param Screen Screen class void Draw(GUIScreen* Screen) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: OnMouseDown - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the mouse goes down on the panel - // Arguments: Mouse Position, Mouse Buttons, Modifier. - + /// Called when the mouse goes down on the panel + /// @param X Mouse Position, Mouse Buttons, Modifier. void OnMouseDown(int X, int Y, int Buttons, int Modifier) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: OnMouseUp - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the mouse goes up on the panel - // Arguments: Mouse Position, Mouse Buttons, Modifier. - + /// Called when the mouse goes up on the panel + /// @param X Mouse Position, Mouse Buttons, Modifier. void OnMouseUp(int X, int Y, int Buttons, int Modifier) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: OnMouseMove - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when the mouse moves (over the panel, or when captured). - // Arguments: Mouse Position, Mouse Buttons, Modifier. - + /// Called when the mouse moves (over the panel, or when captured). + /// @param X Mouse Position, Mouse Buttons, Modifier. void OnMouseMove(int X, int Y, int Buttons, int Modifier) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: OnKeyPress - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Called when a key is pressed (OnDown & repeating). - // Arguments: KeyCode, Modifier. - + /// Called when a key is pressed (OnDown & repeating). + /// @param KeyCode KeyCode, Modifier. void OnKeyPress(int KeyCode, int Modifier) override; void OnTextInput(std::string_view inputText) override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetText - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the text in the textpanel. - // Arguments: Text. - + /// Sets the text in the textpanel. + /// @param Text Text. void SetText(const std::string& Text); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetRightText - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the extra text which appears right-justified in the textpanel. - // Arguments: Text. - + /// Sets the extra text which appears right-justified in the textpanel. + /// @param rightText Text. void SetRightText(const std::string& rightText); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetText - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the text in the textpanel. - // Arguments: None. - + /// Gets the text in the textpanel. std::string GetText() const { return m_Text; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetRightText - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the extra text which appears right-justified in the textpanel. - // Arguments: None. - + /// Gets the extra text which appears right-justified in the textpanel. std::string GetRightText() const { return m_RightText; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetSelection - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the start and end indexes of the selection text. - // Arguments: Start, End. - + /// Sets the start and end indexes of the selection text. + /// @param Start Start, End. void SetSelection(int Start, int End); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetSelectionStart - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the start index of the selection. - // Arguments: None. - // Returns: Index of the start of the selection. -1 if no selection - + /// Gets the start index of the selection. + /// @return Index of the start of the selection. -1 if no selection int GetSelectionStart() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetSelectionEnd - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the end index of the selection. - // Arguments: None. - // Returns: Index of the end of the selection. -1 if no selection - + /// Gets the end index of the selection. + /// @return Index of the end of the selection. -1 if no selection int GetSelectionEnd() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ClearSelection - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears the selection. Does NOT remove the selection text though. - // Arguments: None. - + /// Clears the selection. Does NOT remove the selection text though. void ClearSelection(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetSelectionText - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the selection text. - // Arguments: None. - + /// Gets the selection text. std::string GetSelectionText() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: RemoveSelectionText - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Removes the characters in the selection. - // Arguments: None. - + /// Removes the characters in the selection. void RemoveSelectionText(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetCursorPos - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets where the cursor should be. This will clear any selection. - // Arguments: The index of the new cursor position. - + /// Sets where the cursor should be. This will clear any selection. + /// @param cursorPos The index of the new cursor position. void SetCursorPos(int cursorPos); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetLocked - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the locked state on the textbox. - // Arguments: Locked. - + /// Sets the locked state on the textbox. + /// @param Locked Locked. void SetLocked(bool Locked); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetLocked - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the locked state on the textbox. - // Arguments: None. - + /// Gets the locked state on the textbox. bool GetLocked() const; - /// /// Sets this text panel to accept numeric symbols only. - /// - /// Whether to accept numeric symbols only or not. + /// @param numericOnly Whether to accept numeric symbols only or not. void SetNumericOnly(bool numericOnly) { m_NumericOnly = numericOnly; } - /// /// Sets this text panel's maximum numeric value when in numeric only mode. - /// - /// The maximum numeric value. 0 means no maximum value. + /// @param maxValue The maximum numeric value. 0 means no maximum value. void SetMaxNumericValue(int maxValue) { m_MaxNumericValue = maxValue; } - /// /// Sets the maximum length of the text this text panel can contain. - /// - /// The maximum length of the text this text panel can contain. + /// @param maxLength The maximum length of the text this text panel can contain. void SetMaxTextLength(int maxLength) { m_MaxTextLength = maxLength; } private: @@ -250,38 +145,26 @@ namespace RTE { bool m_NumericOnly; //!< Whether this text panel only accepts numeric symbols. int m_MaxNumericValue; //!< The maximum numeric value when in numeric only mode. 0 means no maximum value. - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: UpdateText - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the cursor and start positions. - // Arguments: Typing, Increment. - + /// Updates the cursor and start positions. + /// @param Typing Typing, Increment. (default: false) void UpdateText(bool Typing = false, bool DoIncrement = true); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: DoSelection - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Update the selection. - // Arguments: Start, End. - + /// Update the selection. + /// @param Start Start, End. void DoSelection(int Start, int End); - /// /// Gets the index of the start of the next contiguous group of letters or special characters in the given string, or the end of the string if there is none. /// Generally used to deal with ctrl + arrows style behavior. - /// - /// A string_view of the string to look for the next word in. - /// The index in the string to start looking from. - /// The index of the start of the next contiguous group of letters or special characters in the given string, or the end of the string if there is none. + /// @param stringToCheck A string_view of the string to look for the next word in. + /// @param currentIndex The index in the string to start looking from. + /// @return The index of the start of the next contiguous group of letters or special characters in the given string, or the end of the string if there is none. int GetStartOfNextCharacterGroup(const std::string_view& stringToCheck, int currentIndex) const; - /// /// Gets the index of the start of the previous contiguous group of letters or special characters in the given string, or the end of the string if there is none. /// Generally used to deal with ctrl + arrows style behavior. - /// - /// A string_view of the string to look for the next word in. - /// The index in the string to start looking from. - /// The index of the start of the previous contiguous group of letters or special characters in the given string, or the end of the string if there is none. + /// @param stringToCheck A string_view of the string to look for the next word in. + /// @param currentIndex The index in the string to start looking from. + /// @return The index of the start of the previous contiguous group of letters or special characters in the given string, or the end of the string if there is none. int GetStartOfPreviousCharacterGroup(const std::string_view& stringToCheck, int currentIndex) const; }; }; // namespace RTE diff --git a/Source/GUI/GUIUtil.cpp b/Source/GUI/GUIUtil.cpp index 1a57857468..7276cccf6b 100644 --- a/Source/GUI/GUIUtil.cpp +++ b/Source/GUI/GUIUtil.cpp @@ -4,8 +4,6 @@ namespace RTE { - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - char* GUIUtil::TrimString(char* String) { char* ptr = String; // Find the first non-space character @@ -25,8 +23,6 @@ namespace RTE { return ptr; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool GUIUtil::GetClipboardText(std::string* text) { if (SDL_HasClipboardText()) { *text = SDL_GetClipboardText(); @@ -35,8 +31,6 @@ namespace RTE { return false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool GUIUtil::SetClipboardText(const std::string& text) { int result = SDL_SetClipboardText(text.c_str()); return result == 0; diff --git a/Source/GUI/GUIUtil.h b/Source/GUI/GUIUtil.h index b953f70610..d8a61aa057 100644 --- a/Source/GUI/GUIUtil.h +++ b/Source/GUI/GUIUtil.h @@ -3,31 +3,23 @@ namespace RTE { - /// /// A utility class with misc static functions for different things. - /// class GUIUtil { public: - /// /// Removes the preceding and ending spaces from a c type string. - /// - /// String to trim. - /// Trimmed string. + /// @param String String to trim. + /// @return Trimmed string. static char* TrimString(char* String); - /// /// Gets the text from the clipboard. - /// - /// Pointer to string receiving the text. - /// True if text was available in the clipboard. + /// @param text Pointer to string receiving the text. + /// @return True if text was available in the clipboard. static bool GetClipboardText(std::string* text); - /// /// Sets the text in the clipboard. - /// - /// String to put into the clipboard. - /// True if text was added to the clipboard. + /// @param text String to put into the clipboard. + /// @return True if text was added to the clipboard. static bool SetClipboardText(const std::string& text); }; } // namespace RTE diff --git a/Source/GUI/GUIWriter.cpp b/Source/GUI/GUIWriter.cpp index 37c074e74d..255e5b23a7 100644 --- a/Source/GUI/GUIWriter.cpp +++ b/Source/GUI/GUIWriter.cpp @@ -2,8 +2,6 @@ namespace RTE { - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIWriter::Clear() { m_Stream = nullptr; m_FilePath.clear(); @@ -12,14 +10,10 @@ namespace RTE { m_IndentCount = 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIWriter::GUIWriter() { Clear(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int GUIWriter::Create(const std::string& fileName, bool append) { m_FilePath = fileName; @@ -36,33 +30,23 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - std::string GUIWriter::GetFilePath() const { return m_FilePath; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - std::string GUIWriter::GetFileName() const { return m_FileName; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - std::string GUIWriter::GetFolderPath() const { return m_FolderPath; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIWriter::ObjectStart(const std::string& className) { *m_Stream << className; ++m_IndentCount; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIWriter::ObjectEnd() { --m_IndentCount; if (m_IndentCount == 0) { @@ -70,8 +54,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIWriter::NewLine(bool toIndent, int lineCount) const { for (int lines = 0; lines < lineCount; ++lines) { *m_Stream << "\n"; @@ -81,141 +63,101 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIWriter::NewLineString(const std::string& textString, bool toIndent) const { NewLine(toIndent); *m_Stream << textString; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIWriter::NewDivider(bool toIndent, int dividerLength) const { NewLine(toIndent); *m_Stream << std::string(dividerLength, '/'); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIWriter::NewProperty(const std::string& propName) const { NewLine(); *m_Stream << propName + " = "; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool GUIWriter::WriterOK() const { return m_Stream.get() && !m_Stream->fail() && m_Stream->is_open(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIWriter::EndWrite() const { m_Stream->flush(); m_Stream->close(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIWriter& GUIWriter::operator<<(const bool& var) { *m_Stream << var; return *this; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIWriter& GUIWriter::operator<<(const char& var) { *m_Stream << var; return *this; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIWriter& GUIWriter::operator<<(const unsigned char& var) { int temp = var; *m_Stream << temp; return *this; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIWriter& GUIWriter::operator<<(const short& var) { *m_Stream << var; return *this; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIWriter& GUIWriter::operator<<(const unsigned short& var) { *m_Stream << var; return *this; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIWriter& GUIWriter::operator<<(const int& var) { *m_Stream << var; return *this; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIWriter& GUIWriter::operator<<(const unsigned int& var) { *m_Stream << var; return *this; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIWriter& GUIWriter::operator<<(const long& var) { *m_Stream << var; return *this; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIWriter& GUIWriter::operator<<(const long long& var) { *m_Stream << var; return *this; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIWriter& GUIWriter::operator<<(const unsigned long& var) { *m_Stream << var; return *this; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIWriter& GUIWriter::operator<<(const unsigned long long& var) { *m_Stream << var; return *this; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIWriter& GUIWriter::operator<<(const float& var) { *m_Stream << var; return *this; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIWriter& GUIWriter::operator<<(const double& var) { *m_Stream << var; return *this; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIWriter& GUIWriter::operator<<(const char* var) { *m_Stream << var; return *this; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIWriter& GUIWriter::operator<<(const std::string& var) { *m_Stream << var; return *this; diff --git a/Source/GUI/GUIWriter.h b/Source/GUI/GUIWriter.h index 2f01ac5c98..3a7db5afdb 100644 --- a/Source/GUI/GUIWriter.h +++ b/Source/GUI/GUIWriter.h @@ -3,106 +3,76 @@ namespace RTE { - /// /// Writes GUI objects to std::ostreams. - /// class GUIWriter { public: #pragma region Creation - /// /// Constructor method used to instantiate a GUIWriter object in system memory. Create() should be called before using the object. - /// GUIWriter(); - /// /// Makes the GUIWriter object ready for use. - /// - /// Path to the file to open for writing. If the directory doesn't exist the stream will fail to open. - /// Whether to append to the file if it exists, or to overwrite it. - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @param filename Path to the file to open for writing. If the directory doesn't exist the stream will fail to open. + /// @param append Whether to append to the file if it exists, or to overwrite it. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create(const std::string& fileName, bool append = false); #pragma endregion #pragma region Getters - /// /// Gets the path to the file being written. - /// - /// The full path to the file being written. + /// @return The full path to the file being written. std::string GetFilePath() const; - /// /// Gets the name (without path) of the file being written. - /// - /// The name of file being written. + /// @return The name of file being written. std::string GetFileName() const; - /// /// Gets the folder path (without filename) to where the file is being written. - /// - /// The name of folder being written in. + /// @return The name of folder being written in. std::string GetFolderPath() const; #pragma endregion #pragma region Writing Operations - /// /// Used to specify the start of an object to be written. - /// - /// The class name of the object about to be written. + /// @param className The class name of the object about to be written. void ObjectStart(const std::string& className); - /// /// Used to specify the end of an object that has just been written. - /// void ObjectEnd(); - /// /// Creates a new line that can be properly indented. - /// - /// Whether to indent the new line or not. - /// How many new lines to create. + /// @param toIndent Whether to indent the new line or not. + /// @param lineCount How many new lines to create. void NewLine(bool toIndent = true, int lineCount = 1) const; - /// /// Creates a new line and writes the specified string to it. - /// - /// The text string to write to the new line. - /// Whether to indent the new line or not. + /// @param textString The text string to write to the new line. + /// @param toIndent Whether to indent the new line or not. void NewLineString(const std::string& textString, bool toIndent = true) const; - /// /// Creates a new line and fills it with slashes to create a divider line for INI. - /// - /// Whether to indent the new line or not. - /// The length of the divider (number of slashes). + /// @param toIndent Whether to indent the new line or not. + /// @param dividerLength The length of the divider (number of slashes). void NewDivider(bool toIndent = true, int dividerLength = 72) const; - /// /// Creates a new line and writes the name of the property in preparation to writing it's value. - /// - /// The name of the property to be written. + /// @param propName The name of the property to be written. void NewProperty(const std::string& propName) const; #pragma endregion #pragma region Writer Status - /// /// Shows whether the writer is ready to start accepting data streamed to it. - /// - /// Whether the writer is ready to start accepting data streamed to it or not. + /// @return Whether the writer is ready to start accepting data streamed to it or not. bool WriterOK() const; - /// /// Flushes and closes the output stream of this GUIWriter. This happens automatically at destruction but needs to be called manually if a written file must be read from in the same scope. - /// void EndWrite() const; #pragma endregion #pragma region Operator Overloads - /// /// Elemental types stream insertions. Stream insertion operator overloads for all the elemental types. - /// - /// A reference to the variable that will be written to the ostream. - /// A GUIWriter reference for further use in an expression. + /// @param var A reference to the variable that will be written to the ostream. + /// @return A GUIWriter reference for further use in an expression. GUIWriter& operator<<(const bool& var); GUIWriter& operator<<(const char& var); GUIWriter& operator<<(const unsigned char& var); @@ -128,9 +98,7 @@ namespace RTE { int m_IndentCount; //!< Indentation counter. private: - /// /// Clears all the member variables of this GUIWriter, effectively resetting the members of this abstraction level only. - /// void Clear(); // Disallow the use of some implicit methods. diff --git a/Source/GUI/Wrappers/AllegroBitmap.cpp b/Source/GUI/Wrappers/AllegroBitmap.cpp index 925e10bcce..53d6631723 100644 --- a/Source/GUI/Wrappers/AllegroBitmap.cpp +++ b/Source/GUI/Wrappers/AllegroBitmap.cpp @@ -4,16 +4,12 @@ namespace RTE { - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void AllegroBitmap::Clear() { m_Bitmap = nullptr; m_BitmapFile.Reset(); m_SelfCreated = false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void AllegroBitmap::Create(const std::string& fileName) { m_BitmapFile.Create(fileName.c_str()); m_Bitmap = m_BitmapFile.GetAsBitmap(); @@ -23,8 +19,6 @@ namespace RTE { m_SelfCreated = false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void AllegroBitmap::Create(int width, int height, int colorDepth) { m_BitmapFile.Reset(); m_Bitmap = create_bitmap_ex(colorDepth, width, height); @@ -35,8 +29,6 @@ namespace RTE { m_SelfCreated = true; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void AllegroBitmap::Destroy() { if (m_SelfCreated && m_Bitmap) { destroy_bitmap(m_Bitmap); @@ -44,39 +36,27 @@ namespace RTE { Clear(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int AllegroBitmap::GetWidth() const { return m_Bitmap ? m_Bitmap->w : 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int AllegroBitmap::GetHeight() const { return m_Bitmap ? m_Bitmap->h : 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int AllegroBitmap::GetColorDepth() const { return m_Bitmap ? bitmap_color_depth(m_Bitmap) : 8; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - unsigned long AllegroBitmap::GetPixel(int posX, int posY) const { return m_Bitmap ? getpixel(m_Bitmap, posX, posY) : 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void AllegroBitmap::SetPixel(int posX, int posY, unsigned long pixelColor) { RTEAssert(m_Bitmap, "Trying to set a pixel on a null bitmap!"); putpixel(m_Bitmap, posX, posY, pixelColor); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void AllegroBitmap::GetClipRect(GUIRect* clippingRect) const { if (m_Bitmap && clippingRect) { int x1; @@ -91,8 +71,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void AllegroBitmap::SetClipRect(GUIRect* clippingRect) { if (!m_Bitmap) { return; @@ -106,8 +84,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void AllegroBitmap::AddClipRect(GUIRect* clippingRect) { if (!m_Bitmap) { return; @@ -121,8 +97,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void AllegroBitmap::Draw(GUIBitmap* destBitmap, int destX, int destY, GUIRect* srcPosAndSizeRect) { if (!m_Bitmap) { return; @@ -136,8 +110,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void AllegroBitmap::DrawTrans(GUIBitmap* destBitmap, int destX, int destY, GUIRect* srcPosAndSizeRect) { if (!m_Bitmap) { return; @@ -151,8 +123,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void AllegroBitmap::DrawTransScaled(GUIBitmap* destBitmap, int destX, int destY, int width, int height) { if (!m_Bitmap) { return; @@ -162,8 +132,6 @@ namespace RTE { stretch_sprite(dynamic_cast(destBitmap)->GetBitmap(), m_Bitmap, destX, destY, width, height); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void AllegroBitmap::DrawLine(int x1, int y1, int x2, int y2, unsigned long color) { if (!m_Bitmap) { return; @@ -171,8 +139,6 @@ namespace RTE { line(m_Bitmap, x1, y1, x2, y2, color); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void AllegroBitmap::DrawRectangle(int posX, int posY, int width, int height, unsigned long color, bool filled) { if (!m_Bitmap) { return; diff --git a/Source/GUI/Wrappers/AllegroBitmap.h b/Source/GUI/Wrappers/AllegroBitmap.h index 386bd2fe89..2e03a41275 100644 --- a/Source/GUI/Wrappers/AllegroBitmap.h +++ b/Source/GUI/Wrappers/AllegroBitmap.h @@ -6,181 +6,135 @@ namespace RTE { - /// /// Wrapper class to convert raw Allegro BITMAPs to GUI library bitmaps. - /// class AllegroBitmap : public GUIBitmap { public: #pragma region Creation - /// /// Constructor method used to instantiate an AllegroBitmap object in system memory. - /// AllegroBitmap() { Clear(); } - /// /// Constructor method used to instantiate an AllegroBitmap object in system memory and make it ready for use. - /// - /// The underlaying BITMAP of this AllegroBitmap. Ownership is NOT transferred! + /// @param bitmap The underlaying BITMAP of this AllegroBitmap. Ownership is NOT transferred! explicit AllegroBitmap(BITMAP* bitmap) { Clear(); m_Bitmap = bitmap; } - /// /// Creates an AllegroBitmap from a file. - /// - /// File name to get the underlaying BITMAP from. Ownership is NOT transferred! + /// @param fileName File name to get the underlaying BITMAP from. Ownership is NOT transferred! void Create(const std::string& fileName); - /// /// Creates an empty BITMAP that is owned by this AllegroBitmap. - /// - /// Bitmap width. - /// Bitmap height. - /// Bitmap color depth (8 or 32). + /// @param width Bitmap width. + /// @param height Bitmap height. + /// @param colorDepth Bitmap color depth (8 or 32). void Create(int width, int height, int colorDepth = 8); #pragma endregion #pragma region Destruction - /// /// Destructor method used to clean up a AllegroBitmap object before deletion from system memory. - /// ~AllegroBitmap() override { Destroy(); } - /// /// Destroys and resets (through Clear()) the AllegroBitmap object. - /// void Destroy() override; #pragma endregion #pragma region Getters and Setters - /// /// Gets the path to the data file this AllegroBitmap uses. - /// - /// Path to the data file this AllegroBitmap uses. + /// @return Path to the data file this AllegroBitmap uses. std::string GetDataPath() const override { return m_BitmapFile.GetDataPath(); } - /// /// Gets the underlying BITMAP of this AllegroBitmap. - /// - /// The underlying BITMAP of this AllegroBitmap. + /// @return The underlying BITMAP of this AllegroBitmap. BITMAP* GetBitmap() const override { return m_Bitmap; } - /// /// Sets the underlying BITMAP for this AllegroBitmap. Ownership is NOT transferred. - /// - /// A pointer to the new BITMAP for this AllegroBitmap. + /// @param newBitmap A pointer to the new BITMAP for this AllegroBitmap. void SetBitmap(BITMAP* newBitmap) override { Destroy(); m_Bitmap = newBitmap; } - /// /// Gets the width of the bitmap. - /// - /// The width of the bitmap. + /// @return The width of the bitmap. int GetWidth() const override; - /// /// Gets the height of the bitmap. - /// - /// The height of the bitmap. + /// @return The height of the bitmap. int GetHeight() const override; - /// /// Gets the number of bits per pixel color depth of the bitmap. - /// - /// The color depth of the bitmap. + /// @return The color depth of the bitmap. int GetColorDepth() const override; - /// /// Gets the color of a pixel at a specific point on the bitmap. - /// - /// X position on bitmap. - /// Y position on bitmap. - /// The color of the pixel at the specified point. + /// @param posX X position on bitmap. + /// @param posY Y position on bitmap. + /// @return The color of the pixel at the specified point. unsigned long GetPixel(int posX, int posY) const override; - /// /// Sets the color of a pixel at a specific point on the bitmap. - /// - /// X position on bitmap. - /// Y position on bitmap. - /// The color to set the pixel to. + /// @param posX X position on bitmap. + /// @param posY Y position on bitmap. + /// @param pixelColor The color to set the pixel to. void SetPixel(int posX, int posY, unsigned long pixelColor) override; #pragma endregion #pragma region Clipping - /// /// Gets the clipping rectangle of the bitmap. - /// - /// Pointer to a GUIRect to fill out. + /// @param clippingRect Pointer to a GUIRect to fill out. void GetClipRect(GUIRect* clippingRect) const override; - /// /// Sets the clipping rectangle of the bitmap. - /// - /// Pointer to a GUIRect to use as the clipping rectangle, or nullptr for no clipping. + /// @param clippingRect Pointer to a GUIRect to use as the clipping rectangle, or nullptr for no clipping. void SetClipRect(GUIRect* clippingRect) override; - /// /// Sets the clipping rectangle of the bitmap as the intersection of its current clipping rectangle and the passed-in rectangle. - /// - /// Pointer to a GUIRect to add to the existing clipping rectangle. + /// @param clippingRect Pointer to a GUIRect to add to the existing clipping rectangle. void AddClipRect(GUIRect* clippingRect) override; #pragma endregion #pragma region Drawing - /// /// Draw a section of this bitmap onto another bitmap - /// - /// Bitmap to draw onto. - /// Destination X position. - /// Destination Y position. - /// Source bitmap position and size rectangle. + /// @param destBitmap Bitmap to draw onto. + /// @param destX Destination X position. + /// @param destY Destination Y position. + /// @param srcPosAndSizeRect Source bitmap position and size rectangle. void Draw(GUIBitmap* destBitmap, int destX, int destY, GUIRect* srcPosAndSizeRect) override; - /// /// Draw a section of this bitmap onto another bitmap ignoring color-keyed pixels. - /// - /// Bitmap to draw onto. - /// Destination X position. - /// Destination Y position. - /// Source bitmap position and size rectangle. + /// @param destBitmap Bitmap to draw onto. + /// @param destX Destination X position. + /// @param destY Destination Y position. + /// @param srcPosAndSizeRect Source bitmap position and size rectangle. void DrawTrans(GUIBitmap* destBitmap, int destX, int destY, GUIRect* srcPosAndSizeRect) override; - /// /// Draw this bitmap scaled onto another bitmap ignoring color-keyed pixels. - /// - /// Bitmap to draw onto. - /// Destination X position. - /// Destination Y position. - /// Target width of the bitmap. - /// Target height of the bitmap. + /// @param destBitmap Bitmap to draw onto. + /// @param destX Destination X position. + /// @param destY Destination Y position. + /// @param width Target width of the bitmap. + /// @param height Target height of the bitmap. void DrawTransScaled(GUIBitmap* destBitmap, int destX, int destY, int width, int height) override; #pragma endregion #pragma region Primitive Drawing - /// /// Draws a line on this bitmap. - /// - /// Start position on X axis. - /// Start position on Y axis. - /// End position on X axis. - /// End position on Y axis. - /// Color to draw this line with. + /// @param x1 Start position on X axis. + /// @param y1 Start position on Y axis. + /// @param x2 End position on X axis. + /// @param y2 End position on Y axis. + /// @param color Color to draw this line with. void DrawLine(int x1, int y1, int x2, int y2, unsigned long color) override; - /// /// Draws a rectangle on this bitmap. - /// - /// Position on X axis. - /// Position on Y axis. - /// Width of rectangle. - /// Height of rectangle. - /// Color to draw this rectangle with. - /// Whether to fill the rectangle with the set color or not. + /// @param posX Position on X axis. + /// @param posY Position on Y axis. + /// @param width Width of rectangle. + /// @param height Height of rectangle. + /// @param color Color to draw this rectangle with. + /// @param filled Whether to fill the rectangle with the set color or not. void DrawRectangle(int posX, int posY, int width, int height, unsigned long color, bool filled) override; #pragma endregion @@ -189,9 +143,7 @@ namespace RTE { ContentFile m_BitmapFile; //!< The ContentFile the underlaying BITMAP was created from, if created from a file. bool m_SelfCreated; //!< Whether the underlaying BITMAP was created by this and is owned. - /// /// Clears all the member variables of this AllegroBitmap, effectively resetting the members of this abstraction level only. - /// void Clear(); // Disallow the use of some implicit methods. diff --git a/Source/GUI/Wrappers/AllegroScreen.cpp b/Source/GUI/Wrappers/AllegroScreen.cpp index f6a3bb029e..5259cab6f2 100644 --- a/Source/GUI/Wrappers/AllegroScreen.cpp +++ b/Source/GUI/Wrappers/AllegroScreen.cpp @@ -5,8 +5,6 @@ namespace RTE { - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIBitmap* AllegroScreen::CreateBitmap(const std::string& fileName) { std::unique_ptr newAllegroBitmap; newAllegroBitmap.reset(new AllegroBitmap()); @@ -15,8 +13,6 @@ namespace RTE { return newAllegroBitmap.release(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIBitmap* AllegroScreen::CreateBitmap(int width, int height) { std::unique_ptr newAllegroBitmap; newAllegroBitmap.reset(new AllegroBitmap()); @@ -25,8 +21,6 @@ namespace RTE { return newAllegroBitmap.release(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void AllegroScreen::DrawBitmap(GUIBitmap* guiBitmap, int destX, int destY, GUIRect* srcPosAndSizeRect) { if (!guiBitmap) { return; @@ -40,8 +34,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void AllegroScreen::DrawBitmapTrans(GUIBitmap* guiBitmap, int destX, int destY, GUIRect* srcPosAndSizeRect) { if (!guiBitmap) { return; @@ -55,8 +47,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - unsigned long AllegroScreen::ConvertColor(unsigned long color, int targetColorDepth) { if (targetColorDepth == 0) { targetColorDepth = get_color_depth(); diff --git a/Source/GUI/Wrappers/AllegroScreen.h b/Source/GUI/Wrappers/AllegroScreen.h index 64cac1b21f..0c200feb51 100644 --- a/Source/GUI/Wrappers/AllegroScreen.h +++ b/Source/GUI/Wrappers/AllegroScreen.h @@ -5,82 +5,62 @@ namespace RTE { - /// /// Wrapper class to convert raw Allegro BITMAPs to GUI library backbuffer bitmaps. - /// class AllegroScreen : public GUIScreen { public: #pragma region Creation - /// /// Constructor method used to instantiate an AllegroScreen object in system memory and make it ready for use. - /// - /// A bitmap that represents the back buffer. Ownership is NOT transferred! + /// @param backBuffer A bitmap that represents the back buffer. Ownership is NOT transferred! explicit AllegroScreen(BITMAP* backBuffer) { m_BackBufferBitmap = std::make_unique(backBuffer); } - /// /// Creates a bitmap from a file. - /// - /// File name to create bitmap from. - /// Pointer to the created bitmap. Ownership IS transferred! + /// @param fileName File name to create bitmap from. + /// @return Pointer to the created bitmap. Ownership IS transferred! GUIBitmap* CreateBitmap(const std::string& fileName) override; - /// /// Creates an empty bitmap. - /// - /// Bitmap width. - /// Bitmap height. - /// Pointer to the created bitmap. Ownership IS transferred! + /// @param width Bitmap width. + /// @param height Bitmap height. + /// @return Pointer to the created bitmap. Ownership IS transferred! GUIBitmap* CreateBitmap(int width, int height) override; #pragma endregion #pragma region Destruction - /// /// Destructor method used to clean up a AllegroScreen object before deletion from system memory. - /// ~AllegroScreen() override { Destroy(); } - /// /// Destroys the AllegroScreen object. - /// void Destroy() override { m_BackBufferBitmap.reset(); } #pragma endregion #pragma region Getters - /// /// Gets the bitmap representing the screen. - /// - /// Pointer to the bitmap representing the screen. Ownership is NOT transferred! + /// @return Pointer to the bitmap representing the screen. Ownership is NOT transferred! GUIBitmap* GetBitmap() const override { return m_BackBufferBitmap.get(); } #pragma endregion #pragma region Drawing - /// /// Draws a bitmap onto the back buffer. - /// - /// The bitmap to draw to this AllegroScreen. - /// Destination X position - /// Destination Y position - /// Source bitmap position and size rectangle. + /// @param guiBitmap The bitmap to draw to this AllegroScreen. + /// @param destX Destination X position + /// @param destY Destination Y position + /// @param srcPosAndSizeRect Source bitmap position and size rectangle. void DrawBitmap(GUIBitmap* guiBitmap, int destX, int destY, GUIRect* srcPosAndSizeRect) override; - /// /// Draws a bitmap onto the back buffer ignoring color-keyed pixels. - /// - /// The bitmap to draw to this AllegroScreen. - /// Destination X position - /// Destination Y position - /// Source bitmap position and size rectangle. + /// @param guiBitmap The bitmap to draw to this AllegroScreen. + /// @param destX Destination X position + /// @param destY Destination Y position + /// @param srcPosAndSizeRect Source bitmap position and size rectangle. void DrawBitmapTrans(GUIBitmap* guiBitmap, int destX, int destY, GUIRect* srcPosAndSizeRect) override; #pragma endregion #pragma region Virtual Override Methods - /// /// Converts an 8bit palette index to a valid pixel format color. - /// - /// Color value in any bit depth. Will be converted to the format specified. - /// An optional target color depth that will determine what format the color should be converted to. If this is 0, then the current video color depth will be used as target. - /// The converted color. + /// @param color Color value in any bit depth. Will be converted to the format specified. + /// @param targetColorDepth An optional target color depth that will determine what format the color should be converted to. If this is 0, then the current video color depth will be used as target. + /// @return The converted color. unsigned long ConvertColor(unsigned long color, int targetColorDepth = 0) override; #pragma endregion diff --git a/Source/GUI/Wrappers/GUIInputWrapper.cpp b/Source/GUI/Wrappers/GUIInputWrapper.cpp index a4838e9369..f8edf53d9f 100644 --- a/Source/GUI/Wrappers/GUIInputWrapper.cpp +++ b/Source/GUI/Wrappers/GUIInputWrapper.cpp @@ -8,8 +8,6 @@ namespace RTE { - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIInputWrapper::GUIInputWrapper(int whichPlayer, bool keyJoyMouseCursor) : GUIInput(whichPlayer, keyJoyMouseCursor) { m_KeyTimer = std::make_unique(); @@ -21,8 +19,6 @@ namespace RTE { m_KeyHoldDuration.fill(-1); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIInputWrapper::ConvertKeyEvent(SDL_Scancode sdlKey, int guilibKey, float elapsedS) { int nKeys; const Uint8* sdlKeyState = SDL_GetKeyboardState(&nKeys); @@ -47,8 +43,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIInputWrapper::Update() { float keyElapsedTime = static_cast(m_KeyTimer->GetElapsedRealTimeS()); m_KeyTimer->Reset(); @@ -67,8 +61,6 @@ namespace RTE { m_MouseY = static_cast(mousePos.GetY() / static_cast(g_WindowMan.GetResMultiplier())); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIInputWrapper::UpdateKeyboardInput(float keyElapsedTime) { // Clear the keyboard buffer, we need it to check for changes. memset(m_KeyboardBuffer, 0, sizeof(uint8_t) * GUIInput::Constants::KEYBOARD_BUFFER_SIZE); @@ -117,8 +109,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIInputWrapper::UpdateMouseInput() { int discard; Uint32 buttonState = SDL_GetMouseState(&discard, &discard); @@ -220,8 +210,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GUIInputWrapper::UpdateKeyJoyMouseInput(float keyElapsedTime) { // TODO Try to not use magic numbers throughout this method. float mouseDenominator = g_WindowMan.GetResMultiplier(); diff --git a/Source/GUI/Wrappers/GUIInputWrapper.h b/Source/GUI/Wrappers/GUIInputWrapper.h index cc458d1c0a..0239319192 100644 --- a/Source/GUI/Wrappers/GUIInputWrapper.h +++ b/Source/GUI/Wrappers/GUIInputWrapper.h @@ -8,32 +8,24 @@ namespace RTE { class Timer; - /// /// Wrapper class to translate input handling of whatever library is currently used to valid GUI library input. - /// class GUIInputWrapper : public GUIInput { public: #pragma region Creation - /// /// Constructor method used to instantiate a GUIInputWrapper object in system memory. - /// - /// Which player this GUIInputWrapper will handle input for. -1 means no specific player and will default to player 1. - /// Whether the keyboard and joysticks also can control the mouse cursor. + /// @param whichPlayer Which player this GUIInputWrapper will handle input for. -1 means no specific player and will default to player 1. + /// @param keyJoyMouseCursor Whether the keyboard and joysticks also can control the mouse cursor. GUIInputWrapper(int whichPlayer, bool keyJoyMouseCursor = false); #pragma endregion #pragma region Destruction - /// /// Destructor method used to clean up a GUIInputWrapper object before deletion from system memory. - /// ~GUIInputWrapper() override = default; #pragma endregion #pragma region Virtual Override Methods - /// /// Updates the input. - /// void Update() override; #pragma endregion @@ -44,28 +36,20 @@ namespace RTE { std::unique_ptr m_KeyTimer; //!< Timer for checking key hold duration. std::unique_ptr m_CursorAccelTimer; //!< Timer to calculate the mouse cursor acceleration when it is controller with the keyboard or joysticks. - /// /// Converts from SDL's key push to that used by this GUI lib, with timings for repeats taken into consideration. - /// - /// The key scancode. - /// The corresponding GUIlib scancode - /// The elapsed time since the last update, in seconds. + /// @param sdlKey The key scancode. + /// @param guilibKey The corresponding GUIlib scancode + /// @param elapsedS The elapsed time since the last update, in seconds. void ConvertKeyEvent(SDL_Scancode sdlKey, int guilibKey, float elapsedS); #pragma region Update Breakdown - /// /// Updates the keyboard input. - /// void UpdateKeyboardInput(float keyElapsedTime); - /// /// Updates the mouse input. - /// void UpdateMouseInput(); - /// /// Updates the mouse input using the joystick or keyboard. - /// void UpdateKeyJoyMouseInput(float keyElapsedTime); #pragma endregion diff --git a/Source/Lua/LuaAdapterDefinitions.h b/Source/Lua/LuaAdapterDefinitions.h index 5d5690b4ea..45a3e14d67 100644 --- a/Source/Lua/LuaAdapterDefinitions.h +++ b/Source/Lua/LuaAdapterDefinitions.h @@ -91,12 +91,10 @@ namespace RTE { #pragma region Entity Lua Adapter Macros struct LuaAdaptersEntityCreate { -/// /// Convenience macro to generate preset clone-create adapter functions that will return the exact pre-cast types, so we don't have to do: myNewActor = ToActor(PresetMan:GetPreset("AHuman", "Soldier Light", "All")):Clone() /// But can instead do: myNewActor = CreateActor("Soldier Light", "All"); /// Or even: myNewActor = CreateActor("Soldier Light"); /// Or for a randomly selected Preset within a group: myNewActor = RandomActor("Light Troops"); -/// #define LuaEntityCreateFunctionsDeclarationsForType(TYPE) \ static TYPE* Create##TYPE(std::string preseName, std::string moduleName); \ static TYPE* Create##TYPE(std::string preset); \ @@ -135,9 +133,7 @@ namespace RTE { }; struct LuaAdaptersEntityClone { -/// /// Convenience macro to generate a preset clone adapter function for a type. -/// #define LuaEntityCloneFunctionDeclarationForType(TYPE) \ static TYPE* Clone##TYPE(const TYPE* thisEntity) @@ -176,9 +172,7 @@ namespace RTE { }; struct LuaAdaptersEntityCast { -/// /// Convenience macro to generate type casting adapter functions for a type. -/// #define LuaEntityCastFunctionsDeclarationsForType(TYPE) \ static TYPE* To##TYPE(Entity* entity); \ static const TYPE* ToConst##TYPE(const Entity* entity); \ @@ -227,10 +221,8 @@ namespace RTE { }; struct LuaAdaptersPropertyOwnershipSafetyFaker { -/// /// Special handling for passing ownership through properties. If you try to pass null to this normally, LuaJIT crashes. /// This handling avoids that, and is a bit safer since there's no actual ownership transfer from Lua to C++. -/// #define LuaPropertyOwnershipSafetyFakerFunctionDeclaration(OBJECTTYPE, PROPERTYTYPE, SETTERFUNCTION) \ static void OBJECTTYPE##SETTERFUNCTION(OBJECTTYPE* luaSelfObject, PROPERTYTYPE* objectToSet) @@ -400,32 +392,24 @@ namespace RTE { #pragma region MovableMan Lua Adapters struct LuaAdaptersMovableMan { - /// /// Adds the given MovableObject to MovableMan if it doesn't already exist in there, or prints an error if it does. - /// - /// A reference to MovableMan, provided by Lua. - /// A pointer to the MovableObject to be added. + /// @param movableMan A reference to MovableMan, provided by Lua. + /// @param movableObject A pointer to the MovableObject to be added. static void AddMO(MovableMan& movableMan, MovableObject* movableObject); - /// /// Adds the given Actor to MovableMan if it doesn't already exist in there, or prints an error if it does. - /// - /// A reference to MovableMan, provided by Lua. - /// A pointer to the Actor to be added. + /// @param movableMan A reference to MovableMan, provided by Lua. + /// @param actor A pointer to the Actor to be added. static void AddActor(MovableMan& movableMan, Actor* actor); - /// /// Adds the given item MovableObject (generally a HeldDevice) to MovableMan if it doesn't already exist in there, or prints an error if it does. - /// - /// A reference to MovableMan, provided by Lua. - /// A pointer to the item to be added. + /// @param movableMan A reference to MovableMan, provided by Lua. + /// @param item A pointer to the item to be added. static void AddItem(MovableMan& movableMan, HeldDevice* item); - /// /// Adds the given particle MovableObject to MovableMan if it doesn't already exist in there, or prints an error if it does. - /// - /// A reference to MovableMan, provided by Lua. - /// A pointer to the particle to be added. + /// @param movableMan A reference to MovableMan, provided by Lua. + /// @param particle A pointer to the particle to be added. static void AddParticle(MovableMan& movableMan, MovableObject* particle); static void SendGlobalMessage1(MovableMan& movableMan, const std::string& message); @@ -435,201 +419,155 @@ namespace RTE { #pragma region TimerMan Lua Adapters struct LuaAdaptersTimerMan { - /// /// Gets the current number of ticks that the simulation should be updating with. Lua can't handle int64 (or long long apparently) so we'll expose this specialized function. - /// - /// The current fixed delta time that the simulation should be updating with, in ticks. + /// @return The current fixed delta time that the simulation should be updating with, in ticks. static double GetDeltaTimeTicks(const TimerMan& timerMan); - /// /// Gets the number of ticks per second. Lua can't handle int64 (or long long apparently) so we'll expose this specialized function. - /// - /// The number of ticks per second. + /// @return The number of ticks per second. static double GetTicksPerSecond(const TimerMan& timerMan); }; #pragma endregion #pragma region UInputMan Lua Adapters struct LuaAdaptersUInputMan { - /// /// Gets whether a mouse button is being held down right now. - /// - /// Which button to check for. - /// Whether the mouse button is held or not. + /// @param whichButton Which button to check for. + /// @return Whether the mouse button is held or not. static bool MouseButtonHeld(const UInputMan& uinputMan, int whichButton); - /// /// Gets whether a mouse button was pressed between the last update and the one previous to it. - /// - /// Which button to check for. - /// Whether the mouse button is pressed or not. + /// @param whichButton Which button to check for. + /// @return Whether the mouse button is pressed or not. static bool MouseButtonPressed(const UInputMan& uinputMan, int whichButton); - /// /// Gets whether a mouse button was released between the last update and the one previous to it. - /// - /// Which button to check for. - /// Whether the mouse button is released or not. + /// @param whichButton Which button to check for. + /// @return Whether the mouse button is released or not. static bool MouseButtonReleased(const UInputMan& uinputMan, int whichButton); }; #pragma endregion #pragma region PresetMan Lua Adapters struct LuaAdaptersPresetMan { - /// /// Reloads the specified Entity preset in PresetMan. - /// - /// The preset name of the Entity to reload. - /// The class name of the Entity to reload. - /// The module name of the Entity to reload. - /// Whether or not the Entity was reloaded. + /// @param presetName The preset name of the Entity to reload. + /// @param className The class name of the Entity to reload. + /// @param moduleName The module name of the Entity to reload. + /// @return Whether or not the Entity was reloaded. static bool ReloadEntityPreset1(PresetMan& presetMan, const std::string& presetName, const std::string& className, const std::string& moduleName); - /// /// Reloads the specified Entity preset in PresetMan. - /// - /// The preset name of the Entity to reload. - /// The class name of the Entity to reload. - /// Whether or not the Entity was reloaded. + /// @param presetName The preset name of the Entity to reload. + /// @param className The class name of the Entity to reload. + /// @return Whether or not the Entity was reloaded. static bool ReloadEntityPreset2(PresetMan& presetMan, const std::string& presetName, const std::string& className); - /// /// Gets a list all previously read in (defined) Entities which are associated with a specific group. - /// - /// The group to look for. "All" will look in all. - /// The name of the least common denominator type of the Entities you want. "All" will look at all types. - /// Whether to only get those of one specific DataModule (0-n), or all (-1). - /// The list of all Entities with the given group and type in the module. + /// @param group The group to look for. "All" will look in all. + /// @param type The name of the least common denominator type of the Entities you want. "All" will look at all types. + /// @param whichModule Whether to only get those of one specific DataModule (0-n), or all (-1). + /// @return The list of all Entities with the given group and type in the module. static std::list* GetAllEntitiesOfGroup(PresetMan& presetMan, const std::string& group, const std::string& type, int whichModule); static std::list* GetAllEntitiesOfGroup2(PresetMan& presetMan, const std::string& group, const std::string& type) { return GetAllEntitiesOfGroup(presetMan, group, type, -1); } static std::list* GetAllEntitiesOfGroup3(PresetMan& presetMan, const std::string& group) { return GetAllEntitiesOfGroup2(presetMan, group, "All"); } - /// /// Gets a list all previously read in (defined) Entities. - /// - /// The list of all Entities. + /// @return The list of all Entities. static std::list* GetAllEntities(PresetMan& presetMan) { return GetAllEntitiesOfGroup3(presetMan, "All"); } }; #pragma endregion #pragma region SceneMan Lua Adapters struct LuaAdaptersSceneMan { - /// /// Takes a Box and returns a list of Boxes that describe the Box, wrapped appropriately for the current Scene. - /// - /// The Box to wrap. - /// A list of Boxes that make up the Box to wrap, wrapped appropriately for the current Scene. + /// @param boxToWrap The Box to wrap. + /// @return A list of Boxes that make up the Box to wrap, wrapped appropriately for the current Scene. static const std::list* WrapBoxes(SceneMan& sceneMan, const Box& boxToWrap); }; #pragma endregion #pragma region PrimitiveMan Lua Adapters struct LuaAdaptersPrimitiveMan { - /// /// Schedule to draw a polygon primitive. - /// - /// A reference to PrimitiveMan, provided by Lua. - /// Position of primitive's center in Scene coordinates. - /// Color to draw primitive with. - /// A Lua table that contains the positions of the primitive's vertices, relative to the center position. + /// @param primitiveMan A reference to PrimitiveMan, provided by Lua. + /// @param centerPos Position of primitive's center in Scene coordinates. + /// @param color Color to draw primitive with. + /// @param verticesTable A Lua table that contains the positions of the primitive's vertices, relative to the center position. static void DrawPolygonPrimitive(PrimitiveMan& primitiveMan, const Vector& centerPos, int color, const luabind::object& verticesTable); - /// /// Schedule to draw a polygon primitive visible only to a specified player. - /// - /// A reference to PrimitiveMan, provided by Lua. - /// Player screen to draw primitive on. - /// Position of primitive's center in Scene coordinates. - /// Color to draw primitive with. - /// A Lua table that contains the positions of the primitive's vertices, relative to the center position. + /// @param primitiveMan A reference to PrimitiveMan, provided by Lua. + /// @param player Player screen to draw primitive on. + /// @param centerPos Position of primitive's center in Scene coordinates. + /// @param color Color to draw primitive with. + /// @param verticesTable A Lua table that contains the positions of the primitive's vertices, relative to the center position. static void DrawPolygonPrimitiveForPlayer(PrimitiveMan& primitiveMan, int player, const Vector& centerPos, int color, const luabind::object& verticesTable); - /// /// Schedule to draw a filled polygon primitive. - /// - /// A reference to PrimitiveMan, provided by Lua. - /// Start position of the primitive in Scene coordinates. - /// Color to draw primitive with. - /// A Lua table that contains the positions of the primitive's vertices, relative to the center position. + /// @param primitiveMan A reference to PrimitiveMan, provided by Lua. + /// @param startPos Start position of the primitive in Scene coordinates. + /// @param color Color to draw primitive with. + /// @param verticesTable A Lua table that contains the positions of the primitive's vertices, relative to the center position. static void DrawPolygonFillPrimitive(PrimitiveMan& primitiveMan, const Vector& startPos, int color, const luabind::object& verticesTable); - /// /// Schedule to draw a filled polygon primitive visible only to a specified player. - /// - /// A reference to PrimitiveMan, provided by Lua. - /// Player screen to draw primitive on. - /// Start position of the primitive in Scene coordinates. - /// Color to draw primitive with. - /// A Lua table that contains the positions of the primitive's vertices, relative to the center position. + /// @param primitiveMan A reference to PrimitiveMan, provided by Lua. + /// @param player Player screen to draw primitive on. + /// @param startPos Start position of the primitive in Scene coordinates. + /// @param color Color to draw primitive with. + /// @param verticesTable A Lua table that contains the positions of the primitive's vertices, relative to the center position. static void DrawPolygonFillPrimitiveForPlayer(PrimitiveMan& primitiveMan, int player, const Vector& startPos, int color, const luabind::object& verticesTable); - /// /// Schedules to draw multiple primitives of varying type with transparency enabled. - /// - /// A reference to PrimitiveMan, provided by Lua. - /// The transparency value the primitives should be drawn at. From 0 (opaque) to 100 (transparent). - /// A Lua table of primitives to schedule drawing for. + /// @param primitiveMan A reference to PrimitiveMan, provided by Lua. + /// @param transValue The transparency value the primitives should be drawn at. From 0 (opaque) to 100 (transparent). + /// @param primitivesTable A Lua table of primitives to schedule drawing for. static void DrawPrimitivesWithTransparency(PrimitiveMan& primitiveMan, int transValue, const luabind::object& primitivesTable); - /// /// Schedule to draw multiple primitives of varying type with blending enabled. - /// - /// A reference to PrimitiveMan, provided by Lua. - /// The blending mode the primitives should be drawn with. See DrawBlendMode enumeration. - /// The blending amount for all the channels. 0-100. - /// A Lua table of primitives to schedule drawing for. + /// @param primitiveMan A reference to PrimitiveMan, provided by Lua. + /// @param blendMode The blending mode the primitives should be drawn with. See DrawBlendMode enumeration. + /// @param blendAmount The blending amount for all the channels. 0-100. + /// @param primitivesTable A Lua table of primitives to schedule drawing for. static void DrawPrimitivesWithBlending(PrimitiveMan& primitiveMan, int blendMode, int blendAmount, const luabind::object& primitivesTable); - /// /// Schedule to draw multiple primitives of varying type with blending enabled. - /// - /// A reference to PrimitiveMan, provided by Lua. - /// The blending mode the primitives should be drawn with. See DrawBlendMode enumeration. - /// The blending amount for the Red channel. 0-100. - /// The blending amount for the Green channel. 0-100. - /// The blending amount for the Blue channel. 0-100. - /// The blending amount for the Alpha channel. 0-100. - /// A Lua table of primitives to schedule drawing for. + /// @param primitiveMan A reference to PrimitiveMan, provided by Lua. + /// @param blendMode The blending mode the primitives should be drawn with. See DrawBlendMode enumeration. + /// @param blendAmountR The blending amount for the Red channel. 0-100. + /// @param blendAmountG The blending amount for the Green channel. 0-100. + /// @param blendAmountB The blending amount for the Blue channel. 0-100. + /// @param blendAmountA The blending amount for the Alpha channel. 0-100. + /// @param primitivesTable A Lua table of primitives to schedule drawing for. static void DrawPrimitivesWithBlendingPerChannel(PrimitiveMan& primitiveMan, int blendMode, int blendAmountR, int blendAmountG, int blendAmountB, int blendAmountA, const luabind::object& primitivesTable); }; #pragma endregion #pragma region Utility Lua Adapters struct LuaAdaptersUtility { - /// /// Gets the ratio between the physics engine's meters and on-screen pixels. - /// - /// A float describing the current MPP ratio. + /// @return A float describing the current MPP ratio. static float GetMPP(); - /// /// Gets the ratio between on-screen pixels and the physics engine's meters. - /// - /// A float describing the current PPM ratio. + /// @return A float describing the current PPM ratio. static float GetPPM(); - /// /// Gets the ratio between the physics engine's Liters and on-screen pixels. - /// - /// A float describing the current LPP ratio. + /// @return A float describing the current LPP ratio. static float GetLPP(); - /// /// Gets the ratio between the on-screen pixels and the physics engine's Liters. - /// - /// A float describing the current PPL ratio. + /// @return A float describing the current PPL ratio. static float GetPPL(); - /// /// Gets the default pathfinder penetration value that'll allow pathing through corpses, debris, and such stuff. - /// - /// A float describing the default pathfinder penetration value. + /// @return A float describing the default pathfinder penetration value. static float GetPathFindingDefaultDigStrength(); - /// /// Explicit deletion of any Entity instance that Lua owns. It will probably be handled by the GC, but this makes it instantaneous. - /// - /// The Entity to delete. + /// @param entityToDelete The Entity to delete. static void DeleteEntity(Entity* entityToDelete); }; #pragma endregion diff --git a/Source/Lua/LuaAdapters.cpp b/Source/Lua/LuaAdapters.cpp index 242087162f..4ecef33977 100644 --- a/Source/Lua/LuaAdapters.cpp +++ b/Source/Lua/LuaAdapters.cpp @@ -7,8 +7,6 @@ namespace RTE { std::unordered_map> LuaAdaptersEntityCast::s_EntityToLuabindObjectCastFunctions = {}; - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - #define LuaEntityCreateFunctionsDefinitionsForType(TYPE) \ TYPE* LuaAdaptersEntityCreate::Create##TYPE(std::string preseName, std::string moduleName) { \ const Entity* entityPreset = g_PresetMan.GetEntityPreset(#TYPE, preseName, moduleName); \ @@ -83,8 +81,6 @@ namespace RTE { LuaEntityCreateFunctionsDefinitionsForType(PieSlice); LuaEntityCreateFunctionsDefinitionsForType(PieMenu); - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - #define LuaEntityCloneFunctionDefinitionForType(TYPE) \ TYPE* LuaAdaptersEntityClone::Clone##TYPE(const TYPE* thisEntity) { \ if (thisEntity) { \ @@ -127,8 +123,6 @@ namespace RTE { LuaEntityCloneFunctionDefinitionForType(PieSlice); LuaEntityCloneFunctionDefinitionForType(PieMenu); - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - #define LuaEntityCastFunctionsDefinitionsForType(TYPE) \ TYPE* LuaAdaptersEntityCast::To##TYPE(Entity* entity) { \ TYPE* targetType = dynamic_cast(entity); \ @@ -194,8 +188,6 @@ namespace RTE { LuaEntityCastFunctionsDefinitionsForType(PieSlice); LuaEntityCastFunctionsDefinitionsForType(PieMenu); - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - #define LuaPropertyOwnershipSafetyFakerFunctionDefinition(OBJECTTYPE, PROPERTYTYPE, SETTERFUNCTION) \ void LuaAdaptersPropertyOwnershipSafetyFaker::OBJECTTYPE##SETTERFUNCTION(OBJECTTYPE* luaSelfObject, PROPERTYTYPE* objectToSet) { \ luaSelfObject->SETTERFUNCTION(objectToSet ? dynamic_cast(objectToSet->Clone()) : nullptr); \ @@ -265,14 +257,10 @@ namespace RTE { LuaPropertyOwnershipSafetyFakerFunctionDefinition(HDFirearm, SoundContainer, SetReloadStartSound); LuaPropertyOwnershipSafetyFakerFunctionDefinition(HDFirearm, SoundContainer, SetReloadEndSound); - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void LuaAdaptersEntity::SetPresetName(Entity* luaSelfObject, const std::string& presetName) { luaSelfObject->SetPresetName(presetName, true); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - std::vector* LuaAdaptersActor::GetSceneWaypoints(Actor* luaSelfObject) { std::vector* sceneWaypoints = new std::vector(); sceneWaypoints->reserve(luaSelfObject->GetWaypointsSize()); @@ -284,8 +272,6 @@ namespace RTE { return sceneWaypoints; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int LuaAdaptersScene::CalculatePath2(Scene* luaSelfObject, const Vector& start, const Vector& end, bool movePathToGround, float digStrength, Activity::Teams team) { std::list& threadScenePath = luaSelfObject->GetScenePath(); team = std::clamp(team, Activity::Teams::NoTeam, Activity::Teams::TeamFour); @@ -302,8 +288,6 @@ namespace RTE { return -1; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void LuaAdaptersScene::CalculatePathAsync2(Scene* luaSelfObject, const luabind::object& callbackParam, const Vector& start, const Vector& end, bool movePathToGround, float digStrength, Activity::Teams team) { team = std::clamp(team, Activity::Teams::NoTeam, Activity::Teams::TeamFour); @@ -338,33 +322,23 @@ namespace RTE { luaSelfObject->CalculatePathAsync(start, end, digStrength, team, callLuaCallback); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void LuaAdaptersAHuman::ReloadFirearms(AHuman* luaSelfObject) { luaSelfObject->ReloadFirearms(false); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - float LuaAdaptersSceneObject::GetTotalValue(const SceneObject* luaSelfObject, int nativeModule, float foreignMult) { return luaSelfObject->GetTotalValue(nativeModule, foreignMult, 1.0F); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int LuaAdaptersSceneObject::GetBuyableMode(const SceneObject* luaSelfObject) { return static_cast(luaSelfObject->GetBuyableMode()); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void LuaAdaptersActivity::SendMessage1(Activity* luaSelfObject, const std::string& message) { luabind::object context; SendMessage2(luaSelfObject, message, context); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void LuaAdaptersActivity::SendMessage2(Activity* luaSelfObject, const std::string& message, luabind::object context) { GAScripted* scriptedActivity = dynamic_cast(luaSelfObject); if (scriptedActivity) { @@ -373,14 +347,10 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool LuaAdaptersMovableObject::HasScript(MovableObject* luaSelfObject, const std::string& scriptPath) { return luaSelfObject->HasScript(g_PresetMan.GetFullModulePath(scriptPath)); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool LuaAdaptersMovableObject::AddScript(MovableObject* luaSelfObject, const std::string& scriptPath) { switch (std::string correctedScriptPath = g_PresetMan.GetFullModulePath(scriptPath); luaSelfObject->LoadScript(correctedScriptPath)) { case 0: @@ -407,60 +377,42 @@ namespace RTE { return false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool LuaAdaptersMovableObject::EnableScript(MovableObject* luaSelfObject, const std::string& scriptPath) { return luaSelfObject->EnableOrDisableScript(g_PresetMan.GetFullModulePath(scriptPath), true); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool LuaAdaptersMovableObject::DisableScript1(MovableObject* luaSelfObject) { std::string currentScriptFilePath(g_LuaMan.GetThreadCurrentLuaState()->GetCurrentlyRunningScriptFilePath()); return luaSelfObject->EnableOrDisableScript(currentScriptFilePath, false); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool LuaAdaptersMovableObject::DisableScript2(MovableObject* luaSelfObject, const std::string& scriptPath) { return luaSelfObject->EnableOrDisableScript(g_PresetMan.GetFullModulePath(scriptPath), false); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void LuaAdaptersMovableObject::SendMessage1(MovableObject* luaSelfObject, const std::string& message) { luaSelfObject->RunScriptedFunctionInAppropriateScripts("OnMessage", false, false, {}, {message}); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void LuaAdaptersMovableObject::SendMessage2(MovableObject* luaSelfObject, const std::string& message, luabind::object context) { LuabindObjectWrapper wrapper(&context, "", false); luaSelfObject->RunScriptedFunctionInAppropriateScripts("OnMessage", false, false, {}, {message}, {&wrapper}); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void LuaAdaptersMOSRotating::GibThis(MOSRotating* luaSelfObject) { luaSelfObject->GibThis(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - std::vector* LuaAdaptersMOSRotating::GetWounds1(const MOSRotating* luaSelfObject) { return GetWounds2(luaSelfObject, true, false, false); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - std::vector* LuaAdaptersMOSRotating::GetWounds2(const MOSRotating* luaSelfObject, bool includePositiveDamageAttachables, bool includeNegativeDamageAttachables, bool includeNoDamageAttachables) { auto* wounds = new std::vector(); GetWoundsImpl(luaSelfObject, includePositiveDamageAttachables, includeNegativeDamageAttachables, includeNoDamageAttachables, *wounds); return wounds; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void LuaAdaptersMOSRotating::GetWoundsImpl(const MOSRotating* luaSelfObject, bool includePositiveDamageAttachables, bool includeNegativeDamageAttachables, bool includeNoDamageAttachables, std::vector& wounds) { wounds.insert(wounds.end(), luaSelfObject->GetWoundList().begin(), luaSelfObject->GetWoundList().end()); @@ -477,8 +429,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - std::list* LuaAdaptersBuyMenuGUI::GetOrderList(const BuyMenuGUI* luaSelfObject) { std::list constOrderList; luaSelfObject->GetOrderList(constOrderList); @@ -494,8 +444,6 @@ namespace RTE { return orderList; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - Attachable* LuaAdaptersAttachable::RemoveFromParent1(Attachable* luaSelfObject) { if (luaSelfObject->IsAttached()) { return luaSelfObject->GetParent()->RemoveAttachable(luaSelfObject); @@ -503,8 +451,6 @@ namespace RTE { return luaSelfObject; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - Attachable* LuaAdaptersAttachable::RemoveFromParent2(Attachable* luaSelfObject, bool addToMovableMan, bool addBreakWounds) { if (luaSelfObject->IsAttached()) { return luaSelfObject->GetParent()->RemoveAttachable(luaSelfObject, addToMovableMan, addBreakWounds); @@ -512,38 +458,26 @@ namespace RTE { return luaSelfObject; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void LuaAdaptersTurret::AddMountedFirearm(Turret* luaSelfObject, HDFirearm* newMountedDevice) { luaSelfObject->AddMountedDevice(newMountedDevice); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void LuaAdaptersGlobalScript::Deactivate(GlobalScript* luaSelfObject) { luaSelfObject->SetActive(false); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool LuaAdaptersPieMenu::AddPieSlice(PieMenu* luaSelfObject, PieSlice* pieSliceToAdd, const Entity* pieSliceOriginalSource) { return luaSelfObject->AddPieSlice(pieSliceToAdd, pieSliceOriginalSource, false); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool LuaAdaptersPieMenu::AddPieSliceIfPresetNameIsUnique1(PieMenu* luaSelfObject, PieSlice* pieSliceToAdd, const Entity* pieSliceOriginalSource) { return luaSelfObject->AddPieSliceIfPresetNameIsUnique(pieSliceToAdd, pieSliceOriginalSource, false, false); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool LuaAdaptersPieMenu::AddPieSliceIfPresetNameIsUnique2(PieMenu* luaSelfObject, PieSlice* pieSliceToAdd, const Entity* pieSliceOriginalSource, bool onlyCheckPieSlicesWithSameOriginalSource) { return luaSelfObject->AddPieSliceIfPresetNameIsUnique(pieSliceToAdd, pieSliceOriginalSource, onlyCheckPieSlicesWithSameOriginalSource, false); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void LuaAdaptersMovableMan::AddMO(MovableMan& movableMan, MovableObject* movableObject) { if (movableMan.ValidMO(movableObject)) { g_ConsoleMan.PrintString("ERROR: Tried to add a MovableObject that already exists in the simulation! " + movableObject->GetPresetName()); @@ -552,8 +486,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void LuaAdaptersMovableMan::AddActor(MovableMan& movableMan, Actor* actor) { if (movableMan.IsActor(actor)) { g_ConsoleMan.PrintString("ERROR: Tried to add an Actor that already exists in the simulation!" + actor->GetPresetName()); @@ -562,8 +494,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void LuaAdaptersMovableMan::AddItem(MovableMan& movableMan, HeldDevice* item) { if (movableMan.ValidMO(dynamic_cast(item))) { g_ConsoleMan.PrintString("ERROR: Tried to add an Item that already exists in the simulation!" + item->GetPresetName()); @@ -572,8 +502,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void LuaAdaptersMovableMan::AddParticle(MovableMan& movableMan, MovableObject* particle) { if (movableMan.ValidMO(particle)) { g_ConsoleMan.PrintString("ERROR: Tried to add a Particle that already exists in the simulation!" + particle->GetPresetName()); @@ -582,8 +510,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void LuaAdaptersMovableMan::SendGlobalMessage1(MovableMan& movableMan, const std::string& message) { GAScripted* scriptedActivity = dynamic_cast(g_ActivityMan.GetActivity()); if (scriptedActivity) { @@ -593,8 +519,6 @@ namespace RTE { movableMan.RunLuaFunctionOnAllMOs("OnGlobalMessage", true, {}, {message}); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void LuaAdaptersMovableMan::SendGlobalMessage2(MovableMan& movableMan, const std::string& message, luabind::object context) { LuabindObjectWrapper wrapper(&context, "", false); @@ -606,138 +530,94 @@ namespace RTE { movableMan.RunLuaFunctionOnAllMOs("OnGlobalMessage", true, {}, {message}, {&wrapper}); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - double LuaAdaptersTimerMan::GetDeltaTimeTicks(const TimerMan& timerMan) { return static_cast(timerMan.GetDeltaTimeTicks()); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - double LuaAdaptersTimerMan::GetTicksPerSecond(const TimerMan& timerMan) { return static_cast(timerMan.GetTicksPerSecond()); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool LuaAdaptersUInputMan::MouseButtonHeld(const UInputMan& uinputMan, int whichButton) { return uinputMan.MouseButtonHeld(whichButton, Players::PlayerOne); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool LuaAdaptersUInputMan::MouseButtonPressed(const UInputMan& uinputMan, int whichButton) { return uinputMan.MouseButtonPressed(whichButton, Players::PlayerOne); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool LuaAdaptersUInputMan::MouseButtonReleased(const UInputMan& uinputMan, int whichButton) { return uinputMan.MouseButtonReleased(whichButton, Players::PlayerOne); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool LuaAdaptersPresetMan::ReloadEntityPreset1(PresetMan& presetMan, const std::string& presetName, const std::string& className, const std::string& moduleName) { return presetMan.ReloadEntityPreset(presetName, className, moduleName); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool LuaAdaptersPresetMan::ReloadEntityPreset2(PresetMan& presetMan, const std::string& presetName, const std::string& className) { return ReloadEntityPreset1(presetMan, presetName, className, ""); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - std::list* LuaAdaptersPresetMan::GetAllEntitiesOfGroup(PresetMan& presetMan, const std::string& group, const std::string& type, int whichModule) { std::list* entityList = new std::list(); presetMan.GetAllOfGroup(*entityList, group, type, whichModule); return entityList; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - const std::list* LuaAdaptersSceneMan::WrapBoxes(SceneMan& sceneMan, const Box& boxToWrap) { std::list* wrappedBoxes = new std::list(); sceneMan.WrapBox(boxToWrap, *wrappedBoxes); return wrappedBoxes; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void LuaAdaptersPrimitiveMan::DrawPolygonPrimitive(PrimitiveMan& primitiveMan, const Vector& centerPos, int color, const luabind::object& verticesTable) { primitiveMan.DrawPolygonOrPolygonFillPrimitive(-1, centerPos, color, ConvertLuaTableToVectorOfType(verticesTable), false); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void LuaAdaptersPrimitiveMan::DrawPolygonPrimitiveForPlayer(PrimitiveMan& primitiveMan, int player, const Vector& centerPos, int color, const luabind::object& verticesTable) { primitiveMan.DrawPolygonOrPolygonFillPrimitive(player, centerPos, color, ConvertLuaTableToVectorOfType(verticesTable), false); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void LuaAdaptersPrimitiveMan::DrawPolygonFillPrimitive(PrimitiveMan& primitiveMan, const Vector& startPos, int color, const luabind::object& verticesTable) { primitiveMan.DrawPolygonOrPolygonFillPrimitive(-1, startPos, color, ConvertLuaTableToVectorOfType(verticesTable), true); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void LuaAdaptersPrimitiveMan::DrawPolygonFillPrimitiveForPlayer(PrimitiveMan& primitiveMan, int player, const Vector& startPos, int color, const luabind::object& verticesTable) { primitiveMan.DrawPolygonOrPolygonFillPrimitive(player, startPos, color, ConvertLuaTableToVectorOfType(verticesTable), true); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void LuaAdaptersPrimitiveMan::DrawPrimitivesWithTransparency(PrimitiveMan& primitiveMan, int transValue, const luabind::object& primitivesTable) { primitiveMan.SchedulePrimitivesForBlendedDrawing(DrawBlendMode::BlendTransparency, transValue, transValue, transValue, BlendAmountLimits::MinBlend, ConvertLuaTableToVectorOfType(primitivesTable)); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void LuaAdaptersPrimitiveMan::DrawPrimitivesWithBlending(PrimitiveMan& primitiveMan, int blendMode, int blendAmount, const luabind::object& primitivesTable) { primitiveMan.SchedulePrimitivesForBlendedDrawing(static_cast(blendMode), blendAmount, blendAmount, blendAmount, blendAmount, ConvertLuaTableToVectorOfType(primitivesTable)); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void LuaAdaptersPrimitiveMan::DrawPrimitivesWithBlendingPerChannel(PrimitiveMan& primitiveMan, int blendMode, int blendAmountR, int blendAmountG, int blendAmountB, int blendAmountA, const luabind::object& primitivesTable) { primitiveMan.SchedulePrimitivesForBlendedDrawing(static_cast(blendMode), blendAmountR, blendAmountG, blendAmountB, blendAmountA, ConvertLuaTableToVectorOfType(primitivesTable)); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - float LuaAdaptersUtility::GetMPP() { return c_MPP; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - float LuaAdaptersUtility::GetPPM() { return c_PPM; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - float LuaAdaptersUtility::GetLPP() { return c_LPP; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - float LuaAdaptersUtility::GetPPL() { return c_PPL; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - float LuaAdaptersUtility::GetPathFindingDefaultDigStrength() { return c_PathFindingDefaultDigStrength; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void LuaAdaptersUtility::DeleteEntity(Entity* entityToDelete) { delete entityToDelete; entityToDelete = nullptr; diff --git a/Source/Lua/LuaBindingRegisterDefinitions.h b/Source/Lua/LuaBindingRegisterDefinitions.h index b1006a52b4..24d8573c33 100644 --- a/Source/Lua/LuaBindingRegisterDefinitions.h +++ b/Source/Lua/LuaBindingRegisterDefinitions.h @@ -131,51 +131,37 @@ namespace RTE { PER_LUA_BINDING(DrawBlendMode) #pragma region Lua Binding Registration Macros -/// /// Convenience macro for declaring a binding register function. -/// #define LuaBindingRegisterFunctionDeclarationForType(TYPE) \ static luabind::scope Register##TYPE##LuaBindings() -/// /// Convenience macro for defining a binding register function. -/// #define LuaBindingRegisterFunctionDefinitionForType(OWNINGSCOPE, TYPE) \ luabind::scope OWNINGSCOPE::Register##TYPE##LuaBindings() -/// /// Convenience macro for a LuaBind scope definition of an abstract type. -/// #define AbstractTypeLuaClassDefinition(TYPE, PARENTTYPE) \ luabind::class_(#TYPE) \ .property("ClassName", &TYPE::GetClassName) -/// /// Convenience macro for a LuaBind scope definition of a concrete type. -/// #define ConcreteTypeLuaClassDefinition(TYPE, PARENTTYPE) \ luabind::class_(#TYPE) \ .def("Clone", &LuaAdaptersEntityClone::Clone##TYPE, luabind::adopt(luabind::result)) \ .property("ClassName", &TYPE::GetClassName) -/// /// Convenience macro for calling a register function of a type. -/// #define RegisterLuaBindingsOfType(OWNINGSCOPE, TYPE) \ OWNINGSCOPE::Register##TYPE##LuaBindings() -/// /// Convenience macro for calling a register function of an abstract type, along with registering global bindings for adapters relevant to the type. -/// #define RegisterLuaBindingsOfAbstractType(OWNINGSCOPE, TYPE) \ luabind::def((std::string("To") + std::string(#TYPE)).c_str(), (TYPE * (*)(Entity*)) & LuaAdaptersEntityCast::To##TYPE), \ luabind::def((std::string("To") + std::string(#TYPE)).c_str(), (const TYPE* (*)(const Entity*)) & LuaAdaptersEntityCast::ToConst##TYPE), \ luabind::def((std::string("Is") + std::string(#TYPE)).c_str(), (bool (*)(const Entity*)) & LuaAdaptersEntityCast::Is##TYPE), \ OWNINGSCOPE::Register##TYPE##LuaBindings() -/// /// Convenience macro for calling a register function of a concrete type, along with registering global bindings for adapters relevant to the type. -/// #define RegisterLuaBindingsOfConcreteType(OWNINGSCOPE, TYPE) \ luabind::def((std::string("Create") + std::string(#TYPE)).c_str(), (TYPE * (*)(std::string, std::string)) & LuaAdaptersEntityCreate::Create##TYPE, luabind::adopt(luabind::result)), \ luabind::def((std::string("Create") + std::string(#TYPE)).c_str(), (TYPE * (*)(std::string)) & LuaAdaptersEntityCreate::Create##TYPE, luabind::adopt(luabind::result)), \ @@ -188,9 +174,7 @@ namespace RTE { OWNINGSCOPE::Register##TYPE##LuaBindings() #pragma endregion - /// /// Struct that contains Lua binding registration functions for System classes. - /// struct SystemLuaBindings { LuaBindingRegisterFunctionDeclarationForType(Box); LuaBindingRegisterFunctionDeclarationForType(Controller); @@ -200,9 +184,7 @@ namespace RTE { LuaBindingRegisterFunctionDeclarationForType(PathRequest); }; - /// /// Struct that contains Lua binding registration functions for Manager classes. - /// struct ManagerLuaBindings { LuaBindingRegisterFunctionDeclarationForType(ActivityMan); LuaBindingRegisterFunctionDeclarationForType(AudioMan); @@ -221,9 +203,7 @@ namespace RTE { LuaBindingRegisterFunctionDeclarationForType(UInputMan); }; - /// /// Struct that contains Lua binding registration functions for Entity classes. - /// struct EntityLuaBindings { LuaBindingRegisterFunctionDeclarationForType(Entity); LuaBindingRegisterFunctionDeclarationForType(ACDropShip); @@ -270,26 +250,20 @@ namespace RTE { LuaBindingRegisterFunctionDeclarationForType(Turret); }; - /// /// Struct that contains Lua binding registration functions for Activity classes. - /// struct ActivityLuaBindings { LuaBindingRegisterFunctionDeclarationForType(Activity); LuaBindingRegisterFunctionDeclarationForType(GameActivity); }; - /// /// Struct that contains Lua binding registration functions for GUI classes. - /// struct GUILuaBindings { LuaBindingRegisterFunctionDeclarationForType(GUIBanner); LuaBindingRegisterFunctionDeclarationForType(BuyMenuGUI); LuaBindingRegisterFunctionDeclarationForType(SceneEditorGUI); }; - /// /// Struct that contains Lua binding registration functions for GraphicalPrimitive classes. - /// struct PrimitiveLuaBindings { LuaBindingRegisterFunctionDeclarationForType(GraphicalPrimitive); LuaBindingRegisterFunctionDeclarationForType(LinePrimitive); @@ -309,9 +283,7 @@ namespace RTE { LuaBindingRegisterFunctionDeclarationForType(BitmapPrimitive); }; - /// /// Struct that contains Lua binding registration functions for various input enumerations. - /// struct InputLuaBindings { LuaBindingRegisterFunctionDeclarationForType(InputDevice); LuaBindingRegisterFunctionDeclarationForType(InputElements); @@ -324,9 +296,7 @@ namespace RTE { LuaBindingRegisterFunctionDeclarationForType(SDL_GameControllerAxis); }; - /// /// Struct that contains Lua binding registration functions for types that don't really belong in any of the other binding structs. - /// struct MiscLuaBindings { LuaBindingRegisterFunctionDeclarationForType(AlarmEvent); LuaBindingRegisterFunctionDeclarationForType(Directions); diff --git a/Source/Lua/LuaBindingsActivities.cpp b/Source/Lua/LuaBindingsActivities.cpp index e6de5cd4b2..8046246e56 100644 --- a/Source/Lua/LuaBindingsActivities.cpp +++ b/Source/Lua/LuaBindingsActivities.cpp @@ -4,8 +4,6 @@ namespace RTE { - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaBindingRegisterFunctionDefinitionForType(ActivityLuaBindings, Activity) { return AbstractTypeLuaClassDefinition(Activity, Entity) @@ -111,8 +109,6 @@ namespace RTE { luabind::value("UNFAIRSKILL", Activity::AISkillSetting::UnfairSkill)]; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaBindingRegisterFunctionDefinitionForType(ActivityLuaBindings, GameActivity) { return luabind::class_("GameActivity") diff --git a/Source/Lua/LuaBindingsEntities.cpp b/Source/Lua/LuaBindingsEntities.cpp index 48f9dd7adf..28ce718056 100644 --- a/Source/Lua/LuaBindingsEntities.cpp +++ b/Source/Lua/LuaBindingsEntities.cpp @@ -4,8 +4,6 @@ namespace RTE { - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaBindingRegisterFunctionDefinitionForType(EntityLuaBindings, Entity) { return luabind::class_("Entity") @@ -28,8 +26,6 @@ namespace RTE { .def("IsInGroup", &Entity::IsInGroup); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaBindingRegisterFunctionDefinitionForType(EntityLuaBindings, ACDropShip) { return ConcreteTypeLuaClassDefinition(ACDropShip, ACraft) @@ -48,8 +44,6 @@ namespace RTE { .def("GetAltitude", &ACDropShip::GetAltitude); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaBindingRegisterFunctionDefinitionForType(EntityLuaBindings, ACrab) { return ConcreteTypeLuaClassDefinition(ACrab, Actor) @@ -112,8 +106,6 @@ namespace RTE { luabind::value("LANDJUMP", ACrab::JumpState::LANDJUMP)]; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaBindingRegisterFunctionDefinitionForType(EntityLuaBindings, ACraft) { return AbstractTypeLuaClassDefinition(ACraft, Actor) @@ -148,8 +140,6 @@ namespace RTE { luabind::value("ASCEND", ACraft::AltitudeMoveState::ASCEND)]; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaBindingRegisterFunctionDefinitionForType(EntityLuaBindings, ACRocket) { return ConcreteTypeLuaClassDefinition(ACRocket, ACraft) @@ -169,8 +159,6 @@ namespace RTE { luabind::value("GearStateCount", ACRocket::LandingGearState::GearStateCount)]; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaBindingRegisterFunctionDefinitionForType(EntityLuaBindings, Actor) { return ConcreteTypeLuaClassDefinition(Actor, MOSRotating) @@ -318,8 +306,6 @@ namespace RTE { luabind::value("FOLLOWWAIT", Actor::TeamBlockState::FOLLOWWAIT)]; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaBindingRegisterFunctionDefinitionForType(EntityLuaBindings, ADoor) { return ConcreteTypeLuaClassDefinition(ADoor, Actor) @@ -343,8 +329,6 @@ namespace RTE { luabind::value("STOPPED", ADoor::DoorState::STOPPED)]; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaBindingRegisterFunctionDefinitionForType(EntityLuaBindings, AEmitter) { return ConcreteTypeLuaClassDefinition(AEmitter, Attachable) @@ -385,8 +369,6 @@ namespace RTE { .def("JustStartedEmitting", &AEmitter::JustStartedEmitting); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaBindingRegisterFunctionDefinitionForType(EntityLuaBindings, AEJetpack) { return ConcreteTypeLuaClassDefinition(AEJetpack, AEmitter) @@ -403,8 +385,6 @@ namespace RTE { luabind::value("JumpPack", AEJetpack::JumpPack)]; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaBindingRegisterFunctionDefinitionForType(EntityLuaBindings, AHuman) { return ConcreteTypeLuaClassDefinition(AHuman, Actor) @@ -510,8 +490,6 @@ namespace RTE { luabind::value("LANDJUMP", AHuman::JumpState::LANDJUMP)]; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaBindingRegisterFunctionDefinitionForType(EntityLuaBindings, Arm) { return ConcreteTypeLuaClassDefinition(Arm, Attachable) @@ -539,8 +517,6 @@ namespace RTE { .def("ClearHandTargets", &Arm::ClearHandTargets); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaBindingRegisterFunctionDefinitionForType(EntityLuaBindings, Attachable) { return ConcreteTypeLuaClassDefinition(Attachable, MOSRotating) @@ -571,8 +547,6 @@ namespace RTE { .def("RemoveFromParent", &LuaAdaptersAttachable::RemoveFromParent2, luabind::adopt(luabind::return_value)); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaBindingRegisterFunctionDefinitionForType(EntityLuaBindings, Deployment) { return AbstractTypeLuaClassDefinition(Deployment, SceneObject) @@ -585,8 +559,6 @@ namespace RTE { .def("CreateDeployedObject", (SceneObject * (Deployment::*)()) & Deployment::CreateDeployedObject, luabind::adopt(luabind::result)); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaBindingRegisterFunctionDefinitionForType(EntityLuaBindings, Emission) { return AbstractTypeLuaClassDefinition(Emission, Entity) @@ -602,8 +574,6 @@ namespace RTE { .def("ResetEmissionTimers", &Emission::ResetEmissionTimers); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaBindingRegisterFunctionDefinitionForType(EntityLuaBindings, Gib) { return luabind::class_("Gib") @@ -624,16 +594,12 @@ namespace RTE { luabind::value("SpreadSpiral", Gib::SpreadMode::SpreadSpiral)]; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaBindingRegisterFunctionDefinitionForType(EntityLuaBindings, GlobalScript) { return AbstractTypeLuaClassDefinition(GlobalScript, Entity) .def("Deactivate", &LuaAdaptersGlobalScript::Deactivate); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaBindingRegisterFunctionDefinitionForType(EntityLuaBindings, HDFirearm) { return ConcreteTypeLuaClassDefinition(HDFirearm, HeldDevice) @@ -686,8 +652,6 @@ namespace RTE { .def("SetNextMagazineName", &HDFirearm::SetNextMagazineName); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaBindingRegisterFunctionDefinitionForType(EntityLuaBindings, HeldDevice) { return ConcreteTypeLuaClassDefinition(HeldDevice, Attachable) @@ -731,8 +695,6 @@ namespace RTE { .def("RemovePickupableByPresetName", &HeldDevice::RemovePickupableByPresetName); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaBindingRegisterFunctionDefinitionForType(EntityLuaBindings, Leg) { return ConcreteTypeLuaClassDefinition(Leg, Attachable) @@ -740,8 +702,6 @@ namespace RTE { .property("MoveSpeed", &Leg::GetMoveSpeed, &Leg::SetMoveSpeed); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaBindingRegisterFunctionDefinitionForType(EntityLuaBindings, LimbPath) { return luabind::class_("LimbPath") @@ -752,8 +712,6 @@ namespace RTE { .def("GetSegment", &LimbPath::GetSegment); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaBindingRegisterFunctionDefinitionForType(EntityLuaBindings, Magazine) { return ConcreteTypeLuaClassDefinition(Magazine, Attachable) @@ -766,8 +724,6 @@ namespace RTE { .property("Discardable", &Magazine::IsDiscardable); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaBindingRegisterFunctionDefinitionForType(EntityLuaBindings, Material) { return luabind::class_("Material") @@ -786,8 +742,6 @@ namespace RTE { .property("IsScrap", &Material::IsScrap); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaBindingRegisterFunctionDefinitionForType(EntityLuaBindings, MetaPlayer) { return luabind::class_("MetaPlayer") @@ -802,8 +756,6 @@ namespace RTE { .def("ChangeBrainPoolCount", &MetaPlayer::ChangeBrainPoolCount); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaBindingRegisterFunctionDefinitionForType(EntityLuaBindings, MOPixel) { return ConcreteTypeLuaClassDefinition(MOPixel, MovableObject) @@ -811,14 +763,10 @@ namespace RTE { .property("Staininess", &MOPixel::GetStaininess, &MOPixel::SetStaininess); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaBindingRegisterFunctionDefinitionForType(EntityLuaBindings, MOSParticle) { return ConcreteTypeLuaClassDefinition(MOSParticle, MOSprite); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaBindingRegisterFunctionDefinitionForType(EntityLuaBindings, MOSprite) { return AbstractTypeLuaClassDefinition(MOSprite, MovableObject) @@ -861,8 +809,6 @@ namespace RTE { luabind::value("ONCOLLIDE", SpriteAnimMode::ONCOLLIDE)]; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaBindingRegisterFunctionDefinitionForType(EntityLuaBindings, MOSRotating) { return ConcreteTypeLuaClassDefinition(MOSRotating, MOSprite) @@ -921,8 +867,6 @@ namespace RTE { .def("GibThis", &LuaAdaptersMOSRotating::GibThis); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaBindingRegisterFunctionDefinitionForType(EntityLuaBindings, MovableObject) { return AbstractTypeLuaClassDefinition(MovableObject, SceneObject) @@ -1038,8 +982,6 @@ namespace RTE { .def("RequestSyncedUpdate", &MovableObject::RequestSyncedUpdate); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaBindingRegisterFunctionDefinitionForType(EntityLuaBindings, PEmitter) { return ConcreteTypeLuaClassDefinition(PEmitter, MOSParticle) @@ -1066,8 +1008,6 @@ namespace RTE { .def("JustStartedEmitting", &PEmitter::JustStartedEmitting); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaBindingRegisterFunctionDefinitionForType(EntityLuaBindings, PieSlice) { return ConcreteTypeLuaClassDefinition(PieSlice, Entity) @@ -1122,8 +1062,6 @@ namespace RTE { luabind::value("Team4", PieSlice::SliceType::EditorTeam4)]; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaBindingRegisterFunctionDefinitionForType(EntityLuaBindings, PieMenu) { return ConcreteTypeLuaClassDefinition(PieMenu, Entity) @@ -1165,8 +1103,6 @@ namespace RTE { .def("ReplacePieSlice", &PieMenu::ReplacePieSlice, luabind::adopt(luabind::result) + luabind::adopt(_3)); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaBindingRegisterFunctionDefinitionForType(EntityLuaBindings, Round) { return ConcreteTypeLuaClassDefinition(Round, Entity) @@ -1182,8 +1118,6 @@ namespace RTE { .property("IsEmpty", &Round::IsEmpty); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaBindingRegisterFunctionDefinitionForType(EntityLuaBindings, Scene) { return ConcreteTypeLuaClassDefinition(Scene, Entity) @@ -1235,8 +1169,6 @@ namespace RTE { luabind::value("PLACEDSETSCOUNT", Scene::PlacedObjectSets::PLACEDSETSCOUNT)]; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaBindingRegisterFunctionDefinitionForType(EntityLuaBindings, SceneArea) { return luabind::class_("Area") @@ -1264,14 +1196,10 @@ namespace RTE { .def("GetRandomPoint", &Scene::Area::GetRandomPoint); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaBindingRegisterFunctionDefinitionForType(EntityLuaBindings, SceneLayer) { return luabind::class_("SceneLayer"); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaBindingRegisterFunctionDefinitionForType(EntityLuaBindings, SceneObject) { return AbstractTypeLuaClassDefinition(SceneObject, Entity) @@ -1299,8 +1227,6 @@ namespace RTE { luabind::value("SCRIPTONLY", static_cast(SceneObject::BuyableMode::ScriptOnly))]; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaBindingRegisterFunctionDefinitionForType(EntityLuaBindings, SLBackground) { return luabind::class_("SLBackground") @@ -1318,8 +1244,6 @@ namespace RTE { .def("IsAutoScrolling", &SLBackground::IsAutoScrolling); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaBindingRegisterFunctionDefinitionForType(EntityLuaBindings, SoundContainer) { return ConcreteTypeLuaClassDefinition(SoundContainer, Entity) @@ -1362,8 +1286,6 @@ namespace RTE { luabind::value("IGNORE_PLAY", SoundContainer::SoundOverlapMode::IGNORE_PLAY)]; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaBindingRegisterFunctionDefinitionForType(EntityLuaBindings, SoundSet) { return luabind::class_("SoundSet") @@ -1386,16 +1308,12 @@ namespace RTE { luabind::value("ALL", SoundSet::SoundSelectionCycleMode::ALL)]; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaBindingRegisterFunctionDefinitionForType(EntityLuaBindings, TDExplosive) { return ConcreteTypeLuaClassDefinition(TDExplosive, ThrownDevice) .property("IsAnimatedManually", &TDExplosive::IsAnimatedManually, &TDExplosive::SetAnimatedManually); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaBindingRegisterFunctionDefinitionForType(EntityLuaBindings, TerrainObject) { return ConcreteTypeLuaClassDefinition(TerrainObject, SceneObject) @@ -1404,8 +1322,6 @@ namespace RTE { .def("GetBitmapHeight", &TerrainObject::GetBitmapHeight); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaBindingRegisterFunctionDefinitionForType(EntityLuaBindings, ThrownDevice) { return ConcreteTypeLuaClassDefinition(ThrownDevice, HeldDevice) @@ -1417,8 +1333,6 @@ namespace RTE { .def("GetCalculatedMaxThrowVelIncludingArmThrowStrength", &ThrownDevice::GetCalculatedMaxThrowVelIncludingArmThrowStrength); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaBindingRegisterFunctionDefinitionForType(EntityLuaBindings, Turret) { return ConcreteTypeLuaClassDefinition(Turret, Attachable) diff --git a/Source/Lua/LuaBindingsGUI.cpp b/Source/Lua/LuaBindingsGUI.cpp index a80d425937..90461c13d9 100644 --- a/Source/Lua/LuaBindingsGUI.cpp +++ b/Source/Lua/LuaBindingsGUI.cpp @@ -4,8 +4,6 @@ namespace RTE { - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaBindingRegisterFunctionDefinitionForType(GUILuaBindings, GUIBanner) { return luabind::class_("GUIBanner") @@ -32,8 +30,6 @@ namespace RTE { luabind::value("YELLOW", GameActivity::BannerColor::YELLOW)]; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaBindingRegisterFunctionDefinitionForType(GUILuaBindings, BuyMenuGUI) { return luabind::class_("BuyMenuGUI") @@ -69,8 +65,6 @@ namespace RTE { .def("GetTotalOrderPassengers", &BuyMenuGUI::GetTotalOrderPassengers); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaBindingRegisterFunctionDefinitionForType(GUILuaBindings, SceneEditorGUI) { return luabind::class_("SceneEditorGUI") diff --git a/Source/Lua/LuaBindingsInput.cpp b/Source/Lua/LuaBindingsInput.cpp index 016dc61ccb..13ae061f86 100644 --- a/Source/Lua/LuaBindingsInput.cpp +++ b/Source/Lua/LuaBindingsInput.cpp @@ -8,8 +8,6 @@ namespace RTE { - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaBindingRegisterFunctionDefinitionForType(InputLuaBindings, InputDevice) { return luabind::class_("InputDevice") @@ -22,8 +20,6 @@ namespace RTE { luabind::value("DEVICE_COUNT", InputDevice::DEVICE_COUNT)]; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaBindingRegisterFunctionDefinitionForType(InputLuaBindings, InputElements) { return luabind::class_("InputElements") @@ -52,8 +48,6 @@ namespace RTE { luabind::value("INPUT_COUNT", InputElements::INPUT_COUNT)]; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaBindingRegisterFunctionDefinitionForType(InputLuaBindings, MouseButtons) { return luabind::class_("MouseButtons") @@ -64,8 +58,6 @@ namespace RTE { luabind::value("MAX_MOUSE_BUTTONS", MouseButtons::MAX_MOUSE_BUTTONS)]; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaBindingRegisterFunctionDefinitionForType(InputLuaBindings, JoyButtons) { return luabind::class_("JoyButtons") @@ -85,8 +77,6 @@ namespace RTE { luabind::value("MAX_JOY_BUTTONS", JoyButtons::MAX_JOY_BUTTONS)]; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaBindingRegisterFunctionDefinitionForType(InputLuaBindings, JoyDirections) { return luabind::class_("JoyDirections") @@ -94,8 +84,6 @@ namespace RTE { luabind::value("JOYDIR_TWO", JoyDirections::JOYDIR_TWO)]; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaBindingRegisterFunctionDefinitionForType(InputLuaBindings, SDL_Keycode) { return luabind::class_("Key") @@ -338,8 +326,6 @@ namespace RTE { luabind::value("SLEEP", SDLK_SLEEP)]; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaBindingRegisterFunctionDefinitionForType(InputLuaBindings, SDL_Scancode) { return luabind::class_("Scancode") @@ -590,8 +576,6 @@ namespace RTE { luabind::value("NUM_SCANCODES", SDL_NUM_SCANCODES)]; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaBindingRegisterFunctionDefinitionForType(InputLuaBindings, SDL_GameControllerButton) { return luabind::class_("GamepadButton") @@ -614,8 +598,6 @@ namespace RTE { luabind::value("MAX", SDL_CONTROLLER_BUTTON_MAX)]; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaBindingRegisterFunctionDefinitionForType(InputLuaBindings, SDL_GameControllerAxis) { return luabind::class_("GamepadAxis") diff --git a/Source/Lua/LuaBindingsManagers.cpp b/Source/Lua/LuaBindingsManagers.cpp index 1a9ea3bec4..102074564c 100644 --- a/Source/Lua/LuaBindingsManagers.cpp +++ b/Source/Lua/LuaBindingsManagers.cpp @@ -4,8 +4,6 @@ namespace RTE { - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaBindingRegisterFunctionDefinitionForType(ManagerLuaBindings, ActivityMan) { return luabind::class_("ActivityManager") @@ -26,8 +24,6 @@ namespace RTE { .def("LoadGame", &ActivityMan::LoadAndLaunchGame); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaBindingRegisterFunctionDefinitionForType(ManagerLuaBindings, AudioMan) { return luabind::class_("AudioManager") @@ -53,8 +49,6 @@ namespace RTE { .def("PlaySound", (SoundContainer * (AudioMan::*)(const std::string& filePath, const Vector& position, int player)) & AudioMan::PlaySound, luabind::adopt(luabind::result)); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaBindingRegisterFunctionDefinitionForType(ManagerLuaBindings, ConsoleMan) { return luabind::class_("ConsoleManager") @@ -64,8 +58,6 @@ namespace RTE { .def("Clear", &ConsoleMan::ClearLog); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaBindingRegisterFunctionDefinitionForType(ManagerLuaBindings, FrameMan) { return luabind::class_("FrameManager") @@ -88,8 +80,6 @@ namespace RTE { .def("SplitStringToFitWidth", &FrameMan::SplitStringToFitWidth); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaBindingRegisterFunctionDefinitionForType(ManagerLuaBindings, MetaMan) { return luabind::class_("MetaManager") @@ -104,8 +94,6 @@ namespace RTE { .def("GetMetaPlayerOfInGamePlayer", &MetaMan::GetMetaPlayerOfInGamePlayer); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaBindingRegisterFunctionDefinitionForType(ManagerLuaBindings, MovableMan) { return luabind::class_("MovableManager") @@ -174,24 +162,18 @@ namespace RTE { .def("AddParticle", &LuaAdaptersMovableMan::AddParticle, luabind::adopt(_2)); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaBindingRegisterFunctionDefinitionForType(ManagerLuaBindings, PerformanceMan) { return luabind::class_("PerformanceManager") .property("ShowPerformanceStats", &PerformanceMan::IsShowingPerformanceStats, &PerformanceMan::ShowPerformanceStats); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaBindingRegisterFunctionDefinitionForType(ManagerLuaBindings, PostProcessMan) { return luabind::class_("PostProcessManager") .def("RegisterPostEffect", &PostProcessMan::RegisterPostEffect); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaBindingRegisterFunctionDefinitionForType(ManagerLuaBindings, PresetMan) { return luabind::class_("PresetManager") @@ -224,8 +206,6 @@ namespace RTE { .def("GetFullModulePath", &PresetMan::GetFullModulePath); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaBindingRegisterFunctionDefinitionForType(ManagerLuaBindings, PrimitiveMan) { return luabind::class_("PrimitiveManager") @@ -283,8 +263,6 @@ namespace RTE { .def("DrawPrimitives", &LuaAdaptersPrimitiveMan::DrawPrimitivesWithBlendingPerChannel); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaBindingRegisterFunctionDefinitionForType(ManagerLuaBindings, SceneMan) { return luabind::class_("SceneManager") @@ -354,8 +332,6 @@ namespace RTE { .def("DislodgePixel", &SceneMan::DislodgePixel); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaBindingRegisterFunctionDefinitionForType(ManagerLuaBindings, CameraMan) { return luabind::class_("CameraManager") @@ -372,8 +348,6 @@ namespace RTE { .def("AddScreenShake", (void(CameraMan::*)(float, const Vector&)) & CameraMan::AddScreenShake); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaBindingRegisterFunctionDefinitionForType(ManagerLuaBindings, SettingsMan) { return luabind::class_("SettingsManager") @@ -384,8 +358,6 @@ namespace RTE { .property("AutomaticGoldDeposit", &SettingsMan::GetAutomaticGoldDeposit); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaBindingRegisterFunctionDefinitionForType(ManagerLuaBindings, TimerMan) { return luabind::class_("TimerManager") @@ -403,8 +375,6 @@ namespace RTE { .def("DrawnSimUpdate", &TimerMan::DrawnSimUpdate); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaBindingRegisterFunctionDefinitionForType(ManagerLuaBindings, UInputMan) { return luabind::class_("UInputManager") diff --git a/Source/Lua/LuaBindingsMisc.cpp b/Source/Lua/LuaBindingsMisc.cpp index 361e9c9d47..554d860490 100644 --- a/Source/Lua/LuaBindingsMisc.cpp +++ b/Source/Lua/LuaBindingsMisc.cpp @@ -4,8 +4,6 @@ namespace RTE { - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaBindingRegisterFunctionDefinitionForType(MiscLuaBindings, AlarmEvent) { return luabind::class_("AlarmEvent") @@ -17,8 +15,6 @@ namespace RTE { .def_readwrite("Range", &AlarmEvent::m_Range); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaBindingRegisterFunctionDefinitionForType(MiscLuaBindings, Directions) { return luabind::class_("Directions") @@ -30,8 +26,6 @@ namespace RTE { luabind::value("Any", Directions::Any)]; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaBindingRegisterFunctionDefinitionForType(MiscLuaBindings, DrawBlendMode) { return luabind::class_("DrawBlendMode") diff --git a/Source/Lua/LuaBindingsPrimitives.cpp b/Source/Lua/LuaBindingsPrimitives.cpp index 57fc5171c4..fd7e3d56e6 100644 --- a/Source/Lua/LuaBindingsPrimitives.cpp +++ b/Source/Lua/LuaBindingsPrimitives.cpp @@ -4,126 +4,94 @@ namespace RTE { - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaBindingRegisterFunctionDefinitionForType(PrimitiveLuaBindings, GraphicalPrimitive) { return luabind::class_("GraphicalPrimitive"); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaBindingRegisterFunctionDefinitionForType(PrimitiveLuaBindings, LinePrimitive) { return luabind::class_("LinePrimitive") .def(luabind::constructor()); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaBindingRegisterFunctionDefinitionForType(PrimitiveLuaBindings, ArcPrimitive) { return luabind::class_("ArcPrimitive") .def(luabind::constructor()); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaBindingRegisterFunctionDefinitionForType(PrimitiveLuaBindings, SplinePrimitive) { return luabind::class_("SplinePrimitive") .def(luabind::constructor()); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaBindingRegisterFunctionDefinitionForType(PrimitiveLuaBindings, BoxPrimitive) { return luabind::class_("BoxPrimitive") .def(luabind::constructor()); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaBindingRegisterFunctionDefinitionForType(PrimitiveLuaBindings, BoxFillPrimitive) { return luabind::class_("BoxFillPrimitive") .def(luabind::constructor()); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaBindingRegisterFunctionDefinitionForType(PrimitiveLuaBindings, RoundedBoxPrimitive) { return luabind::class_("RoundedBoxPrimitive") .def(luabind::constructor()); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaBindingRegisterFunctionDefinitionForType(PrimitiveLuaBindings, RoundedBoxFillPrimitive) { return luabind::class_("RoundedBoxFillPrimitive") .def(luabind::constructor()); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaBindingRegisterFunctionDefinitionForType(PrimitiveLuaBindings, CirclePrimitive) { return luabind::class_("CirclePrimitive") .def(luabind::constructor()); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaBindingRegisterFunctionDefinitionForType(PrimitiveLuaBindings, CircleFillPrimitive) { return luabind::class_("CircleFillPrimitive") .def(luabind::constructor()); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaBindingRegisterFunctionDefinitionForType(PrimitiveLuaBindings, EllipsePrimitive) { return luabind::class_("EllipsePrimitive") .def(luabind::constructor()); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaBindingRegisterFunctionDefinitionForType(PrimitiveLuaBindings, EllipseFillPrimitive) { return luabind::class_("EllipseFillPrimitive") .def(luabind::constructor()); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaBindingRegisterFunctionDefinitionForType(PrimitiveLuaBindings, TrianglePrimitive) { return luabind::class_("TrianglePrimitive") .def(luabind::constructor()); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaBindingRegisterFunctionDefinitionForType(PrimitiveLuaBindings, TriangleFillPrimitive) { return luabind::class_("TriangleFillPrimitive") .def(luabind::constructor()); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaBindingRegisterFunctionDefinitionForType(PrimitiveLuaBindings, TextPrimitive) { return luabind::class_("TextPrimitive") .def(luabind::constructor()); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaBindingRegisterFunctionDefinitionForType(PrimitiveLuaBindings, BitmapPrimitive) { return luabind::class_("BitmapPrimitive") diff --git a/Source/Lua/LuaBindingsSystem.cpp b/Source/Lua/LuaBindingsSystem.cpp index 2e964d7999..e63e8393c9 100644 --- a/Source/Lua/LuaBindingsSystem.cpp +++ b/Source/Lua/LuaBindingsSystem.cpp @@ -4,8 +4,6 @@ namespace RTE { - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaBindingRegisterFunctionDefinitionForType(SystemLuaBindings, Box) { return luabind::class_("Box") @@ -34,8 +32,6 @@ namespace RTE { .def("IntersectsBox", &Box::IntersectsBox); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaBindingRegisterFunctionDefinitionForType(SystemLuaBindings, Controller) { return luabind::class_("Controller") @@ -112,8 +108,6 @@ namespace RTE { luabind::value("CIM_INPUTMODECOUNT", Controller::InputMode::CIM_INPUTMODECOUNT)]; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaBindingRegisterFunctionDefinitionForType(SystemLuaBindings, DataModule) { return luabind::class_("DataModule") @@ -128,8 +122,6 @@ namespace RTE { .def_readwrite("Presets", &DataModule::m_EntityList, luabind::return_stl_iterator); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaBindingRegisterFunctionDefinitionForType(SystemLuaBindings, Timer) { return luabind::class_("Timer") @@ -167,8 +159,6 @@ namespace RTE { .def("AlternateSim", &Timer::AlternateSim); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaBindingRegisterFunctionDefinitionForType(SystemLuaBindings, Vector) { return luabind::class_("Vector") @@ -231,8 +221,6 @@ namespace RTE { .def("SetXY", &Vector::SetXY); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaBindingRegisterFunctionDefinitionForType(SystemLuaBindings, PathRequest) { using namespace micropather; return luabind::class_("PathRequest") diff --git a/Source/Lua/LuabindDefinitions.h b/Source/Lua/LuabindDefinitions.h index c28be35b21..ee0dcb6481 100644 --- a/Source/Lua/LuabindDefinitions.h +++ b/Source/Lua/LuabindDefinitions.h @@ -4,7 +4,7 @@ #define BOOST_BIND_GLOBAL_PLACEHOLDERS 1 // Todo - figure out luabind error callbacks and blah-de-blah -//#define LUABIND_NO_EXCEPTIONS +// #define LUABIND_NO_EXCEPTIONS #include "lua.hpp" #include "luabind.hpp" @@ -17,27 +17,21 @@ #include "luabind/return_reference_to_policy.hpp" namespace luabind { - /// /// Function that extracts the raw pointer from the smart pointer. This is needed when Lua calls member functions on held types, the 'this' pointer must be a raw pointer, it is also needed to allow the smart_pointer to raw_pointer conversion from Lua to C++. - /// - /// The smart pointer to get raw pointer for. - /// Raw pointer of the passed in smart pointer. + /// @param ptr The smart pointer to get raw pointer for. + /// @return Raw pointer of the passed in smart pointer. template Type* get_pointer(boost::shared_ptr& ptr) { return ptr.get(); } - /// /// Can't have global enums in the master state so we use this dummy struct as a class and register the enums under it. - /// struct enum_wrapper {}; } // namespace luabind namespace RTE { - /// /// Derived structs for each of the input enums because we can't register enum_wrapper multiple times under a different name. /// We're doing this so we can access each enum separately by name rather than having all of them accessed from a shared name. /// If this proves to be a hassle then we can easily revert to the shared name access by registering everything under enum_wrapper. - /// struct input_device : public luabind::enum_wrapper {}; struct input_elements : public luabind::enum_wrapper {}; struct mouse_buttons : public luabind::enum_wrapper {}; @@ -50,11 +44,9 @@ namespace RTE { struct directions : public luabind::enum_wrapper {}; struct blend_modes : public luabind::enum_wrapper {}; - /// /// Special callback function for adding file name and line number to error messages when calling functions incorrectly. - /// - /// The Lua master state. - /// An error signal, 1, so Lua correctly reports that there's been an error. + /// @param luaState The Lua master state. + /// @return An error signal, 1, so Lua correctly reports that there's been an error. static int AddFileAndLineToError(lua_State* luaState) { lua_Debug luaDebug; if (lua_getstack(luaState, 2, &luaDebug) > 0) { @@ -73,12 +65,10 @@ namespace RTE { return 1; } - /// /// Converts a Lua table to a C++ vector of the specified type. Ownership of the objects in the Lua table is transferred! - /// - /// The Lua table object to convert to vector. - /// A C++ vector containing all the objects from the Lua table. Ownership is transferred! - /// In case of type mismatch (by specifying wrong type or a mix of types in the Lua table) object_cast will print an error to the console and throw, so no need to check what it returns before emplacing. + /// @param luaTable The Lua table object to convert to vector. + /// @return A C++ vector containing all the objects from the Lua table. Ownership is transferred! + /// @remark In case of type mismatch (by specifying wrong type or a mix of types in the Lua table) object_cast will print an error to the console and throw, so no need to check what it returns before emplacing. template static std::vector ConvertLuaTableToVectorOfType(const luabind::object& luaObject) { std::vector outVector = {}; if (luaObject.is_valid() && luabind::type(luaObject) == LUA_TTABLE) { diff --git a/Source/Lua/LuabindObjectWrapper.cpp b/Source/Lua/LuabindObjectWrapper.cpp index e02a9e9b7f..1e295fec02 100644 --- a/Source/Lua/LuabindObjectWrapper.cpp +++ b/Source/Lua/LuabindObjectWrapper.cpp @@ -16,8 +16,6 @@ namespace RTE { // This is because we may assign an object to another state in a singlethreaded context, before the GC runs in the multithreaded context static std::vector s_QueuedDeletions; - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void LuabindObjectWrapper::ApplyQueuedDeletions() { for (luabind::adl::object* obj: s_QueuedDeletions) { delete obj; @@ -26,8 +24,6 @@ namespace RTE { s_QueuedDeletions.clear(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuabindObjectWrapper::~LuabindObjectWrapper() { if (m_OwnsObject) { static std::mutex mut; @@ -36,8 +32,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - luabind::adl::object GetCopyForStateInternal(const luabind::adl::object& obj, lua_State& targetState) { if (obj.is_valid()) { int type = luabind::type(obj); @@ -68,8 +62,6 @@ namespace RTE { return luabind::adl::object(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuabindObjectWrapper LuabindObjectWrapper::GetCopyForState(lua_State& targetState) const { luabind::adl::object* copy = new luabind::adl::object(GetCopyForStateInternal(*m_LuabindObject, targetState)); return LuabindObjectWrapper(copy, m_FilePath, true); diff --git a/Source/Lua/LuabindObjectWrapper.h b/Source/Lua/LuabindObjectWrapper.h index 50f4861c40..46a956bf89 100644 --- a/Source/Lua/LuabindObjectWrapper.h +++ b/Source/Lua/LuabindObjectWrapper.h @@ -21,21 +21,15 @@ namespace RTE { } #pragma endregion - /// /// A wrapper for luabind objects, to avoid include problems with luabind. - /// class LuabindObjectWrapper { public: #pragma region Creation - /// /// Constructor method used for LuabindObjectWrapper. - /// LuabindObjectWrapper() = default; - /// /// Constructor method used to instantiate a LuabindObjectWrapper object in system memory. - /// explicit LuabindObjectWrapper(luabind::adl::object* luabindObject, const std::string_view& filePath, bool ownsObject = true) : m_LuabindObject(luabindObject), m_FilePath(filePath), m_OwnsObject(ownsObject) {} #pragma endregion @@ -43,28 +37,20 @@ namespace RTE { #pragma region Destruction static void ApplyQueuedDeletions(); - /// /// Destructor method used to clean up a LuabindObjectWrapper object before deletion from system memory. - /// ~LuabindObjectWrapper(); #pragma endregion - /// /// Attempts to copy a luabind object into another state. - /// LuabindObjectWrapper GetCopyForState(lua_State& newState) const; #pragma region Getters - /// /// Gets the LuabindObjectWrapper's luabind object. Ownership is NOT transferred! - /// - /// The LuabindObjectWrapper's luabind object. + /// @return The LuabindObjectWrapper's luabind object. luabind::adl::object* GetLuabindObject() const { return m_LuabindObject; } - /// /// Gets the LuabindObjectWrapper's file path. - /// - /// The LuabindObjectWrapper's file path. + /// @return The LuabindObjectWrapper's file path. const std::string& GetFilePath() const { return m_FilePath; } #pragma endregion diff --git a/Source/Main.cpp b/Source/Main.cpp index 27b9ff540b..0bc536ff5f 100644 --- a/Source/Main.cpp +++ b/Source/Main.cpp @@ -58,8 +58,6 @@ using namespace RTE; namespace RTE { - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - /// /// Initializes all the essential managers. /// @@ -118,8 +116,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - /// /// Destroys all the managers and frees all loaded data before termination. /// @@ -148,8 +144,6 @@ namespace RTE { #endif } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - /// /// Command-line argument handling. /// @@ -201,8 +195,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - /// /// Polls the SDL event queue and passes events to be handled by the relevant managers. /// @@ -243,8 +235,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - /// /// Game menus loop. /// @@ -282,8 +272,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - /// /// Game simulation loop. /// @@ -416,8 +404,6 @@ namespace RTE { } } // namespace RTE -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - /// /// Self-invoking lambda that installs exception handlers before Main is executed. /// @@ -426,8 +412,6 @@ static const bool RTESetExceptionHandlers = []() { return true; }(); -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - /// /// Implementation of the main function. /// diff --git a/Source/Managers/ActivityMan.cpp b/Source/Managers/ActivityMan.cpp index 5d6f3399c1..8412ad6173 100644 --- a/Source/Managers/ActivityMan.cpp +++ b/Source/Managers/ActivityMan.cpp @@ -29,8 +29,6 @@ namespace RTE { - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ActivityMan::Clear() { m_DefaultActivityType = "GATutorial"; m_DefaultActivityName = "Tutorial Mission"; @@ -48,8 +46,6 @@ namespace RTE { m_LaunchIntoEditor = false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool ActivityMan::Initialize() { if (g_NetworkServer.IsServerModeEnabled()) { return SetStartMultiplayerServerOverview(); @@ -63,16 +59,12 @@ namespace RTE { return false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool ActivityMan::ForceAbortSave() { // Just a utility function we can call in the debugger quickwatch window to force an abort save to occur (great for force-saving the game when it crashes) // Throw ActivityMan::Instance().ForceAbortSave() into a quickwatch window and evaluate :) return SaveCurrentGame("AbortSave"); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool ActivityMan::SaveCurrentGame(const std::string& fileName) { m_SaveGameTask.wait(); m_SaveGameTask = BS::multi_future(); @@ -142,8 +134,6 @@ namespace RTE { return true; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool ActivityMan::LoadAndLaunchGame(const std::string& fileName) { m_SaveGameTask.wait(); @@ -191,15 +181,11 @@ namespace RTE { return true; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ActivityMan::SetStartActivity(Activity* newActivity) { RTEAssert(newActivity, "Trying to replace an activity with a null one!"); m_StartActivity.reset(newActivity); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ActivityMan::SetStartTutorialActivity() { SetStartActivity(dynamic_cast(g_PresetMan.GetEntityPreset("GATutorial", "Tutorial Mission")->Clone())); if (GameActivity* gameActivity = dynamic_cast(GetStartActivity())) { @@ -208,8 +194,6 @@ namespace RTE { g_SceneMan.SetSceneToLoad("Tutorial Bunker"); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ActivityMan::SetStartEditorActivity(const std::string_view& editorToLaunch) { std::unique_ptr editorActivityToStart = nullptr; @@ -238,8 +222,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool ActivityMan::SetStartEditorActivitySetToLaunchInto() { std::array validEditorNames = {"ActorEditor", "GibEditor", "SceneEditor", "AreaEditor", "AssemblyEditor"}; @@ -257,8 +239,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool ActivityMan::SetStartMultiplayerActivity() { if (std::unique_ptr multiplayerGame = std::make_unique()) { if (g_MetaMan.GameInProgress()) { @@ -273,8 +253,6 @@ namespace RTE { return false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool ActivityMan::SetStartMultiplayerServerOverview() { g_NetworkServer.Start(); @@ -297,8 +275,6 @@ namespace RTE { return false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int ActivityMan::StartActivity(Activity* activity) { RTEAssert(activity, "Trying to start a null activity!"); @@ -343,8 +319,6 @@ namespace RTE { return error; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int ActivityMan::StartActivity(const std::string& className, const std::string& presetName) { if (const Entity* entity = g_PresetMan.GetEntityPreset(className, presetName)) { Activity* newActivity = dynamic_cast(entity->Clone()); @@ -363,8 +337,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ActivityMan::PauseActivity(bool pause, bool skipPauseMenu) { if (!m_Activity) { g_ConsoleMan.PrintString("ERROR: No Activity to pause!"); @@ -398,8 +370,6 @@ namespace RTE { g_ConsoleMan.PrintString("SYSTEM: Activity \"" + m_Activity->GetPresetName() + "\" was " + (pause ? "paused" : "resumed")); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ActivityMan::ResumeActivity() { if (GetActivity()->GetActivityState() != Activity::NotStarted) { m_InActivity = true; @@ -411,8 +381,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool ActivityMan::RestartActivity() { m_ActivityNeedsRestart = false; g_ConsoleMan.PrintString("SYSTEM: Activity was reset!"); @@ -445,8 +413,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ActivityMan::EndActivity() const { // TODO: Set the activity pointer to nullptr so it doesn't return junk after being destructed. Do it here, or wherever works without crashing. if (m_Activity) { @@ -460,16 +426,12 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ActivityMan::LateUpdateGlobalScripts() const { if (GAScripted* scriptedActivity = dynamic_cast(m_Activity.get())) { scriptedActivity->UpdateGlobalScripts(true); } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ActivityMan::Update() { g_PerformanceMan.StartPerformanceMeasurement(PerformanceMan::ActivityUpdate); if (m_Activity) { diff --git a/Source/Managers/ActivityMan.h b/Source/Managers/ActivityMan.h index a6aabc3d0c..2351fbad9f 100644 --- a/Source/Managers/ActivityMan.h +++ b/Source/Managers/ActivityMan.h @@ -10,150 +10,104 @@ namespace RTE { - /// /// The singleton manager of the Activities and rules of Cortex Command. - /// class ActivityMan : public Singleton { friend class SettingsMan; public: #pragma region Creation - /// /// Constructor method used to instantiate an ActivityMan object in system memory. Create() should be called before using the object. - /// ActivityMan() { Clear(); } - /// /// Makes the ActivityMan object ready for use. - /// - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. bool Initialize(); #pragma endregion #pragma region Destruction - /// /// Destructor method used to clean up an ActivityMan object before deletion from system memory. - /// ~ActivityMan() { Destroy(); } - /// /// Destroys and resets (through Clear()) the ActivityMan object. - /// void Destroy() { Clear(); } #pragma endregion #pragma region Getters and Setters - /// /// Gets the currently active Activity. Won't be what has been set by SetStartActivity unless RestartActivity has been called since. - /// - /// The currently active Activity. Will be nullptr if no Activity is going. + /// @return The currently active Activity. Will be nullptr if no Activity is going. Activity* GetActivity() const { return m_Activity.get(); } - /// /// Gets the async save game task. - /// - /// The savegame task. + /// @return The savegame task. BS::multi_future& GetSaveGameTask() { return m_SaveGameTask; } - /// /// Indicates whether the game is currently running or not (not editing, over or paused). - /// - /// Whether the game is running or not. + /// @return Whether the game is running or not. bool ActivityRunning() const { return m_Activity && m_Activity->IsRunning(); } - /// /// Indicates whether the game is currently paused or not. - /// - /// Whether the game is paused or not. + /// @return Whether the game is paused or not. bool ActivityPaused() const { return !m_Activity || m_Activity->IsPaused(); } - /// /// Gets whether we are currently in game (as in, not in the main menu or any other out-of-game menus), regardless of its state. - /// - /// Whether we are currently in game, regardless of it's state. + /// @return Whether we are currently in game, regardless of it's state. bool IsInActivity() const { return m_InActivity; } - /// /// Sets whether we are currently in game (as in, not in the main menu or any other out-of-game menus) or not. - /// - /// In game or not. + /// @param isInActivity In game or not. void SetInActivity(bool isInActivity) { m_InActivity = isInActivity; } - /// /// Gets whether the current Activity needs to be restarted. - /// - /// Whether the current Activity needs to be restarted. + /// @return Whether the current Activity needs to be restarted. bool ActivitySetToRestart() const { return m_ActivityNeedsRestart; } - /// /// Sets whether the current Activity needs to be restarted. - /// - /// Restart the Activity or not. + /// @param restartActivity Restart the Activity or not. void SetRestartActivity(bool restartActivity = true) { m_ActivityNeedsRestart = restartActivity; } - /// /// Gets whether the game simulation needs to be started back up after the current Activity was unpaused. - /// - /// Whether the game simulation needs to be started back up after the current Activity was unpaused. + /// @return Whether the game simulation needs to be started back up after the current Activity was unpaused. bool ActivitySetToResume() const { return m_ActivityNeedsResume; } - /// /// Sets the game simulation to be started back up after the current Activity was unpaused. - /// - /// Whether the game simulation is being resumed from the pause menu. + /// @param resumingFromPauseMenu Whether the game simulation is being resumed from the pause menu. void SetResumeActivity(bool resumingFromPauseMenu = false) { m_ActivityNeedsResume = true; m_ResumingActivityFromPauseMenu = resumingFromPauseMenu; } - /// /// Gets whether the pause menu should be skipped when the game simulation is paused. - /// - /// Whether the pause menu should be skipped when the game simulation is paused. + /// @return Whether the pause menu should be skipped when the game simulation is paused. bool SkipPauseMenuWhenPausingActivity() const { return m_SkipPauseMenuWhenPausingActivity; } #pragma endregion #pragma region Default Activity Handling - /// /// Gets the type name of the default Activity to be loaded if nothing else is available. - /// - /// The default Activity type name. + /// @return The default Activity type name. std::string GetDefaultActivityType() const { return m_DefaultActivityType; } - /// /// Sets the type name of the default Activity to be loaded if nothing else is available. - /// - /// The default Activity type name. + /// @param defaultActivityType The default Activity type name. void SetDefaultActivityType(const std::string_view& defaultActivityType) { m_DefaultActivityType = defaultActivityType; } - /// /// Gets the name of the default Activity to be loaded if nothing else is available. - /// - /// The default Activity preset name. + /// @return The default Activity preset name. std::string GetDefaultActivityName() const { return m_DefaultActivityName; } - /// /// Sets the preset name of the default Activity to be loaded if nothing else is available. - /// - /// The default Activity preset name. + /// @param defaultActivityName The default Activity preset name. void SetDefaultActivityName(const std::string_view& defaultActivityName) { m_DefaultActivityName = defaultActivityName; } - /// /// Gets whether the intro and main menu should be skipped on game start and launch directly into the set default Activity instead. - /// - /// Whether the game is set to launch directly into the set default Activity or not. + /// @return Whether the game is set to launch directly into the set default Activity or not. bool IsSetToLaunchIntoActivity() const { return m_LaunchIntoActivity; } - /// /// Gets whether the intro and main menu should be skipped on game start and launch directly into the set editor Activity instead. - /// - /// Whether the game is set to launch directly into the set editor Activity or not. + /// @return Whether the game is set to launch directly into the set editor Activity or not. bool IsSetToLaunchIntoEditor() const { return m_LaunchIntoEditor; } - /// /// Sets the name of the editor to launch directly into. - /// - /// + /// @param editorName void SetEditorToLaunch(const std::string_view& editorName) { if (!editorName.empty()) { m_EditorToLaunch = editorName; @@ -163,119 +117,83 @@ namespace RTE { #pragma endregion #pragma region Saving and Loading - /// /// A utility function we can call in the debugger quickwatch window to force an abort save to occur (great for force-saving the game when it crashes) - /// - /// Whether the game was successfully saved. + /// @return Whether the game was successfully saved. bool ForceAbortSave(); - /// /// Saves the currently running Scene and Activity to a savegame file. Note this only works for GAScripted activities. - /// - /// Path to the file. - /// Whether the game was successfully saved. + /// @param fileName Path to the file. + /// @return Whether the game was successfully saved. bool SaveCurrentGame(const std::string& fileName); - /// /// Loads a saved game, and launches its Scene and Activity. - /// - /// Path to the file. - /// Whether or not the saved game was successfully loaded. + /// @param fileName Path to the file. + /// @return Whether or not the saved game was successfully loaded. bool LoadAndLaunchGame(const std::string& fileName); #pragma endregion #pragma region Activity Start Handling // TODO: Fix crappy naming. None of these actually start anything. Maybe "...ActivityToStart" instead of "...StartActivity". - /// /// Gets the Activity that will be used in the next restart. Ownership is NOT transferred! - /// - /// The Activity to put into effect next time ResetActivity is called. + /// @return The Activity to put into effect next time ResetActivity is called. Activity* GetStartActivity() const { return m_StartActivity.get(); } - /// /// Sets a new Activity to copy for next restart. You have to use RestartActivity to get it going. Ownership IS transferred! - /// - /// The new Activity to put into effect next time ResetActivity is called. + /// @param newActivity The new Activity to put into effect next time ResetActivity is called. void SetStartActivity(Activity* newActivity); - /// /// Loads the "Tutorial Mission" Scene and starts the Tutorial Activity. - /// void SetStartTutorialActivity(); - /// /// Loads "Editor Scene" and starts the given editor Activity. - /// - /// The editor name to put into effect next time ResetActivity is called. + /// @param editorToLaunch The editor name to put into effect next time ResetActivity is called. void SetStartEditorActivity(const std::string_view& editorToLaunch); - /// /// Launch editor Activity specified in command-line argument. - /// - /// Whether a valid editor name was passed in and set to be launched next time ResetActivity is called. + /// @return Whether a valid editor name was passed in and set to be launched next time ResetActivity is called. bool SetStartEditorActivitySetToLaunchInto(); - /// /// Loads "Multiplayer Scene" and starts the MultiplayerGame Activity. - /// - /// Whether the MultiplayerGame Activity was successfully created and set to be launched next time ResetActivity is called. + /// @return Whether the MultiplayerGame Activity was successfully created and set to be launched next time ResetActivity is called. bool SetStartMultiplayerActivity(); - /// /// Launch multiplayer server overview Activity. - /// - /// Whether the server overview Activity was successfully created and set to be launched next time ResetActivity is called. + /// @return Whether the server overview Activity was successfully created and set to be launched next time ResetActivity is called. bool SetStartMultiplayerServerOverview(); #pragma endregion #pragma region Concrete Methods - /// /// Officially starts the Activity passed in. Ownership IS transferred! - /// - /// The new activity to start. - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @param activity The new activity to start. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal.@return int StartActivity(Activity* activity); - /// /// Officially gets and starts the Activity described. - /// - /// The class name of the Activity to start. - /// The PresetName of the Activity to start. - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @param className The class name of the Activity to start. + /// @param presetName The PresetName of the Activity to start. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int StartActivity(const std::string& className, const std::string& presetName); - /// /// Pauses/unpauses the game and saving/resuming in-game music if possible, or queuing default music if not. - /// - /// Whether to pause the game or not. - /// Whether the pause menu should be skipped when the game simulation is paused. + /// @param pause Whether to pause the game or not. + /// @param skipPauseMenu Whether the pause menu should be skipped when the game simulation is paused. void PauseActivity(bool pause = true, bool skipPauseMenu = false); - /// /// Start the game simulation back up after the current Activity was unpaused. - /// void ResumeActivity(); - /// /// Completely restarts whatever Activity was last started. - /// - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. bool RestartActivity(); - /// /// Forces the current game's end. - /// void EndActivity() const; - /// /// Only updates Global Scripts of the current activity with LateUpdate flag enabled. - /// void LateUpdateGlobalScripts() const; - /// /// Updates the state of this and the current Activity. Supposed to be done every frame before drawing. - /// void Update(); #pragma endregion @@ -301,9 +219,7 @@ namespace RTE { bool m_LaunchIntoEditor; //!< Whether to skip the intro and main menu and launch directly into the set editor Activity instead. std::string_view m_EditorToLaunch; //!< The name of the editor Activity to launch directly into. - /// /// Clears all the member variables of this ActivityMan, effectively resetting the members of this abstraction level only. - /// void Clear(); // Disallow the use of some implicit methods. diff --git a/Source/Managers/AudioMan.cpp b/Source/Managers/AudioMan.cpp index 28b26cf31b..f184cd1c45 100644 --- a/Source/Managers/AudioMan.cpp +++ b/Source/Managers/AudioMan.cpp @@ -12,8 +12,6 @@ namespace RTE { - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void AudioMan::Clear() { m_AudioEnabled = false; m_CurrentActivityHumanPlayerPositions.clear(); @@ -47,8 +45,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool AudioMan::Initialize() { FMOD_RESULT audioSystemSetupResult = FMOD::System_Create(&m_AudioSystem); @@ -113,8 +109,6 @@ namespace RTE { return true; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void AudioMan::Destroy() { if (m_AudioEnabled) { StopAll(); @@ -123,8 +117,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void AudioMan::Update() { if (m_AudioEnabled) { @@ -191,8 +183,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void AudioMan::SetGlobalPitch(float pitch, bool includeImmobileSounds, bool includeMusic) { if (!m_AudioEnabled) { return; @@ -209,8 +199,6 @@ namespace RTE { m_SFXChannelGroup->setPitch(m_GlobalPitch); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void AudioMan::SetTempMusicVolume(float volume) { if (m_AudioEnabled && IsMusicPlaying()) { FMOD::Channel* musicChannel; @@ -223,8 +211,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool AudioMan::SetMusicPitch(float pitch) { if (!m_AudioEnabled) { return false; @@ -244,8 +230,6 @@ namespace RTE { return true; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - float AudioMan::GetMusicPosition() const { if (m_AudioEnabled && IsMusicPlaying()) { FMOD_RESULT result; @@ -263,8 +247,6 @@ namespace RTE { return 0.0F; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void AudioMan::SetMusicPosition(float position) { if (m_AudioEnabled && IsMusicPlaying()) { FMOD::Channel* musicChannel; @@ -284,8 +266,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void AudioMan::FinishIngameLoopingSounds() { if (m_AudioEnabled) { int numberOfPlayingChannels; @@ -308,8 +288,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void AudioMan::PlayMusic(const char* filePath, int loops, float volumeOverrideIfNotMuted) { if (m_AudioEnabled) { const std::string fullFilePath = g_PresetMan.GetFullModulePath(filePath); @@ -380,8 +358,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void AudioMan::PlayNextStream() { if (m_AudioEnabled && !m_MusicPlayList.empty()) { std::string nextString = m_MusicPlayList.front(); @@ -413,8 +389,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void AudioMan::StopMusic() { if (m_AudioEnabled) { if (m_IsInMultiplayerMode) { @@ -429,8 +403,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void AudioMan::QueueMusicStream(const char* filepath) { if (m_AudioEnabled) { bool isPlaying; @@ -446,8 +418,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - SoundContainer* AudioMan::PlaySound(const std::string& filePath, const Vector& position, int player) { if (m_IsInMultiplayerMode) { return nullptr; @@ -462,8 +432,6 @@ namespace RTE { return newSoundContainer; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void AudioMan::GetMusicEvents(int player, std::list& list) { if (player < 0 || player >= c_MaxClients) { return; @@ -478,8 +446,6 @@ namespace RTE { g_SoundEventsListMutex[player].unlock(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void AudioMan::RegisterMusicEvent(int player, NetworkMusicState state, const char* filepath, int loopsOrSilence, float position, float pitch) { if (player == -1) { for (int i = 0; i < c_MaxClients; i++) { @@ -502,8 +468,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void AudioMan::ClearMusicEvents(int player) { if (player == -1 || player >= c_MaxClients) { for (int i = 0; i < c_MaxClients; i++) { @@ -516,8 +480,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void AudioMan::GetSoundEvents(int player, std::list& list) { if (player < 0 || player >= c_MaxClients) { return; @@ -540,8 +502,6 @@ namespace RTE { g_SoundEventsListMutex[player].unlock(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void AudioMan::RegisterSoundEvent(int player, NetworkSoundState state, const SoundContainer* soundContainer, int fadeoutTime) { if (player == -1) { for (int i = 0; i < c_MaxClients; i++) { @@ -590,8 +550,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void AudioMan::ClearSoundEvents(int player) { if (player == -1 || player >= c_MaxClients) { for (int i = 0; i < c_MaxClients; i++) { @@ -604,8 +562,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool AudioMan::PlaySoundContainer(SoundContainer* soundContainer, int player) { if (!m_AudioEnabled || !soundContainer || soundContainer->GetPlayingChannels()->size() >= c_MaxPlayingSoundsPerContainer) { return false; @@ -699,8 +655,6 @@ namespace RTE { return true; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool AudioMan::ChangeSoundContainerPlayingChannelsPosition(const SoundContainer* soundContainer) { if (!m_AudioEnabled || !soundContainer) { return false; @@ -728,8 +682,6 @@ namespace RTE { return result == FMOD_OK; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool AudioMan::ChangeSoundContainerPlayingChannelsVolume(const SoundContainer* soundContainer, float newVolume) { if (!m_AudioEnabled || !soundContainer || !soundContainer->IsBeingPlayed()) { return false; @@ -762,8 +714,6 @@ namespace RTE { return result == FMOD_OK; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool AudioMan::ChangeSoundContainerPlayingChannelsPitch(const SoundContainer* soundContainer) { if (!m_AudioEnabled || !soundContainer || !soundContainer->IsBeingPlayed()) { return false; @@ -786,8 +736,6 @@ namespace RTE { return result == FMOD_OK; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool AudioMan::ChangeSoundContainerPlayingChannelsCustomPanValue(const SoundContainer* soundContainer) { if (!m_AudioEnabled || !soundContainer || !soundContainer->IsBeingPlayed()) { return false; @@ -810,8 +758,6 @@ namespace RTE { return result == FMOD_OK; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool AudioMan::StopSoundContainerPlayingChannels(SoundContainer* soundContainer, int player) { if (!m_AudioEnabled || !soundContainer || !soundContainer->IsBeingPlayed()) { return false; @@ -835,8 +781,6 @@ namespace RTE { return result == FMOD_OK; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void AudioMan::FadeOutSoundContainerPlayingChannels(SoundContainer* soundContainer, int fadeOutTime) { if (!m_AudioEnabled || !soundContainer || !soundContainer->IsBeingPlayed()) { return; @@ -868,8 +812,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void AudioMan::Update3DEffectsForSFXChannels() { int numberOfPlayingChannels; FMOD::Channel* soundChannel; @@ -914,8 +856,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - FMOD_RESULT AudioMan::UpdatePositionalEffectsForSoundChannel(FMOD::Channel* soundChannel, const FMOD_VECTOR* positionOverride) const { FMOD_RESULT result = FMOD_OK; @@ -1004,8 +944,6 @@ namespace RTE { return result; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - FMOD_RESULT F_CALLBACK AudioMan::MusicChannelEndedCallback(FMOD_CHANNELCONTROL* channelControl, FMOD_CHANNELCONTROL_TYPE channelControlType, FMOD_CHANNELCONTROL_CALLBACK_TYPE callbackType, void* unusedCommandData1, void* unusedCommandData2) { if (channelControlType == FMOD_CHANNELCONTROL_CHANNEL && callbackType == FMOD_CHANNELCONTROL_CALLBACK_END) { void* userData; @@ -1017,8 +955,6 @@ namespace RTE { return FMOD_OK; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - FMOD_RESULT F_CALLBACK AudioMan::SoundChannelEndedCallback(FMOD_CHANNELCONTROL* channelControl, FMOD_CHANNELCONTROL_TYPE channelControlType, FMOD_CHANNELCONTROL_CALLBACK_TYPE callbackType, void* unusedCommandData1, void* unusedCommandData2) { if (channelControlType == FMOD_CHANNELCONTROL_CHANNEL && callbackType == FMOD_CHANNELCONTROL_CALLBACK_END) { FMOD::Channel* channel = reinterpret_cast(channelControl); @@ -1050,15 +986,11 @@ namespace RTE { return FMOD_OK; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - FMOD_VECTOR AudioMan::GetAsFMODVector(const Vector& vector, float zValue) const { Vector sceneDimensions = g_SceneMan.GetScene() ? g_SceneMan.GetSceneDim() : Vector(); return sceneDimensions.IsZero() ? FMOD_VECTOR{0, 0, zValue} : FMOD_VECTOR{vector.m_X, sceneDimensions.m_Y - vector.m_Y, zValue}; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - Vector AudioMan::GetAsVector(FMOD_VECTOR fmodVector) const { Vector sceneDimensions = g_SceneMan.GetScene() ? g_SceneMan.GetSceneDim() : Vector(); return sceneDimensions.IsZero() ? Vector() : Vector(fmodVector.x, sceneDimensions.m_Y - fmodVector.y); diff --git a/Source/Managers/AudioMan.h b/Source/Managers/AudioMan.h index d112319832..b7daea2502 100644 --- a/Source/Managers/AudioMan.h +++ b/Source/Managers/AudioMan.h @@ -16,26 +16,20 @@ namespace RTE { class SoundContainer; - /// /// The singleton manager of sound effect and music playback. - /// class AudioMan : public Singleton { friend class SettingsMan; friend class SoundContainer; public: - /// /// Hardcoded playback priorities for sounds. Note that sounds don't have to use these specifically; their priority can be anywhere between high and low. - /// enum PlaybackPriority { PRIORITY_HIGH = 0, PRIORITY_NORMAL = 128, PRIORITY_LOW = 256 }; - /// /// Music event states for sending music data from the server to clients during multiplayer games. - /// enum NetworkMusicState { MUSIC_PLAY = 0, MUSIC_STOP, @@ -43,9 +37,7 @@ namespace RTE { MUSIC_SET_PITCH }; - /// /// The data struct used to send music data from the server to clients during multiplayer games. - /// struct NetworkMusicData { unsigned char State; char Path[256]; @@ -54,9 +46,7 @@ namespace RTE { float Pitch; }; - /// /// Sound event states for sending sound data from the server to clients during multiplayer games. - /// enum NetworkSoundState { SOUND_SET_GLOBAL_PITCH = 0, SOUND_PLAY, @@ -69,9 +59,7 @@ namespace RTE { SOUND_FADE_OUT }; - /// /// The data struct used to send sound data from the server to clients during multiplayer games. - /// struct NetworkSoundData { unsigned char State; std::size_t SoundFileHash; @@ -90,84 +78,60 @@ namespace RTE { }; #pragma region Creation - /// /// Constructor method used to instantiate a AudioMan object in system memory. /// Create() should be called before using the object. - /// AudioMan() { Clear(); } - /// /// Makes the AudioMan object ready for use. - /// - /// Whether the audio system was initialized successfully. If not, no audio will be available. + /// @return Whether the audio system was initialized successfully. If not, no audio will be available. bool Initialize(); #pragma endregion #pragma region Destruction - /// /// Destructor method used to clean up a AudioMan object before deletion from system memory. - /// ~AudioMan() { Destroy(); } - /// /// Destroys and resets (through Clear()) the AudioMan object. - /// void Destroy(); #pragma endregion #pragma region Concrete Methods - /// /// Updates the state of this AudioMan. Supposed to be done every frame before drawing. - /// void Update(); #pragma endregion #pragma region General Getters and Setters - /// /// Gets the audio management system object used for playing all audio. - /// - /// The audio management system object used by AudioMan for playing audio. + /// @return The audio management system object used by AudioMan for playing audio. FMOD::System* GetAudioSystem() const { return m_AudioSystem; } - /// /// Reports whether audio is enabled. - /// - /// Whether audio is enabled. + /// @return Whether audio is enabled. bool IsAudioEnabled() const { return m_AudioEnabled; } - /// /// Gets the virtual and real playing channel counts, filling in the passed-in out-parameters. - /// - /// The out-parameter that will hold the virtual channel count. - /// The out-parameter that will hold the real channel count. - /// Whether or not the playing channel count was succesfully gotten. + /// @param outVirtualChannelCount The out-parameter that will hold the virtual channel count. + /// @param outRealChannelCount The out-parameter that will hold the real channel count. + /// @return Whether or not the playing channel count was succesfully gotten. bool GetPlayingChannelCount(int* outVirtualChannelCount, int* outRealChannelCount) const { return m_AudioSystem->getChannelsPlaying(outVirtualChannelCount, outRealChannelCount) == FMOD_OK; } - /// /// Returns the total number of virtual audio channels available. - /// - /// The number of virtual audio channels available. + /// @return The number of virtual audio channels available. int GetTotalVirtualChannelCount() const { return c_MaxVirtualChannels; } - /// /// Returns the total number of real audio channels available. - /// - /// The number of real audio channels available. + /// @return The number of real audio channels available. int GetTotalRealChannelCount() const { int channelCount; return m_AudioSystem->getSoftwareChannels(&channelCount) == FMOD_OK ? channelCount : 0; } - /// /// Gets whether all audio is muted or not. - /// - /// Whether all the audio is muted or not. + /// @return Whether all the audio is muted or not. bool GetMasterMuted() const { return m_MuteMaster; } - /// /// Mutes or unmutes all audio. - /// - /// Whether to mute or unmute all the audio. + /// @param muteOrUnmute Whether to mute or unmute all the audio. void SetMasterMuted(bool muteOrUnmute = true) { m_MuteMaster = muteOrUnmute; if (m_AudioEnabled) { @@ -175,16 +139,12 @@ namespace RTE { } } - /// /// Gets the volume of all audio. Does not get music or sounds individual volumes. - /// - /// Current volume scalar value. 0.0-1.0. + /// @return Current volume scalar value. 0.0-1.0. float GetMasterVolume() const { return m_MasterVolume; } - /// /// Sets all the audio to a specific volume. Does not affect music or sounds individual volumes. - /// - /// The desired volume scalar. 0.0-1.0. + /// @param volume The desired volume scalar. 0.0-1.0. void SetMasterVolume(float volume = 1.0F) { m_MasterVolume = std::clamp(volume, 0.0F, 1.0F); if (m_AudioEnabled) { @@ -192,47 +152,35 @@ namespace RTE { } } - /// /// Gets the global pitch scalar value for all sounds and music. - /// - /// The current pitch scalar. Will be > 0. + /// @return The current pitch scalar. Will be > 0. float GetGlobalPitch() const { return m_GlobalPitch; } - /// /// Sets the global pitch multiplier for mobile sounds, optionally setting it for immobile sounds and music. - /// - /// New global pitch, limited to 8 octaves up or down (i.e. 0.125 - 8). Defaults to 1. - /// Whether to include immobile sounds (normally used for GUI and so on) in global pitch modification. Defaults to false. - /// Whether to include the music in global pitch modification. Defaults to false. + /// @param pitch New global pitch, limited to 8 octaves up or down (i.e. 0.125 - 8). Defaults to 1. + /// @param includeImmobileSounds Whether to include immobile sounds (normally used for GUI and so on) in global pitch modification. Defaults to false. + /// @param includeMusic Whether to include the music in global pitch modification. Defaults to false. void SetGlobalPitch(float pitch = 1.0F, bool includeImmobileSounds = false, bool includeMusic = false); - /// /// The strength of the sound panning effect. - /// - /// 0 - 1, where 0 is no panning and 1 is fully panned. + /// @return 0 - 1, where 0 is no panning and 1 is fully panned. float GetSoundPanningEffectStrength() const { return m_SoundPanningEffectStrength; } #pragma endregion #pragma region Music Getters and Setters - /// /// Reports whether any music stream is currently playing. - /// - /// Whether any music stream is currently playing. + /// @return Whether any music stream is currently playing. bool IsMusicPlaying() const { bool isPlayingMusic; return m_AudioEnabled && m_MusicChannelGroup->isPlaying(&isPlayingMusic) == FMOD_OK ? isPlayingMusic : false; } - /// /// Gets whether the music channel is muted or not. - /// - /// Whether the music channel is muted or not. + /// @return Whether the music channel is muted or not. bool GetMusicMuted() const { return m_MuteMusic; } - /// /// Mutes or unmutes the music channel. - /// - /// Whether to mute or unmute the music channel. + /// @param muteOrUnmute Whether to mute or unmute the music channel. void SetMusicMuted(bool muteOrUnmute = true) { m_MuteMusic = muteOrUnmute; if (m_AudioEnabled) { @@ -240,16 +188,12 @@ namespace RTE { } } - /// /// Gets the volume of music. Does not get volume of sounds. - /// - /// Current volume scalar value. 0.0-1.0. + /// @return Current volume scalar value. 0.0-1.0. float GetMusicVolume() const { return m_MusicVolume; } - /// /// Sets the music to a specific volume. Does not affect sounds. - /// - /// The desired volume scalar. 0.0-1.0. + /// @param volume The desired volume scalar. 0.0-1.0. void SetMusicVolume(float volume = 1.0F) { m_MusicVolume = std::clamp(volume, 0.0F, 1.0F); if (m_AudioEnabled) { @@ -257,49 +201,35 @@ namespace RTE { } } - /// /// Sets the music to a specific volume, but it will only last until a new song is played. Useful for fading etc. - /// - /// The desired volume scalar. 0.0-1.0. + /// @param volume The desired volume scalar. 0.0-1.0. void SetTempMusicVolume(float volume = 1.0F); - /// /// Gets the path of the last played music stream. - /// - /// The file path of the last played music stream. + /// @return The file path of the last played music stream. std::string GetMusicPath() const { return m_MusicPath; } - /// /// Sets/updates the frequency/pitch for the music channel. - /// - /// New pitch, a multiplier of the original normal frequency. Keep it > 0. - /// Whether the music channel's pitch was successfully updated. + /// @param pitch New pitch, a multiplier of the original normal frequency. Keep it > 0. + /// @return Whether the music channel's pitch was successfully updated. bool SetMusicPitch(float pitch); - /// /// Gets the position of playback of the current music stream, in seconds. - /// - /// The current position of the current stream playing, in seconds. + /// @return The current position of the current stream playing, in seconds. float GetMusicPosition() const; - /// /// Sets the music to a specific position in the song. - /// - /// The desired position from the start, in seconds. + /// @param position The desired position from the start, in seconds. void SetMusicPosition(float position); #pragma endregion #pragma region Overall Sound Getters and Setters - /// /// Gets whether all the sound effects channels are muted or not. - /// - /// Whether all the sound effects channels are muted or not. + /// @return Whether all the sound effects channels are muted or not. bool GetSoundsMuted() const { return m_MuteSounds; } - /// /// Mutes or unmutes all the sound effects channels. - /// - /// Whether to mute or unmute all the sound effects channels. + /// @param muteOrUnmute Whether to mute or unmute all the sound effects channels. void SetSoundsMuted(bool muteOrUnmute = true) { m_MuteSounds = muteOrUnmute; if (m_AudioEnabled) { @@ -309,16 +239,12 @@ namespace RTE { } } - /// /// Gets the volume of all sounds. Does not get volume of music. - /// - /// Current volume scalar value. 0.0-1.0. + /// @return Current volume scalar value. 0.0-1.0. float GetSoundsVolume() const { return m_SoundsVolume; } - /// /// Sets the volume of all sounds to a specific volume. Does not affect music. - /// - /// The desired volume scalar. 0.0-1.0. + /// @param volume The desired volume scalar. 0.0-1.0. void SetSoundsVolume(float volume = 1.0F) { m_SoundsVolume = volume; if (m_AudioEnabled) { @@ -329,9 +255,7 @@ namespace RTE { #pragma endregion #pragma region Global Playback and Handling - /// /// Stops all playback and clears the music playlist. - /// void StopAll() { if (m_AudioEnabled) { m_MasterChannelGroup->stop(); @@ -339,15 +263,11 @@ namespace RTE { m_MusicPlayList.clear(); } - /// /// Makes all sounds that are looping stop looping, allowing them to play once more then be finished. - /// void FinishIngameLoopingSounds(); - /// /// Pauses all ingame sounds. - /// Whether to pause sounds or resume them. - /// + /// @param pause Whether to pause sounds or resume them. void PauseIngameSounds(bool pause = true) { if (m_AudioEnabled) { m_SFXChannelGroup->setPaused(pause); @@ -356,129 +276,95 @@ namespace RTE { #pragma endregion #pragma region Music Playback and Handling - /// /// Starts playing a certain WAVE, MOD, MIDI, OGG, MP3 file in the music channel. - /// - /// The path to the music file to play. - /// The number of times to loop the song. 0 means play once. -1 means play infinitely until stopped. - /// The volume override for music for this song only, if volume is not muted. < 0 means no override. + /// @param filePath The path to the music file to play. + /// @param loops The number of times to loop the song. 0 means play once. -1 means play infinitely until stopped. + /// @param volumeOverrideIfNotMuted The volume override for music for this song only, if volume is not muted. < 0 means no override. void PlayMusic(const char* filePath, int loops = -1, float volumeOverrideIfNotMuted = -1.0F); - /// /// Plays the next music stream in the queue, if any is queued. - /// void PlayNextStream(); - /// /// Stops playing a the music channel. - /// void StopMusic(); - /// /// Queues up another path to a stream that will be played after the current one is done. /// Can be done several times to queue up many tracks. The last track in the queue will be looped infinitely. - /// - /// The path to the music file to play after the current one. + /// @param filePath The path to the music file to play after the current one. void QueueMusicStream(const char* filePath); - /// /// Queues up a period of silence in the music stream playlist. - /// - /// The number of secs to wait before going to the next stream. + /// @param seconds The number of secs to wait before going to the next stream. void QueueSilence(int seconds) { if (m_AudioEnabled && seconds > 0) { m_MusicPlayList.push_back("@" + std::to_string(seconds)); } } - /// /// Clears the music queue. - /// void ClearMusicQueue() { m_MusicPlayList.clear(); } #pragma endregion #pragma region Lua Sound File Playing - /// /// Starts playing a certain sound file. - /// - /// The path to the sound file to play. - /// The new SoundContainer being played. OWNERSHIP IS TRANSFERRED! + /// @param filePath The path to the sound file to play. + /// @return The new SoundContainer being played. OWNERSHIP IS TRANSFERRED! SoundContainer* PlaySound(const std::string& filePath) { return PlaySound(filePath, Vector(), -1); } - /// /// Starts playing a certain sound file at a certain position for all players. - /// - /// The path to the sound file to play. - /// The new SoundContainer being played. OWNERSHIP IS TRANSFERRED! + /// @param filePath The path to the sound file to play. + /// @return The new SoundContainer being played. OWNERSHIP IS TRANSFERRED! SoundContainer* PlaySound(const std::string& filePath, const Vector& position) { return PlaySound(filePath, position, -1); } - /// /// Starts playing a certain sound file at a certain position for a certain player. - /// - /// The path to the sound file to play. - /// The position at which to play the SoundContainer's sounds. - /// Which player to play the SoundContainer's sounds for, -1 means all players. - /// The new SoundContainer being played. OWNERSHIP IS TRANSFERRED! + /// @param filePath The path to the sound file to play. + /// @param position The position at which to play the SoundContainer's sounds. + /// @param player Which player to play the SoundContainer's sounds for, -1 means all players. + /// @return The new SoundContainer being played. OWNERSHIP IS TRANSFERRED! SoundContainer* PlaySound(const std::string& filePath, const Vector& position, int player); #pragma endregion #pragma region Network Audio Handling - /// /// Returns true if manager is in multiplayer mode. - /// - /// True if in multiplayer mode. + /// @return True if in multiplayer mode. bool IsInMultiplayerMode() const { return m_IsInMultiplayerMode; } - /// /// Sets the multiplayer mode flag. - /// - /// Whether this manager should operate in multiplayer mode. + /// @param value Whether this manager should operate in multiplayer mode. void SetMultiplayerMode(bool value) { m_IsInMultiplayerMode = value; } - /// /// Fills the list with music events happened for the specified network player. - /// - /// Player to get events for. - /// List with events for this player. + /// @param player Player to get events for. + /// @param list List with events for this player. void GetMusicEvents(int player, std::list& list); - /// /// Adds the music event to internal list of music events for the specified player. - /// - /// Player(s) for which the event happened. - /// NetworkMusicState for the event. - /// Music file path to transmit to client. - /// LoopsOrSilence counter or, if state is silence, the length of the silence. - /// Music playback position. - /// Pitch value. + /// @param player Player(s) for which the event happened. + /// @param state NetworkMusicState for the event. + /// @param filepath Music file path to transmit to client. + /// @param loops LoopsOrSilence counter or, if state is silence, the length of the silence. + /// @param position Music playback position. + /// @param pitch Pitch value. void RegisterMusicEvent(int player, NetworkMusicState state, const char* filepath, int loopsOrSilence = 0, float position = 0, float pitch = 1.0F); - /// /// Clears the list of current Music events for the target player. - /// - /// Player to clear music events for. -1 clears for all players + /// @param player Player to clear music events for. -1 clears for all players void ClearMusicEvents(int player); - /// /// Fills the list with sound events happened for the specified network player. - /// - /// Player to get events for. - /// List with events for this player. + /// @param player Player to get events for. + /// @param list List with events for this player. void GetSoundEvents(int player, std::list& list); - /// /// Adds the sound event to the internal list of sound events for the specified player. - /// - /// Player(s) for which the event happened. - /// NetworkSoundState for the event. - /// A pointer to the SoundContainer this event is happening to, or a null pointer for global events. - /// THe amount of time, in MS, to fade out over. This data isn't contained in SoundContainer, so it needs to be passed in separately. + /// @param player Player(s) for which the event happened. + /// @param state NetworkSoundState for the event. + /// @param soundContainer A pointer to the SoundContainer this event is happening to, or a null pointer for global events. + /// @param fadeOutTime THe amount of time, in MS, to fade out over. This data isn't contained in SoundContainer, so it needs to be passed in separately. void RegisterSoundEvent(int player, NetworkSoundState state, const SoundContainer* soundContainer, int fadeOutTime = 0); - /// /// Clears the list of current Sound events for the target player. - /// - /// Player to clear sound events for. -1 clears for all players. + /// @param player Player to clear sound events for. -1 clears for all players. void ClearSoundEvents(int player); #pragma endregion @@ -525,105 +411,77 @@ namespace RTE { private: #pragma region Sound Container Actions and Modifications - /// /// Starts playing the next SoundSet of the given SoundContainer for the give player. - /// - /// Pointer to the SoundContainer to start playing. Ownership is NOT transferred! - /// Which player to play the SoundContainer's sounds for, -1 means all players. Defaults to -1. - /// Whether or not playback of the Sound was successful. + /// @param soundContainer Pointer to the SoundContainer to start playing. Ownership is NOT transferred! + /// @param player Which player to play the SoundContainer's sounds for, -1 means all players. Defaults to -1. + /// @return Whether or not playback of the Sound was successful. bool PlaySoundContainer(SoundContainer* soundContainer, int player = -1); - /// /// Sets/updates the position of a SoundContainer's playing sounds. - /// - /// A pointer to a SoundContainer object. Ownership IS NOT transferred! - /// Whether the position was successfully set. + /// @param soundContainer A pointer to a SoundContainer object. Ownership IS NOT transferred! + /// @return Whether the position was successfully set. bool ChangeSoundContainerPlayingChannelsPosition(const SoundContainer* soundContainer); - /// /// Changes the volume of a SoundContainer's playing sounds. - /// - /// A pointer to a SoundContainer object. Ownership IS NOT transferred! - /// The new volume to play sounds at, between 0 and 1. - /// Whether the volume was successfully updated. + /// @param soundContainer A pointer to a SoundContainer object. Ownership IS NOT transferred! + /// @param newVolume The new volume to play sounds at, between 0 and 1. + /// @return Whether the volume was successfully updated. bool ChangeSoundContainerPlayingChannelsVolume(const SoundContainer* soundContainer, float newVolume); - /// /// Changes the frequency/pitch of a SoundContainer's playing sounds. - /// - /// A pointer to a SoundContainer object. Ownership IS NOT transferred! - /// Whether the pitch was successfully updated. + /// @param soundContainer A pointer to a SoundContainer object. Ownership IS NOT transferred! + /// @return Whether the pitch was successfully updated. bool ChangeSoundContainerPlayingChannelsPitch(const SoundContainer* soundContainer); - /// /// Updates the custom pan value of a SoundContainer's playing sounds. - /// - /// A pointer to a SoundContainer object. Ownership IS NOT transferred! - /// Whether the custom pan value was successfully updated. + /// @param soundContainer A pointer to a SoundContainer object. Ownership IS NOT transferred! + /// @return Whether the custom pan value was successfully updated. bool ChangeSoundContainerPlayingChannelsCustomPanValue(const SoundContainer* soundContainer); - /// /// Stops playing a SoundContainer's playing sounds for a certain player. - /// - /// A pointer to a SoundContainer object6. Ownership is NOT transferred! - /// Which player to stop playing the SoundContainer for. - /// + /// @param soundContainer A pointer to a SoundContainer object6. Ownership is NOT transferred! + /// @param player Which player to stop playing the SoundContainer for. + /// @return bool StopSoundContainerPlayingChannels(SoundContainer* soundContainer, int player); - /// /// Fades out playback a SoundContainer. - /// - /// A pointer to a SoundContainer object. Ownership is NOT transferred! - /// The amount of time, in ms, to fade out over. + /// @param soundContainer A pointer to a SoundContainer object. Ownership is NOT transferred! + /// @param fadeOutTime The amount of time, in ms, to fade out over. void FadeOutSoundContainerPlayingChannels(SoundContainer* soundContainer, int fadeOutTime); #pragma endregion #pragma region 3D Effect Handling - /// /// Updates 3D effects calculations for all sound channels whose SoundContainers isn't immobile. - /// void Update3DEffectsForSFXChannels(); - /// /// Sets or updates the position of the given sound channel so it handles scene wrapping correctly. Also handles volume attenuation and minimum audible distance. - /// - /// The channel whose position should be set or updated. - /// An optional position to set for this sound channel. Done this way to save setting and resetting data in FMOD. - /// Whether the channel's position was succesfully set. + /// @param soundChannel The channel whose position should be set or updated. + /// @param positionToUse An optional position to set for this sound channel. Done this way to save setting and resetting data in FMOD. + /// @return Whether the channel's position was succesfully set. FMOD_RESULT UpdatePositionalEffectsForSoundChannel(FMOD::Channel* soundChannel, const FMOD_VECTOR* positionToUse = nullptr) const; #pragma endregion #pragma region FMOD Callbacks - /// /// A static callback function for FMOD to invoke when the music channel finishes playing. See fmod docs - FMOD_CHANNELCONTROL_CALLBACK for details - /// static FMOD_RESULT F_CALLBACK MusicChannelEndedCallback(FMOD_CHANNELCONTROL* channelControl, FMOD_CHANNELCONTROL_TYPE channelControlType, FMOD_CHANNELCONTROL_CALLBACK_TYPE callbackType, void* commandData1, void* commandData2); - /// /// A static callback function for FMOD to invoke when a sound channel finished playing. See fmod docs - FMOD_CHANNELCONTROL_CALLBACK for details - /// static FMOD_RESULT F_CALLBACK SoundChannelEndedCallback(FMOD_CHANNELCONTROL* channelControl, FMOD_CHANNELCONTROL_TYPE channelControlType, FMOD_CHANNELCONTROL_CALLBACK_TYPE callbackType, void* commandData1, void* commandData2); #pragma endregion #pragma region Utility Methods - /// /// Gets the corresponding FMOD_VECTOR for a given RTE Vector. - /// - /// The RTE Vector to get as an FMOD_VECTOR. - /// The FMOD_VECTOR that corresponds to the given RTE Vector. + /// @param vector The RTE Vector to get as an FMOD_VECTOR. + /// @return The FMOD_VECTOR that corresponds to the given RTE Vector. FMOD_VECTOR GetAsFMODVector(const Vector& vector, float zValue = 0) const; - /// /// Gets the corresponding RTE Vector for a given FMOD_VECTOR. - /// - /// The FMOD_VECTOR to get as an RTE Vector. - /// The RTE Vector that corresponds to the given FMOD_VECTOR. + /// @param fmodVector The FMOD_VECTOR to get as an RTE Vector. + /// @return The RTE Vector that corresponds to the given FMOD_VECTOR. Vector GetAsVector(FMOD_VECTOR fmodVector) const; #pragma endregion - /// /// Clears all the member variables of this AudioMan, effectively resetting the members of this abstraction level only. - /// void Clear(); // Disallow the use of some implicit methods. diff --git a/Source/Managers/CameraMan.cpp b/Source/Managers/CameraMan.cpp index 20a26865e4..6d13aeb193 100644 --- a/Source/Managers/CameraMan.cpp +++ b/Source/Managers/CameraMan.cpp @@ -10,8 +10,6 @@ namespace RTE { - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void CameraMan::Clear() { m_ScreenShakeStrength = 1.0F; m_ScreenShakeDecay = 50.0F; @@ -36,23 +34,17 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void CameraMan::SetOffset(const Vector& offset, int screenId) { m_Screens[screenId].Offset = offset.GetFloored(); CheckOffset(screenId); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - Vector CameraMan::GetUnwrappedOffset(int screenId) const { const Screen& screen = m_Screens[screenId]; const SLTerrain* terrain = g_SceneMan.GetScene()->GetTerrain(); return Vector(screen.Offset.GetX() + static_cast(terrain->GetBitmap()->w * screen.SeamCrossCount[Axes::X]), screen.Offset.GetY() + static_cast(terrain->GetBitmap()->h * screen.SeamCrossCount[Axes::Y])); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void CameraMan::SetScroll(const Vector& center, int screenId) { Screen& screen = m_Screens[screenId]; if (g_FrameMan.IsInMultiplayerMode()) { @@ -63,14 +55,10 @@ namespace RTE { CheckOffset(screenId); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - Vector CameraMan::GetScrollTarget(int screenId) const { return g_NetworkClient.IsConnectedAndRegistered() ? g_NetworkClient.GetFrameTarget() : m_Screens[screenId].ScrollTarget; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void CameraMan::SetScrollTarget(const Vector& targetCenter, float speed, int screenId) { Screen& screen = m_Screens[screenId]; @@ -87,8 +75,6 @@ namespace RTE { screen.TargetYWrapped = screen.TargetYWrapped || targetYWrapped; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - float CameraMan::TargetDistanceScalar(const Vector& point) const { if (!g_SceneMan.GetScene()) { return 0.0F; @@ -123,8 +109,6 @@ namespace RTE { return closestScalar; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void CameraMan::CheckOffset(int screenId) { RTEAssert(g_SceneMan.GetScene(), "Trying to check offset before there is a scene or terrain!"); @@ -153,8 +137,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - Vector CameraMan::GetFrameSize(int screenId) { int frameWidth = g_WindowMan.GetResX(); int frameHeight = g_WindowMan.GetResY(); @@ -170,8 +152,6 @@ namespace RTE { return Vector(static_cast(frameWidth), static_cast(frameHeight)); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void CameraMan::ResetAllScreenShake() { for (int screenId = 0; screenId < g_FrameMan.GetScreenCount(); ++screenId) { Screen& screen = m_Screens[screenId]; @@ -180,8 +160,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void CameraMan::AddScreenShake(float magnitude, const Vector& position) { for (int screenId = 0; screenId < g_FrameMan.GetScreenCount(); ++screenId) { Screen& screen = m_Screens[screenId]; @@ -209,8 +187,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void CameraMan::Update(int screenId) { Screen& screen = m_Screens[screenId]; const SLTerrain* terrain = g_SceneMan.GetScene()->GetTerrain(); diff --git a/Source/Managers/CameraMan.h b/Source/Managers/CameraMan.h index adec7208b9..bf19b8abdb 100644 --- a/Source/Managers/CameraMan.h +++ b/Source/Managers/CameraMan.h @@ -9,242 +9,173 @@ namespace RTE { - /// /// The singleton manager of the camera for each player. - /// class CameraMan : public Singleton { friend class SettingsMan; public: #pragma region Creation - /// /// Constructor method used to instantiate a CameraMan object in system memory. Create() should be called before using the object. - /// CameraMan() { Clear(); } - /// /// Makes the CameraMan object ready for use. - /// - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Initialize() const { return 0; } #pragma endregion #pragma region Destruction - /// /// Destructor method used to clean up a CameraMan object before deletion from system memory. - /// ~CameraMan() { Destroy(); } - /// /// Resets the entire CameraMan to their default settings or values. - /// void Reset() { Clear(); } - /// /// Destroys and resets (through Clear()) the CameraMan object. - /// void Destroy() { Clear(); } #pragma endregion #pragma region Screen Handling - /// /// Gets the offset (scroll position) of the terrain. - /// - /// Which screen you want to get the offset of. - /// The offset for the given screen. + /// @param screenId Which screen you want to get the offset of. + /// @return The offset for the given screen. Vector GetOffset(int screenId = 0) const { return m_Screens[screenId].Offset; } - /// /// Sets the offset (scroll position) of the terrain. - /// - /// The new offset value. - /// Which screen you want to set the offset of. + /// @param offset The new offset value. + /// @param screenId Which screen you want to set the offset of. void SetOffset(const Vector& offset, int screenId = 0); - /// /// Gets the difference in current offset and that of the Update() before. - /// - /// The delta offset in pixels. + /// @return The delta offset in pixels. Vector GetDeltaOffset(int screenId = 0) const { return m_Screens[screenId].DeltaOffset; } - /// /// Gets the offset (scroll position) of the terrain, without taking wrapping into account. - /// - /// Which screen you want to get the offset of. - /// The offset for the given screen. + /// @param screenId Which screen you want to get the offset of. + /// @return The offset for the given screen. Vector GetUnwrappedOffset(int screenId = 0) const; - /// /// Sets the offset (scroll position) of the terrain to center on specific world coordinates. /// If the coordinate to center on is close to the terrain border edges, the view will not scroll outside the borders. - /// - /// The coordinates to center the terrain scroll on. - /// Which screen you want to set the offset of. + /// @param center The coordinates to center the terrain scroll on. + /// @param screenId Which screen you want to set the offset of. void SetScroll(const Vector& center, int screenId = 0); - /// /// Gets the team associated with a specific screen. - /// - /// Which screen you want to get the team of. - /// The team associated with the screen. + /// @param screenId Which screen you want to get the team of. + /// @return The team associated with the screen. int GetScreenTeam(int screenId = 0) const { return m_Screens[screenId].ScreenTeam; } - /// /// Sets the team associated with a specific screen. - /// - /// The team to set the screen to. - /// Which screen you want to set the team of. + /// @param team The team to set the screen to. + /// @param screenId Which screen you want to set the team of. void SetScreenTeam(int team, int screenId = 0) { m_Screens[screenId].ScreenTeam = team; } - /// /// Gets the amount that a specific screen is occluded by a GUI panel or something of the sort. /// This will affect how the scroll target translates into the offset of the screen, in order to keep the target centered on the screen. - /// - /// Which screen you want to get the team of. - /// A vector indicating the screen occlusion amount. + /// @param screenId Which screen you want to get the team of. + /// @return A vector indicating the screen occlusion amount. Vector& GetScreenOcclusion(int screenId = 0) { return m_Screens[screenId].ScreenOcclusion; } - /// /// Sets the amount that a specific screen is occluded by a GUI panel or something of the sort. /// This will affect how the scroll target translates into the offset of the screen, in order to keep the target centered on the screen. - /// - /// The amount of occlusion of the screen. - /// Which screen you want to set the occlusion of. + /// @param occlusion The amount of occlusion of the screen. + /// @param screenId Which screen you want to set the occlusion of. void SetScreenOcclusion(const Vector& occlusion, int screenId = 0) { m_Screens[screenId].ScreenOcclusion = occlusion; } - /// /// Gets the currently set scroll target, i.e. where the center of the specific screen is trying to line up with. - /// - /// Which screen to get the target for. - /// Current target vector in Scene coordinates. + /// @param screenId Which screen to get the target for. + /// @return Current target vector in Scene coordinates. Vector GetScrollTarget(int screenId = 0) const; - /// /// Interpolates a smooth scroll of the view from wherever it is now, towards centering on a new scroll target over time. - /// - /// The new target vector in Scene coordinates. - /// The normalized speed at screen the view scrolls. 0 being no movement, and 1.0 being instant movement to the target in one frame. - /// Which screen you want to set the scroll offset of. + /// @param targetCenter The new target vector in Scene coordinates. + /// @param speed The normalized speed at screen the view scrolls. 0 being no movement, and 1.0 being instant movement to the target in one frame. + /// @param screenId Which screen you want to set the scroll offset of. void SetScrollTarget(const Vector& targetCenter, float speed = 0.1F, int screenId = 0); - /// /// Calculates a scalar of how distant a certain point in the world is from the currently closest scroll target of all active screens. - /// - /// The world coordinate point to check distance to/from. - /// + /// @param point The world coordinate point to check distance to/from. + /// @return /// A normalized scalar representing the distance between the closest scroll target of all active screens, to the passed in point. /// 0 means it's the point is within half a screen's width of the target, and 1.0 means it's on the clear opposite side of the scene. - /// float TargetDistanceScalar(const Vector& point) const; - /// /// Makes sure the current offset won't create a view of outside the scene. /// If that is found to be the case, the offset is corrected so that the view rectangle /// is as close to the old offset as possible, but still entirely within the scene world. - /// - /// Which screen you want to check the offset of. + /// @param screenId Which screen you want to check the offset of. void CheckOffset(int screenId = 0); - /// /// Gets the frame width/height for a given screen. - /// - /// Which screen you want to get frame width/height of. - /// The frame width (x) and height (y). + /// @param screenId Which screen you want to get frame width/height of. + /// @return The frame width (x) and height (y). Vector GetFrameSize(int screenId = 0); #pragma endregion #pragma region Screen Shake Getters and Setters - /// /// Gets the screen shake strength multiplier. - /// - /// The screen shake strength multiplier. + /// @return The screen shake strength multiplier. float GetScreenShakeStrength() const { return m_ScreenShakeStrength; } - /// /// Sets the screen shake strength multiplier. - /// - /// New value for the screen shake strength multiplier. + /// @param newValue New value for the screen shake strength multiplier. void SetScreenShakeStrength(float newValue) { m_ScreenShakeStrength = newValue; } - /// /// Gets how quickly screen shake decays, per second. - /// - /// The screen shake decay. + /// @return The screen shake decay. float GetScreenShakeDecay() const { return m_ScreenShakeDecay; } - /// /// Gets the maximum amount of screen shake time, i.e. the number of seconds screen shake will happen until ScreenShakeDecay reduces it to zero. - /// - /// The maximum screen shake time, in seconds. + /// @return The maximum screen shake time, in seconds. float GetMaxScreenShakeTime() const { return m_MaxScreenShakeTime; } - /// /// Gets how much the screen should shake per unit of energy from gibbing (i.e explosions), when screen shake amount is auto-calculated. - /// - /// The default shakiness per unit of gib energy. + /// @return The default shakiness per unit of gib energy. float GetDefaultShakePerUnitOfGibEnergy() const { return m_DefaultShakePerUnitOfGibEnergy; } - /// /// Gets how much the screen should shake per unit of energy for recoil, when screen shake amount is auto-calculated. - /// - /// The default shakiness per unit of recoil energy. + /// @return The default shakiness per unit of recoil energy. float GetDefaultShakePerUnitOfRecoilEnergy() const { return m_DefaultShakePerUnitOfRecoilEnergy; } - /// /// The maximum amount of screen shake recoil can cause, when screen shake is auto-calculated. This is ignored by per-firearm shake settings. - /// - /// The maximum auto-calculated recoil shakiness. + /// @return The maximum auto-calculated recoil shakiness. float GetDefaultShakeFromRecoilMaximum() const { return m_DefaultShakeFromRecoilMaximum; } #pragma endregion #pragma region Screen Shake Actions - /// /// Resets all screen shake and the screen scroll timers that affect it. - /// void ResetAllScreenShake(); - /// /// Increases the magnitude of screen shake. /// This is used for spatially located screen-shake, and will automatically determine which screens have shake applied /// If the screen-shake position is outside our view, it'll gradually weaken and fade away depending on distance. - /// - /// The amount of screen shake. - /// The spatial location of the screen-shake event. + /// @param magnitude The amount of screen shake. + /// @param position The spatial location of the screen-shake event. void AddScreenShake(float magnitude, const Vector& position); - /// /// Increases the magnitude of screen shake. - /// - /// The amount of screen shake to add. - /// Which screen you want to add screen-shake to. + /// @param magnitude The amount of screen shake to add. + /// @param screenId Which screen you want to add screen-shake to. void AddScreenShake(float magnitude, int screenId = 0) { m_Screens[screenId].ScreenShakeMagnitude += magnitude; } - /// /// Sets the magnitude of screen shake. - /// - /// The amount of screen shake. - /// Which screen you want to set screen-shake for. + /// @param magnitude The amount of screen shake. + /// @param screenId Which screen you want to set screen-shake for. void SetScreenShake(float magnitude, int screenId = 0) { m_Screens[screenId].ScreenShakeMagnitude = magnitude; } - /// /// Applies screen shake to be at least magnitude. - /// - /// The amount of screen shake. - /// Which screen you want to set screen-shake for. + /// @param magnitude The amount of screen shake. + /// @param screenId Which screen you want to set screen-shake for. void ApplyScreenShake(float magnitude, int screenId = 0) { m_Screens[screenId].ScreenShakeMagnitude = std::max(magnitude, m_Screens[screenId].ScreenShakeMagnitude); } #pragma endregion #pragma region Concrete Methods - /// /// Updates the state of this CameraMan. Supposed to be done every frame before drawing. - /// void Update(int screenId); #pragma endregion private: - /// /// A screen. Each player should have one of these. - /// /// TODO: This is a struct right now, as it has been torn verbatim out of SceneMan. In future it should be a proper class with methods, instead of CameraMan handling everything. struct Screen { int ScreenTeam = 0; //!< The team associated with this Screen. @@ -275,9 +206,7 @@ namespace RTE { std::array m_Screens; //!< Array with the Screen of each player. - /// /// Clears all the member variables of this CameraMan, effectively resetting the members of this abstraction level only. - /// void Clear(); // Disallow the use of some implicit methods. diff --git a/Source/Managers/ConsoleMan.cpp b/Source/Managers/ConsoleMan.cpp index f59812ceea..14191cd821 100644 --- a/Source/Managers/ConsoleMan.cpp +++ b/Source/Managers/ConsoleMan.cpp @@ -16,8 +16,6 @@ namespace RTE { - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ConsoleMan::Clear() { m_ConsoleState = ConsoleState::Disabled; m_ReadOnly = false; @@ -38,8 +36,6 @@ namespace RTE { m_ConsoleUseMonospaceFont = false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int ConsoleMan::Initialize() { if (!m_GUIScreen) { m_GUIScreen = new AllegroScreen(g_FrameMan.GetBackBuffer32()); @@ -81,8 +77,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ConsoleMan::Destroy() { if (!g_WindowMan.ResolutionChanged()) { SaveAllText("LogConsole.txt"); @@ -102,8 +96,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ConsoleMan::SetEnabled(bool enable) { if (enable && m_ConsoleState != ConsoleState::Enabled && m_ConsoleState != ConsoleState::Enabling) { m_ConsoleState = ConsoleState::Enabling; @@ -114,8 +106,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ConsoleMan::SetReadOnly() { if (!m_ReadOnly) { // Save the current input string before changing to the read-only notice so we can restore it when switching back @@ -126,8 +116,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ConsoleMan::SetConsoleScreenSize(float screenRatio) { m_ConsoleScreenRatio = Limit(screenRatio, 1.0F, 0.1F); @@ -142,8 +130,6 @@ namespace RTE { m_InputTextBox->Resize(m_ParentBox->GetWidth() - 3, m_InputTextBox->GetHeight()); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ConsoleMan::SetConsoleUseMonospaceFont(bool useFont) { m_ConsoleUseMonospaceFont = useFont; if (m_GUIControlManager) { @@ -151,8 +137,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ConsoleMan::AddLoadWarningLogExtensionMismatchEntry(const std::string& pathToLog, const std::string& readerPosition, const std::string& altFileExtension) { const std::string pathAndAccessLocation = "\"" + pathToLog + "\" referenced " + readerPosition + ". "; std::string newEntry = pathAndAccessLocation + (!altFileExtension.empty() ? "Found and loaded a file with \"" + altFileExtension + "\" extension." : "The file was not loaded."); @@ -166,8 +150,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ConsoleMan::SaveLoadWarningLog(const std::string& filePath) { Writer logWriter(filePath.c_str()); if (logWriter.WriterOK()) { @@ -180,8 +162,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ConsoleMan::SaveInputLog(const std::string& filePath) { Writer logWriter(filePath.c_str()); if (logWriter.WriterOK()) { @@ -197,8 +177,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool ConsoleMan::SaveAllText(const std::string& filePath) { Writer logWriter(filePath.c_str()); if (logWriter.WriterOK()) { @@ -212,16 +190,12 @@ namespace RTE { return false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ConsoleMan::ClearLog() { m_InputLog.clear(); m_InputLogPosition = m_InputLog.begin(); m_OutputLog.clear(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ConsoleMan::PrintString(const std::string& stringToPrint) { static std::mutex printStringMutex; std::scoped_lock printStringLock(printStringMutex); @@ -232,8 +206,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ConsoleMan::ShowShortcuts() { if (!IsEnabled()) { SetEnabled(); @@ -265,8 +237,6 @@ namespace RTE { "F12 - Make a single screenshot"); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ConsoleMan::Update() { if (g_UInputMan.FlagCtrlState() && g_UInputMan.KeyPressed(SDL_SCANCODE_GRAVE)) { SetReadOnly(); @@ -339,8 +309,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ConsoleMan::ConsoleOpenClose() { float travelCompletionDistance; @@ -375,8 +343,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ConsoleMan::FeedString(bool feedEmptyString) { char strLine[1024]; std::stringstream inputStream(m_InputTextBox->GetText()); @@ -409,8 +375,6 @@ namespace RTE { m_InputTextBox->SetText(""); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ConsoleMan::LoadLoggedInput(bool nextEntry) { if (nextEntry) { // See if we should decrement doubly because the last move was in the opposite direction @@ -446,8 +410,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ConsoleMan::RemoveGraveAccents() const { std::string textBoxString = m_InputTextBox->GetText(); if (std::find(textBoxString.begin(), textBoxString.end(), '`') != textBoxString.end()) { @@ -457,8 +419,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ConsoleMan::Draw(BITMAP* targetBitmap) const { if (m_ConsoleState != ConsoleState::Disabled) { AllegroScreen drawScreen(targetBitmap); diff --git a/Source/Managers/ConsoleMan.h b/Source/Managers/ConsoleMan.h index a943c73728..ef552f4993 100644 --- a/Source/Managers/ConsoleMan.h +++ b/Source/Managers/ConsoleMan.h @@ -14,150 +14,104 @@ namespace RTE { class GUITextBox; class GUILabel; - /// /// The singleton manager of the lua console. - /// class ConsoleMan : public Singleton { friend class SettingsMan; public: #pragma region Creation - /// /// Constructor method used to instantiate a ConsoleMan object in system memory. Create() should be called before using the object. - /// ConsoleMan() { Clear(); } - /// /// Makes the ConsoleMan object ready for use. - /// - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Initialize(); #pragma endregion #pragma region Destruction - /// /// Destructor method used to clean up a ConsoleMan object before deletion from system memory. - /// ~ConsoleMan() { Destroy(); } - /// /// Destroys and resets (through Clear()) the ConsoleMan object. - /// void Destroy(); #pragma endregion #pragma region Getters and Setters - /// /// Reports whether the console is enabled or not. - /// - /// Whether the console is enabled or not. + /// @return Whether the console is enabled or not. bool IsEnabled() const { return m_ConsoleState == ConsoleState::Enabled || m_ConsoleState == ConsoleState::Enabling; } - /// /// Enables or disables the console. - /// - /// Whether to enable or disable the console. + /// @param enable Whether to enable or disable the console. void SetEnabled(bool enable = true); - /// /// Reports whether the console is in read-only mode or not. - /// - /// Whether the console is in read-only mode or not. + /// @return Whether the console is in read-only mode or not. bool IsReadOnly() const { return m_ReadOnly; } - /// /// Gets how much of the screen that the console is covering when opened. - /// - /// The ratio of the screen that is covered. + /// @return The ratio of the screen that is covered. float GetConsoleScreenSize() const { return m_ConsoleScreenRatio; } - /// /// Sets how much of the screen that the console should cover when opened. - /// - /// The ratio of the screen to cover. 0 - 1.0. + /// @param screenRatio The ratio of the screen to cover. 0 - 1.0. void SetConsoleScreenSize(float screenRatio = 0.3F); - /// /// Gets whether the console text is using the monospace font or the regular proportional one. - /// - /// Whether the console text is using the monospace font or the regular proportional one. + /// @return Whether the console text is using the monospace font or the regular proportional one. bool GetConsoleUseMonospaceFont() const { return m_ConsoleUseMonospaceFont; } - /// /// Sets whether the console text is using the monospace font and changes to the appropriate skin to apply the setting. - /// - /// Whether to use the monospace font or not. + /// @param useFont Whether to use the monospace font or not. void SetConsoleUseMonospaceFont(bool useFont); #pragma endregion #pragma region Logging - /// /// Gets whether the loading warning log has any warnings logged or not. - /// - /// Whether the log has logged warnings. + /// @return Whether the log has logged warnings. bool LoadWarningsExist() const { return !m_LoadWarningLog.empty(); } - /// /// Adds a new file extension mismatch entry to the loading warning log. - /// - /// The path that produced the warning. - /// The file and line currently being loaded. - /// The alternative file extension to the path that produced the warning (e.g. if file is ".bmp", alternative extension is ".png"). + /// @param pathToLog The path that produced the warning. + /// @param readerPosition The file and line currently being loaded. + /// @param altFileExtension The alternative file extension to the path that produced the warning (e.g. if file is ".bmp", alternative extension is ".png"). void AddLoadWarningLogExtensionMismatchEntry(const std::string& pathToLog, const std::string& readerPosition = "", const std::string& altFileExtension = ""); - /// /// Writes the entire loading warning log to a file. - /// - /// The filename of the file to write to. + /// @param filePath The filename of the file to write to. void SaveLoadWarningLog(const std::string& filePath); - /// /// Writes all the input strings to a log in the order they were entered. - /// - /// The filename of the file to write to. + /// @param filePath The filename of the file to write to. void SaveInputLog(const std::string& filePath); - /// /// Writes the entire console buffer to a file. - /// - /// The filename of the file to write to. - /// Whether writing to the file was successful. + /// @param filePath The filename of the file to write to. + /// @return Whether writing to the file was successful. bool SaveAllText(const std::string& filePath); - /// /// Clears all previous input. - /// void ClearLog(); #pragma endregion #pragma region Concrete Methods - /// /// Prints a string into the console. - /// - /// The string to print. + /// @param stringToPrint The string to print. void PrintString(const std::string& stringToPrint); - /// /// Opens the console and prints the shortcut help text. - /// void ShowShortcuts(); - /// /// Updates the state of this ConsoleMan. Supposed to be done every frame before drawing. - /// void Update(); - /// /// Draws this ConsoleMan's current graphical representation to a BITMAP of choice. - /// - /// A pointer to a BITMAP to draw on. + /// @param targetBitmap A pointer to a BITMAP to draw on. void Draw(BITMAP* targetBitmap) const; #pragma endregion protected: - /// /// Enumeration for console states when enabling/disabling the console. NOTE: This can't be lower down because m_ConsoleState relies on this definition. - /// enum ConsoleState { Enabling = 0, Enabled, @@ -189,39 +143,27 @@ namespace RTE { private: bool m_ConsoleUseMonospaceFont; //!< Whether the console text is using the monospace font. - /// /// Sets the console to read-only mode and enables it. - /// void SetReadOnly(); #pragma region Update Breakdown - /// /// Console open/close animation handling and GUI element enabling/disabling. This is called from Update(). - /// void ConsoleOpenClose(); - /// /// Executes the string currently in the console textbox or multiple strings if a newline character is found. /// The input string is saved to the input log if it's different from the previous string. This is called from Update(). - /// - /// Whether to just pass in an empty string to make a new line. + /// @param feedEmptyString Whether to just pass in an empty string to make a new line. void FeedString(bool feedEmptyString = false); - /// /// Loads a previously entered console string from the input log when pressing up or down. This is called from Update(). - /// - /// Whether to load the next entry in the log (true) or the previous (false). + /// @param nextEntry Whether to load the next entry in the log (true) or the previous (false). void LoadLoggedInput(bool nextEntry); - /// /// Removes any grave accents (`) that are pasted or typed into the textbox by opening/closing it. This is called from Update(). - /// void RemoveGraveAccents() const; #pragma endregion - /// /// Clears all the member variables of this ConsoleMan, effectively resetting the members of this abstraction level only. - /// void Clear(); // Disallow the use of some implicit methods. diff --git a/Source/Managers/FrameMan.cpp b/Source/Managers/FrameMan.cpp index bbd65d7ad7..983f7d913a 100644 --- a/Source/Managers/FrameMan.cpp +++ b/Source/Managers/FrameMan.cpp @@ -43,8 +43,6 @@ namespace RTE { nullptr // Transparency does not rely on the blender setting, it creates a map with the dedicated function instead of with the generic one. }; - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void FrameMan::Clear() { m_HSplit = false; m_VSplit = false; @@ -92,8 +90,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int FrameMan::Initialize() { set_color_depth(c_BPP); // Sets the allowed color conversions when loading bitmaps from files @@ -120,8 +116,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int FrameMan::CreateBackBuffers() { int resX = g_WindowMan.GetResX(); int resY = g_WindowMan.GetResY(); @@ -173,8 +167,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void FrameMan::CreatePresetColorTables() { // Create RGB lookup table that supposedly speeds up calculation of other color tables. create_rgb_table(&m_RGBTable, m_DefaultPalette, nullptr); @@ -193,8 +185,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void FrameMan::Destroy() { for (const GUIScreen* guiScreen: m_GUIScreens) { delete guiScreen; @@ -208,8 +198,6 @@ namespace RTE { Clear(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void FrameMan::Update() { // Remove all scheduled primitives, those will be re-added by updates from other entities. // This needs to happen here, otherwise if there are multiple sim updates during a single frame duplicates will be added to the primitive queue. @@ -244,8 +232,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void FrameMan::ResetSplitScreens(bool hSplit, bool vSplit) { if (m_PlayerScreen) { release_bitmap(m_PlayerScreen.get()); @@ -278,8 +264,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - Vector FrameMan::GetMiddleOfPlayerScreen(int whichPlayer) { Vector middleOfPlayerScreen; @@ -299,8 +283,6 @@ namespace RTE { return middleOfPlayerScreen; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int FrameMan::GetPlayerFrameBufferWidth(int whichPlayer) const { if (IsInMultiplayerMode()) { if (whichPlayer < 0 || whichPlayer >= c_MaxScreenCount) { @@ -320,8 +302,6 @@ namespace RTE { return m_PlayerScreenWidth; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int FrameMan::GetPlayerFrameBufferHeight(int whichPlayer) const { if (IsInMultiplayerMode()) { if (whichPlayer < 0 || whichPlayer >= c_MaxScreenCount) { @@ -341,14 +321,10 @@ namespace RTE { return m_PlayerScreenHeight; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int FrameMan::CalculateTextHeight(const std::string& text, int maxWidth, bool isSmall) { return isSmall ? GetSmallFont()->CalculateHeight(text, maxWidth) : GetLargeFont()->CalculateHeight(text, maxWidth); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - std::string FrameMan::SplitStringToFitWidth(const std::string& stringToSplit, int widthLimit, bool useSmallFont) { GUIFont* fontToUse = GetFont(useSmallFont, false); auto SplitSingleLineAsNeeded = [this, &widthLimit, &fontToUse](std::string& lineToSplitAsNeeded) { @@ -388,14 +364,10 @@ namespace RTE { return splitString; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int FrameMan::CalculateTextWidth(const std::string& text, bool isSmall) { return isSmall ? GetSmallFont()->CalculateWidth(text) : GetLargeFont()->CalculateWidth(text); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void FrameMan::SetScreenText(const std::string& message, int whichScreen, int blinkInterval, int displayDuration, bool centered) { // See if we can overwrite the previous message if (whichScreen >= 0 && whichScreen < c_MaxScreenCount && m_TextDurationTimer[whichScreen].IsPastRealMS(m_TextDuration[whichScreen])) { @@ -407,8 +379,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void FrameMan::ClearScreenText(int whichScreen) { if (whichScreen >= 0 && whichScreen < c_MaxScreenCount) { m_ScreenText[whichScreen].clear(); @@ -418,8 +388,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void FrameMan::SetColorTable(DrawBlendMode blendMode, std::array colorChannelBlendAmounts) { RTEAssert(blendMode > DrawBlendMode::NoBlend && blendMode < DrawBlendMode::BlendModeCount, "Invalid DrawBlendMode or DrawBlendMode::NoBlend passed into FrameMan::SetColorTable. See DrawBlendMode enumeration for defined values."); @@ -470,8 +438,6 @@ namespace RTE { m_ColorTables[blendMode].at(colorChannelBlendAmounts).second = usedPresetTransparencyTable ? -1 : (g_TimerMan.GetAbsoluteTime() / 10000); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void FrameMan::SetTransTableFromPreset(TransparencyPreset transPreset) { RTEAssert(transPreset == TransparencyPreset::LessTrans || transPreset == TransparencyPreset::HalfTrans || transPreset == TransparencyPreset::MoreTrans, "Undefined transparency preset value passed in. See TransparencyPreset enumeration for defined values."); std::array colorChannelBlendAmounts = {transPreset, transPreset, transPreset, BlendAmountLimits::MinBlend}; @@ -481,8 +447,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void FrameMan::CreateNewNetworkPlayerBackBuffer(int player, int width, int height) { for (int f = 0; f < 2; f++) { m_NetworkBackBufferIntermediate8[f][player] = std::unique_ptr(create_bitmap_ex(8, width, height)); @@ -494,8 +458,6 @@ namespace RTE { m_PlayerScreenHeight = height; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool FrameMan::LoadPalette(const std::string& palettePath) { const std::string fullPalettePath = g_PresetMan.GetFullModulePath(palettePath); BITMAP* tempBitmap = load_bitmap(fullPalettePath.c_str(), m_Palette); @@ -512,8 +474,6 @@ namespace RTE { return true; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int FrameMan::SaveBitmap(SaveBitmapMode modeToSave, const std::string& nameBase, BITMAP* bitmapToSave) { if ((modeToSave == WorldDump || modeToSave == ScenePreviewDump) && !g_ActivityMan.ActivityRunning()) { return 0; @@ -622,8 +582,6 @@ namespace RTE { glGetTexImage(GL_TEXTURE_2D, 0, GL_RGB, GL_UNSIGNED_BYTE, m_ScreenDumpBuffer->line[0]); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int FrameMan::SaveIndexedPNG(const char* fileName, BITMAP* bitmapToSave) const { // nullptr for the PALETTE parameter here because the bitmap is 32bpp and whatever we index it with will end up wrong anyway. save_png(fileName, bitmapToSave, nullptr); @@ -646,8 +604,6 @@ namespace RTE { return saveResult; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int FrameMan::SharedDrawLine(BITMAP* bitmap, const Vector& start, const Vector& end, int color, int altColor, int skip, int skipStart, bool shortestWrap, bool drawDot, BITMAP* dot) const { RTEAssert(bitmap, "Trying to draw line to null Bitmap"); if (drawDot) { @@ -749,8 +705,6 @@ namespace RTE { return skipped; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIFont* FrameMan::GetFont(bool isSmall, bool trueColor) { size_t colorIndex = trueColor ? 1 : 0; @@ -786,8 +740,6 @@ namespace RTE { return m_LargeFonts[colorIndex]; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void FrameMan::UpdateScreenOffsetForSplitScreen(int playerScreen, Vector& screenOffset) const { switch (playerScreen) { case Players::PlayerTwo: @@ -814,8 +766,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void FrameMan::Draw() { ZoneScopedN("Draw"); @@ -967,8 +917,6 @@ namespace RTE { #endif } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void FrameMan::DrawScreenText(int playerScreen, AllegroBitmap playerGUIBitmap) { int textPosY = 0; // Only draw screen text to actual human players @@ -1017,8 +965,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void FrameMan::DrawScreenFlash(int playerScreen, BITMAP* playerGUIBitmap) { if (m_FlashScreenColor[playerScreen] != -1) { // If set to flash for a period of time, first be solid and then start flashing slower @@ -1038,8 +984,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void FrameMan::DrawWorldDump(bool drawForScenePreview) const { float worldBitmapWidth = static_cast(m_WorldDumpBuffer->w); float worldBitmapHeight = static_cast(m_WorldDumpBuffer->h); @@ -1095,8 +1039,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void FrameMan::PrepareFrameForNetwork() { int dx = 0; int dy = 0; diff --git a/Source/Managers/FrameMan.h b/Source/Managers/FrameMan.h index db6c0529df..51c5e3c0af 100644 --- a/Source/Managers/FrameMan.h +++ b/Source/Managers/FrameMan.h @@ -18,9 +18,7 @@ namespace RTE { void operator()(BITMAP* bitmap) const; }; - /// /// The singleton manager over the composition of frames. - /// class FrameMan : public Singleton { friend class SettingsMan; friend class WindowMan; @@ -31,463 +29,337 @@ namespace RTE { Vector SLOffset[c_MaxScreenCount][c_MaxLayersStoredForNetwork]; //!< SceneLayer offsets for each screen in online multiplayer. #pragma region Creation - /// /// Constructor method used to instantiate a FrameMan object in system memory. Initialize() should be called before using the object. - /// FrameMan() { Clear(); } - /// /// Makes the FrameMan object ready for use, which is to be used with SettingsMan first. - /// - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Initialize(); #pragma endregion #pragma region Destruction - /// /// Destructor method used to clean up a FrameMan object before deletion from system memory. - /// ~FrameMan() { Destroy(); } - /// /// Destroys and resets (through Clear()) the FrameMan object. - /// void Destroy(); #pragma endregion #pragma region Concrete Methods - /// /// Updates the state of this FrameMan. Supposed to be done every frame. - /// void Update(); - /// /// Draws the current frame to the screen. - /// void Draw(); #pragma endregion #pragma region Getters - /// /// Gets the 8bpp backbuffer bitmap. - /// - /// A pointer to the BITMAP 8bpp backbuffer. OWNERSHIP IS NOT TRANSFERRED! + /// @return A pointer to the BITMAP 8bpp backbuffer. OWNERSHIP IS NOT TRANSFERRED! BITMAP* GetBackBuffer8() const { return m_BackBuffer8.get(); } - /// /// Gets the 32bpp backbuffer bitmap. Make sure you don't do any blending stuff to the 8bpp one! - /// - /// A pointer to the BITMAP 32bpp backbuffer. OWNERSHIP IS NOT TRANSFERRED! + /// @return A pointer to the BITMAP 32bpp backbuffer. OWNERSHIP IS NOT TRANSFERRED! BITMAP* GetBackBuffer32() const { return m_BackBuffer32.get(); } - /// /// Gets the 32bpp bitmap that is used for overlaying the screen. - /// - /// A pointer to the overlay BITMAP. OWNERSHIP IS NOT TRANSFERRED! + /// @return A pointer to the overlay BITMAP. OWNERSHIP IS NOT TRANSFERRED! BITMAP* GetOverlayBitmap32() const { return m_OverlayBitmap32.get(); } #pragma endregion #pragma region Split - Screen Handling - /// /// Gets whether the screen is split horizontally across the screen, ie as two splitscreens one above the other. - /// - /// Whether or not screen has a horizontal split. + /// @return Whether or not screen has a horizontal split. bool GetHSplit() const { return m_HSplit; } - /// /// Sets whether the screen is split horizontally across the screen, ie as two splitscreens one above the other. - /// - /// Whether or not to have a horizontal split. + /// @param hSplit Whether or not to have a horizontal split. void SetHSplit(bool hSplit) { m_HSplit = hSplit; } - /// /// Gets whether the screen is split vertically across the screen, ie as two splitscreens side by side. - /// - /// Whether screen has a vertical split. + /// @return Whether screen has a vertical split. bool GetVSplit() const { return m_VSplit; } - /// /// Sets whether the screen is split vertically across the screen, ie as two splitscreens side by side. - /// - /// Whether or not to have a vertical split. + /// @param vSplit Whether or not to have a vertical split. void SetVSplit(bool vSplit) { m_VSplit = vSplit; } - /// /// Gets whether the screen is being split vertically when in two player splitscreen, or is default split horizontally. - /// - /// Whether the screen is being split vertically when in two player splitscreen or not. + /// @return Whether the screen is being split vertically when in two player splitscreen or not. bool GetTwoPlayerVSplit() const { return m_TwoPlayerVSplit; } - /// /// Sets whether the screen should be split vertically when in two player splitscreen or default to the horizontal split. - /// - /// Whether the screen should be split vertically when in two player splitscreen or default to the horizontal split. + /// @param vSplit Whether the screen should be split vertically when in two player splitscreen or default to the horizontal split. void SetTwoPlayerVSplit(bool vSplit) { m_TwoPlayerVSplit = vSplit; } - /// /// Sets new values for the split screen configuration. - /// - /// Whether the new setting should be horizontally split (over and under). - /// Whether the new setting should be vertically split (side by side). + /// @param hSplit Whether the new setting should be horizontally split (over and under). + /// @param vSplit Whether the new setting should be vertically split (side by side). void ResetSplitScreens(bool hSplit = false, bool vSplit = false); - /// /// Gets the number of currently active screens, counting all splits. - /// - /// The number of currently active screens. + /// @return The number of currently active screens. int GetScreenCount() const { return m_HSplit || m_VSplit ? (m_HSplit && m_VSplit ? 4 : 2) : 1; } - /// /// Gets the width of the individual player screens. This will only be less than the backbuffer resolution if there are split screens. - /// - /// The width of the player screens. + /// @return The width of the player screens. int GetPlayerScreenWidth() const { return GetPlayerFrameBufferWidth(-1); } - /// /// Gets the height of the individual player screens. This will only be less than the backbuffer resolution if there are split screens. - /// - /// The height of the player screens. + /// @return The height of the player screens. int GetPlayerScreenHeight() const { return GetPlayerFrameBufferHeight(-1); } - /// /// Gets a Vector with the absolute position of the middle of the specified player's screen. - /// - /// Player to get the middle of the screen for. -1 will give the middle of the entire game window. - /// The middle of the screen for the specified player, or the middle of the game window if that player is -1. + /// @param whichPlayer Player to get the middle of the screen for. -1 will give the middle of the entire game window. + /// @return The middle of the screen for the specified player, or the middle of the game window if that player is -1. Vector GetMiddleOfPlayerScreen(int whichPlayer); - /// /// Gets the width of the specified player screen. This will only be less than the backbuffer resolution if there are split screens. - /// - /// Player to get screen width for, only used by multiplayer parts. - /// The width of the specified player screen. + /// @param whichPlayer Player to get screen width for, only used by multiplayer parts. + /// @return The width of the specified player screen. int GetPlayerFrameBufferWidth(int whichPlayer) const; - /// /// Gets the height of the specified player screen. This will only be less than the backbuffer resolution if there are split screens. - /// - /// Player to get screen width for, only used by multiplayer parts. - /// The height of the specified player screen. + /// @param whichPlayer Player to get screen width for, only used by multiplayer parts. + /// @return The height of the specified player screen. int GetPlayerFrameBufferHeight(int whichPlayer) const; #pragma endregion #pragma region Text Handling - /// /// Gets the small font from the GUI engine's current skin. Ownership is NOT transferred! - /// - /// Whether to get the 32bpp color version of the font. - /// A pointer to the requested font, or 0 if no small font was found. + /// @param trueColor Whether to get the 32bpp color version of the font. + /// @return A pointer to the requested font, or 0 if no small font was found. GUIFont* GetSmallFont(bool trueColor = false) { return GetFont(true, trueColor); } - /// /// Gets the large font from the GUI engine's current skin. Ownership is NOT transferred! - /// - /// Whether to get the 32bpp color version of the font. - /// A pointer to the requested font, or 0 if no large font was found. + /// @param trueColor Whether to get the 32bpp color version of the font. + /// @return A pointer to the requested font, or 0 if no large font was found. GUIFont* GetLargeFont(bool trueColor = false) { return GetFont(false, trueColor); } - /// /// Calculates the width of a text string using the given font size. - /// - /// Text string. - /// Whether to use small or large font. - /// Width of the text string. + /// @param text Text string. + /// @param isSmall Whether to use small or large font. + /// @return Width of the text string. int CalculateTextWidth(const std::string& text, bool isSmall); - /// /// Calculates the height of a text string using the given font size. - /// - /// Text string. - /// Maximum width of the text string. - /// Whether to use small or large font. - /// Height of the text string. + /// @param text Text string. + /// @param maxWidth Maximum width of the text string. + /// @param isSmall Whether to use small or large font. + /// @return Height of the text string. int CalculateTextHeight(const std::string& text, int maxWidth, bool isSmall); - /// /// Gets a copy of the passed in string, split into multiple lines as needed to fit within the specified width limit, based on the font to use. - /// - /// The string to get a split copy of. - /// The maximum width each line of the string can be. - /// The font the string will use for calculating the string's width. - /// A copy of the passed in string, split into multiple lines as needed. + /// @param stringToSplit The string to get a split copy of. + /// @param widthLimit The maximum width each line of the string can be. + /// @param fontToUse The font the string will use for calculating the string's width. + /// @return A copy of the passed in string, split into multiple lines as needed. std::string SplitStringToFitWidth(const std::string& stringToSplit, int widthLimit, bool useSmallFont); - /// /// Gets the message to be displayed on top of each player's screen. - /// - /// Which player screen to get message from. - /// Current message shown to player. + /// @param whichScreen Which player screen to get message from. + /// @return Current message shown to player. std::string GetScreenText(int whichScreen = 0) const { return (whichScreen >= 0 && whichScreen < c_MaxScreenCount) ? m_ScreenText[whichScreen] : ""; } - /// /// Sets the message to be displayed on top of each player's screen - /// - /// An std::string that specifies what should be displayed. - /// Which screen you want to set text to. - /// The interval with which the screen will be blinking, in ms. 0 means no blinking. - /// The duration, in MS to force this message to display. No other message can be displayed before this expires. ClearScreenText overrides it though. - /// Vertically centered on the screen. + /// @param message An std::string that specifies what should be displayed. + /// @param whichScreen Which screen you want to set text to. + /// @param blinkInterval The interval with which the screen will be blinking, in ms. 0 means no blinking. + /// @param displayDuration The duration, in MS to force this message to display. No other message can be displayed before this expires. ClearScreenText overrides it though. + /// @param centered Vertically centered on the screen. void SetScreenText(const std::string& message, int whichScreen = 0, int blinkInterval = 0, int displayDuration = -1, bool centered = false); - /// /// Clears the message to be displayed on top of each player's screen. - /// - /// Which screen message to clear. + /// @param whichScreen Which screen message to clear. void ClearScreenText(int whichScreen = 0); #pragma endregion #pragma region Drawing - /// /// Clears the 8bpp backbuffer with black. - /// void ClearBackBuffer8() { clear_to_color(m_BackBuffer8.get(), m_BlackColor); } - /// /// Clears the 32bpp backbuffer with black. - /// void ClearBackBuffer32() { clear_to_color(m_BackBuffer32.get(), 0); } - /// /// Sets a specific color table which is used for any subsequent blended drawing in indexed color modes. - /// - /// The blending mode that will be used in drawing. - /// The color channel blend amounts that will be used to select or create the correct table in the specified blending mode. + /// @param blendMode The blending mode that will be used in drawing. + /// @param colorChannelBlendAmounts The color channel blend amounts that will be used to select or create the correct table in the specified blending mode. void SetColorTable(DrawBlendMode blendMode, std::array colorChannelBlendAmounts); - /// /// Sets a specific pre-calculated transparency table which is used for any subsequent transparency drawing in indexed color modes. - /// - /// The transparency preset value. See the TransparencyPreset enumeration for values. + /// @param transValue The transparency preset value. See the TransparencyPreset enumeration for values. void SetTransTableFromPreset(TransparencyPreset transValue); - /// /// Flashes any of the players' screen with the specified color for this frame. - /// - /// Which screen to flash. - /// What color to flash it. -1 means no color or flash. - /// How long a period to fill the frame with color. If 0, a single-frame flash will happen. + /// @param screen Which screen to flash. + /// @param color What color to flash it. -1 means no color or flash. + /// @param periodMS How long a period to fill the frame with color. If 0, a single-frame flash will happen. void FlashScreen(int screen, int color, float periodMS = 0) { m_FlashScreenColor[screen] = color; m_FlashTimer[screen].SetRealTimeLimitMS(periodMS); m_FlashTimer[screen].Reset(); } - /// /// Draws a line that can be dotted or with other effects. - /// - /// The Bitmap to draw to. Ownership is NOT transferred. - /// The absolute Start point. - /// The absolute end point. - /// The color value of the line. - /// A color to alternate with. Every other pixel drawn will have this if !0. - /// How many pixels to skip drawing between drawn ones. 0 means solid line 2 means there's a gap of two pixels between each drawn one. - /// The start of the skipping phase. If skip is 10 and this is 5, the first dot will be drawn after 5 pixels. - /// Whether the line should take the shortest possible route across scene wraps. - /// The end state of the skipping phase. Eg if 4 is returned here the last dot was placed 4 pixels ago. + /// @param bitmap The Bitmap to draw to. Ownership is NOT transferred. + /// @param start The absolute Start point. + /// @param end The absolute end point. + /// @param color The color value of the line. + /// @param altColor A color to alternate with. Every other pixel drawn will have this if !0. + /// @param skip How many pixels to skip drawing between drawn ones. 0 means solid line 2 means there's a gap of two pixels between each drawn one. + /// @param skipStart The start of the skipping phase. If skip is 10 and this is 5, the first dot will be drawn after 5 pixels. + /// @param shortestWrap Whether the line should take the shortest possible route across scene wraps. + /// @return The end state of the skipping phase. Eg if 4 is returned here the last dot was placed 4 pixels ago. int DrawLine(BITMAP* bitmap, const Vector& start, const Vector& end, int color, int altColor = 0, int skip = 0, int skipStart = 0, bool shortestWrap = false) const { return SharedDrawLine(bitmap, start, end, color, altColor, skip, skipStart, shortestWrap, false, nullptr); } - /// /// Draws a line that can be dotted with bitmaps. - /// - /// The Bitmap to draw to. Ownership is NOT transferred. - /// The absolute Start point. - /// The absolute end point. - /// The bitmap to be used for dots (will be centered). - /// How many pixels to gap between drawing dots. Should be more than 0. - /// The start of the skipping phase. If skip is 10 and this is 5, the first dot will be drawn after 5 pixels. - /// Whether the line should take the shortest possible route across scene wraps. - /// The end state of the skipping phase. Eg if 4 is returned here the last dot was placed 4 pixels ago. + /// @param bitmap The Bitmap to draw to. Ownership is NOT transferred. + /// @param start The absolute Start point. + /// @param end The absolute end point. + /// @param dot The bitmap to be used for dots (will be centered). + /// @param skip How many pixels to gap between drawing dots. Should be more than 0. + /// @param skipStart The start of the skipping phase. If skip is 10 and this is 5, the first dot will be drawn after 5 pixels. + /// @param shortestWrap Whether the line should take the shortest possible route across scene wraps. + /// @return The end state of the skipping phase. Eg if 4 is returned here the last dot was placed 4 pixels ago. int DrawDotLine(BITMAP* bitmap, const Vector& start, const Vector& end, BITMAP* dot, int skip = 0, int skipStart = 0, bool shortestWrap = false) const { return SharedDrawLine(bitmap, start, end, 0, 0, skip, skipStart, shortestWrap, true, dot); } #pragma endregion - /// /// Gets whether or not the HUD is disabled for a given screen. - /// - /// The screen to check for. - /// True if in given screen's HUD is disabled. + /// @param screenId The screen to check for. + /// @return True if in given screen's HUD is disabled. bool IsHudDisabled(int screenId = 0) const { return m_HUDDisabled[screenId]; } - /// /// Sets whether or not the HUD is disabled for a given screen. - /// - /// Whether the HUD should be disabled. - /// The screen to set for. + /// @param value Whether the HUD should be disabled. + /// @param screenId The screen to set for. void SetHudDisabled(bool value, int screenId = 0) { m_HUDDisabled[screenId] = value; } #pragma region Network Handling - /// /// Returns true if this manager is in multiplayer mode, storing the 8bpp backbuffer for network transmission. - /// - /// True if in multiplayer mode. + /// @return True if in multiplayer mode. bool IsInMultiplayerMode() const { return m_StoreNetworkBackBuffer; } - /// /// Sets the multiplayer mode flag, telling the manager to store the 8bpp backbuffer for network transmission. - /// - /// Whether this manager should operate in multiplayer mode. + /// @param value Whether this manager should operate in multiplayer mode. void SetMultiplayerMode(bool value) { m_StoreNetworkBackBuffer = value; } - /// /// Gets the ready 8bpp backbuffer bitmap used to draw network transmitted image on top of everything. - /// - /// Which player screen to get backbuffer bitmap for. - /// A pointer to the 8bpp backbuffer BITMAP. OWNERSHIP IS NOT TRANSFERRED! + /// @param player Which player screen to get backbuffer bitmap for. + /// @return A pointer to the 8bpp backbuffer BITMAP. OWNERSHIP IS NOT TRANSFERRED! BITMAP* GetNetworkBackBuffer8Ready(int player) const { return m_NetworkBackBufferFinal8[m_NetworkFrameReady][player].get(); } - /// /// Gets the ready 8bpp backbuffer GUI bitmap used to draw network transmitted image on top of everything. - /// - /// Which player screen to get GUI backbuffer bitmap for. - /// A pointer to the 8bpp GUI backbuffer BITMAP. OWNERSHIP IS NOT TRANSFERRED! + /// @param player Which player screen to get GUI backbuffer bitmap for. + /// @return A pointer to the 8bpp GUI backbuffer BITMAP. OWNERSHIP IS NOT TRANSFERRED! BITMAP* GetNetworkBackBufferGUI8Ready(int player) const { return m_NetworkBackBufferFinalGUI8[m_NetworkFrameReady][player].get(); } - /// /// Gets the current 8bpp backbuffer bitmap used to draw network transmitted image on top of everything. - /// - /// Which player screen to get backbuffer bitmap for. - /// A pointer to the 8bpp backbuffer BITMAP. OWNERSHIP IS NOT TRANSFERRED! + /// @param player Which player screen to get backbuffer bitmap for. + /// @return A pointer to the 8bpp backbuffer BITMAP. OWNERSHIP IS NOT TRANSFERRED! BITMAP* GetNetworkBackBuffer8Current(int player) const { return m_NetworkBackBufferFinal8[m_NetworkFrameCurrent][player].get(); } - /// /// Gets the current 8bpp backbuffer GUI bitmap used to draw network transmitted image on top of everything. - /// - /// Which player screen to get backbuffer bitmap for. - /// A pointer to the 8bpp GUI backbuffer BITMAP. OWNERSHIP IS NOT TRANSFERRED! + /// @param player Which player screen to get backbuffer bitmap for. + /// @return A pointer to the 8bpp GUI backbuffer BITMAP. OWNERSHIP IS NOT TRANSFERRED! BITMAP* GetNetworkBackBufferGUI8Current(int player) const { return m_NetworkBackBufferFinalGUI8[m_NetworkFrameCurrent][player].get(); } - /// /// Gets the ready 8bpp intermediate backbuffer bitmap used to copy network transmitted image to before sending. - /// - /// Which player screen to get intermediate bitmap for. - /// A pointer to the 8bpp intermediate BITMAP. OWNERSHIP IS NOT TRANSFERRED! + /// @param player Which player screen to get intermediate bitmap for. + /// @return A pointer to the 8bpp intermediate BITMAP. OWNERSHIP IS NOT TRANSFERRED! BITMAP* GetNetworkBackBufferIntermediate8Ready(int player) const { return m_NetworkBackBufferIntermediate8[m_NetworkFrameReady][player].get(); } - /// /// Gets the ready 8bpp intermediate backbuffer GUI bitmap used to copy network transmitted image to before sending. - /// - /// Which player screen to get intermediate GUI bitmap for. - /// A pointer to the 8bpp intermediate GUI BITMAP. OWNERSHIP IS NOT TRANSFERRED! + /// @param player Which player screen to get intermediate GUI bitmap for. + /// @return A pointer to the 8bpp intermediate GUI BITMAP. OWNERSHIP IS NOT TRANSFERRED! BITMAP* GetNetworkBackBufferIntermediate8Current(int player) const { return m_NetworkBackBufferIntermediate8[m_NetworkFrameCurrent][player].get(); } - /// /// Gets the current 8bpp intermediate backbuffer bitmap used to copy network transmitted image to before sending. - /// - /// Which player screen to get intermediate bitmap for. - /// A pointer to the 8bpp intermediate BITMAP. OWNERSHIP IS NOT TRANSFERRED! + /// @param player Which player screen to get intermediate bitmap for. + /// @return A pointer to the 8bpp intermediate BITMAP. OWNERSHIP IS NOT TRANSFERRED! BITMAP* GetNetworkBackBufferIntermediateGUI8Ready(int player) const { return m_NetworkBackBufferIntermediateGUI8[m_NetworkFrameReady][player].get(); } - /// /// Gets the current 8bpp intermediate backbuffer GUI bitmap used to copy network transmitted image to before sending. - /// - /// Which player screen to get intermediate GUI bitmap for. - /// A pointer to the 8bpp intermediate GUI BITMAP. OWNERSHIP IS NOT TRANSFERRED! + /// @param player Which player screen to get intermediate GUI bitmap for. + /// @return A pointer to the 8bpp intermediate GUI BITMAP. OWNERSHIP IS NOT TRANSFERRED! BITMAP* GetNetworkBackBufferIntermediateGUI8Current(int player) const { return m_NetworkBackBufferIntermediateGUI8[m_NetworkFrameCurrent][player].get(); } // TODO: Figure out. - /// /// - /// - /// - /// + /// @param screen + /// @return Vector GetTargetPos(int screen) const { return m_TargetPos[m_NetworkFrameReady][screen]; } - /// /// Gets whether we are drawing the contents of the network backbuffers on top of m_BackBuffer8 every frame. - /// - /// Whether we are drawing the contents of the network backbuffers on top of m_BackBuffer8 every frame or not. + /// @return Whether we are drawing the contents of the network backbuffers on top of m_BackBuffer8 every frame or not. bool GetDrawNetworkBackBuffer() const { return m_DrawNetworkBackBuffer; } - /// /// Sets whether to draw the contents of the network backbuffers on top of m_BackBuffer8 every frame. - /// - /// Whether to draw the contents of the network backbuffers on top of m_BackBuffer8 every frame or not. + /// @param value Whether to draw the contents of the network backbuffers on top of m_BackBuffer8 every frame or not. void SetDrawNetworkBackBuffer(bool value) { m_DrawNetworkBackBuffer = value; } - /// /// Gets whether we are dumping the contents of the m_BackBuffer8 to the network backbuffers every frame. - /// - /// Whether the contents of the m_BackBuffer8 are being dumped to the network backbuffers every frame. + /// @return Whether the contents of the m_BackBuffer8 are being dumped to the network backbuffers every frame. bool GetStoreNetworkBackBuffer() const { return m_StoreNetworkBackBuffer; } - /// /// Creates a new set of network backbuffers for the specified player. - /// - /// Player to create new backbuffer for. - /// Width of new backbuffer. - /// Height of new backbuffer + /// @param player Player to create new backbuffer for. + /// @param width Width of new backbuffer. + /// @param height Height of new backbuffer void CreateNewNetworkPlayerBackBuffer(int player, int width, int height); #pragma endregion #pragma region Palette Routines - /// /// Loads a palette from a bitmap file and sets it as the currently used screen palette. - /// - /// String with the path to the palette bitmap file. - /// Whether palette loaded successfully or not. + /// @param palettePath String with the path to the palette bitmap file. + /// @return Whether palette loaded successfully or not. bool LoadPalette(const std::string& palettePath); - /// /// Gets the ContentFile describing the location of the color palette. - /// - /// An reference to a ContentFile which described the palette location. + /// @return An reference to a ContentFile which described the palette location. const ContentFile& GetPaletteFile() const { return m_PaletteFile; } - /// /// Fades the palette in from black at a specified speed. - /// - /// Speed specified from (slowest) 1 - 64 (fastest). + /// @param fadeSpeed Speed specified from (slowest) 1 - 64 (fastest). void FadeInPalette(int fadeSpeed = 1) { PALETTE pal; get_palette(pal); fade_in(pal, Limit(fadeSpeed, 64, 1)); } - /// /// Fades the palette out to black at a specified speed. - /// - /// Speed specified from (slowest) 1 - 64 (fastest). + /// @param fadeSpeed Speed specified from (slowest) 1 - 64 (fastest). void FadeOutPalette(int fadeSpeed = 1) { fade_out(Limit(fadeSpeed, 64, 1)); } #pragma endregion #pragma region Screen Capture - /// /// Dumps a bitmap to a 8bpp PNG file. - /// - /// The individual bitmap that will be dumped. - /// The filename of the file to save to, WITHOUT EXTENSION. - /// 0 for success, anything below 0 is a sign of failure. + /// @param bitmap The individual bitmap that will be dumped. + /// @param nameBase The filename of the file to save to, WITHOUT EXTENSION. + /// @return 0 for success, anything below 0 is a sign of failure. int SaveBitmapToPNG(BITMAP* bitmap, const char* nameBase) { return SaveBitmap(SingleBitmap, nameBase, bitmap); } - /// /// Dumps a bitmap of the screen backbuffer to a 8bpp PNG file. - /// - /// The filename of the file to save to, WITHOUT EXTENSION. - /// 0 for success, anything below 0 is a sign of failure. + /// @param nameBase The filename of the file to save to, WITHOUT EXTENSION. + /// @return 0 for success, anything below 0 is a sign of failure. int SaveScreenToPNG(const char* nameBase) { return SaveBitmap(ScreenDump, nameBase); } - /// /// Dumps a bitmap of everything on the scene to a PNG file. - /// - /// The filename of the file to save to, WITHOUT EXTENSION. - /// 0 for success, anything below 0 is a sign of failure. + /// @param nameBase The filename of the file to save to, WITHOUT EXTENSION. + /// @return 0 for success, anything below 0 is a sign of failure. int SaveWorldToPNG(const char* nameBase) { return SaveBitmap(WorldDump, nameBase); } - /// /// Dumps a miniature screenshot of the whole scene to be used as a preview to a PNG file. - /// - /// The filename of the file to save to, WITHOUT EXTENSION. - /// 0 for success, anything below 0 is a sign of failure. + /// @param nameBase The filename of the file to save to, WITHOUT EXTENSION. + /// @return 0 for success, anything below 0 is a sign of failure. int SaveWorldPreviewToPNG(const char* nameBase) { return SaveBitmap(ScenePreviewDump, nameBase); } #pragma endregion private: - /// /// Enumeration with different settings for the SaveBitmap() method. - /// enum SaveBitmapMode { SingleBitmap, ScreenDump, @@ -509,10 +381,8 @@ namespace RTE { int m_BlackColor; //!< Palette index for the black color. int m_AlmostBlackColor; //!< Palette index for the closest to black color. - /// /// Color tables for blended drawing in indexed color mode. /// The key is an array of the RGBA values. The value is a pair of the color table itself and a time stamp of when it was last accessed for use during color table pruning. - /// std::array, std::pair>, DrawBlendMode::BlendModeCount> m_ColorTables; Timer m_ColorTablePruneTimer; //!< Timer for pruning unused color tables to prevent ridiculous memory usage. @@ -562,111 +432,83 @@ namespace RTE { std::mutex m_NetworkBitmapLock[c_MaxScreenCount]; //!< Mutex lock for thread safe updating of the network backbuffer bitmaps. #pragma region Initialize Breakdown - /// /// Creates all the frame buffer bitmaps to be used by FrameMan. This is called during Initialize(). - /// - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int CreateBackBuffers(); - /// /// Creates the RGB lookup table and color table presets for drawing with transparency in indexed color mode. This is called during Initialize(). - /// void CreatePresetColorTables(); #pragma endregion #pragma region Draw Breakdown - /// /// Updates the drawing position of each player screen on the backbuffer when split screen is active. This is called during Draw(). - /// - /// The player screen to update offset for. - /// Vector representing the screen offset. + /// @param playerScreen The player screen to update offset for. + /// @param screenOffset Vector representing the screen offset. void UpdateScreenOffsetForSplitScreen(int playerScreen, Vector& screenOffset) const; - /// /// Draws all the text messages to the specified player screen. This is called during Draw(). - /// - /// The player screen the text will be shown on. - /// The bitmap the text will be drawn on. + /// @param playerScreen The player screen the text will be shown on. + /// @param playerGUIBitmap The bitmap the text will be drawn on. void DrawScreenText(int playerScreen, AllegroBitmap playerGUIBitmap); - /// /// Draws the screen flash effect to the specified player screen with parameters set by FlashScreen(). This is called during Draw(). - /// - /// The player screen the flash effect will be shown to. - /// The bitmap the flash effect will be drawn on. + /// @param playerScreen The player screen the flash effect will be shown to. + /// @param playerGUIBitmap The bitmap the flash effect will be drawn on. void DrawScreenFlash(int playerScreen, BITMAP* playerGUIBitmap); - /// /// Renders current frame and marks it ready for network transmission. This is called during Draw(). - /// void PrepareFrameForNetwork(); #pragma endregion #pragma region Screen Capture - /// /// Draws the current frame of the whole scene to a temporary buffer that is later saved as a screenshot. - /// - /// If true will skip drawing objects, post-effects and sky gradient in the WorldDump. To be used for dumping scene preview images. + /// @param drawForScenePreview If true will skip drawing objects, post-effects and sky gradient in the WorldDump. To be used for dumping scene preview images. void DrawWorldDump(bool drawForScenePreview = false) const; - /// /// Shared method for saving screenshots or individual bitmaps. - /// - /// What is being saved. See SaveBitmapMode enumeration for a list of modes. - /// + /// @param modeToSave What is being saved. See SaveBitmapMode enumeration for a list of modes. + /// @param nameBase /// The name of the file that is being saved, WITHOUT EXTENSION. /// Eg, If "Test" is passed in, this function will save to Test000.bmp, if that file does not already exist. If it does exist, it will attempt 001, and so on. - /// - /// The individual bitmap that will be dumped. 0 or nullptr if not in SingleBitmap mode. - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @param bitmapToSave The individual bitmap that will be dumped. 0 or nullptr if not in SingleBitmap mode. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int SaveBitmap(SaveBitmapMode modeToSave, const std::string& nameBase, BITMAP* bitmapToSave = nullptr); - /// /// Saves the front buffer to the screen dump buffer. - /// void SaveScreenToBitmap(); - /// /// Saves a BITMAP as an 8bpp bitmap file that is indexed with the specified palette. - /// - /// The full name of the file that is being saved. Path and everything included. - /// The BITMAP that is being saved into a file. - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. - /// + /// @param fileName The full name of the file that is being saved. Path and everything included. + /// @param bitmapToSave The BITMAP that is being saved into a file. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @remark /// This method is a workaround to Allegro being unable to set a color conversion mode when saving files. /// It works by first saving the 32bpp bitmap as is, then loading it back under the REDUCE_TO_256 color conversion mode, blitting it to a fresh bitmap and saving it again with the passed in palette. /// The re-blitted bitmap is properly 8bpp and will be indexed correctly. The old saved file is deleted in the process before the new one is saved. - /// int SaveIndexedPNG(const char* fileName, BITMAP* bitmapToSave) const; #pragma endregion - /// /// Shared method for drawing lines to avoid duplicate code. Will by called by either DrawLine() or DrawDotLine(). - /// - /// The Bitmap to draw to. Ownership is NOT transferred. - /// The absolute Start point. - /// The absolute end point. - /// The color value of the line. - /// A color to alternate with. Every other pixel drawn will have this if !0. - /// How many pixels to skip drawing between drawn ones. 0 means solid line 2 means there's a gap of two pixels between each drawn one. Should be more than 0 for dots. - /// The start of the skipping phase. If skip is 10 and this is 5, the first dot will be drawn after 5 pixels. - /// Whether the line should take the shortest possible route across scene wraps. - /// Whether to draw a regular line or a dot line. True for dot line. - /// The bitmap to be used for dots (will be centered). - /// The end state of the skipping phase. Eg if 4 is returned here the last dot was placed 4 pixels ago. + /// @param bitmap The Bitmap to draw to. Ownership is NOT transferred. + /// @param start The absolute Start point. + /// @param end The absolute end point. + /// @param color The color value of the line. + /// @param altColor A color to alternate with. Every other pixel drawn will have this if !0. + /// @param skip How many pixels to skip drawing between drawn ones. 0 means solid line 2 means there's a gap of two pixels between each drawn one. Should be more than 0 for dots. + /// @param skipStart The start of the skipping phase. If skip is 10 and this is 5, the first dot will be drawn after 5 pixels. + /// @param shortestWrap Whether the line should take the shortest possible route across scene wraps. + /// @param drawDot Whether to draw a regular line or a dot line. True for dot line. + /// @param dot The bitmap to be used for dots (will be centered). + /// @return The end state of the skipping phase. Eg if 4 is returned here the last dot was placed 4 pixels ago. int SharedDrawLine(BITMAP* bitmap, const Vector& start, const Vector& end, int color, int altColor = 0, int skip = 0, int skipStart = 0, bool shortestWrap = false, bool drawDot = false, BITMAP* dot = nullptr) const; - /// /// Gets the requested font from the GUI engine's current skin. Ownership is NOT transferred! - /// - /// Size of font to get. True for small font, false for large font. - /// Whether to get the 32bpp color version of the font. - /// A pointer to the requested font, or 0 if no font was found. + /// @param isSmall Size of font to get. True for small font, false for large font. + /// @param trueColor Whether to get the 32bpp color version of the font. + /// @return A pointer to the requested font, or 0 if no font was found. GUIFont* GetFont(bool isSmall, bool trueColor); - /// /// Clears all the member variables of this FrameMan, effectively resetting the members of this abstraction level only. - /// void Clear(); // Disallow the use of some implicit methods. diff --git a/Source/Managers/LuaMan.cpp b/Source/Managers/LuaMan.cpp index 3a467337a0..684388f90c 100644 --- a/Source/Managers/LuaMan.cpp +++ b/Source/Managers/LuaMan.cpp @@ -11,8 +11,6 @@ namespace RTE { const std::unordered_set LuaMan::c_FileAccessModes = {"r", "r+", "w", "w+", "a", "a+", "rt", "wt"}; - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void LuaStateWrapper::Clear() { m_State = nullptr; m_TempEntity = nullptr; @@ -21,8 +19,6 @@ namespace RTE { m_CurrentlyRunningScriptPath = ""; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void LuaStateWrapper::Initialize() { m_State = luaL_newstate(); luabind::open(m_State); @@ -248,38 +244,26 @@ namespace RTE { "_TriggerAsyncPathCallback = function(id, param) if _AsyncPathCallbacks[id] ~= nil then _AsyncPathCallbacks[id](param); _AsyncPathCallbacks[id] = nil; end end\n"); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void LuaStateWrapper::Destroy() { lua_close(m_State); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int LuaStateWrapper::SelectRand(int minInclusive, int maxInclusive) { return m_RandomGenerator.RandomNum(minInclusive, maxInclusive); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - double LuaStateWrapper::RangeRand(double minInclusive, double maxInclusive) { return m_RandomGenerator.RandomNum(minInclusive, maxInclusive); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - double LuaStateWrapper::NormalRand() { return m_RandomGenerator.RandomNormalNum(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - double LuaStateWrapper::PosRand() { return m_RandomGenerator.RandomNum(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // Passthrough LuaMan Functions const std::vector* LuaStateWrapper::DirectoryList(const std::string& path) { return g_LuaMan.DirectoryList(path); } const std::vector* LuaStateWrapper::FileList(const std::string& path) { return g_LuaMan.FileList(path); } @@ -300,14 +284,10 @@ namespace RTE { void LuaStateWrapper::FileWriteLine(int fileIndex, const std::string& line) { return g_LuaMan.FileWriteLine(fileIndex, line); } bool LuaStateWrapper::FileEOF(int fileIndex) { return g_LuaMan.FileEOF(fileIndex); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void LuaMan::Clear() { m_OpenedFiles.fill(nullptr); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void LuaMan::Initialize() { m_MasterScriptState.Initialize(); @@ -322,40 +302,28 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaStateWrapper& LuaMan::GetMasterScriptState() { return m_MasterScriptState; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaStatesArray& LuaMan::GetThreadedScriptStates() { return m_ScriptStates; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - thread_local LuaStateWrapper* s_luaStateOverride = nullptr; LuaStateWrapper* LuaMan::GetThreadLuaStateOverride() const { return s_luaStateOverride; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void LuaMan::SetThreadLuaStateOverride(LuaStateWrapper* luaState) { s_luaStateOverride = luaState; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - thread_local LuaStateWrapper* s_currentLuaState = nullptr; LuaStateWrapper* LuaMan::GetThreadCurrentLuaState() const { return s_currentLuaState; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LuaStateWrapper* LuaMan::GetAndLockFreeScriptState() { if (s_luaStateOverride) { // We're creating this object in a multithreaded environment, ensure that it's assigned to the same script state as us @@ -383,8 +351,6 @@ namespace RTE { return &m_ScriptStates[ourState]; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void LuaMan::ClearUserModuleCache() { m_GarbageCollectionTask.wait(); @@ -399,15 +365,11 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void LuaMan::AddLuaScriptCallback(const std::function& callback) { std::scoped_lock lock(m_ScriptCallbacksMutex); m_ScriptCallbacks.emplace_back(callback); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void LuaMan::ExecuteLuaScriptCallbacks() { std::vector> callbacks; @@ -422,8 +384,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - const std::unordered_map LuaMan::GetScriptTimings() const { std::unordered_map timings = m_MasterScriptState.GetScriptTimings(); for (const LuaStateWrapper& luaState: m_ScriptStates) { @@ -436,8 +396,6 @@ namespace RTE { return timings; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void LuaMan::Destroy() { for (int i = 0; i < c_MaxOpenFiles; ++i) { FileClose(i); @@ -445,38 +403,26 @@ namespace RTE { Clear(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void LuaStateWrapper::ClearUserModuleCache() { luaL_dostring(m_State, "for m, n in pairs(package.loaded) do if type(n) == \"boolean\" then package.loaded[m] = nil; end; end;"); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void LuaStateWrapper::ClearLuaScriptCache() { m_ScriptCache.clear(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - Entity* LuaStateWrapper::GetTempEntity() const { return m_TempEntity; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void LuaStateWrapper::SetTempEntity(Entity* entity) { m_TempEntity = entity; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - const std::vector& LuaStateWrapper::GetTempEntityVector() const { return m_TempEntityVector; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void LuaStateWrapper::SetTempEntityVector(const std::vector& entityVector) { m_TempEntityVector.reserve(entityVector.size()); for (const Entity* entity: entityVector) { @@ -484,8 +430,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void LuaStateWrapper::SetLuaPath(const std::string& filePath) { const std::string moduleName = g_PresetMan.GetModuleNameFromPath(filePath); const std::string moduleFolder = g_PresetMan.IsModuleOfficial(moduleName) ? System::GetDataDirectory() : System::GetModDirectory(); @@ -506,14 +450,10 @@ namespace RTE { lua_pop(m_State, 1); // get rid of package table from top of stack. } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - const std::unordered_map& LuaStateWrapper::GetScriptTimings() const { return m_ScriptTimings; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int LuaStateWrapper::RunScriptFunctionString(const std::string& functionName, const std::string& selfObjectName, const std::vector& variablesToSafetyCheck, const std::vector& functionEntityArguments, const std::vector& functionLiteralArguments) { std::stringstream scriptString; if (!variablesToSafetyCheck.empty()) { @@ -569,8 +509,6 @@ namespace RTE { return result; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int LuaStateWrapper::RunScriptString(const std::string& scriptString, bool consoleErrors) { if (scriptString.empty()) { return -1; @@ -598,8 +536,6 @@ namespace RTE { return error; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int LuaStateWrapper::RunScriptFunctionObject(const LuabindObjectWrapper* functionObject, const std::string& selfGlobalTableName, const std::string& selfGlobalTableKey, const std::vector& functionEntityArguments, const std::vector& functionLiteralArguments, const std::vector& functionObjectArguments) { int status = 0; @@ -673,8 +609,6 @@ namespace RTE { return status; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int LuaStateWrapper::RunScriptFile(const std::string& filePath, bool consoleErrors, bool doInSandboxedEnvironment) { const std::string fullScriptPath = g_PresetMan.GetFullModulePath(filePath); if (fullScriptPath.empty()) { @@ -751,8 +685,6 @@ namespace RTE { return error; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool LuaStateWrapper::RetrieveFunctions(const std::string& funcObjectName, const std::vector& functionNamesToLookFor, std::unordered_map& outFunctionNamesAndObjects) { std::lock_guard lock(m_Mutex); s_currentLuaState = this; @@ -783,8 +715,6 @@ namespace RTE { return true; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int LuaStateWrapper::RunScriptFileAndRetrieveFunctions(const std::string& filePath, const std::vector& functionNamesToLookFor, std::unordered_map& outFunctionNamesAndObjects, bool forceReload) { static bool disableCaching = false; forceReload = forceReload || disableCaching; @@ -815,8 +745,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void LuaStateWrapper::Update() { for (MovableObject* mo: m_AddedRegisteredMOs) { m_RegisteredMOs.insert(mo); @@ -824,14 +752,10 @@ namespace RTE { m_AddedRegisteredMOs.clear(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void LuaStateWrapper::ClearScriptTimings() { m_ScriptTimings.clear(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool LuaStateWrapper::ExpressionIsTrue(const std::string& expression, bool consoleErrors) { if (expression.empty()) { return false; @@ -858,8 +782,6 @@ namespace RTE { return result; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void LuaStateWrapper::SavePointerAsGlobal(void* objectToSave, const std::string& globalName) { std::lock_guard lock(m_Mutex); @@ -869,8 +791,6 @@ namespace RTE { lua_setglobal(m_State, globalName.c_str()); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool LuaStateWrapper::GlobalIsDefined(const std::string& globalName) { std::lock_guard lock(m_Mutex); @@ -884,8 +804,6 @@ namespace RTE { return isDefined; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool LuaStateWrapper::TableEntryIsDefined(const std::string& tableName, const std::string& indexName) { std::lock_guard lock(m_Mutex); @@ -906,27 +824,19 @@ namespace RTE { return isDefined; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool LuaStateWrapper::ErrorExists() const { return !m_LastError.empty(); ; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - std::string LuaStateWrapper::GetLastError() const { return m_LastError; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void LuaStateWrapper::ClearErrors() { m_LastError.clear(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - std::string LuaStateWrapper::DescribeLuaStack() { int indexOfTopOfStack = lua_gettop(m_State); if (indexOfTopOfStack == 0) { @@ -957,8 +867,6 @@ namespace RTE { return stackDescription.str(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - const std::vector* LuaMan::DirectoryList(const std::string& path) { std::string fullPath = System::GetWorkingDirectory() + g_PresetMan.GetFullModulePath(path); auto* directoryPaths = new std::vector(); @@ -978,8 +886,6 @@ namespace RTE { return directoryPaths; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - const std::vector* LuaMan::FileList(const std::string& path) { std::string fullPath = System::GetWorkingDirectory() + g_PresetMan.GetFullModulePath(path); auto* filePaths = new std::vector(); @@ -999,8 +905,6 @@ namespace RTE { return filePaths; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool LuaMan::FileExists(const std::string& path) { std::string fullPath = System::GetWorkingDirectory() + g_PresetMan.GetFullModulePath(path); if (IsValidModulePath(fullPath)) { @@ -1012,8 +916,6 @@ namespace RTE { return false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool LuaMan::DirectoryExists(const std::string& path) { std::string fullPath = System::GetWorkingDirectory() + g_PresetMan.GetFullModulePath(path); if (IsValidModulePath(fullPath)) { @@ -1025,15 +927,11 @@ namespace RTE { return false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // TODO: Move to ModuleMan, once the ModuleMan PR has been merged bool LuaMan::IsValidModulePath(const std::string& path) { return (path.find("..") == std::string::npos) && (path.find(System::GetModulePackageExtension()) != std::string::npos); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int LuaMan::FileOpen(const std::string& path, const std::string& accessMode) { if (c_FileAccessModes.find(accessMode) == c_FileAccessModes.end()) { g_ConsoleMan.PrintString("ERROR: Cannot open file, invalid file access mode specified."); @@ -1105,8 +1003,6 @@ namespace RTE { return -1; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void LuaMan::FileClose(int fileIndex) { if (fileIndex > -1 && fileIndex < c_MaxOpenFiles && m_OpenedFiles.at(fileIndex)) { fclose(m_OpenedFiles[fileIndex]); @@ -1114,16 +1010,12 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void LuaMan::FileCloseAll() { for (int file = 0; file < c_MaxOpenFiles; ++file) { FileClose(file); } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool LuaMan::FileRemove(const std::string& path) { std::string fullPath = System::GetWorkingDirectory() + g_PresetMan.GetFullModulePath(path); if (IsValidModulePath(fullPath)) { @@ -1138,8 +1030,6 @@ namespace RTE { return false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool LuaMan::DirectoryCreate(const std::string& path, bool recursive) { std::string fullPath = System::GetWorkingDirectory() + g_PresetMan.GetFullModulePath(path); if (IsValidModulePath(fullPath)) { @@ -1158,8 +1048,6 @@ namespace RTE { return false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool LuaMan::DirectoryRemove(const std::string& path, bool recursive) { std::string fullPath = System::GetWorkingDirectory() + g_PresetMan.GetFullModulePath(path); if (IsValidModulePath(fullPath)) { @@ -1180,8 +1068,6 @@ namespace RTE { return false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool LuaMan::FileRename(const std::string& oldPath, const std::string& newPath) { std::string fullOldPath = System::GetWorkingDirectory() + g_PresetMan.GetFullModulePath(oldPath); std::string fullNewPath = System::GetWorkingDirectory() + g_PresetMan.GetFullModulePath(newPath); @@ -1203,8 +1089,6 @@ namespace RTE { return false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool LuaMan::DirectoryRename(const std::string& oldPath, const std::string& newPath) { std::string fullOldPath = System::GetWorkingDirectory() + g_PresetMan.GetFullModulePath(oldPath); std::string fullNewPath = System::GetWorkingDirectory() + g_PresetMan.GetFullModulePath(newPath); @@ -1226,8 +1110,6 @@ namespace RTE { return false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - std::string LuaMan::FileReadLine(int fileIndex) { if (fileIndex > -1 && fileIndex < c_MaxOpenFiles && m_OpenedFiles.at(fileIndex)) { char buf[4096]; @@ -1240,8 +1122,6 @@ namespace RTE { return ""; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void LuaMan::FileWriteLine(int fileIndex, const std::string& line) { if (fileIndex > -1 && fileIndex < c_MaxOpenFiles && m_OpenedFiles.at(fileIndex)) { if (fputs(line.c_str(), m_OpenedFiles[fileIndex]) == EOF) { @@ -1252,8 +1132,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool LuaMan::FileEOF(int fileIndex) { if (fileIndex > -1 && fileIndex < c_MaxOpenFiles && m_OpenedFiles.at(fileIndex)) { return feof(m_OpenedFiles[fileIndex]); @@ -1262,8 +1140,6 @@ namespace RTE { return false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void LuaMan::Update() { ZoneScoped; @@ -1279,8 +1155,6 @@ namespace RTE { LuabindObjectWrapper::ApplyQueuedDeletions(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void LuaMan::StartAsyncGarbageCollection() { ZoneScoped; @@ -1304,8 +1178,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void LuaMan::ClearScriptTimings() { m_MasterScriptState.ClearScriptTimings(); for (LuaStateWrapper& luaState: m_ScriptStates) { diff --git a/Source/Managers/LuaMan.h b/Source/Managers/LuaMan.h index e4192da1fa..fe4939ecc9 100644 --- a/Source/Managers/LuaMan.h +++ b/Source/Managers/LuaMan.h @@ -17,273 +17,197 @@ namespace RTE { class LuabindObjectWrapper; class MovableObject; - /// /// A single lua state. Multiple of these can exist at once for multithreaded scripting. - /// class LuaStateWrapper { public: #pragma region Creation - /// /// Constructor method used to instantiate a LuaStateWrapper object in system memory. Initialize() should be called before using the object. - /// LuaStateWrapper() { Clear(); } - /// /// Makes the LuaStateWrapper object ready for use. - /// void Initialize(); #pragma endregion #pragma region Destruction - /// /// Destructor method used to clean up a LuaStateWrapper object before deletion from system memory. - /// ~LuaStateWrapper() { Destroy(); } - /// /// Destroys and resets (through Clear()) the LuaStateWrapper object. - /// void Destroy(); #pragma endregion #pragma region Getters and Setters - /// /// Gets a temporary Entity that can be accessed in the Lua state. - /// - /// The temporary entity. Ownership is NOT transferred! + /// @return The temporary entity. Ownership is NOT transferred! Entity* GetTempEntity() const; - /// /// Sets a temporary Entity that can be accessed in the Lua state. - /// - /// The temporary entity. Ownership is NOT transferred! + /// @param entity The temporary entity. Ownership is NOT transferred! void SetTempEntity(Entity* entity); - /// /// Gets the temporary vector of Entities that can be accessed in the Lua state. - /// - /// The temporary vector of entities. Ownership is NOT transferred! + /// @return The temporary vector of entities. Ownership is NOT transferred! const std::vector& GetTempEntityVector() const; - /// /// Sets a temporary vector of Entities that can be accessed in the Lua state. These Entities are const_cast so they're non-const, for ease-of-use in Lua. - /// - /// The temporary vector of entities. Ownership is NOT transferred! + /// @param entityVector The temporary vector of entities. Ownership is NOT transferred! void SetTempEntityVector(const std::vector& entityVector); - /// /// Sets the proper package.path for the script to run. - /// - /// The path to the file to load and run. + /// @param filePath The path to the file to load and run. void SetLuaPath(const std::string& filePath); - /// /// Gets this LuaStateWrapper's internal lua state. - /// - /// This LuaStateWrapper's internal lua state. + /// @return This LuaStateWrapper's internal lua state. lua_State* GetLuaState() { return m_State; }; - /// /// Gets m_ScriptTimings. - /// - /// m_ScriptTimings. + /// @return m_ScriptTimings. const std::unordered_map& GetScriptTimings() const; - /// /// Gets the currently running script filepath, if applicable. - /// - /// The currently running script filepath. May return inaccurate values for non-MO scripts due to weirdness in setup. + /// @return The currently running script filepath. May return inaccurate values for non-MO scripts due to weirdness in setup. std::string_view GetCurrentlyRunningScriptFilePath() const { return m_CurrentlyRunningScriptPath; } #pragma endregion #pragma region Script Responsibility Handling - /// /// Registers an MO as using us. - /// - /// The MO to register with us. Ownership is NOT transferred! + /// @param moToRegister The MO to register with us. Ownership is NOT transferred! void RegisterMO(MovableObject* moToRegister) { m_AddedRegisteredMOs.insert(moToRegister); } - /// /// Unregisters an MO as using us. - /// - /// The MO to unregister as using us. Ownership is NOT transferred! + /// @param moToUnregister The MO to unregister as using us. Ownership is NOT transferred! void UnregisterMO(MovableObject* moToUnregister) { m_RegisteredMOs.erase(moToUnregister); m_AddedRegisteredMOs.erase(moToUnregister); } - /// /// Gets a list of the MOs registed as using us. - /// - /// The MOs registed as using us. + /// @return The MOs registed as using us. const std::unordered_set& GetRegisteredMOs() const { return m_RegisteredMOs; } #pragma endregion #pragma region Script Execution Handling - /// /// Runs the given Lua function with optional safety checks and arguments. The first argument to the function will always be the self object. /// If either argument list has entries, they will be passed into the function in order, with entity arguments first. - /// - /// The name that gives access to the function in the global Lua namespace. - /// The name that gives access to the self object in the global Lua namespace. - /// Optional vector of strings that should be safety checked in order before running the Lua function. Defaults to empty. - /// Optional vector of entity pointers that should be passed into the Lua function. Their internal Lua states will not be accessible. Defaults to empty. - /// Optional vector of strings that should be passed into the Lua function. Entries must be surrounded with escaped quotes (i.e.`\"`) they'll be passed in as-is, allowing them to act as booleans, etc. Defaults to empty. - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @param functionName The name that gives access to the function in the global Lua namespace. + /// @param selfObjectName The name that gives access to the self object in the global Lua namespace. + /// @param variablesToSafetyCheck Optional vector of strings that should be safety checked in order before running the Lua function. Defaults to empty. + /// @param functionEntityArguments Optional vector of entity pointers that should be passed into the Lua function. Their internal Lua states will not be accessible. Defaults to empty. + /// @param functionLiteralArguments Optional vector of strings that should be passed into the Lua function. Entries must be surrounded with escaped quotes (i.e.`\"`) they'll be passed in as-is, allowing them to act as booleans, etc. Defaults to empty. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int RunScriptFunctionString(const std::string& functionName, const std::string& selfObjectName, const std::vector& variablesToSafetyCheck = std::vector(), const std::vector& functionEntityArguments = std::vector(), const std::vector& functionLiteralArguments = std::vector()); - /// /// Takes a string containing a script snippet and runs it on the state. - /// - /// The string with the script snippet. - /// Whether to report any errors to the console immediately. - /// Returns less than zero if any errors encountered when running this script. To get the actual error string, call GetLastError. + /// @param scriptString The string with the script snippet. + /// @param consoleErrors Whether to report any errors to the console immediately. + /// @return Returns less than zero if any errors encountered when running this script. To get the actual error string, call GetLastError. int RunScriptString(const std::string& scriptString, bool consoleErrors = true); - /// /// Runs the given Lua function object. The first argument to the function will always be the self object. /// If either argument list has entries, they will be passed into the function in order, with entity arguments first. - /// - /// The LuabindObjectWrapper containing the Lua function to be run. - /// The name of the global Lua table that gives access to the self object. - /// The key for this object in the respective global Lua table. - /// Optional vector of entity pointers that should be passed into the Lua function. Their internal Lua states will not be accessible. Defaults to empty. - /// Optional vector of strings that should be passed into the Lua function. Entries must be surrounded with escaped quotes (i.e.`\"`) they'll be passed in as-is, allowing them to act as booleans, etc.. Defaults to empty. - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @param functionObjectWrapper The LuabindObjectWrapper containing the Lua function to be run. + /// @param selfGlobalTableName The name of the global Lua table that gives access to the self object. + /// @param selfGlobalTableKey The key for this object in the respective global Lua table. + /// @param functionEntityArguments Optional vector of entity pointers that should be passed into the Lua function. Their internal Lua states will not be accessible. Defaults to empty. + /// @param functionLiteralArguments Optional vector of strings that should be passed into the Lua function. Entries must be surrounded with escaped quotes (i.e.`\"`) they'll be passed in as-is, allowing them to act as booleans, etc.. Defaults to empty. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int RunScriptFunctionObject(const LuabindObjectWrapper* functionObjectWrapper, const std::string& selfGlobalTableName, const std::string& selfGlobalTableKey, const std::vector& functionEntityArguments = std::vector(), const std::vector& functionLiteralArguments = std::vector(), const std::vector& functionObjectArguments = std::vector()); - /// /// Opens and loads a file containing a script and runs it on the state. - /// - /// The path to the file to load and run. - /// Whether to report any errors to the console immediately. - /// Whether to do it in a sandboxed environment, or the global environment. - /// Returns less than zero if any errors encountered when running this script. To get the actual error string, call GetLastError. + /// @param filePath The path to the file to load and run. + /// @param consoleErrors Whether to report any errors to the console immediately. + /// @param doInSandboxedEnvironment Whether to do it in a sandboxed environment, or the global environment. + /// @return Returns less than zero if any errors encountered when running this script. To get the actual error string, call GetLastError. int RunScriptFile(const std::string& filePath, bool consoleErrors = true, bool doInSandboxedEnvironment = true); - /// /// Retrieves all of the specified functions that exist into the output map, and refreshes the cache. - /// - /// The path to the file to load and run. - /// The vector of strings defining the function names to be retrieved. - /// The map of function names to LuabindObjectWrappers to be retrieved from the script that was run. - /// Returns whether functions were successfully retrieved. + /// @param filePath The path to the file to load and run. + /// @param functionNamesToLookFor The vector of strings defining the function names to be retrieved. + /// @param outFunctionNamesAndObjects The map of function names to LuabindObjectWrappers to be retrieved from the script that was run. + /// @return Returns whether functions were successfully retrieved. bool RetrieveFunctions(const std::string& functionObjectName, const std::vector& functionNamesToLookFor, std::unordered_map& outFunctionNamesAndObjects); - /// /// Opens and loads a file containing a script and runs it on the state, then retrieves all of the specified functions that exist into the output map. - /// - /// The path to the file to load and run. - /// The vector of strings defining the function names to be retrieved. - /// The map of function names to LuabindObjectWrappers to be retrieved from the script that was run. - /// Whether caching shouldn't be used. - /// Returns less than zero if any errors encountered when running this script. To get the actual error string, call GetLastError. + /// @param filePath The path to the file to load and run. + /// @param functionNamesToLookFor The vector of strings defining the function names to be retrieved. + /// @param outFunctionNamesAndObjects The map of function names to LuabindObjectWrappers to be retrieved from the script that was run. + /// @param noCaching Whether caching shouldn't be used. + /// @return Returns less than zero if any errors encountered when running this script. To get the actual error string, call GetLastError. int RunScriptFileAndRetrieveFunctions(const std::string& filePath, const std::vector& functionNamesToLookFor, std::unordered_map& outFunctionNamesAndObjects, bool forceReload = false); #pragma endregion #pragma region Concrete Methods - /// /// Updates this Lua state. - /// void Update(); - /// /// Clears m_ScriptTimings. - /// void ClearScriptTimings(); #pragma endregion #pragma region MultiThreading - /// /// Gets the mutex to lock this lua state. - /// std::recursive_mutex& GetMutex() { return m_Mutex; }; #pragma endregion #pragma region - /// /// Gets whether the given Lua expression evaluates to true or false. - /// - /// The string with the expression to evaluate. - /// Whether to report any errors to the console immediately. - /// Whether the expression was true. + /// @param expression The string with the expression to evaluate. + /// @param consoleErrors Whether to report any errors to the console immediately. + /// @return Whether the expression was true. bool ExpressionIsTrue(const std::string& expression, bool consoleErrors); - /// /// Takes a pointer to an object and saves it in the Lua state as a global of a specified variable name. - /// - /// The pointer to the object to save. Ownership is NOT transferred! - /// The name of the global var in the Lua state to save the pointer to. + /// @param objectToSave The pointer to the object to save. Ownership is NOT transferred! + /// @param globalName The name of the global var in the Lua state to save the pointer to. void SavePointerAsGlobal(void* objectToSave, const std::string& globalName); - /// /// Checks if there is anything defined on a specific global var in Lua. - /// - /// The name of the global var in the Lua state to check. - /// Whether that global var has been defined yet in the Lua state. + /// @param globalName The name of the global var in the Lua state to check. + /// @return Whether that global var has been defined yet in the Lua state. bool GlobalIsDefined(const std::string& globalName); - /// /// Checks if there is anything defined in a specific index of a table. - /// - /// The name of the table to look inside. - /// The name of the index to check inside that table. - /// Whether that table var has been defined yet in the Lua state. + /// @param tableName The name of the table to look inside. + /// @param indexName The name of the index to check inside that table. + /// @return Whether that table var has been defined yet in the Lua state. bool TableEntryIsDefined(const std::string& tableName, const std::string& indexName); - /// /// Clears internal Lua package tables from all user-defined modules. Those must be reloaded with ReloadAllScripts(). - /// void ClearUserModuleCache(); - /// /// Clears the Lua script cache. - /// void ClearLuaScriptCache(); #pragma endregion #pragma region Error Handling - /// /// Tells whether there are any errors reported waiting to be read. - /// - /// Whether errors exist. + /// @return Whether errors exist. bool ErrorExists() const; - /// /// Returns the last error message from executing scripts. - /// - /// The error string with hopefully meaningful info about what went wrong. + /// @return The error string with hopefully meaningful info about what went wrong. std::string GetLastError() const; - /// /// Clears the last error message, so the Lua state will not be considered to have any errors until the next time there's a script error. - /// void ClearErrors(); #pragma endregion private: - /// /// Gets a random integer between minInclusive and maxInclusive. - /// - /// A random integer between minInclusive and maxInclusive. + /// @return A random integer between minInclusive and maxInclusive. int SelectRand(int minInclusive, int maxInclusive); - /// /// Gets a random real between minInclusive and maxInclusive. - /// - /// A random real between minInclusive and maxInclusive. + /// @return A random real between minInclusive and maxInclusive. double RangeRand(double minInclusive, double maxInclusive); - /// /// Gets a random number between -1 and 1. - /// - /// A random number between -1 and 1. + /// @return A random number between -1 and 1. double NormalRand(); - /// /// Gets a random number between 0 and 1. - /// - /// A random number between 0 and 1. + /// @return A random number between 0 and 1. double PosRand(); #pragma region Passthrough LuaMan Functions @@ -307,15 +231,11 @@ namespace RTE { bool FileEOF(int fileIndex); #pragma endregion - /// /// Generates a string that describes the current state of the Lua stack, for debugging purposes. - /// - /// A string that describes the current state of the Lua stack. + /// @return A string that describes the current state of the Lua stack. std::string DescribeLuaStack(); - /// /// Clears all the member variables of this LuaStateWrapper, effectively resetting the members of this abstraction level only. - /// void Clear(); std::unordered_set m_RegisteredMOs; //!< The objects using our lua state. @@ -343,236 +263,168 @@ namespace RTE { typedef std::vector LuaStatesArray; - /// /// The singleton manager of each Lua state. - /// class LuaMan : public Singleton { friend class SettingsMan; friend class LuaStateWrapper; public: #pragma region Creation - /// /// Constructor method used to instantiate a LuaMan object in system memory. Initialize() should be called before using the object. - /// LuaMan() { Clear(); } - /// /// Makes the LuaMan object ready for use. - /// void Initialize(); #pragma endregion #pragma region Destruction - /// /// Destructor method used to clean up a LuaMan object before deletion from system memory. - /// ~LuaMan() { Destroy(); } - /// /// Destroys and resets (through Clear()) the LuaMan object. - /// void Destroy(); #pragma endregion #pragma region Lua State Handling - /// /// Returns our master script state (where activies, global scripts etc run). - /// - /// The master script state. + /// @return The master script state. LuaStateWrapper& GetMasterScriptState(); - /// /// Returns our threaded script states which movable objects use. - /// - /// A list of threaded script states. + /// @return A list of threaded script states. LuaStatesArray& GetThreadedScriptStates(); - /// /// Gets the current thread lua state override that new objects created will be assigned to. - /// - /// The current lua state to force objects to be assigned to. + /// @return The current lua state to force objects to be assigned to. LuaStateWrapper* GetThreadLuaStateOverride() const; - /// /// Forces all new MOs created in this thread to be assigned to a particular lua state. /// This is to ensure that objects created in threaded Lua environments can be safely used. - /// - /// The lua state to force objects to be assigned to. + /// @param luaState The lua state to force objects to be assigned to. void SetThreadLuaStateOverride(LuaStateWrapper* luaState); - /// /// Gets the current thread lua state that is running. - /// - /// The current lua state that is running. + /// @return The current lua state that is running. LuaStateWrapper* GetThreadCurrentLuaState() const; - /// /// Returns a free threaded script states to assign a movableobject to. /// This will be locked to our thread and safe to use - ensure that it'll be unlocked after use! - /// - /// A script state. + /// @return A script state. LuaStateWrapper* GetAndLockFreeScriptState(); - /// /// Clears internal Lua package tables from all user-defined modules. Those must be reloaded with ReloadAllScripts(). - /// void ClearUserModuleCache(); - /// /// Adds a function to be called prior to executing lua scripts. This is used to callback into lua from other threads safely. - /// - /// The callback function that will be executed. + /// @param callback The callback function that will be executed. void AddLuaScriptCallback(const std::function& callback); - /// /// Executes and clears all pending script callbacks. - /// void ExecuteLuaScriptCallbacks(); - /// /// Gets m_ScriptTimings. - /// - /// m_ScriptTimings. + /// @return m_ScriptTimings. const std::unordered_map GetScriptTimings() const; #pragma endregion #pragma region File I / O Handling - /// /// Returns a vector of all the directories in path, which is relative to the working directory. - /// - /// Directory path relative to the working directory. - /// A vector of the directories in path. + /// @param path Directory path relative to the working directory. + /// @return A vector of the directories in path. const std::vector* DirectoryList(const std::string& path); - /// /// Returns a vector of all the files in path, which is relative to the working directory. - /// - /// Directory path relative to the working directory. - /// A vector of the files in path. + /// @param path Directory path relative to the working directory. + /// @return A vector of the files in path. const std::vector* FileList(const std::string& path); - /// /// Returns whether or not the specified file exists. You can only check for files inside .rte folders in the working directory. - /// - /// Path to the file. All paths are made absolute by adding current working directory to the specified path. - /// Whether or not the specified file exists. + /// @param path Path to the file. All paths are made absolute by adding current working directory to the specified path. + /// @return Whether or not the specified file exists. bool FileExists(const std::string& path); - /// /// Returns whether or not the specified directory exists. You can only check for directories inside .rte folders in the working directory. - /// - /// Path to the directory. All paths are made absolute by adding current working directory to the specified path. - /// Whether or not the specified file exists. + /// @param path Path to the directory. All paths are made absolute by adding current working directory to the specified path. + /// @return Whether or not the specified file exists. bool DirectoryExists(const std::string& path); - /// /// Returns whether or not the path refers to an accessible file or directory. You can only check for files or directories inside .rte directories in the working directory. - /// - /// Path to the file or directory. All paths are made absolute by adding current working directory to the specified path. - /// Whether or not the specified file exists. + /// @param path Path to the file or directory. All paths are made absolute by adding current working directory to the specified path. + /// @return Whether or not the specified file exists. bool IsValidModulePath(const std::string& path); - /// /// Opens a file or creates one if it does not exist, depending on access mode. You can open files only inside .rte folders in the working directory. You can't open more that c_MaxOpenFiles file simultaneously. /// On Linux will attempt to open a file case insensitively. - /// - /// Path to the file. All paths are made absolute by adding current working directory to the specified path. - /// File access mode. See 'fopen' for list of modes. - /// File index in the opened files array. + /// @param path Path to the file. All paths are made absolute by adding current working directory to the specified path. + /// @param mode File access mode. See 'fopen' for list of modes. + /// @return File index in the opened files array. int FileOpen(const std::string& path, const std::string& accessMode); - /// /// Closes a previously opened file. - /// - /// File index in the opened files array. + /// @param fileIndex File index in the opened files array. void FileClose(int fileIndex); - /// /// Closes all previously opened files. - /// void FileCloseAll(); - /// /// Removes a file. - /// - /// Path to the file. All paths are made absolute by adding current working directory to the specified path. - /// Whether or not the file was removed. + /// @param path Path to the file. All paths are made absolute by adding current working directory to the specified path. + /// @return Whether or not the file was removed. bool FileRemove(const std::string& path); - /// /// Creates a directory, optionally recursively. - /// - /// Path to the directory to be created. All paths are made absolute by adding current working directory to the specified path. - /// Whether to recursively create parent directories. - /// Whether or not the directory was removed. + /// @param path Path to the directory to be created. All paths are made absolute by adding current working directory to the specified path. + /// @param recursive Whether to recursively create parent directories. + /// @return Whether or not the directory was removed. bool DirectoryCreate(const std::string& path, bool recursive); - /// /// Removes a directory, optionally recursively. - /// - /// Path to the directory to be removed. All paths are made absolute by adding current working directory to the specified path. - /// Whether to recursively remove files and directories. - /// Whether or not the directory was removed. + /// @param path Path to the directory to be removed. All paths are made absolute by adding current working directory to the specified path. + /// @param recursive Whether to recursively remove files and directories. + /// @return Whether or not the directory was removed. bool DirectoryRemove(const std::string& path, bool recursive); - /// /// Moves or renames the file oldPath to newPath. /// In order to get consistent behavior across Windows and Linux across all 4 combinations of oldPath and newPath being a directory/file, /// the newPath isn't allowed to already exist. - /// - /// Path to the filesystem object. All paths are made absolute by adding current working directory to the specified path. - /// Path to the filesystem object. All paths are made absolute by adding current working directory to the specified path. - /// Whether or not renaming succeeded. + /// @param oldPath Path to the filesystem object. All paths are made absolute by adding current working directory to the specified path. + /// @param newPath Path to the filesystem object. All paths are made absolute by adding current working directory to the specified path. + /// @return Whether or not renaming succeeded. bool FileRename(const std::string& oldPath, const std::string& newPath); - /// /// Moves or renames the directory oldPath to newPath. /// In order to get consistent behavior across Windows and Linux across all 4 combinations of oldPath and newPath being a directory/file, /// the newPath isn't allowed to already exist. - /// - /// Path to the filesystem object. All paths are made absolute by adding current working directory to the specified path. - /// Path to the filesystem object. All paths are made absolute by adding current working directory to the specified path. - /// Whether or not renaming succeeded. + /// @param oldPath Path to the filesystem object. All paths are made absolute by adding current working directory to the specified path. + /// @param newPath Path to the filesystem object. All paths are made absolute by adding current working directory to the specified path. + /// @return Whether or not renaming succeeded. bool DirectoryRename(const std::string& oldPath, const std::string& newPath); - /// /// Reads a line from a file. - /// - /// File index in the opened files array. - /// Line from file, or empty string on error. + /// @param fileIndex File index in the opened files array. + /// @return Line from file, or empty string on error. std::string FileReadLine(int fileIndex); - /// /// Writes a text line to a file. - /// - /// File index in the opened files array. - /// String to write. + /// @param fileIndex File index in the opened files array. + /// @param line String to write. void FileWriteLine(int fileIndex, const std::string& line); - /// /// Returns true if end of file was reached. - /// - /// File index in the opened files array. - /// Whether or not EOF was reached. + /// @param fileIndex File index in the opened files array. + /// @return Whether or not EOF was reached. bool FileEOF(int fileIndex); #pragma endregion #pragma region Concrete Methods - /// /// Updates the state of this LuaMan. - /// void Update(); - /// /// Asynchronously enforces a GC run to occur. - /// void StartAsyncGarbageCollection(); #pragma endregion - /// /// Clears Script Timings. - /// void ClearScriptTimings(); private: @@ -591,9 +443,7 @@ namespace RTE { BS::multi_future m_GarbageCollectionTask; - /// /// Clears all the member variables of this LuaMan, effectively resetting the members of this abstraction level only. - /// void Clear(); // Disallow the use of some implicit methods. diff --git a/Source/Managers/MenuMan.cpp b/Source/Managers/MenuMan.cpp index 0308254725..a4dc7373df 100644 --- a/Source/Managers/MenuMan.cpp +++ b/Source/Managers/MenuMan.cpp @@ -21,8 +21,6 @@ namespace RTE { - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void MenuMan::Initialize(bool firstTimeInit) { m_ActiveMenu = ActiveMenu::MenusDisabled; @@ -43,8 +41,6 @@ namespace RTE { g_MetaMan.GetGUI()->Create(m_MenuController.get()); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void MenuMan::Reinitialize() { g_MetaMan.GetGUI()->Destroy(); @@ -57,8 +53,6 @@ namespace RTE { Initialize(false); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void MenuMan::SetActiveMenu() { ActiveMenu newActiveMenu = ActiveMenu::MenusDisabled; @@ -108,8 +102,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void MenuMan::HandleTransitionIntoMenuLoop() { if (g_MetaMan.GameInProgress()) { if (g_ActivityMan.SkipPauseMenuWhenPausingActivity()) { @@ -135,8 +127,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool MenuMan::Update() { m_TitleScreen->Update(); SetActiveMenu(); @@ -173,8 +163,6 @@ namespace RTE { return false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool MenuMan::UpdateMainMenu() const { switch (m_MainMenu->Update()) { case MainMenuGUI::MainMenuUpdateResult::MetaGameStarted: @@ -205,8 +193,6 @@ namespace RTE { return false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void MenuMan::UpdateScenarioMenu() const { switch (m_ScenarioMenu->Update()) { case ScenarioGUI::ScenarioMenuUpdateResult::BackToMain: @@ -228,8 +214,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool MenuMan::UpdateMetaGameMenu() const { g_MetaMan.GetGUI()->SetStationOrbitPos(m_TitleScreen->GetStationPos()); g_MetaMan.Update(); @@ -247,8 +231,6 @@ namespace RTE { return g_MetaMan.GetGUI()->QuitProgram(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void MenuMan::UpdatePauseMenu() const { switch (m_PauseMenu->Update()) { case PauseMenuGUI::PauseMenuUpdateResult::ActivityResumed: @@ -263,8 +245,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void MenuMan::Draw() const { g_FrameMan.ClearBackBuffer32(); diff --git a/Source/Managers/MenuMan.h b/Source/Managers/MenuMan.h index 677b1a6ef2..e2d1ed6c5d 100644 --- a/Source/Managers/MenuMan.h +++ b/Source/Managers/MenuMan.h @@ -15,52 +15,36 @@ namespace RTE { class ScenarioGUI; class PauseMenuGUI; - /// /// The singleton manager responsible for handling all the out-of-game menu screens (main menu, scenario menu, etc.). - /// class MenuMan : public Singleton { public: #pragma region Creation - /// /// Constructor method used to instantiate a MenuMan object in system memory. Initialize() should be called before using the object. - /// MenuMan() = default; - /// /// Makes the MenuMan object ready for use. - /// - /// Whether this is initializing for the first time, meaning the game is booting up, so the loading screen needs to be shown and all module loading should happen. + /// @param firstTimeInit Whether this is initializing for the first time, meaning the game is booting up, so the loading screen needs to be shown and all module loading should happen. void Initialize(bool firstTimeInit = true); - /// /// Reinitializes all the Main Menu GUIs after a resolution change. Must be done otherwise the GUIs retain the original resolution settings and become all screwy. - /// void Reinitialize(); #pragma endregion #pragma region Concrete Methods - /// /// Sets the appropriate TitleScreen transition before entering the menu loop. - /// void HandleTransitionIntoMenuLoop(); - /// /// Updates the MenuMan state. - /// - /// Whether the MenuMan update has reached a state where the menu loop should be exited so the simulation loop can proceed. + /// @return Whether the MenuMan update has reached a state where the menu loop should be exited so the simulation loop can proceed. bool Update(); - /// /// Draws the MenuMan to the screen. - /// void Draw() const; #pragma endregion private: - /// /// Enumeration for the different menu screens that are active based on transition states. - /// enum ActiveMenu { MenusDisabled, MainMenuActive, @@ -81,31 +65,21 @@ namespace RTE { std::unique_ptr m_PauseMenu; //!< The game pause menu screen. #pragma region Updates - /// /// Sets the active menu screen to be enabled, updated and drawn to the screen, besides the title screen which is always active. - /// void SetActiveMenu(); - /// /// Updates the main menu screen and handles the update results. - /// - /// Whether the program was set to be terminated by the user through the main menu screen. + /// @return Whether the program was set to be terminated by the user through the main menu screen. bool UpdateMainMenu() const; - /// /// Updates the scenario menu screen and handles the update results. - /// void UpdateScenarioMenu() const; - /// /// Updates the MetaGame menu screen and handles the update results. - /// - /// Whether the program was set to be terminated by the user through the MetaGame menu screen. + /// @return Whether the program was set to be terminated by the user through the MetaGame menu screen. bool UpdateMetaGameMenu() const; - /// /// Updates the pause menu screen and handles the update results. - /// void UpdatePauseMenu() const; #pragma endregion diff --git a/Source/Managers/MetaMan.cpp b/Source/Managers/MetaMan.cpp index 6a7e47d9a4..bfcf126594 100644 --- a/Source/Managers/MetaMan.cpp +++ b/Source/Managers/MetaMan.cpp @@ -1,15 +1,3 @@ -////////////////////////////////////////////////////////////////////////////////////////// -// File: MetaMan.cpp -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Source file for the MetaMan class. -// Project: Retro Terrain Engine -// Author(s): Daniel Tabar -// data@datarealms.com -// http://www.datarealms.com - -////////////////////////////////////////////////////////////////////////////////////////// -// Inclusions of header files - #include "MetaMan.h" #include "MetaSave.h" #include "PresetMan.h" @@ -29,12 +17,6 @@ namespace RTE { const std::string MetaMan::c_ClassName = "MetaMan"; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Clear - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears all the member variables of this MetaMan, effectively - // resetting the members of this abstraction level only. - void MetaMan::Clear() { m_pMetaGUI = 0; m_GameState = NOGAME; @@ -60,11 +42,6 @@ namespace RTE { m_TeamAISkill[team] = Activity::DefaultSkill; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes the MetaMan object ready for use. - int MetaMan::Initialize() { // if (Serializable::Create() < 0) // return -1; @@ -76,11 +53,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: NewGame - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Wipes any current and sets up a new game based on a size parameter. - int MetaMan::NewGame(int gameSize) { // Grab a random selection of Scene presets from all available std::list scenePresets; @@ -164,14 +136,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: EndGame - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Wipes any current metagame and sets things back to as if program start. - // Arguments: None. - // Return value: An error return value signaling success or any particular failure. - // Anything below 0 is an error signal. - int MetaMan::EndGame() { // Reset metagame UI m_pMetaGUI->SetToStartNewGame(); @@ -199,11 +163,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Load - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Load a MetaMan from disk out of the special MetaMan.rte data module - int MetaMan::Load(const MetaSave* pSave) { if (!pSave) return -1; @@ -235,14 +194,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: ReadProperty - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Reads a property value from a Reader stream. If the name isn't - // recognized by this class, then ReadProperty of the parent class - // is called. If the property isn't recognized by any of the base classes, - // false is returned, and the Reader's position is untouched. - int MetaMan::ReadProperty(const std::string_view& propName, Reader& reader) { StartPropertyList(return Serializable::ReadProperty(propName, reader)); @@ -284,12 +235,6 @@ namespace RTE { EndPropertyList; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Save - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Saves the complete state of this MetaMan to an output stream for - // later recreation with Create(Reader &reader); - int MetaMan::Save(Writer& writer) const { Serializable::Save(writer); @@ -347,12 +292,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SaveSceneData - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Saves the bitmap data of all Scenes of this Metagame that are currently - // loaded. - int MetaMan::SaveSceneData(std::string pathBase) { for (std::vector::const_iterator sItr = m_Scenes.begin(); sItr != m_Scenes.end(); ++sItr) { // Only save the data of revealed scenes that have already had their layers built and saved into files @@ -365,12 +304,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: LoadSceneData - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Loads the bitmap data of all Scenes of this Metagame that have once - // been saved to files. - int MetaMan::LoadSceneData() { for (std::vector::iterator sItr = g_MetaMan.m_Scenes.begin(); sItr != g_MetaMan.m_Scenes.end(); ++sItr) { // Only load the data of revealed scenes that have already had their layers built and saved into files @@ -383,12 +316,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ClearSceneData - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears the bitmap data of all Scenes of this Metagame that have once - // been saved to files. - int MetaMan::ClearSceneData() { for (std::vector::iterator sItr = g_MetaMan.m_Scenes.begin(); sItr != g_MetaMan.m_Scenes.end(); ++sItr) { if ((*sItr)->ClearData() < 0) @@ -397,11 +324,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destroys and resets (through Clear()) the MetaMan object. - void MetaMan::Destroy() { delete m_pMetaGUI; @@ -413,11 +335,6 @@ namespace RTE { Clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetPlayerTurn - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Shows which player's turn is now or coming up. - int MetaMan::GetPlayerTurn() const { // Player 1's turn is coming up on this round if (g_MetaMan.m_GameState <= PLAYER1TURN) @@ -430,11 +347,6 @@ namespace RTE { return g_MetaMan.m_GameState - PLAYER1TURN; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetMetaPlayerOfInGamePlayer - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the MetaPlayer playing a specific in-game player, if any. - MetaPlayer* MetaMan::GetMetaPlayerOfInGamePlayer(int inGamePlayer) { for (std::vector::iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr) { if ((*itr).GetInGamePlayer() == inGamePlayer) @@ -445,11 +357,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetNextSceneOfPlayer - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the next Scene in play that is owned by a specific player. - const Scene* MetaMan::GetNextSceneOfPlayer(int player, const Scene* pStartScene) const { if (m_Scenes.empty()) return 0; @@ -483,12 +390,6 @@ namespace RTE { return pFoundScene; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetTotalBrainCountOfPlayer - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the total number of brains that a player has, including ones of - // his that are resident down on sites. - int MetaMan::GetTotalBrainCountOfPlayer(int metaPlayer, bool countPoolsOnly) const { if (metaPlayer <= Players::NoPlayer || metaPlayer >= Players::MaxPlayerCount) return 0; @@ -509,11 +410,6 @@ namespace RTE { return brainCount; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetGoldCountOfTeam - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the total gold funds of all the players of a specific team combined. - int MetaMan::GetGoldCountOfTeam(int team) const { if (team <= Activity::NoTeam || team >= m_TeamCount) return 0; @@ -528,11 +424,6 @@ namespace RTE { return goldTotal; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetSceneCountOfTeam - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the total number of bases that any specific team owns. - int MetaMan::GetSceneCountOfTeam(int team) const { if (team <= Activity::NoTeam || team >= m_TeamCount) return 0; @@ -548,12 +439,6 @@ namespace RTE { return sceneCount; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetTotalBrainCountOfTeam - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the total number of brains that a team has, including ones that - // are resident down on sites. - int MetaMan::GetTotalBrainCountOfTeam(int team, bool countPoolsOnly) const { if (team <= Activity::NoTeam || team >= m_TeamCount) return 0; @@ -569,12 +454,6 @@ namespace RTE { return brainCount; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: OnlyTeamWithAnyBrainPoolLeft - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Indicates which team, if any, is the only one left with brains in its - // pool. - int MetaMan::OnlyTeamWithAnyBrainPoolLeft() { // See if only one team remains with any brains int brainTeamCount = 0; @@ -657,12 +536,6 @@ namespace RTE { } */ - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: NoBrainsLeftInAnyPool - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Indicates whether there are no brains left in any active player's pool - // at all. This does NOT count deployed brain in bases. - bool MetaMan::NoBrainsLeftInAnyPool() { // Go through all players and check each for any brains in any pool for (std::vector::iterator mpItr = m_Players.begin(); mpItr != m_Players.end(); ++mpItr) { @@ -672,12 +545,6 @@ namespace RTE { return true; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: WhichTeamIsLeading - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Indicates which single team has the most owned bases, and if there's a - // tie between two teams, total owned gold funds is used as a tiebreaker. - int MetaMan::WhichTeamIsLeading() { int leaderTeam = Activity::NoTeam; bool tiedTeams[Activity::MaxTeamCount]; @@ -733,11 +600,6 @@ namespace RTE { return leaderTeam; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetSceneIncomeOfPlayer - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the total income from all scenes owned by a specific player. - float MetaMan::GetSceneIncomeOfPlayer(int metaPlayer) const { float totalIncome = 0; @@ -749,11 +611,6 @@ namespace RTE { return totalIncome; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetBudgetedRatioOfPlayer - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the ratio of funds already allocated to budgets of this player. - float MetaMan::GetBudgetedRatioOfPlayer(int metaPlayer, const Scene* pException, bool includeOffensive, bool includeDefensive) const { float totalAllocated = 0; @@ -773,12 +630,6 @@ namespace RTE { return totalAllocated / m_Players[metaPlayer].GetFunds(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetSuspend - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Suspends or unsuspends the game so exclusive GUIs and menus can be - // shown - void MetaMan::SetSuspend(bool suspend) { if (suspend && !m_Suspended) { m_Suspended = true; @@ -789,11 +640,6 @@ namespace RTE { } } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: WhichTeamOwnsAllSites - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Checks whether one team has ownership of all revealed sites. - int MetaMan::WhichTeamOwnsAllSites() { int owner = Activity::NoTeam; for (std::vector::iterator sItr = m_Scenes.begin(); sItr != m_Scenes.end(); ++sItr) { @@ -817,11 +663,6 @@ namespace RTE { return owner; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: IsGameOver - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Checks for game over condition - bool MetaMan::IsGameOver() { // This is the old condition of all sites being conquered // if (m_RevealedScenes >= m_Scenes.size() && WhichTeamOwnsAllSites() != Activity::NoTeam) @@ -836,11 +677,6 @@ namespace RTE { return false; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: TotalScenePresets - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Yields a set of ALL eligible Scene presets for a new game. - int MetaMan::TotalScenePresets(std::list* pScenes) { int totalCount = 0; // Get the list of ALL read-in Scene presets @@ -884,11 +720,6 @@ namespace RTE { return totalCount; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SelectScenePresets - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Yields a set of randomly selected Scene presets for a new game. - int MetaMan::SelectScenePresets(int gameSize, std::list* pSelected) { // Get the list of ALL eligible read-in Scene presets std::list scenePresets; @@ -922,11 +753,6 @@ namespace RTE { return gameSize; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ClearActivities - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears out all the lined-up activities for the current round. - void MetaMan::ClearActivities() { for (std::vector::iterator aItr = m_RoundOffensives.begin(); aItr != m_RoundOffensives.end(); ++aItr) delete (*aItr); @@ -934,11 +760,6 @@ namespace RTE { m_CurrentOffensive = 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: AIPlayerTurn - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Does all the things an AI player needs to do during his turn. - void MetaMan::AIPlayerTurn(int metaPlayer) { if (metaPlayer < 0 || metaPlayer >= m_Players.size()) return; @@ -1068,11 +889,6 @@ namespace RTE { // TODO: Pay for and schedule to scan a random unfriendly site to keep things fair } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Update - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the state of this. Supposed to be done every frame before drawing. - void MetaMan::Update() { m_pMetaGUI->Update(); @@ -1316,12 +1132,6 @@ namespace RTE { } } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Draw - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws this MetaMan's current graphical representation to a - // BITMAP of choice. This includes all game-related graphics. - void MetaMan::Draw(BITMAP* pTargetBitmap, const Vector& targetPos) { /* GUIFont *pLargeFont = g_FrameMan.GetLargeFont(); diff --git a/Source/Managers/MetaMan.h b/Source/Managers/MetaMan.h index 21d97d1e7b..360c5eb7d0 100644 --- a/Source/Managers/MetaMan.h +++ b/Source/Managers/MetaMan.h @@ -1,27 +1,20 @@ #ifndef _RTEMETAMAN_ #define _RTEMETAMAN_ -////////////////////////////////////////////////////////////////////////////////////////// -// File: MetaMan.h -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Header file for the MetaMan class. -// Project: Retro Terrain Engine -// Author(s): Daniel Tabar -// data@datarealms.com -// http://www.datarealms.com - -////////////////////////////////////////////////////////////////////////////////////////// -// Inclusions of header files - +/// Header file for the MetaMan class. +/// @author Daniel Tabar +/// data@datarealms.com +/// http://www.datarealms.com +/// Inclusions of header files #include "RTETools.h" #include "Singleton.h" #define g_MetaMan MetaMan::Instance() -//#include "Serializable.h" +// #include "Serializable.h" #include "SceneObject.h" #include "Controller.h" -//#include "FrameMan.h" -//#include "SceneMan.h" +// #include "FrameMan.h" +// #include "SceneMan.h" #include "ActivityMan.h" #include "MetaPlayer.h" #include "GAScripted.h" @@ -39,20 +32,12 @@ namespace RTE { class MetaSave; class Scene; - ////////////////////////////////////////////////////////////////////////////////////////// - // Class: MetaMan - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: The singleton manager of the Metagame of Cortex Command, ie the - // games played out in the campaign screen. - // Parent(s): Singleton, serializable - // Class history: 10/10/2009 MetaMan created. - + /// The singleton manager of the Metagame of Cortex Command, ie the + /// games played out in the campaign screen. class MetaMan : public Singleton, public Serializable { friend struct ManagerLuaBindings; - ////////////////////////////////////////////////////////////////////////////////////////// - // Public member variable, method and friend function declarations - + /// Public member variable, method and friend function declarations public: friend class MetagameGUI; friend class MetaSave; @@ -76,455 +61,242 @@ namespace RTE { GAMEOVER }; - ////////////////////////////////////////////////////////////////////////////////////////// - // Constructor: MetaMan - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Constructor method used to instantiate a MetaMan object in system - // memory. Create() should be called before using the object. - // Arguments: None. - + /// Constructor method used to instantiate a MetaMan object in system + /// memory. Create() should be called before using the object. MetaMan() { Clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Destructor: ~MetaMan - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destructor method used to clean up a MetaMan object before deletion - // from system memory. - // Arguments: None. - + /// Destructor method used to clean up a MetaMan object before deletion + /// from system memory. ~MetaMan() { Destroy(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes the MetaMan object ready for use. - // Arguments: None. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Makes the MetaMan object ready for use. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Initialize(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: NewGame - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Wipes any current and sets up a new game based on a size parameter. - // Arguments: The size of the new Metagame, which will affect how - // many Scenes/Sites will ultimately be used. - // Return value: An error return value signaling success or any particular failure. - // Anything below 0 is an error signal. - + /// Wipes any current and sets up a new game based on a size parameter. + /// @param gameSize The size of the new Metagame, which will affect how (default: 3) + /// many Scenes/Sites will ultimately be used. + /// @return An error return value signaling success or any particular failure. + /// Anything below 0 is an error signal. int NewGame(int gameSize = 3); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: EndGame - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Wipes any current metagame and sets things back to as if program start. - // Arguments: None. - // Return value: An error return value signaling success or any particular failure. - // Anything below 0 is an error signal. - + /// Wipes any current metagame and sets things back to as if program start. + /// @return An error return value signaling success or any particular failure. + /// Anything below 0 is an error signal. int EndGame(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Load - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Load a Metagame from disk out of the special Metagame.rte data module - // Arguments: The MetaSave object to load from - Ownership Is Not Transferred! - // Return value: An error return value signaling success or any particular failure. - // Anything below 0 is an error signal. - + /// Load a Metagame from disk out of the special Metagame.rte data module + /// @param pSave The MetaSave object to load from - Ownership Is Not Transferred! + /// @return An error return value signaling success or any particular failure. + /// Anything below 0 is an error signal. int Load(const MetaSave* pSave); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SaveSceneData - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Saves the bitmap data of all Scenes of this Metagame that are currently - // loaded. - // Arguments: The filepath base to the where to save the Bitmap data. This means - // everything up to and including the unique name of the game. - // Return value: An error return value signaling success or any particular failure. - // Anything below 0 is an error signal. - + /// Saves the bitmap data of all Scenes of this Metagame that are currently + /// loaded. + /// @param pathBase The filepath base to the where to save the Bitmap data. This means + /// everything up to and including the unique name of the game. + /// @return An error return value signaling success or any particular failure. + /// Anything below 0 is an error signal. int SaveSceneData(std::string pathBase); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: LoadSceneData - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Loads the bitmap data of all Scenes of this Metagame that have once - // been saved to files. - // Arguments: None. - // Return value: An error return value signaling success or any particular failure. - // Anything below 0 is an error signal. - + /// Loads the bitmap data of all Scenes of this Metagame that have once + /// been saved to files. + /// @return An error return value signaling success or any particular failure. + /// Anything below 0 is an error signal. int LoadSceneData(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ClearSceneData - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears the bitmap data of all Scenes of this Metagame that have once - // been saved to files. - // Arguments: None. - // Return value: An error return value signaling success or any particular failure. - // Anything below 0 is an error signal. - + /// Clears the bitmap data of all Scenes of this Metagame that have once + /// been saved to files. + /// @return An error return value signaling success or any particular failure. + /// Anything below 0 is an error signal. int ClearSceneData(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Reset - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Resets the entire MetaMan, including its inherited members, to - // their default settings or values. - // Arguments: None. - // Return value: None. - + /// Resets the entire MetaMan, including its inherited members, to + /// their default settings or values. void Reset() override { Clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destroys and resets (through Clear()) the MetaMan object. - // Return value: None. - + /// Destroys and resets (through Clear()) the MetaMan object. void Destroy(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetGameName - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the name of the currently played Metagame. It's what's used when - // saving to disk. - // Arguments: The Metagame's name. - // Return value: None. - + /// Sets the name of the currently played Metagame. It's what's used when + /// saving to disk. + /// @param newName The Metagame's name. void SetGameName(std::string newName) { m_GameName = newName; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetGameName - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the name of the currently played Metagame. It's what's used when - // saving to disk. - // Arguments: None. - // Return value: The name of the current metagame. - + /// Gets the name of the currently played Metagame. It's what's used when + /// saving to disk. + /// @return The name of the current metagame. std::string GetGameName() const { return m_GameName; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetGUI - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the GUI controller of this Metagame. - // Arguments: None. - // Return value: The GUI controller of the metagame. - + /// Gets the GUI controller of this Metagame. + /// @return The GUI controller of the metagame. MetagameGUI* GetGUI() { return m_pMetaGUI; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetPlayerTurn - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Shows which player's turn is now or coming up. - // Arguments: None. - // Return value: The player who is currently doing his turn, or coming up next in an - // intermediate phase. - + /// Shows which player's turn is now or coming up. + /// @return The player who is currently doing his turn, or coming up next in an + /// intermediate phase. int GetPlayerTurn() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetPlayerCount - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets current number of MetaPlayers - // Arguments: None - // Return value: The number of meta players in the current game. - + /// Gets current number of MetaPlayers + /// @return The number of meta players in the current game. int GetPlayerCount() const { return m_Players.size(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetTeamOfPlayer - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the designated team of a specific player - // Arguments: Which player. - // Return value: The team of that player. - + /// Gets the designated team of a specific player + /// @param metaPlayer Which player. + /// @return The team of that player. int GetTeamOfPlayer(int metaPlayer) const { return metaPlayer >= Players::PlayerOne && metaPlayer < m_Players.size() ? m_Players[metaPlayer].GetTeam() : Activity::NoTeam; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetPlayer - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the specified MetaPlayer - // Arguments: Which player. - // Return value: The requested MetaPlayer - + /// Gets the specified MetaPlayer + /// @param metaPlayer Which player. + /// @return The requested MetaPlayer MetaPlayer* GetPlayer(int metaPlayer) { return (metaPlayer >= Players::PlayerOne && metaPlayer < m_Players.size()) ? &(m_Players[metaPlayer]) : 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetMetaPlayerOfInGamePlayer - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the MetaPlayer playing a specific in-game player, if any. - // Arguments: Which in-game player to translate into a metaplayer. - // Return value: The requested MetaPlayer, if any is playing that in-game player. If not - // 0 is returned. - + /// Gets the MetaPlayer playing a specific in-game player, if any. + /// @param inGamePlayer Which in-game player to translate into a metaplayer. + /// @return The requested MetaPlayer, if any is playing that in-game player. If not + /// 0 is returned. MetaPlayer* GetMetaPlayerOfInGamePlayer(int inGamePlayer); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetTeamIcon - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the flag Icon of a specific team - // Arguments: The team to get the Team icon of. - // Return value: A reference to the Icon. - + /// Gets the flag Icon of a specific team + /// @param team The team to get the Team icon of. + /// @return A reference to the Icon. Icon& GetTeamIcon(int team) { return m_TeamIcons[team]; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetNextSceneOfPlayer - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the next Scene in play that is owned by a specific player. - // Arguments: The player to get the next owned Scene of. - // The Scene to start searching from in the current roster of Scenes, OWNERSHIP IS NOT TRANSFERRED! - // Return value: A pointer to the next Scene found in the sequence. OWNERSHIP IS NOT TRANSFERRED! - + /// Gets the next Scene in play that is owned by a specific player. + /// @param metaPlayer The player to get the next owned Scene of. + /// @param pScene The Scene to start searching from in the current roster of Scenes, OWNERSHIP IS NOT TRANSFERRED! (default: 0) + /// @return A pointer to the next Scene found in the sequence. OWNERSHIP IS NOT TRANSFERRED! const Scene* GetNextSceneOfPlayer(int metaPlayer, const Scene* pScene = 0) const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetTotalBrainCountOfPlayer - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the total number of brains that a player has, including ones of - // his that are resident down on sites. - // Arguments: The metagame player to get the total brain count from. - // Whether to only count the brains in the pools, or to also include all - // resident brains as well. - // Return value: The total number of brains that belong to the metagame player. - + /// Gets the total number of brains that a player has, including ones of + /// his that are resident down on sites. + /// @param metaPlayer The metagame player to get the total brain count from. + /// @param countPoolsOnly Whether to only count the brains in the pools, or to also include all (default: false) + /// resident brains as well. + /// @return The total number of brains that belong to the metagame player. int GetTotalBrainCountOfPlayer(int metaPlayer, bool countPoolsOnly = false) const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetGoldCountOfTeam - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the total gold funds of all the players of a specific team combined. - // Arguments: The metagame team to get the total gold funds of. - // Return value: The total amount of ounces of gold this team has. - + /// Gets the total gold funds of all the players of a specific team combined. + /// @param team The metagame team to get the total gold funds of. + /// @return The total amount of ounces of gold this team has. int GetGoldCountOfTeam(int team) const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetSceneCountOfTeam - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the total number of bases that any specific team owns. - // Arguments: The team to get the scene/site ownership count of. - // Return value: The count of scenes owned by this team. - + /// Gets the total number of bases that any specific team owns. + /// @param team The team to get the scene/site ownership count of. + /// @return The count of scenes owned by this team. int GetSceneCountOfTeam(int team) const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetTotalBrainCountOfTeam - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the total number of brains that a team has, including ones that - // are resident down on sites. - // Arguments: The metagame team to get the total brain count from. - // Whether to only count the brains in the pools, or to also include all - // resident brains as well. - // Return value: The total number of brains that belong to the metagame team. - + /// Gets the total number of brains that a team has, including ones that + /// are resident down on sites. + /// @param team The metagame team to get the total brain count from. + /// @param countPoolsOnly Whether to only count the brains in the pools, or to also include all (default: false) + /// resident brains as well. + /// @return The total number of brains that belong to the metagame team. int GetTotalBrainCountOfTeam(int team, bool countPoolsOnly = false) const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: OnlyTeamWithAnyBrainPoolLeft - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Indicates which team, if any, is the only one left with brains in its - // pool. - // Arguments: None. - // Return value: Which team, if any, is the sole remaining with any brains left in its - // players' brain pools. - + /// Indicates which team, if any, is the only one left with brains in its + /// pool. + /// @return Which team, if any, is the sole remaining with any brains left in its + /// players' brain pools. int OnlyTeamWithAnyBrainPoolLeft(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: NoBrainsLeftInAnyPool - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Indicates whether there are no brains left in any active player's pool - // at all. This does NOT count deployed brain in bases. - // Arguments: None. - // Return value: Whether there are no brains left in any player's brain pool. - + /// Indicates whether there are no brains left in any active player's pool + /// at all. This does NOT count deployed brain in bases. + /// @return Whether there are no brains left in any player's brain pool. bool NoBrainsLeftInAnyPool(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: WhichTeamIsLeading - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Indicates which single team has the most owned bases, and if there's a - // tie between two teams, total owned gold funds is used as a tiebreaker. - // Arguments: None. - // Return value: Which team is currently in the lead. - + /// Indicates which single team has the most owned bases, and if there's a + /// tie between two teams, total owned gold funds is used as a tiebreaker. + /// @return Which team is currently in the lead. int WhichTeamIsLeading(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetSceneIncomeOfPlayer - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the total income from all scenes owned by a specific metaPlayer. - // Arguments: The metagame player to get the total scene income from. - // Return value: The amount of income, in oz, the player made this round from its scenes. - + /// Gets the total income from all scenes owned by a specific metaPlayer. + /// @param metaPlayer The metagame player to get the total scene income from. + /// @return The amount of income, in oz, the player made this round from its scenes. float GetSceneIncomeOfPlayer(int metaPlayer) const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetBudgetedRatioOfPlayer - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the ratio of funds already allocated to budgets of this player. - // Arguments: The metagame player to get the budget ratio of. - // A scene to exclude from the tally, if any. - // Whether to count the money allocated for offensive action. - // Whether to count the money allocated for defensive actions. - // Return value: The amount, in ratio, that this player already has allocated. - + /// Gets the ratio of funds already allocated to budgets of this player. + /// @param metaPlayer The metagame player to get the budget ratio of. + /// @param pException A scene to exclude from the tally, if any. (default: 0) + /// @param includeOffensive Whether to count the money allocated for offensive action. (default: true) + /// @param includeDefensive Whether to count the money allocated for defensive actions. (default: true) + /// @return The amount, in ratio, that this player already has allocated. float GetBudgetedRatioOfPlayer(int metaPlayer, const Scene* pException = 0, bool includeOffensive = true, bool includeDefensive = true) const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetRemainingFundsOfPlayer - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the count of funds still unbudgeted and available of a player. - // Arguments: The metagame player to get the unallocated funds of. - // A scene to exclude from the tally, if any. - // Whether to count the money allocated for offensive action as remaining. - // Whether to count the money allocated for defensive action as remaining. - // Return value: The amount, in oz, that this player unallocated and unused this turn. - + /// Gets the count of funds still unbudgeted and available of a player. + /// @param metaPlayer The metagame player to get the unallocated funds of. + /// @param pException A scene to exclude from the tally, if any. (default: 0) + /// @param deductOffensive Whether to count the money allocated for offensive action as remaining. (default: false) + /// @param deductDefensive Whether to count the money allocated for defensive action as remaining. (default: false) const { return m_Players[metaPlayer].GetFunds() - m_Players[metaPlayer].GetFunds() * GetBudgetedRatioOfPlayer(metaPlayer) + /// @return The amount, in oz, that this player unallocated and unused this turn. float GetRemainingFundsOfPlayer(int metaPlayer, const Scene* pException = 0, bool deductOffensive = false, bool deductDefensive = false) const { return m_Players[metaPlayer].GetFunds() - m_Players[metaPlayer].GetFunds() * GetBudgetedRatioOfPlayer(metaPlayer, pException, !deductOffensive, !deductDefensive); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GameInProgress - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Shows whether a game is currently in progress - // Arguments: None. - // Return value: Whether a game is going or not. - + /// Shows whether a game is currently in progress + /// @return Whether a game is going or not. bool GameInProgress() { return m_GameState >= GAMEINTRO && m_GameState <= ENDROUND; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: IsSuspended - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Shows whether game is suspended or not. - // Arguments: None. - // Return value: Whether suspended or not. - + /// Shows whether game is suspended or not. + /// @return Whether suspended or not. bool IsSuspended() { return m_Suspended; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetSuspend - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Suspends or unsuspends the game so exclusive GUIs and menus can be - // shown. - // Arguments: Whether to suspend or not. - // Return value: None. - + /// Suspends or unsuspends the game so exclusive GUIs and menus can be + /// shown. + /// @param suspend Whether to suspend or not. void SetSuspend(bool suspend); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: IsActivePlayer - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Checks wheter a certain player index is valid for the current game - // Arguments: None. - // Return value: Whether the player index passed in is active for the current game. - + /// Checks wheter a certain player index is valid for the current game + /// @return Whether the player index passed in is active for the current game. bool IsActivePlayer(int metaPlayer) { return metaPlayer >= Players::PlayerOne && metaPlayer < m_Players.size(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: IsActiveTeam - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Checks wheter a certain team index is valid for the current game - // Arguments: None. - // Return value: Whether the team index passed in is active for the current game. - + /// Checks wheter a certain team index is valid for the current game + /// @return Whether the team index passed in is active for the current game. bool IsActiveTeam(int team) { return team >= Activity::TeamOne && team < m_TeamCount; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: WhichTeamOwnsAllSites - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Checks whether one team has ownership of all revealed sites. - // Arguments: None. - // Return value: Which team has all sites, if any. If not NoTeam is returned. - + /// Checks whether one team has ownership of all revealed sites. + /// @return Which team has all sites, if any. If not NoTeam is returned. int WhichTeamOwnsAllSites(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: IsGameOver - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Checks for game over condition - // Arguments: None. - // Return value: Whether the game over conditions have been met - + /// Checks for game over condition + /// @return Whether the game over conditions have been met bool IsGameOver(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GameIsSaved - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Shows whether the game has been saved and no data loss will result - // if program is quit right now. - // Arguments: None. - // Return value: Whether the game is saved. - + /// Shows whether the game has been saved and no data loss will result + /// if program is quit right now. + /// @return Whether the game is saved. bool GameIsSaved() { return m_GameSaved || m_GameState <= NOGAME || m_GameState >= GAMEOVER; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: TotalScenePresets - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Yields a set of ALL eligible Scene presets for a new game. - // Arguments: The list to fill with all the eligible presets. If no list is passed - // it will be ignored. Presets returned in list are NOT OWNED there. - // Return value: The count of total number preset scenes eligible for gameplay. - + /// Yields a set of ALL eligible Scene presets for a new game. + /// @param pScenes The list to fill with all the eligible presets. If no list is passed (default: 0) + /// it will be ignored. Presets returned in list are NOT OWNED there. + /// @return The count of total number preset scenes eligible for gameplay. int TotalScenePresets(std::list* pScenes = 0); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SelectScenePresets - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Yields a set of randomly selected Scene presets for a new game. - // Arguments: The size of the set. - // The list to fill with the selected presets, depending on currently - // set player numbers and loaded eligible scenes. If no list is passed - // it will be ignored. Presets returned in list are NOT OWNED there. - // Return value: The count of selected preset scenes. - + /// Yields a set of randomly selected Scene presets for a new game. + /// @param gameSize The size of the set. + /// @param pSelected The list to fill with the selected presets, depending on currently (default: 0) + /// set player numbers and loaded eligible scenes. If no list is passed + /// it will be ignored. Presets returned in list are NOT OWNED there. + /// @return The count of selected preset scenes. int SelectScenePresets(int gameSize, std::list* pSelected = 0); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ClearActivities - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears out all the lined-up activities for the current round. - // Arguments: None. - // Return value: None. - + /// Clears out all the lined-up activities for the current round. void ClearActivities(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: AIPlayerTurn - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Does all the things an AI metaPlayer needs to do during his turn. - // Arguments: Which AI metaPlayer we're going to process. - // Return value: None. - + /// Does all the things an AI metaPlayer needs to do during his turn. + /// @param metaPlayer Which AI metaPlayer we're going to process. void AIPlayerTurn(int metaPlayer); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Update - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the state of this and the current Metagame. Supposed to be - // done every frame before drawing. - // Arguments: None. - // Return value: None. - + /// Updates the state of this and the current Metagame. Supposed to be + /// done every frame before drawing. void Update(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Draw - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws this MetaMan's current graphical representation to a BITMAP of choice. - // Arguments: A pointer to a BITMAP to draw on. - // The absolute position of the target bitmap's upper left corner in the scene. - // Return value: None. - + /// Draws this MetaMan's current graphical representation to a BITMAP of choice. + /// @param pTargetBitmap A pointer to a BITMAP to draw on. + /// @param targetPos The absolute position of the target bitmap's upper left corner in the scene. (default: Vector()) void Draw(BITMAP* pTargetBitmap, const Vector& targetPos = Vector()); - ////////////////////////////////////////////////////////////////////////////////////////// - // Protected member variable and method declarations - + /// Protected member variable and method declarations protected: // GUI controller, owned MetagameGUI* m_pMetaGUI; @@ -569,20 +341,12 @@ namespace RTE { // Timer for measuring how long each phase has gone for Timer m_PhaseTimer; - ////////////////////////////////////////////////////////////////////////////////////////// - // Private member variable and method declarations - + /// Private member variable and method declarations private: static const std::string c_ClassName; //!< A string with the friendly-formatted type name of this object. - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Clear - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears all the member variables of this MetaMan, effectively - // resetting the members of this abstraction level only. - // Arguments: None. - // Return value: None. - + /// Clears all the member variables of this MetaMan, effectively + /// resetting the members of this abstraction level only. void Clear(); // Disallow the use of some implicit methods. diff --git a/Source/Managers/MovableMan.cpp b/Source/Managers/MovableMan.cpp index 6172abddb2..c93d6af18d 100644 --- a/Source/Managers/MovableMan.cpp +++ b/Source/Managers/MovableMan.cpp @@ -1,15 +1,3 @@ -////////////////////////////////////////////////////////////////////////////////////////// -// File: MovableMan.cpp -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Source file for the MovableMan class. -// Project: Retro Terrain Engine -// Author(s): Daniel Tabar -// data@datarealms.com -// http://www.datarealms.com - -////////////////////////////////////////////////////////////////////////////////////////// -// Inclusions of header files - #include "MovableMan.h" #include "PrimitiveMan.h" @@ -53,12 +41,6 @@ namespace RTE { bool operator()(MovableObject* pRhs, MovableObject* pLhs) { return pRhs->GetPos().m_X < pLhs->GetPos().m_X; } }; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Clear - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears all the member variables of this MovableMan, effectively - // resetting the members of this abstraction level only. - void MovableMan::Clear() { m_Actors.clear(); m_ContiguousActorIDs.clear(); @@ -87,11 +69,6 @@ namespace RTE { m_MOSubtractionEnabled = true; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes the MovableMan object ready for use. - int MovableMan::Initialize() { // TODO: Increase this number, or maybe only for certain classes? Entity::ClassInfo::FillAllPools(); @@ -99,14 +76,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: ReadProperty - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Reads a property value from a reader stream. If the name isn't - // recognized by this class, then ReadProperty of the parent class - // is called. If the property isn't recognized by any of the base classes, - // false is returned, and the reader's position is untouched. - int MovableMan::ReadProperty(const std::string_view& propName, Reader& reader) { StartPropertyList(return Serializable::ReadProperty(propName, reader)); @@ -119,12 +88,6 @@ namespace RTE { EndPropertyList; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Save - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Saves the complete state of this MovableMan with a Writer for - // later recreation with Create(Reader &reader); - int MovableMan::Save(Writer& writer) const { Serializable::Save(writer); @@ -139,11 +102,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destroys and resets (through Clear()) the MovableMan object. - void MovableMan::Destroy() { for (std::deque::iterator it1 = m_Actors.begin(); it1 != m_Actors.end(); ++it1) delete (*it1); @@ -155,12 +113,6 @@ namespace RTE { Clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetMOFromID - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets a MO from its MOID. Note that MOID's are only valid during the - // same frame as they were assigned to the MOs! - MovableObject* MovableMan::GetMOFromID(MOID whichID) { if (whichID != g_NoMOID && whichID != 0 && whichID < m_MOIDIndex.size()) { return m_MOIDIndex[whichID]; @@ -168,8 +120,6 @@ namespace RTE { return nullptr; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - MOID MovableMan::GetMOIDPixel(int pixelX, int pixelY, const std::vector& moidList) { // Note - We loop through the MOs in reverse to make sure that the topmost (last drawn) MO that overlaps the specified coordinates is the one returned. for (auto itr = moidList.rbegin(), itrEnd = moidList.rend(); itr < itrEnd; ++itr) { @@ -191,15 +141,6 @@ namespace RTE { return g_NoMOID; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: RegisterObject - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Registers an object in a global Map collection so it could be found later with FindObjectByUniqueId - // Arguments: MO to register. - // Return value: None. - void MovableMan::RegisterObject(MovableObject* mo) { if (!mo) { return; @@ -209,13 +150,6 @@ namespace RTE { m_KnownObjects[mo->GetUniqueID()] = mo; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: UnregisterObject - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Removes an object from the global lookup collection - // Arguments: MO to remove. - // Return value: None. - void MovableMan::UnregisterObject(MovableObject* mo) { if (!mo) { return; @@ -225,28 +159,18 @@ namespace RTE { m_KnownObjects.erase(mo->GetUniqueID()); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - const std::vector* MovableMan::GetMOsInBox(const Box& box, int ignoreTeam, bool getsHitByMOsOnly) const { std::vector* vectorForLua = new std::vector(); *vectorForLua = std::move(g_SceneMan.GetMOIDGrid().GetMOsInBox(box, ignoreTeam, getsHitByMOsOnly)); return vectorForLua; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - const std::vector* MovableMan::GetMOsInRadius(const Vector& centre, float radius, int ignoreTeam, bool getsHitByMOsOnly) const { std::vector* vectorForLua = new std::vector(); *vectorForLua = std::move(g_SceneMan.GetMOIDGrid().GetMOsInRadius(centre, radius, ignoreTeam, getsHitByMOsOnly)); return vectorForLua; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: PurgeAllMOs - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears out all MovableObject:s out of this. Effectively empties the world - // of anything moving, without resetting all of this' settings. - void MovableMan::PurgeAllMOs() { for (std::deque::iterator itr = m_Actors.begin(); itr != m_Actors.end(); ++itr) { (*itr)->DestroyScriptState(); @@ -292,12 +216,6 @@ namespace RTE { // m_KnownObjects.clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetNextActorInGroup - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Get a pointer to the first Actor in the internal Actor list that is - // of a specifc group, alternatively the first one AFTER a specific actor! - Actor* MovableMan::GetNextActorInGroup(std::string group, Actor* pAfterThis) { if (group.empty()) return 0; @@ -344,12 +262,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetPrevActorInGroup - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Get a pointer to the last Actor in the internal Actor list that is - // of a specifc group, alternatively the last one BEFORE a specific actor! - Actor* MovableMan::GetPrevActorInGroup(std::string group, Actor* pBeforeThis) { if (group.empty()) return 0; @@ -396,12 +308,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetNextTeamActor - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Get a pointer to the first Actor in the internal Actor list that is - // of a specifc team, alternatively the first one AFTER a specific actor! - Actor* MovableMan::GetNextTeamActor(int team, Actor* pAfterThis) { if (team < Activity::TeamOne || team >= Activity::MaxTeamCount || m_ActorRoster[team].empty()) return 0; @@ -477,12 +383,6 @@ namespace RTE { return *aIt; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetPrevTeamActor - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Get a pointer to the last Actor in the internal Actor list that is - // of a specifc team, alternatively the last one BEFORE a specific actor! - Actor* MovableMan::GetPrevTeamActor(int team, Actor* pBeforeThis) { if (team < Activity::TeamOne || team >= Activity::MaxTeamCount || m_Actors.empty() || m_ActorRoster[team].empty()) return 0; @@ -558,12 +458,6 @@ namespace RTE { return *aIt; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetClosestTeamActor - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Get a pointer to an Actor in the internal Actor list that is of a - // specifc team and closest to a specific scene point. - Actor* MovableMan::GetClosestTeamActor(int team, int player, const Vector& scenePoint, int maxRadius, Vector& getDistance, bool onlyPlayerControllableActors, const Actor* excludeThis) { if (team < Activity::NoTeam || team >= Activity::MaxTeamCount || m_Actors.empty() || m_ActorRoster[team].empty()) return 0; @@ -610,12 +504,6 @@ namespace RTE { return pClosestActor; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetClosestEnemyActor - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Get a pointer to an Actor in the internal Actor list that is is not of - // the specified team and closest to a specific scene point. - Actor* MovableMan::GetClosestEnemyActor(int team, const Vector& scenePoint, int maxRadius, Vector& getDistance) { if (team < Activity::NoTeam || team >= Activity::MaxTeamCount || m_Actors.empty()) return 0; @@ -643,12 +531,6 @@ namespace RTE { return pClosestActor; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetClosestActor - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Get a pointer to an Actor in the internal Actor list that is closest - // to a specific scene point. - Actor* MovableMan::GetClosestActor(const Vector& scenePoint, int maxRadius, Vector& getDistance, const Actor* pExcludeThis) { if (m_Actors.empty()) return 0; @@ -676,12 +558,6 @@ namespace RTE { return pClosestActor; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetClosestBrainActor - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Get a pointer to the brain actor of a specific team that is closest to - // a scene point. - Actor* MovableMan::GetClosestBrainActor(int team, const Vector& scenePoint) const { if (team < Activity::TeamOne || team >= Activity::MaxTeamCount || m_ActorRoster[team].empty()) return 0; @@ -706,12 +582,6 @@ namespace RTE { return pClosestBrain; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetClosestOtherBrainActor - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Get a pointer to the brain actor NOT of a specific team that is closest - // to a scene point. - Actor* MovableMan::GetClosestOtherBrainActor(int notOfTeam, const Vector& scenePoint) const { if (notOfTeam < Activity::TeamOne || notOfTeam >= Activity::MaxTeamCount || m_Actors.empty()) return 0; @@ -735,12 +605,6 @@ namespace RTE { return pClosestBrain; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetUnassignedBrain - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Get a pointer to the brain actor of a specific team. - // Arguments: Which team to try to get the brain for. 0 means first team, 1 means 2nd. - Actor* MovableMan::GetUnassignedBrain(int team) const { if (/*m_Actors.empty() || */ m_ActorRoster[team].empty()) return 0; @@ -762,8 +626,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool MovableMan::AddMO(MovableObject* movableObjectToAdd) { if (!movableObjectToAdd) { return false; @@ -781,8 +643,6 @@ namespace RTE { return true; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void MovableMan::AddActor(Actor* actorToAdd) { if (actorToAdd) { actorToAdd->SetAsAddedToMovableMan(); @@ -813,8 +673,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void MovableMan::AddItem(HeldDevice* itemToAdd) { if (itemToAdd) { g_ActivityMan.GetActivity()->ForceSetTeamAsActive(itemToAdd->GetTeam()); @@ -838,8 +696,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void MovableMan::AddParticle(MovableObject* particleToAdd) { if (particleToAdd) { g_ActivityMan.GetActivity()->ForceSetTeamAsActive(particleToAdd->GetTeam()); @@ -868,13 +724,6 @@ namespace RTE { } } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: RemoveActor - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Removes an Actor from the internal list of MO:s. After the Actor is - // removed, ownership is effectively released and transferred to whatever - // client called this method. - Actor* MovableMan::RemoveActor(MovableObject* pActorToRem) { Actor* removed = nullptr; @@ -906,13 +755,6 @@ namespace RTE { return removed; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: RemoveItem - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Removes a pickup-able MovableObject item from the internal list of - // MO:s. After the item is removed, ownership is effectively released and - // transferred to whatever client called this method. - MovableObject* MovableMan::RemoveItem(MovableObject* pItemToRem) { MovableObject* removed = nullptr; @@ -943,13 +785,6 @@ namespace RTE { return removed; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: RemoveParticle - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Removes a MovableObject from the internal list of MO:s. After the - // MO is removed, ownership is effectively released and transferred to - // whatever client called this method. - MovableObject* MovableMan::RemoveParticle(MovableObject* pMOToRem) { MovableObject* removed = nullptr; @@ -980,13 +815,6 @@ namespace RTE { return removed; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: AddActorToTeamRoster - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Adds actor to internal team roster - // Arguments: Pointer to actor - // Return value: None. - void MovableMan::AddActorToTeamRoster(Actor* pActorToAdd) { if (!pActorToAdd) { return; @@ -1004,13 +832,6 @@ namespace RTE { } } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: RemoveActorToTeamRoster - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Removes actor from internal team roster - // Arguments: Pointer to actor - // Return value: None. - void MovableMan::RemoveActorFromTeamRoster(Actor* pActorToRem) { if (!pActorToRem) { return; @@ -1025,11 +846,6 @@ namespace RTE { } } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ChangeActorTeam - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Changes actor team and updates team rosters. - void MovableMan::ChangeActorTeam(Actor* pActor, int team) { if (!pActor) { return; @@ -1055,13 +871,6 @@ namespace RTE { } } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ValidateMOIDs - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Goes through and checks that all MOID's have valid MO pointers - // associated with them. This shuold only be used for testing, as it will - // crash the app if validation fails. - bool MovableMan::ValidateMOIDs() { #ifdef DEBUG_BUILD for (const MovableObject* mo: m_MOIDIndex) { @@ -1071,12 +880,6 @@ namespace RTE { return true; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ValidMO - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Indicates whether the passed in MovableObject pointer points to an - // MO that's currently active in the simulation, and kept by this MovableMan. - bool MovableMan::ValidMO(const MovableObject* pMOToCheck) { bool exists = m_ValidActors.find(pMOToCheck) != m_ValidActors.end() || m_ValidItems.find(pMOToCheck) != m_ValidItems.end() || @@ -1085,42 +888,18 @@ namespace RTE { return pMOToCheck && exists; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: IsActor - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Indicates whether the passed in MovableObject is an active Actor kept - // by this MovableMan or not. - bool MovableMan::IsActor(const MovableObject* pMOToCheck) { return pMOToCheck && m_ValidActors.find(pMOToCheck) != m_ValidActors.end(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: IsDevice - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Indicates whether the passed in MovableObject is an active Item kept - // by this MovableMan or not. - bool MovableMan::IsDevice(const MovableObject* pMOToCheck) { return pMOToCheck && m_ValidItems.find(pMOToCheck) != m_ValidItems.end(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: IsParticle - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Indicates whether the passed in MovableObject is an active Item kept - // by this MovableMan or not. - bool MovableMan::IsParticle(const MovableObject* pMOToCheck) { return pMOToCheck && m_ValidParticles.find(pMOToCheck) != m_ValidParticles.end(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: IsOfActor - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Indicates whether the passed in MOID is that of an MO which either is - // or is parented to an active Actor by this MovableMan, or not. - bool MovableMan::IsOfActor(MOID checkMOID) { if (checkMOID == g_NoMOID) return false; @@ -1151,8 +930,6 @@ namespace RTE { return found; } - ////////////////////////////////////////////////////////////////////////////////////////// - int MovableMan::GetContiguousActorID(const Actor* actor) const { auto itr = m_ContiguousActorIDs.find(actor); if (itr == m_ContiguousActorIDs.end()) { @@ -1162,11 +939,6 @@ namespace RTE { return itr->second; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetRootMOID - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Produces the root MOID of the MOID of a potential child MO to another MO. - MOID MovableMan::GetRootMOID(MOID checkMOID) { MovableObject* pMO = GetMOFromID(checkMOID); if (pMO) @@ -1175,13 +947,6 @@ namespace RTE { return g_NoMOID; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: RemoveMO - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Removes a MovableObject from the any and all internal lists of MO:s. - // After the MO is removed, ownership is effectively released and - // transferred to whatever client called this method. - bool MovableMan::RemoveMO(MovableObject* pMOToRem) { if (pMOToRem) { if (RemoveActor(pMOToRem)) @@ -1195,8 +960,6 @@ namespace RTE { return false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int MovableMan::KillAllTeamActors(int teamToKill) const { int killCount = 0; @@ -1217,8 +980,6 @@ namespace RTE { return killCount; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int MovableMan::KillAllEnemyActors(int teamNotToKill) const { int killCount = 0; @@ -1239,8 +1000,6 @@ namespace RTE { return killCount; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int MovableMan::GetAllActors(bool transferOwnership, std::list& actorList, int onlyTeam, bool noBrains) { int addedCount = 0; @@ -1283,8 +1042,6 @@ namespace RTE { return addedCount; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int MovableMan::GetAllItems(bool transferOwnership, std::list& itemList) { int addedCount = 0; @@ -1310,8 +1067,6 @@ namespace RTE { return addedCount; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int MovableMan::GetAllParticles(bool transferOwnership, std::list& particleList) { int addedCount = 0; @@ -1337,8 +1092,6 @@ namespace RTE { return addedCount; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int MovableMan::GetTeamMOIDCount(int team) const { if (team > Activity::NoTeam && team < Activity::MaxTeamCount) return m_TeamMOIDCount[team]; @@ -1346,8 +1099,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void MovableMan::OpenAllDoors(bool open, int team) const { for (std::deque actorDeque: {m_Actors, m_AddedActors}) { for (Actor* actor: actorDeque) { @@ -1367,8 +1118,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // TODO: Completely tear out and delete this. // It shouldn't belong to MovableMan, instead it probably ought to be on the pathfinder. On that note, pathfinders shouldn't be part of the scene! // AIMan? PathingMan? Something like that. Ideally, we completely tear out this hack, and allow for doors in a completely different way. @@ -1382,19 +1131,11 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void MovableMan::RegisterAlarmEvent(const AlarmEvent& newEvent) { std::lock_guard lock(m_AddedAlarmEventsMutex); m_AddedAlarmEvents.push_back(newEvent); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: RedrawOverlappingMOIDs - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Forces all objects potnetially overlapping a specific MO to re-draw - // this MOID representations onto the MOID bitmap. - void MovableMan::RedrawOverlappingMOIDs(MovableObject* pOverlapsThis) { for (std::deque::iterator aIt = m_Actors.begin(); aIt != m_Actors.end(); ++aIt) { (*aIt)->DrawMOIDIfOverlapping(pOverlapsThis); @@ -1409,8 +1150,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void callLuaFunctionOnMORecursive(MovableObject* mo, const std::string& functionName, const std::vector& functionEntityArguments, const std::vector& functionLiteralArguments, const std::vector& functionObjectArguments) { if (MOSRotating* mosr = dynamic_cast(mo)) { for (auto attachablrItr = mosr->GetAttachableList().begin(); attachablrItr != mosr->GetAttachableList().end();) { @@ -1433,8 +1172,6 @@ namespace RTE { mo->RunScriptedFunctionInAppropriateScripts(functionName, false, false, functionEntityArguments, functionLiteralArguments, functionObjectArguments); }; - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void MovableMan::RunLuaFunctionOnAllMOs(const std::string& functionName, bool includeAdded, const std::vector& functionEntityArguments, const std::vector& functionLiteralArguments, const std::vector& functionObjectArguments) { if (includeAdded) { for (Actor* actor: m_AddedActors) { @@ -1463,8 +1200,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void reloadLuaFunctionsOnMORecursive(MovableObject* mo) { if (MOSRotating* mosr = dynamic_cast(mo)) { for (auto attachablrItr = mosr->GetAttachableList().begin(); attachablrItr != mosr->GetAttachableList().end();) { @@ -1487,8 +1222,6 @@ namespace RTE { mo->ReloadScripts(); }; - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void MovableMan::ReloadLuaScripts() { for (Actor* actor: m_AddedActors) { reloadLuaFunctionsOnMORecursive(actor); @@ -1515,11 +1248,6 @@ namespace RTE { } } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Update - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the state of this MovableMan. Supposed to be done every frame. - void MovableMan::Update() { ZoneScoped; @@ -1922,8 +1650,6 @@ if (g_TimerMan.DrawnSimUpdate()) } } -////////////////////////////////////////////////////////////////////////////////////////// - void MovableMan::Travel() { ZoneScoped; @@ -1981,8 +1707,6 @@ void MovableMan::Travel() { } } -////////////////////////////////////////////////////////////////////////////////////////// - void MovableMan::UpdateControllers() { ZoneScoped; @@ -2016,8 +1740,6 @@ void MovableMan::UpdateControllers() { g_PerformanceMan.StopPerformanceMeasurement(PerformanceMan::ActorsAI); } -////////////////////////////////////////////////////////////////////////////////////////// - void MovableMan::PreControllerUpdate() { ZoneScoped; @@ -2038,12 +1760,6 @@ void MovableMan::PreControllerUpdate() { g_PerformanceMan.StopPerformanceMeasurement(PerformanceMan::ParticlesUpdate); } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: DrawMatter -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Draws this MovableMan's all MO's current material representations to a -// BITMAP of choice. - void MovableMan::DrawMatter(BITMAP* pTargetBitmap, Vector& targetPos) { // Draw objects to accumulation bitmap for (std::deque::iterator aIt = --m_Actors.end(); aIt != --m_Actors.begin(); --aIt) @@ -2053,13 +1769,6 @@ void MovableMan::DrawMatter(BITMAP* pTargetBitmap, Vector& targetPos) { (*parIt)->Draw(pTargetBitmap, targetPos, g_DrawMaterial); } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: VerifyMOIDIndex -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Verifieis whether all elements of MOID index has correct ID. Should be used in Debug mode only. -// Arguments: None. -// Return value: None. - void MovableMan::VerifyMOIDIndex() { int count = 0; for (std::vector::iterator aIt = m_MOIDIndex.begin(); aIt != m_MOIDIndex.end(); ++aIt) { @@ -2083,12 +1792,6 @@ void MovableMan::VerifyMOIDIndex() { } } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: UpdateDrawMOIDs -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Updates the MOIDs of all current MOs and draws their ID's to a BITMAP -// of choice. - void MovableMan::UpdateDrawMOIDs(BITMAP* pTargetBitmap) { ZoneScoped; @@ -2153,12 +1856,6 @@ void MovableMan::UpdateDrawMOIDs(BITMAP* pTargetBitmap) { } } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: Draw -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Draws this MovableMan's current graphical representation to a -// BITMAP of choice. - void MovableMan::Draw(BITMAP* pTargetBitmap, const Vector& targetPos) { ZoneScoped; @@ -2189,12 +1886,6 @@ void MovableMan::Draw(BITMAP* pTargetBitmap, const Vector& targetPos) { } } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: DrawHUD -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Draws this MovableMan's current graphical representation to a -// BITMAP of choice. - void MovableMan::DrawHUD(BITMAP* pTargetBitmap, const Vector& targetPos, int which, bool playerControlled) { ZoneScoped; diff --git a/Source/Managers/MovableMan.h b/Source/Managers/MovableMan.h index d4c8aec97a..22b0c3a697 100644 --- a/Source/Managers/MovableMan.h +++ b/Source/Managers/MovableMan.h @@ -1,18 +1,11 @@ #ifndef _RTEMOVABLEMAN_ #define _RTEMOVABLEMAN_ -////////////////////////////////////////////////////////////////////////////////////////// -// File: MovableMan.h -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Header file for the MovableMan class. -// Project: Retro Terrain Engine -// Author(s): Daniel Tabar -// data@datarealms.com -// http://www.datarealms.com - -////////////////////////////////////////////////////////////////////////////////////////// -// Inclusions of header files - +/// Header file for the MovableMan class. +/// @author Daniel Tabar +/// data@datarealms.com +/// http://www.datarealms.com +/// Inclusions of header files #include "Serializable.h" #include "Singleton.h" #include "Activity.h" @@ -32,13 +25,7 @@ namespace RTE { class Box; class LuabindObjectWrapper; - ////////////////////////////////////////////////////////////////////////////////////////// - // Struct: AlarmEvent - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: A struct to keep all data about a an alarming event for the AI Actors. - // Parent(s): None. - // Class history: 10/3/2008 AlarmEvent created. - + /// A struct to keep all data about a an alarming event for the AI Actors. struct AlarmEvent { AlarmEvent() { m_ScenePos.Reset(); @@ -56,754 +43,453 @@ namespace RTE { float m_Range; }; - ////////////////////////////////////////////////////////////////////////////////////////// - // Class: MovableMan - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: The singleton manager of all movable objects in the RTE. - // Parent(s): Singleton, Serializable. - // Class history: 12/25/2001 MovableMan created. - + /// The singleton manager of all movable objects in the RTE. class MovableMan : public Singleton, public Serializable { friend class SettingsMan; friend struct ManagerLuaBindings; - ////////////////////////////////////////////////////////////////////////////////////////// - // Public member variable, method and friend function declarations - + /// Public member variable, method and friend function declarations public: SerializableClassNameGetter; SerializableOverrideMethods; - ////////////////////////////////////////////////////////////////////////////////////////// - // Constructor: MovableMan - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Constructor method used to instantiate a MovableMan object in system - // memory. Create() should be called before using the object. - // Arguments: None. - + /// Constructor method used to instantiate a MovableMan object in system + /// memory. Create() should be called before using the object. MovableMan() { Clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Destructor: ~MovableMan - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destructor method used to clean up a MovableMan object before deletion - // from system memory. - // Arguments: None. - + /// Destructor method used to clean up a MovableMan object before deletion + /// from system memory. ~MovableMan() { Destroy(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes the MovableMan object ready for use. - // Arguments: None. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Makes the MovableMan object ready for use. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Initialize(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Reset - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Resets the entire MovableMan, including its inherited members, to - // their default settings or values. - // Arguments: None. - // Return value: None. - + /// Resets the entire MovableMan, including its inherited members, to + /// their default settings or values. void Reset() override { Clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destroys and resets (through Clear()) the MovableMan object. - // Arguments: None. - // Return value: None. - + /// Destroys and resets (through Clear()) the MovableMan object. void Destroy(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetMOFromID - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets a MO from its MOID. Note that MOID's are only valid during the - // same frame as they were assigned to the MOs! - // Arguments: The MOID to get the matching MO from. - // Return value: A pointer to the requested MovableObject instance. 0 if no MO with that - // MOID was found. 0 if 0 was passed in as MOID (no MOID). Ownership is - // *NOT* transferred!! - + /// Gets a MO from its MOID. Note that MOID's are only valid during the + /// same frame as they were assigned to the MOs! + /// @param whichID The MOID to get the matching MO from. + /// @return A pointer to the requested MovableObject instance. 0 if no MO with that + /// MOID was found. 0 if 0 was passed in as MOID (no MOID). Ownership is + /// *NOT* transferred!! MovableObject* GetMOFromID(MOID whichID); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetMOIDCount - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the number of MOID's currently in use this frame. - // Arguments: None. - // Return value: The count of MOIDs in use this frame. - + /// Gets the number of MOID's currently in use this frame. + /// @return The count of MOIDs in use this frame. int GetMOIDCount() { return m_MOIDIndex.size(); } - /// /// Gets a MOID from pixel coordinates in the Scene. - /// - /// The X coordinate of the Scene pixel to get the MOID of. - /// The Y coordinate of the Scene pixel to get the MOID of. - /// The collection of MOIDs to check the against the specified coordinates. - /// The topmost MOID currently at the specified pixel coordinates. + /// @param pixelX The X coordinate of the Scene pixel to get the MOID of. + /// @param pixelY The Y coordinate of the Scene pixel to get the MOID of. + /// @param moidList The collection of MOIDs to check the against the specified coordinates. + /// @return The topmost MOID currently at the specified pixel coordinates. MOID GetMOIDPixel(int pixelX, int pixelY, const std::vector& moidList); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetTeamMOIDCount - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns MO count for specified team - // Arguments: Team to count MO's - // Return value: MO's count owned by this team - + /// Returns MO count for specified team + /// @param team Team to count MO's + /// @return MO's count owned by this team int GetTeamMOIDCount(int team) const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: PurgeAllMOs - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears out all MovableObject:s out of this. Effectively empties the world - // of anything moving, without resetting all of this' settings. - // Arguments: None. - // Return value: None. - + /// Clears out all MovableObject:s out of this. Effectively empties the world + /// of anything moving, without resetting all of this' settings. void PurgeAllMOs(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetNextActorInGroup - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Get a pointer to the first Actor in the internal Actor list that is - // of a specifc group, alternatively the first one AFTER a specific actor! - // Arguments: Which group to try to get an Actor for. - // A pointer to an Actor to use as starting point in the forward search. - // Ownership NOT xferred! - // Return value: An Actor pointer to the requested team's first Actor encountered - // in the list. 0 if there are no Actors of that team. - + /// Get a pointer to the first Actor in the internal Actor list that is + /// of a specifc group, alternatively the first one AFTER a specific actor! + /// @param group Which group to try to get an Actor for. + /// @param pAfterThis A pointer to an Actor to use as starting point in the forward search. (default: 0) + /// Ownership NOT xferred! + /// @return An Actor pointer to the requested team's first Actor encountered + /// in the list. 0 if there are no Actors of that team. Actor* GetNextActorInGroup(std::string group, Actor* pAfterThis = 0); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetPrevActorInGroup - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Get a pointer to the last Actor in the internal Actor list that is - // of a specifc group, alternatively the last one BEFORE a specific actor! - // Arguments: Which group to try to get an Actor for. - // A pointer to an Actor to use as starting point in the backward search. - // Ownership NOT xferred! - // Return value: An Actor pointer to the requested team's last Actor encountered - // in the list. 0 if there are no Actors of that team. - + /// Get a pointer to the last Actor in the internal Actor list that is + /// of a specifc group, alternatively the last one BEFORE a specific actor! + /// @param group Which group to try to get an Actor for. + /// @param pBeforeThis A pointer to an Actor to use as starting point in the backward search. (default: 0) + /// Ownership NOT xferred! + /// @return An Actor pointer to the requested team's last Actor encountered + /// in the list. 0 if there are no Actors of that team. Actor* GetPrevActorInGroup(std::string group, Actor* pBeforeThis = 0); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetTeamRoster - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the list of all actors on one team, ordered by their X positions. - // Arguments: Which team to try to get the roster for. - // Return value: A pointer to the list of all the actors on the specified team, sorted - // ascending by their X posistions. Ownership of the list or contained - // actors is NOT transferred! - + /// Gets the list of all actors on one team, ordered by their X positions. + /// @param team Which team to try to get the roster for. (default: 0) { return &(m_ActorRoster[team]) + /// @return A pointer to the list of all the actors on the specified team, sorted + /// ascending by their X posistions. Ownership of the list or contained + /// actors is NOT transferred! std::list* GetTeamRoster(int team = 0) { return &(m_ActorRoster[team]); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetNextTeamActor - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Get a pointer to the first Actor in the internal Actor list that is - // of a specifc team, alternatively the first one AFTER a specific actor! - // Arguments: Which team to try to get an Actor for. 0 means first team, 1 means 2nd. - // A pointer to an Actor to use as starting point in the forward search. - // Ownership NOT xferred! - // Return value: An Actor pointer to the requested team's first Actor encountered - // in the list. 0 if there are no Actors of that team. - + /// Get a pointer to the first Actor in the internal Actor list that is + /// of a specifc team, alternatively the first one AFTER a specific actor! + /// @param team Which team to try to get an Actor for. 0 means first team, 1 means 2nd. (default: 0) + /// @param pAfterThis A pointer to an Actor to use as starting point in the forward search. (default: 0) + /// Ownership NOT xferred! + /// @return An Actor pointer to the requested team's first Actor encountered + /// in the list. 0 if there are no Actors of that team. Actor* GetNextTeamActor(int team = 0, Actor* pAfterThis = 0); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetPrevTeamActor - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Get a pointer to the last Actor in the internal Actor list that is - // of a specifc team, alternatively the last one BEFORE a specific actor! - // Arguments: Which team to try to get an Actor for. 0 means first team, 1 means 2nd. - // A pointer to an Actor to use as starting point in the backward search. - // Ownership NOT xferred! - // Return value: An Actor pointer to the requested team's last Actor encountered - // in the list. 0 if there are no Actors of that team. - + /// Get a pointer to the last Actor in the internal Actor list that is + /// of a specifc team, alternatively the last one BEFORE a specific actor! + /// @param team Which team to try to get an Actor for. 0 means first team, 1 means 2nd. (default: 0) + /// @param pBeforeThis A pointer to an Actor to use as starting point in the backward search. (default: 0) + /// Ownership NOT xferred! + /// @return An Actor pointer to the requested team's last Actor encountered + /// in the list. 0 if there are no Actors of that team. Actor* GetPrevTeamActor(int team = 0, Actor* pBeforeThis = 0); - /// /// Get a pointer to an Actor in the internal Actor list that is of a specifc team and closest to a specific scene point. - /// - /// Which team to try to get an Actor for. 0 means first team, 1 means 2nd. - /// The player to get the Actor for. This affects which brain can be marked. - /// The Scene point to search for the closest to. - /// The maximum radius around that scene point to search. - /// A Vector to be filled out with the distance of the returned closest to the search point. Will be unaltered if no object was found within radius. - /// An Actor to exclude from the search. OWNERSHIP IS NOT TRANSFERRED! - /// An Actor pointer to the requested team's Actor closest to the Scene point, but not outside the max radius. If no Actor other than the excluded one was found within the radius of the point, nullptr is returned. + /// @param team Which team to try to get an Actor for. 0 means first team, 1 means 2nd. + /// @param player The player to get the Actor for. This affects which brain can be marked. + /// @param scenePoint The Scene point to search for the closest to. + /// @param maxRadius The maximum radius around that scene point to search. + /// @param getDistance A Vector to be filled out with the distance of the returned closest to the search point. Will be unaltered if no object was found within radius. + /// @param excludeThis An Actor to exclude from the search. OWNERSHIP IS NOT TRANSFERRED! + /// @return An Actor pointer to the requested team's Actor closest to the Scene point, but not outside the max radius. If no Actor other than the excluded one was found within the radius of the point, nullptr is returned. Actor* GetClosestTeamActor(int team, int player, const Vector& scenePoint, int maxRadius, Vector& getDistance, const Actor* excludeThis = nullptr) { return GetClosestTeamActor(team, player, scenePoint, maxRadius, getDistance, false, excludeThis); } - /// /// Get a pointer to an Actor in the internal Actor list that is of a specifc team and closest to a specific scene point. - /// - /// Which team to try to get an Actor for. 0 means first team, 1 means 2nd. - /// The player to get the Actor for. This affects which brain can be marked. - /// The Scene point to search for the closest to. - /// The maximum radius around that scene point to search. - /// A Vector to be filled out with the distance of the returned closest to the search point. Will be unaltered if no object was found within radius. - /// Whether to only get Actors that are flagged as player controllable. - /// An Actor to exclude from the search. OWNERSHIP IS NOT TRANSFERRED! - /// An Actor pointer to the requested team's Actor closest to the Scene point, but not outside the max radius. If no Actor other than the excluded one was found within the radius of the point, nullptr is returned. + /// @param team Which team to try to get an Actor for. 0 means first team, 1 means 2nd. + /// @param player The player to get the Actor for. This affects which brain can be marked. + /// @param scenePoint The Scene point to search for the closest to. + /// @param maxRadius The maximum radius around that scene point to search. + /// @param getDistance A Vector to be filled out with the distance of the returned closest to the search point. Will be unaltered if no object was found within radius. + /// @param onlyPlayerControllableActors Whether to only get Actors that are flagged as player controllable. + /// @param excludeThis An Actor to exclude from the search. OWNERSHIP IS NOT TRANSFERRED! + /// @return An Actor pointer to the requested team's Actor closest to the Scene point, but not outside the max radius. If no Actor other than the excluded one was found within the radius of the point, nullptr is returned. Actor* GetClosestTeamActor(int team, int player, const Vector& scenePoint, int maxRadius, Vector& getDistance, bool onlyPlayerControllableActors, const Actor* excludeThis = nullptr); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetClosestEnemyActor - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Get a pointer to an Actor in the internal Actor list that is is not of - // the specified team and closest to a specific scene point. - // Arguments: Which team to try to get an enemy Actor for. NoTeam means all teams. - // The Scene point to search for the closest to. - // The maximum radius around that scene point to search. - // A Vector to be filled out with the distance of the returned closest to - // the search point. Will be unaltered if no object was found within radius. - // Return value: An Actor pointer to the enemy closest to the Scene - // point, but not outside the max radius. If no Actor - // was found within the radius of the point, 0 is returned. - + /// Get a pointer to an Actor in the internal Actor list that is is not of + /// the specified team and closest to a specific scene point. + /// @param team Which team to try to get an enemy Actor for. NoTeam means all teams. + /// @param scenePoint The Scene point to search for the closest to. + /// @param maxRadius The maximum radius around that scene point to search. + /// @param getDistance A Vector to be filled out with the distance of the returned closest to + /// the search point. Will be unaltered if no object was found within radius. + /// @return An Actor pointer to the enemy closest to the Scene + /// point, but not outside the max radius. If no Actor + /// was found within the radius of the point, 0 is returned. Actor* GetClosestEnemyActor(int team, const Vector& scenePoint, int maxRadius, Vector& getDistance); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetFirstTeamActor - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Get a pointer to first best Actor in the internal Actor list that is - // of a specifc team. - // Arguments: Which team to try to get an Actor for. 0 means first team, 1 means 2nd. - // The player to get the Actor for. This affects which brain can be marked. - // Return value: An Actor pointer to the first one of the requested team. If no Actor - // is in that team, 0 is returned. - + /// Get a pointer to first best Actor in the internal Actor list that is + /// of a specifc team. + /// @param team Which team to try to get an Actor for. 0 means first team, 1 means 2nd. + /// @param player The player to get the Actor for. This affects which brain can be marked. + /// @return An Actor pointer to the first one of the requested team. If no Actor + /// is in that team, 0 is returned. Actor* GetFirstTeamActor(int team, int player) { Vector temp; return GetClosestTeamActor(team, player, Vector(), 10000000, temp); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetClosestActor - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Get a pointer to an Actor in the internal Actor list that is closest - // to a specific scene point. - // Arguments: Which team to try to get an Actor for. 0 means first team, 1 means 2nd. - // The Scene point to search for the closest to. - // The maximum radius around that scene point to search. - // A Vector to be filled out with the distance of the returned closest to - // the search point. Will be unaltered if no object was found within radius. - // An Actor to exclude from the search. OWNERSHIP IS NOT TRANSFERRED! - // Return value: An Actor pointer to the requested Actor closest to the Scene - // point, but not outside the max radius. If no Actor other than the - // excluded one was found within the radius of the point, 0 is returned. - + /// Get a pointer to an Actor in the internal Actor list that is closest + /// to a specific scene point. + /// @param scenePoint Which team to try to get an Actor for. 0 means first team, 1 means 2nd. + /// @param maxRadius The Scene point to search for the closest to. + /// @param getDistance The maximum radius around that scene point to search. + /// @param pExcludeThis A Vector to be filled out with the distance of the returned closest to (default: 0) + /// the search point. Will be unaltered if no object was found within radius. + /// An Actor to exclude from the search. OWNERSHIP IS NOT TRANSFERRED! + /// @return An Actor pointer to the requested Actor closest to the Scene + /// point, but not outside the max radius. If no Actor other than the + /// excluded one was found within the radius of the point, 0 is returned. Actor* GetClosestActor(const Vector& scenePoint, int maxRadius, Vector& getDistance, const Actor* pExcludeThis = 0); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetClosestBrainActor - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Get a pointer to the brain actor of a specific team that is closest to - // a scene point. OWNERSHIP IS NOT TRANSFERRED! - // Arguments: Which team to try to get the brain for. 0 means first team, 1 means 2nd. - // The point in the scene where to look for the closest opposite team brain. - // Return value: An Actor pointer to the requested team's brain closest to the point. - // 0 if there are no brains of that team. OWNERSHIP IS NOT TRANSFERRED! - + /// Get a pointer to the brain actor of a specific team that is closest to + /// a scene point. OWNERSHIP IS NOT TRANSFERRED! + /// @param team Which team to try to get the brain for. 0 means first team, 1 means 2nd. + /// @param scenePoint The point in the scene where to look for the closest opposite team brain. + /// @return An Actor pointer to the requested team's brain closest to the point. + /// 0 if there are no brains of that team. OWNERSHIP IS NOT TRANSFERRED! Actor* GetClosestBrainActor(int team, const Vector& scenePoint) const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetFirstBrainActor - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Get a pointer to the brain actor of a specific team that is closest to - // a scene point. OWNERSHIP IS NOT TRANSFERRED! - // Arguments: Which team to try to get the brain for. 0 means first team, 1 means 2nd. - // The point in the scene where to look for the closest opposite team brain. - // Return value: An Actor pointer to the requested team's brain closest to the point. - // 0 if there are no brains of that team. OWNERSHIP IS NOT TRANSFERRED! - + /// Get a pointer to the brain actor of a specific team that is closest to + /// a scene point. OWNERSHIP IS NOT TRANSFERRED! + /// @param GetClosestBrainActor(team Which team to try to get the brain for. 0 means first team, 1 means 2nd. + /// @param Vector() The point in the scene where to look for the closest opposite team brain. + /// @return An Actor pointer to the requested team's brain closest to the point. + /// 0 if there are no brains of that team. OWNERSHIP IS NOT TRANSFERRED! Actor* GetFirstBrainActor(int team) const { return GetClosestBrainActor(team, Vector()); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetClosestOtherBrainActor - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Get a pointer to the brain actor NOT of a specific team that is closest - // to a scene point. OWNERSHIP IS NOT TRANSFERRED! - // Arguments: Which team to NOT get the brain for. 0 means first team, 1 means 2nd. - // The point where to look for the closest brain not of this team. - // Return value: An Actor pointer to the requested brain closest to the point. - // 0 if there are no brains not on that team. OWNERSHIP IS NOT TRANSFERRED! - + /// Get a pointer to the brain actor NOT of a specific team that is closest + /// to a scene point. OWNERSHIP IS NOT TRANSFERRED! + /// @param notOfTeam Which team to NOT get the brain for. 0 means first team, 1 means 2nd. + /// @param scenePoint The point where to look for the closest brain not of this team. + /// @return An Actor pointer to the requested brain closest to the point. + /// 0 if there are no brains not on that team. OWNERSHIP IS NOT TRANSFERRED! Actor* GetClosestOtherBrainActor(int notOfTeam, const Vector& scenePoint) const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetFirstOtherBrainActor - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Get a pointer to the brain actor NOT of a specific team. OWNERSHIP IS NOT TRANSFERRED! - // Arguments: Which team to NOT get the brain for. 0 means first team, 1 means 2nd. - // Return value: An Actor pointer to the requested brain of that team. - // 0 if there are no brains not on that team. OWNERSHIP IS NOT TRANSFERRED! - + /// Get a pointer to the brain actor NOT of a specific team. OWNERSHIP IS NOT TRANSFERRED! + /// @param GetClosestOtherBrainActor(notOfTeam Which team to NOT get the brain for. 0 means first team, 1 means 2nd. + /// @return An Actor pointer to the requested brain of that team. + /// 0 if there are no brains not on that team. OWNERSHIP IS NOT TRANSFERRED! Actor* GetFirstOtherBrainActor(int notOfTeam) const { return GetClosestOtherBrainActor(notOfTeam, Vector()); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetUnassignedBrain - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Get a pointer to the first brain actor of a specific team which hasn't - // been assigned to a player yet. - // Arguments: Which team to try to get the brain for. 0 means first team, 1 means 2nd. - // Return value: An Actor pointer to the requested team's first brain encountered - // in the list that hasn't been assigned to a player. 0 if there are no - // unassigned brains of that team. - + /// Get a pointer to the first brain actor of a specific team which hasn't + /// been assigned to a player yet. + /// @param team Which team to try to get the brain for. 0 means first team, 1 means 2nd. (default: 0) + /// @return An Actor pointer to the requested team's first brain encountered + /// in the list that hasn't been assigned to a player. 0 if there are no + /// unassigned brains of that team. Actor* GetUnassignedBrain(int team = 0) const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetActorCount - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the number of actors currently held. - // Arguments: None. - // Return value: The number of actors. - + /// Gets the number of actors currently held. + /// @return The number of actors. long GetActorCount() const { return m_Actors.size(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetParticleCount - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the number of particles (MOPixel:s) currently held. - // Arguments: None. - // Return value: The number of particles. - + /// Gets the number of particles (MOPixel:s) currently held. + /// @return The number of particles. long GetParticleCount() const { return m_Particles.size(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetSplashRatio - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the global setting for how much splash MOPixels should be created - // an MO penetrates the terrain deeply. - // Arguments: None. - // Return value: A float with the global splash amount setting, form 1.0 to 0.0. - + /// Gets the global setting for how much splash MOPixels should be created + /// an MO penetrates the terrain deeply. + /// @return A float with the global splash amount setting, form 1.0 to 0.0. float GetSplashRatio() const { return m_SplashRatio; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetMaxDroppedItems - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the max number of dropped items that will be reached before the - // first dropped with be copied to the terrain. - // Arguments: An int spefifying the limit. - // Return value: None. - + /// Sets the max number of dropped items that will be reached before the + /// first dropped with be copied to the terrain. + /// @param newLimit An int spefifying the limit. void SetMaxDroppedItems(int newLimit) { m_MaxDroppedItems = newLimit; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetMaxDroppedItems - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the max number of dropped items that will be reached before the - // first dropped with be copied to the terrain. - // Arguments: None. - // Return value: An int spefifying the limit. - + /// Gets the max number of dropped items that will be reached before the + /// first dropped with be copied to the terrain. + /// @return An int spefifying the limit. int GetMaxDroppedItems() const { return m_MaxDroppedItems; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SortTeamRoster - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets this to draw HUD lines for a specific team's roster this frame. - // Arguments: Which team to have lines drawn of. - // Return value: None. - + /// Sets this to draw HUD lines for a specific team's roster this frame. + /// @param team Which team to have lines drawn of. void SortTeamRoster(int team) { m_SortTeamRoster[team] = true; } - /// /// Adds a MovableObject to this, after it is determined what it is and the best way to add it is. E.g. if it's an Actor, it will be added as such. Ownership IS transferred! - /// - /// A pointer to the MovableObject to add. Ownership IS transferred! - /// Whether the MovableObject was successfully added or not. Note that Ownership IS transferred either way, but the MovableObject will be deleted if this is not successful. + /// @param movableObjectToAdd A pointer to the MovableObject to add. Ownership IS transferred! + /// @return Whether the MovableObject was successfully added or not. Note that Ownership IS transferred either way, but the MovableObject will be deleted if this is not successful. bool AddMO(MovableObject* movableObjectToAdd); - /// /// Adds an Actor to the internal list of Actors. Destruction and deletion will be taken care of automatically. Ownership IS transferred! - /// - /// A pointer to the Actor to add. Ownership IS transferred! + /// @param actorToAdd A pointer to the Actor to add. Ownership IS transferred! void AddActor(Actor* actorToAdd); - /// /// Adds a pickup-able item to the internal list of items. Destruction and deletion will be taken care of automatically. Ownership IS transferred! - /// - /// A pointer to the item to add. Ownership IS transferred! + /// @param itemToAdd A pointer to the item to add. Ownership IS transferred! void AddItem(HeldDevice* itemToAdd); - /// /// Adds a MovableObject to the internal list of particles. Destruction and deletion will be taken care of automatically. Ownership IS transferred! - /// - /// A pointer to the MovableObject to add. Ownership is transferred! + /// @param particleToAdd A pointer to the MovableObject to add. Ownership is transferred! void AddParticle(MovableObject* particleToAdd); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: RemoveActor - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Removes an Actor from the internal list of MO:s. After the Actor is - // removed, ownership is effectively released and transferred to whatever - // client called this method. - // Arguments: A pointer to the MovableObject to remove. - // Return value: Whether the object was found in the particle list, and consequently - // removed. If the particle entry wasn't found, false is returned. - + /// Removes an Actor from the internal list of MO:s. After the Actor is + /// removed, ownership is effectively released and transferred to whatever + /// client called this method. + /// @param pActorToRem A pointer to the MovableObject to remove. + /// @return Whether the object was found in the particle list, and consequently + /// removed. If the particle entry wasn't found, false is returned. Actor* RemoveActor(MovableObject* pActorToRem); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: RemoveItem - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Removes a pickup-able MovableObject item from the internal list of - // MO:s. After the item is removed, ownership is effectively released and - // transferred to whatever client called this method. - // Arguments: A pointer to the MovableObject to remove. - // Return value: Whether the object was found in the particle list, and consequently - // removed. If the particle entry wasn't found, false is returned. - + /// Removes a pickup-able MovableObject item from the internal list of + /// MO:s. After the item is removed, ownership is effectively released and + /// transferred to whatever client called this method. + /// @param pItemToRem A pointer to the MovableObject to remove. + /// @return Whether the object was found in the particle list, and consequently + /// removed. If the particle entry wasn't found, false is returned. MovableObject* RemoveItem(MovableObject* pItemToRem); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: RemoveParticle - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Removes a MovableObject from the internal list of MO:s. After the - // MO is removed, ownership is effectively released and transferred to - // whatever client called this method. - // Arguments: A pointer to the MovableObject to remove. - // Return value: Whether the object was found in the particle list, and consequently - // removed. If the particle entry wasn't found, false is returned. - + /// Removes a MovableObject from the internal list of MO:s. After the + /// MO is removed, ownership is effectively released and transferred to + /// whatever client called this method. + /// @param pMOToRem A pointer to the MovableObject to remove. + /// @return Whether the object was found in the particle list, and consequently + /// removed. If the particle entry wasn't found, false is returned. MovableObject* RemoveParticle(MovableObject* pMOToRem); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ChangeActorTeam - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Changes actor team and updates team rosters. - // Arguments: Pointer to actor, new team value - // Return value: None. - + /// Changes actor team and updates team rosters. + /// @param pActor Pointer to actor, new team value void ChangeActorTeam(Actor* pActor, int team); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: AddActorToTeamRoster - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Adds actor to internal team roster - // Arguments: Pointer to actor - // Return value: None. - + /// Adds actor to internal team roster + /// @param pActorToAdd Pointer to actor void AddActorToTeamRoster(Actor* pActorToAdd); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: RemoveActorToTeamRoster - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Removes actor from internal team roster - // Arguments: Pointer to actor - // Return value: None. - + /// Removes actor from internal team roster + /// @param pActorToRem Pointer to actor void RemoveActorFromTeamRoster(Actor* pActorToRem); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ValidateMOIDs - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Goes through and checks that all MOID's have valid MO pointers - // associated with them. This shuold only be used for testing, as it will - // crash the app if validation fails. - // Arguments: None. - // Return value: All MOIDs valid. - + /// Goes through and checks that all MOID's have valid MO pointers + /// associated with them. This shuold only be used for testing, as it will + /// crash the app if validation fails. + /// @return All MOIDs valid. bool ValidateMOIDs(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ValidMO - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Indicates whether the passed in MovableObject pointer points to an - // MO that's currently active in the simulation, and kept by this - // MovableMan. Internal optimization is made so that the same MO can - // efficiently be checked many times during the same frame. - // Arguments: A pointer to the MovableObject to check for being actively kept by - // this MovableMan. - // Return value: Whether the MO instance was found in the active list or not. - + /// Indicates whether the passed in MovableObject pointer points to an + /// MO that's currently active in the simulation, and kept by this + /// MovableMan. Internal optimization is made so that the same MO can + /// efficiently be checked many times during the same frame. + /// @param pMOToCheck A pointer to the MovableObject to check for being actively kept by + /// this MovableMan. + /// @return Whether the MO instance was found in the active list or not. bool ValidMO(const MovableObject* pMOToCheck); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: IsActor - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Indicates whether the passed in MovableObject is an active Actor kept - // by this MovableMan or not. - // Arguments: A pointer to the MovableObject to check for Actorness. - // Return value: Whether the object was found in the Actor list or not. - + /// Indicates whether the passed in MovableObject is an active Actor kept + /// by this MovableMan or not. + /// @param pMOToCheck A pointer to the MovableObject to check for Actorness. + /// @return Whether the object was found in the Actor list or not. bool IsActor(const MovableObject* pMOToCheck); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: IsDevice - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Indicates whether the passed in MovableObject is an active Item kept - // by this MovableMan or not. - // Arguments: A pointer to the MovableObject to check for Itemness. - // Return value: Whether the object was found in the Item list or not. - + /// Indicates whether the passed in MovableObject is an active Item kept + /// by this MovableMan or not. + /// @param pMOToCheck A pointer to the MovableObject to check for Itemness. + /// @return Whether the object was found in the Item list or not. bool IsDevice(const MovableObject* pMOToCheck); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: IsParticle - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Indicates whether the passed in MovableObject is an active Item kept - // by this MovableMan or not. - // Arguments: A pointer to the MovableObject to check for Itemness. - // Return value: Whether the object was found in the Particle list or not. - + /// Indicates whether the passed in MovableObject is an active Item kept + /// by this MovableMan or not. + /// @param pMOToCheck A pointer to the MovableObject to check for Itemness. + /// @return Whether the object was found in the Particle list or not. bool IsParticle(const MovableObject* pMOToCheck); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: IsOfActor - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Indicates whether the passed in MOID is that of an MO which either is - // or is parented to an active Actor by this MovableMan, or not. - // Arguments: An MOID to check for Actorness. - // Return value: Whether the object was found or owned by an MO in the Actor list or not. - + /// Indicates whether the passed in MOID is that of an MO which either is + /// or is parented to an active Actor by this MovableMan, or not. + /// @param checkMOID An MOID to check for Actorness. + /// @return Whether the object was found or owned by an MO in the Actor list or not. bool IsOfActor(MOID checkMOID); - /// /// Gives a unique, contiguous id per-actor. This is regenerated every frame. - /// - /// The actor to get a contiguous id for. - /// A contiguous id for the actor. Returns -1 if the actor doesn't exist in MovableMan. - /// This function is used for AI throttling. + /// @param actor The actor to get a contiguous id for. + /// @return A contiguous id for the actor. Returns -1 if the actor doesn't exist in MovableMan. + /// @remark This function is used for AI throttling. int GetContiguousActorID(const Actor* actor) const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetRootMOID - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Produces the root MOID of the MOID of a potential child MO to another MO. - // Arguments: An MOID to get the root MOID of. - // Return value: The MOID of the root MO of the MO the passed-in MOID represents. This - // will be the same as the MOID passed in if the MO is a root itself. It will - // be equal to g_NoMOID if the MOID isn't allocated to an MO. - + /// Produces the root MOID of the MOID of a potential child MO to another MO. + /// @param checkMOID An MOID to get the root MOID of. + /// @return The MOID of the root MO of the MO the passed-in MOID represents. This + /// will be the same as the MOID passed in if the MO is a root itself. It will + /// be equal to g_NoMOID if the MOID isn't allocated to an MO. MOID GetRootMOID(MOID checkMOID); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: RemoveMO - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Removes a MovableObject from the any and all internal lists of MO:s. - // After the MO is removed, ownership is effectively released and - // transferred to whatever client called this method. - // Arguments: A pointer to the MovableObject to remove. - // Return value: Whether the object was found in MovableMan's custody, and consequently - // removed. If the MO entry wasn't found, false is returned. - + /// Removes a MovableObject from the any and all internal lists of MO:s. + /// After the MO is removed, ownership is effectively released and + /// transferred to whatever client called this method. + /// @param pMOToRem A pointer to the MovableObject to remove. + /// @return Whether the object was found in MovableMan's custody, and consequently + /// removed. If the MO entry wasn't found, false is returned. bool RemoveMO(MovableObject* pMOToRem); - /// /// Kills and destroys all Actors of a specific Team. - /// - /// The team to annihilate. If NoTeam is passed in, then NO Actors die. - /// How many Actors were killed. + /// @param teamToKill The team to annihilate. If NoTeam is passed in, then NO Actors die. + /// @return How many Actors were killed. int KillAllTeamActors(int teamToKill) const; - /// /// Kills and destroys all enemy Actors of a specific Team. - /// - /// The team to NOT annihilate. If NoTeam is passed in, then ALL Actors die. - /// How many Actors were killed. + /// @param teamNotToKill The team to NOT annihilate. If NoTeam is passed in, then ALL Actors die. + /// @return How many Actors were killed. int KillAllEnemyActors(int teamNotToKill = Activity::NoTeam) const; - /// /// Adds all Actors in MovableMan to the given list. - /// - /// Whether or not ownership of the Actors should be transferred from MovableMan to the list. - /// The list to be filled with Actors. - /// The team to get Actors of. If NoTeam, then all teams will be used. - /// Whether or not to get brain Actors. - /// The number of Actors added to the list. + /// @param transferOwnership Whether or not ownership of the Actors should be transferred from MovableMan to the list. + /// @param actorList The list to be filled with Actors. + /// @param onlyTeam The team to get Actors of. If NoTeam, then all teams will be used. + /// @param noBrains Whether or not to get brain Actors. + /// @return The number of Actors added to the list. int GetAllActors(bool transferOwnership, std::list& actorList, int onlyTeam = -1, bool noBrains = false); - /// - /// Whether or not ownershp of the items shoudl be transferred from MovableMan to the list. - /// The list to be filled with items. - /// The number of items added to the list. + /// @param transferOwnership Whether or not ownershp of the items shoudl be transferred from MovableMan to the list. + /// @param itemList The list to be filled with items. + /// @return The number of items added to the list. int GetAllItems(bool transferOwnership, std::list& itemList); - /// /// Adds all particles in MovableMan to the given list. - /// - /// Whether or not ownership of the particles should be transferred from MovableMan to the list. - /// The list to be filled with particles. - /// The number of particles added to the list. + /// @param transferOwnership Whether or not ownership of the particles should be transferred from MovableMan to the list. + /// @param particleList The list to be filled with particles. + /// @return The number of particles added to the list. int GetAllParticles(bool transferOwnership, std::list& particleList); - /// /// Opens all doors and keeps them open until this is called again with false. - /// - /// Whether to open all doors (true), or close all doors (false). - /// Which team to open doors for. NoTeam means all teams. + /// @param open Whether to open all doors (true), or close all doors (false). + /// @param team Which team to open doors for. NoTeam means all teams. void OpenAllDoors(bool open = true, int team = Activity::NoTeam) const; - /// /// Temporarily erases or redraws any material door representations of a specific team. /// Used to make pathfinding work better, allowing Actors to navigate through firendly bases despite the door material layer. - /// - /// Whether to erase door material, thereby overriding it, or redraw it and undo the override. - /// Which team to do this for, NoTeam means all teams. + /// @param eraseDoorMaterial Whether to erase door material, thereby overriding it, or redraw it and undo the override. + /// @param team Which team to do this for, NoTeam means all teams. void OverrideMaterialDoors(bool eraseDoorMaterial, int team = Activity::NoTeam) const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: RegisterAlarmEvent - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Registers an AlarmEvent to notify things around that somehting alarming - // like a gunshot or explosion just happened. - // Arguments: The AlarmEvent to register. - // Return value: None. - + /// Registers an AlarmEvent to notify things around that somehting alarming + /// like a gunshot or explosion just happened. + /// @param newEvent The AlarmEvent to register. void RegisterAlarmEvent(const AlarmEvent& newEvent); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetAlarmEvents - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the list of AlarmEvent:s from last frame's update. - // Arguments: None. - // Return value: The const list of AlarmEvent:s. - + /// Gets the list of AlarmEvent:s from last frame's update. + /// @return The const list of AlarmEvent:s. const std::vector& GetAlarmEvents() const { return m_AlarmEvents; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: IsParticleSettlingEnabled - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Shows whetehr particles are set to get copied to the terrain upon - // settling - // Arguments: None. - // Return value: Whether enabled or not. - + /// Shows whetehr particles are set to get copied to the terrain upon + /// settling + /// @return Whether enabled or not. bool IsParticleSettlingEnabled() { return m_SettlingEnabled; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: EnableParticleSettling - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets whether particles will get copied into the terrain upon them - // settling down. - // Arguments: Whether to enable or not. - // Return value: None. - + /// Sets whether particles will get copied into the terrain upon them + /// settling down. + /// @param enable Whether to enable or not. (default: true) void EnableParticleSettling(bool enable = true) { m_SettlingEnabled = enable; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: IsMOSubtractionEnabled - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Shows whether MO's sihouettes can get subtracted from the terrain at all. - // Arguments: None. - // Return value: Whether enabled or not. - + /// Shows whether MO's sihouettes can get subtracted from the terrain at all. + /// @return Whether enabled or not. bool IsMOSubtractionEnabled() { return m_MOSubtractionEnabled; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: RedrawOverlappingMOIDs - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Forces all objects potnetially overlapping a specific MO to re-draw - // this MOID representations onto the MOID bitmap. - // Arguments: A pointer to the MO to check for overlaps against. Ownerhip is NOT - // transferred. - // Return value: None. - + /// Forces all objects potnetially overlapping a specific MO to re-draw + /// this MOID representations onto the MOID bitmap. + /// @param pOverlapsThis A pointer to the MO to check for overlaps against. Ownerhip is NOT + /// transferred. void RedrawOverlappingMOIDs(MovableObject* pOverlapsThis); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Update - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the state of this MovableMan. Supposed to be done every frame. - // Arguments: None. - // Return value: None. - + /// Updates the state of this MovableMan. Supposed to be done every frame. void Update(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: DrawMatter - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws this MovableMan's all MO's current material representations to a - // BITMAP of choice. - // Arguments: A pointer to a BITMAP to draw on. - // The absolute position of the target bitmap's upper left corner in the scene. - // Return value: None. - + /// Draws this MovableMan's all MO's current material representations to a + /// BITMAP of choice. + /// @param pTargetBitmap A pointer to a BITMAP to draw on. + /// @param targetPos The absolute position of the target bitmap's upper left corner in the scene. void DrawMatter(BITMAP* pTargetBitmap, Vector& targetPos); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: UpdateDrawMOIDs - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the MOIDs of all current MOs and draws their ID's to a BITMAP - // of choice. If there are more than 255 MO's to draw, some will not be. - // Arguments: A pointer to a BITMAP to draw on. - // Return value: None. - + /// Updates the MOIDs of all current MOs and draws their ID's to a BITMAP + /// of choice. If there are more than 255 MO's to draw, some will not be. + /// @param pTargetBitmap A pointer to a BITMAP to draw on. void UpdateDrawMOIDs(BITMAP* pTargetBitmap); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Draw - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws this MovableMan's current graphical representation to a - // BITMAP of choice. - // Arguments: A pointer to a BITMAP to draw on. - // The absolute position of the target bitmap's upper left corner in the scene. - // Return value: None. - + /// Draws this MovableMan's current graphical representation to a + /// BITMAP of choice. + /// @param pTargetBitmap A pointer to a BITMAP to draw on. + /// @param targetPos The absolute position of the target bitmap's upper left corner in the scene. (default: Vector()) void Draw(BITMAP* pTargetBitmap, const Vector& targetPos = Vector()); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: DrawHUD - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws the HUDs of all MovableObject:s of this MovableMan to a BITMAP - // of choice. - // Arguments: A pointer to a BITMAP to draw on. - // The absolute position of the target bitmap's upper left corner in the scene. - // Which player's screen is being drawn. Tis affects which actor's HUDs - // get drawn. - // Return value: None. - + /// Draws the HUDs of all MovableObject:s of this MovableMan to a BITMAP + /// of choice. + /// @param pTargetBitmap A pointer to a BITMAP to draw on. + /// @param targetPos The absolute position of the target bitmap's upper left corner in the scene. (default: Vector()) + /// @param which Which player's screen is being drawn. Tis affects which actor's HUDs (default: 0) + /// get drawn. void DrawHUD(BITMAP* pTargetBitmap, const Vector& targetPos = Vector(), int which = 0, bool playerControlled = false); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: VerifyMOIDIndex - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Verifieis whether all elements of MOID index has correct ID. Should be used in Debug mode only. - // Arguments: None. - // Return value: None. - + /// Verifieis whether all elements of MOID index has correct ID. Should be used in Debug mode only. void VerifyMOIDIndex(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: RegisterObject - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Registers an object in a global Map collection so it could be found later with FindObjectByUniqueId - // Arguments: MO to register. - // Return value: None. - + /// Registers an object in a global Map collection so it could be found later with FindObjectByUniqueId + /// @param mo MO to register. void RegisterObject(MovableObject* mo); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: UnregisterObject - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Removes an object from the global lookup collection - // Arguments: MO to remove. - // Return value: None. - + /// Removes an object from the global lookup collection + /// @param mo MO to remove. void UnregisterObject(MovableObject* mo); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: FindObjectByUniqueId - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Uses a global lookup map to find an object by it's unique id. - // Arguments: Unique Id to look for. - // Return value: Object found or 0 if not found any. - + /// Uses a global lookup map to find an object by it's unique id. + /// @param id Unique Id to look for. + /// @return Object found or 0 if not found any. MovableObject* FindObjectByUniqueID(long int id) { if (m_KnownObjects.count(id) > 0) return m_KnownObjects[id]; @@ -811,88 +497,60 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetKnownObjectsCount - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns the size of the object registry collection - // Arguments: None. - // Return value: Size of the objects registry. - + /// Returns the size of the object registry collection + /// @return Size of the objects registry. unsigned int GetKnownObjectsCount() { return m_KnownObjects.size(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetSimUpdateFrameNumber - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns the current sim update frame number - // Arguments: None. - // Return value: Current sim update frame number. - + /// Returns the current sim update frame number + /// @return Current sim update frame number. unsigned int GetSimUpdateFrameNumber() const { return m_SimUpdateFrameNumber; } - /// /// Gets pointers to the MOs that are within the given Box, and whose team is not ignored. - /// - /// The Box to get MOs within. - /// The team to ignore. - /// Whether to only include MOs that have GetsHitByMOs enabled, or all MOs. - /// Pointers to the MOs that are within the given Box, and whose team is not ignored. + /// @param box The Box to get MOs within. + /// @param ignoreTeam The team to ignore. + /// @param getsHitByMOsOnly Whether to only include MOs that have GetsHitByMOs enabled, or all MOs. + /// @return Pointers to the MOs that are within the given Box, and whose team is not ignored. const std::vector* GetMOsInBox(const Box& box, int ignoreTeam, bool getsHitByMOsOnly) const; - /// /// Gets pointers to the MOs that are within the given Box, and whose team is not ignored. - /// - /// The Box to get MOs within. - /// The team to ignore. - /// Pointers to the MOs that are within the given Box, and whose team is not ignored. + /// @param box The Box to get MOs within. + /// @param ignoreTeam The team to ignore. + /// @return Pointers to the MOs that are within the given Box, and whose team is not ignored. const std::vector* GetMOsInBox(const Box& box, int ignoreTeam) const { return GetMOsInBox(box, ignoreTeam, false); } - /// /// Gets pointers to the MOs that are within the given Box. - /// - /// The Box to get MOs within. - /// Pointers to the MOs that are within the given Box. + /// @param box The Box to get MOs within. + /// @return Pointers to the MOs that are within the given Box. const std::vector* GetMOsInBox(const Box& box) const { return GetMOsInBox(box, Activity::NoTeam); } - /// /// Gets pointers to the MOs that are within the specified radius of the given centre position, and whose team is not ignored. - /// - /// The position to check for MOs in. - /// The radius to check for MOs within. - /// The team to ignore. - /// Whether to only include MOs that have GetsHitByMOs enabled, or all MOs. - /// Pointers to the MOs that are within the specified radius of the given centre position, and whose team is not ignored. + /// @param centre The position to check for MOs in. + /// @param radius The radius to check for MOs within. + /// @param ignoreTeam The team to ignore. + /// @param getsHitByMOsOnly Whether to only include MOs that have GetsHitByMOs enabled, or all MOs. + /// @return Pointers to the MOs that are within the specified radius of the given centre position, and whose team is not ignored. const std::vector* GetMOsInRadius(const Vector& centre, float radius, int ignoreTeam, bool getsHitByMOsOnly) const; - /// /// Gets pointers to the MOs that are within the specified radius of the given centre position, and whose team is not ignored. - /// - /// The position to check for MOs in. - /// The radius to check for MOs within. - /// The team to ignore. - /// Pointers to the MOs that are within the specified radius of the given centre position, and whose team is not ignored. + /// @param centre The position to check for MOs in. + /// @param radius The radius to check for MOs within. + /// @param ignoreTeam The team to ignore. + /// @return Pointers to the MOs that are within the specified radius of the given centre position, and whose team is not ignored. const std::vector* GetMOsInRadius(const Vector& centre, float radius, int ignoreTeam) const { return GetMOsInRadius(centre, radius, ignoreTeam, false); } - /// /// Gets pointers to the MOs that are within the specified radius of the given centre position. - /// - /// The position to check for MOs in. - /// The radius to check for MOs within. - /// Pointers to the MOs that are within the specified radius of the given centre position. + /// @param centre The position to check for MOs in. + /// @param radius The radius to check for MOs within. + /// @return Pointers to the MOs that are within the specified radius of the given centre position. const std::vector* GetMOsInRadius(const Vector& centre, float radius) const { return GetMOsInRadius(centre, radius, Activity::NoTeam); } - /// /// Runs a lua function on all MOs in the simulation, including owned child MOs. - /// void RunLuaFunctionOnAllMOs(const std::string& functionName, bool includeAdded, const std::vector& functionEntityArguments = std::vector(), const std::vector& functionLiteralArguments = std::vector(), const std::vector& functionObjectArguments = std::vector()); - /// /// Clears all cached lua functions on all MOs, including owned child MOs. - /// void ReloadLuaScripts(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Protected member variable and method declarations - + /// Protected member variable and method declarations protected: // All actors in the scene std::deque m_Actors; @@ -971,39 +629,25 @@ namespace RTE { // Global map which stores all objects so they could be foud by their unique ID std::map m_KnownObjects; - ////////////////////////////////////////////////////////////////////////////////////////// - // Private member variable and method declarations - + /// Private member variable and method declarations private: static const std::string c_ClassName; //!< A string with the friendly-formatted type name of this object. - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Clear - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears all the member variables of this MovableMan, effectively - // resetting the members of this abstraction level only. - // Arguments: None. - // Return value: None. - + /// Clears all the member variables of this MovableMan, effectively + /// resetting the members of this abstraction level only. void Clear(); - /// /// Travels all of our MOs, updating their location/velocity/physical characteristics. - /// void Travel(); - /// /// Updates the controllers of all the actors we own. /// This is needed for a tricky reason - we want the controller from the activity to override the normal controller state /// So we need to update the controller state prior to activity, so the changes from activity are layered on top. - /// void UpdateControllers(); - /// /// Updates all things that need to be done before we update the controllers. /// This is needed because of a very awkward and ugly old code path where controllers were updated in the middle of update, and various mods relied of this behaviour for actions that were therefore delayed by a frame /// Ideally we wouldn't need this, but this is all very fragile code and I'd prefer to avoid breaking things. - /// void PreControllerUpdate(); // Disallow the use of some implicit methods. diff --git a/Source/Managers/NetworkClient.cpp b/Source/Managers/NetworkClient.cpp index 23a5c2378f..48a9db93fb 100644 --- a/Source/Managers/NetworkClient.cpp +++ b/Source/Managers/NetworkClient.cpp @@ -16,8 +16,6 @@ namespace RTE { - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void NetworkClient::Clear() { m_LastInputSentTime = 0; m_ReceivedData = 0; @@ -60,8 +58,6 @@ namespace RTE { m_ServerSounds.clear(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int NetworkClient::Initialize() { // Record the first client that connects to us so we can pass it to the ping function m_ClientID = RakNet::UNASSIGNED_SYSTEM_ADDRESS; @@ -70,8 +66,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void NetworkClient::Connect(std::string serverName, unsigned short serverPort, std::string playerName) { g_ConsoleMan.PrintString("CLIENT: Connecting to " + serverName); @@ -85,8 +79,6 @@ namespace RTE { g_ConsoleMan.PrintString((connectionAttempt == RakNet::CONNECTION_ATTEMPT_STARTED) ? "CLIENT: Connect request sent" : "CLIENT: Unable to connect"); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void NetworkClient::ConnectNAT(RakNet::SystemAddress address) { g_ConsoleMan.PrintString("CLIENT: Connecting to server through NAT"); g_ConsoleMan.PrintString(address.ToString()); @@ -97,8 +89,6 @@ namespace RTE { g_ConsoleMan.PrintString((connectionAttempt == RakNet::CONNECTION_ATTEMPT_STARTED) ? "CLIENT: Connect request sent" : "CLIENT: Unable to connect"); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void NetworkClient::Disconnect() { if (m_IsConnected || m_IsRegistered) { SendDisconnectMsg(); @@ -112,8 +102,6 @@ namespace RTE { g_ConsoleMan.PrintString("CLIENT: Disconnect"); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void NetworkClient::PerformNATPunchThrough(std::string serviceServerName, unsigned short serviceServerPort, std::string playerName, std::string serverName, std::string serverPassword) { m_UseNATPunchThroughService = true; @@ -136,8 +124,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - RakNet::SystemAddress NetworkClient::ConnectBlocking(RakNet::RakPeerInterface* rakPeer, const char* address, unsigned short port) { if (rakPeer->Connect(address, port, nullptr, 0) != RakNet::CONNECTION_ATTEMPT_STARTED) { return RakNet::UNASSIGNED_SYSTEM_ADDRESS; @@ -157,8 +143,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - unsigned char NetworkClient::GetPacketIdentifier(RakNet::Packet* packet) const { if (packet == nullptr) { return 255; @@ -171,8 +155,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void NetworkClient::SendRegisterMsg() { MsgRegister msg = {}; msg.Id = ID_CLT_REGISTER; @@ -183,15 +165,11 @@ namespace RTE { g_ConsoleMan.PrintString("CLIENT: Registration Sent"); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void NetworkClient::ReceiveAcceptedMsg() { g_ConsoleMan.PrintString("CLIENT: Registration accepted."); m_IsRegistered = true; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void NetworkClient::SendDisconnectMsg() { MsgRegister msg = {}; msg.Id = ID_CLT_DISCONNECT; @@ -199,8 +177,6 @@ namespace RTE { g_ConsoleMan.PrintString("CLIENT: Disconnection Sent"); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void NetworkClient::SendServerGUIDRequest(RakNet::SystemAddress address, std::string serverName, std::string serverPassword) { MsgGetServerRequest msg = {}; msg.Id = ID_NAT_SERVER_GET_SERVER_GUID; @@ -209,8 +185,6 @@ namespace RTE { m_Client->Send((const char*)&msg, sizeof(RTE::MsgGetServerRequest), IMMEDIATE_PRIORITY, RELIABLE, 0, address, false); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void NetworkClient::ReceiveServerGUIDAnswer(RakNet::Packet* packet) { const MsgGetServerAnswer* msg = (MsgGetServerAnswer*)packet->data; m_ServerGUID.FromString(msg->ServerGuid); @@ -219,8 +193,6 @@ namespace RTE { g_ConsoleMan.PrintString(m_ServerGUID.ToString()); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void NetworkClient::SendInputMsg() { MsgInput msg = {}; msg.Id = ID_CLT_INPUT; @@ -266,8 +238,6 @@ namespace RTE { m_Client->Send((const char*)&msg, sizeof(msg), IMMEDIATE_PRIORITY, RELIABLE_ORDERED, 0, m_ServerID, false); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void NetworkClient::ReceiveFrameSetupMsg(RakNet::Packet* packet) { const MsgFrameSetup* frameData = (MsgFrameSetup*)packet->data; if (frameData->FrameNumber >= c_FramesToRemember) { @@ -295,8 +265,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void NetworkClient::ReceiveFrameLineMsg(RakNet::Packet* packet) { const MsgFrameLine* frameData = (MsgFrameLine*)packet->data; int lineNumber = frameData->LineNumber; @@ -337,8 +305,6 @@ namespace RTE { release_bitmap(bmp); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void NetworkClient::ReceiveFrameBoxMsg(RakNet::Packet* packet) { const MsgFrameBox* frameData = (MsgFrameBox*)packet->data; @@ -446,8 +412,6 @@ namespace RTE { release_bitmap(bmp); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void NetworkClient::SendSceneAcceptedMsg() { MsgRegister msg = {}; msg.Id = ID_CLT_SCENE_ACCEPTED; @@ -455,8 +419,6 @@ namespace RTE { g_ConsoleMan.PrintString("CLIENT: Scene ACK Sent"); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void NetworkClient::ReceiveSceneMsg(RakNet::Packet* packet) { const MsgSceneLine* frameData = (MsgSceneLine*)packet->data; if (frameData->SceneId != m_SceneID) { @@ -496,15 +458,11 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void NetworkClient::ReceiveSceneEndMsg() { g_ConsoleMan.PrintString("CLIENT: Scene received."); SendSceneAcceptedMsg(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void NetworkClient::ReceiveSceneSetupMsg(RakNet::Packet* packet) { clear_to_color(g_FrameMan.GetNetworkBackBufferIntermediateGUI8Ready(0), g_MaskColor); clear_to_color(g_FrameMan.GetNetworkBackBufferGUI8Ready(0), g_MaskColor); @@ -578,8 +536,6 @@ namespace RTE { g_ConsoleMan.PrintString("CLIENT: Scene setup accepted"); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void NetworkClient::SendSceneSetupAcceptedMsg() { MsgRegister msg; msg.Id = ID_CLT_SCENE_SETUP_ACCEPTED; @@ -587,8 +543,6 @@ namespace RTE { g_ConsoleMan.PrintString("CLIENT: Scene setup ACK Sent"); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void NetworkClient::ReceiveTerrainChangeMsg(RakNet::Packet* packet) { const MsgTerrainChange* frameData = (MsgTerrainChange*)packet->data; if (frameData->SceneId != m_SceneID) { @@ -624,8 +578,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void NetworkClient::ReceivePostEffectsMsg(RakNet::Packet* packet) { MsgPostEffects* msg = (MsgPostEffects*)packet->data; const PostEffectNetworkData* effDataPtr = (PostEffectNetworkData*)((char*)msg + sizeof(MsgPostEffects)); @@ -644,8 +596,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void NetworkClient::ReceiveSoundEventsMsg(RakNet::Packet* packet) { MsgSoundEvents* msg = (MsgSoundEvents*)packet->data; const AudioMan::NetworkSoundData* soundDataPointer = (AudioMan::NetworkSoundData*)((char*)msg + sizeof(MsgSoundEvents)); @@ -723,8 +673,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void NetworkClient::ReceiveMusicEventsMsg(RakNet::Packet* packet) { MsgMusicEvents* msg = (MsgMusicEvents*)packet->data; const AudioMan::NetworkMusicData* musicDataPointer = (AudioMan::NetworkMusicData*)((char*)msg + sizeof(MsgMusicEvents)); @@ -762,8 +710,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void NetworkClient::DrawBackgrounds(BITMAP* targetBitmap) { for (int i = m_ActiveBackgroundLayers - 1; i >= 0; i--) { if (m_BackgroundBitmaps[i] != 0) { @@ -842,7 +788,7 @@ namespace RTE { set_clip_rect(targetBitmap, targetBox.GetCorner().m_X, targetBox.GetCorner().m_Y, targetBox.GetCorner().m_X + targetBox.GetWidth() - 1, targetBox.GetCorner().m_Y + targetBox.GetHeight() - 1); // Choose the correct blitting function based on transparency setting - void (*pfBlit)(BITMAP* source, BITMAP* dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height) = m_BackgroundLayers[frame][i].DrawTrans ? &masked_blit : &blit; + void (*pfBlit)(BITMAP * source, BITMAP * dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height) = m_BackgroundLayers[frame][i].DrawTrans ? &masked_blit : &blit; // See if this SceneLayer is wider AND higher than the target bitmap; then use simple wrapping logic - otherwise need to tile if (m_BackgroundBitmaps[i]->w >= targetBitmap->w && m_BackgroundBitmaps[i]->h >= targetBitmap->h) { @@ -944,14 +890,10 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void NetworkClient::DrawPostEffects(int frame) { g_PostProcessMan.SetNetworkPostEffectsList(0, m_PostEffects[frame]); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void NetworkClient::DrawFrame(int frameNumber, bool useInterlacing, bool clearFramebuffer) { BITMAP* src_bmp = g_FrameMan.GetNetworkBackBufferIntermediate8Ready(0); BITMAP* dst_bmp = g_FrameMan.GetNetworkBackBuffer8Ready(0); @@ -1052,8 +994,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void NetworkClient::Update() { HandleNetworkPackets(); @@ -1157,8 +1097,6 @@ namespace RTE { #endif } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void NetworkClient::HandleNetworkPackets() { std::string msg; diff --git a/Source/Managers/NetworkClient.h b/Source/Managers/NetworkClient.h index 91504c3f58..64791aff29 100644 --- a/Source/Managers/NetworkClient.h +++ b/Source/Managers/NetworkClient.h @@ -23,118 +23,86 @@ namespace RTE { class SoundContainer; - /// /// The centralized singleton manager of the network multiplayer client. - /// class NetworkClient : public Singleton { friend class SettingsMan; public: #pragma region Creation - /// /// Constructor method used to instantiate a NetworkClient object in system memory. Create() should be called before using the object. - /// NetworkClient() { Clear(); Initialize(); } - /// /// Makes the NetworkClient object ready for use. - /// - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Initialize(); #pragma endregion #pragma region Destruction - /// /// Destructor method used to clean up a NetworkClient object before deletion from system memory. - /// ~NetworkClient() { Destroy(); } - /// /// Destroys and resets (through Clear()) the NetworkClient object. - /// void Destroy() { Clear(); } #pragma endregion #pragma region Getters - /// /// Gets whether the client is connected and registered to a server. - /// - /// Whether the client is connected and registered to a server. + /// @return Whether the client is connected and registered to a server. bool IsConnectedAndRegistered() const { return m_IsConnected && m_IsRegistered; } - /// /// Gets scene width for network client. - /// - /// Current scene width. + /// @return Current scene width. int GetSceneWidth() const { return m_SceneWidth; } - /// /// Gets scene height for network client. - /// - /// Current scene height. + /// @return Current scene height. int GetSceneHeight() const { return m_SceneHeight; } - /// /// Indicates whether the scene wraps its scrolling around the X axis for network client. - /// - /// Whether the scene wraps around the X axis or not. + /// @return Whether the scene wraps around the X axis or not. bool SceneWrapsX() const { return m_SceneWrapsX; } - /// /// Get the coordinates of the center of the current frame. - /// - /// A vector containing the X/Y coordinates of the frame target. + /// @return A vector containing the X/Y coordinates of the frame target. const Vector& GetFrameTarget() const { return m_TargetPos[m_CurrentFrameNum]; } #pragma endregion #pragma region Concrete Methods - /// /// Updates the state of this NetworkClient. Supposed to be done every frame. - /// void Update(); #pragma endregion #pragma region Connection Handling - /// /// Connects the client to a server. - /// - /// Server name (or address) to connect to. - /// Server port. - /// Player name to be used in network game. + /// @param serverName Server name (or address) to connect to. + /// @param serverPort Server port. + /// @param playerName Player name to be used in network game. void Connect(std::string serverName, unsigned short serverPort, std::string playerName); - /// /// Connects the client to a server through a NAT service. - /// - /// The NAT service address. + /// @param address The NAT service address. void ConnectNAT(RakNet::SystemAddress address); - /// /// Disconnects the client from the currently connected server. - /// void Disconnect(); - /// /// Connects to a NAT service and performs punch-through. - /// - /// NAT service server name (or address) to use for punch-through. - /// NAT service server port. - /// Player name to be used in network game. - /// Server name (or address) to connect to. - /// Server password. + /// @param serviceServerName NAT service server name (or address) to use for punch-through. + /// @param serviceServerPort NAT service server port. + /// @param playerName Player name to be used in network game. + /// @param serverName Server name (or address) to connect to. + /// @param serverPassword Server password. void PerformNATPunchThrough(std::string serviceServerName, unsigned short serviceServerPort, std::string playerName, std::string serverName, std::string serverPassword); - /// /// - /// - /// - /// - /// - /// + /// @param rakPeer + /// @param address + /// @param port + /// @return RakNet::SystemAddress ConnectBlocking(RakNet::RakPeerInterface* rakPeer, const char* address, unsigned short port); #pragma endregion @@ -198,155 +166,105 @@ namespace RTE { private: #pragma region Update Breakdown - /// /// - /// void HandleNetworkPackets(); #pragma endregion #pragma region Network Event Handling - /// /// - /// - /// - /// + /// @param packet + /// @return unsigned char GetPacketIdentifier(RakNet::Packet* packet) const; - /// /// - /// void SendRegisterMsg(); - /// /// - /// void ReceiveAcceptedMsg(); - /// /// - /// void SendDisconnectMsg(); - /// /// - /// - /// - /// - /// + /// @param address + /// @param serverName + /// @param serverPassword void SendServerGUIDRequest(RakNet::SystemAddress address, std::string serverName, std::string serverPassword); - /// /// - /// - /// + /// @param packet void ReceiveServerGUIDAnswer(RakNet::Packet* packet); - /// /// - /// void SendInputMsg(); - /// /// - /// - /// + /// @param packet void ReceiveFrameSetupMsg(RakNet::Packet* packet); - /// /// - /// - /// + /// @param packet void ReceiveFrameLineMsg(RakNet::Packet* packet); - /// /// - /// - /// + /// @param packet void ReceiveFrameBoxMsg(RakNet::Packet* packet); - /// /// - /// void SendSceneAcceptedMsg(); - /// /// - /// - /// + /// @param packet void ReceiveSceneMsg(RakNet::Packet* packet); - /// /// - /// void ReceiveSceneEndMsg(); - /// /// - /// - /// + /// @param packet void ReceiveSceneSetupMsg(RakNet::Packet* packet); - /// /// - /// void SendSceneSetupAcceptedMsg(); - /// /// Receive and handle a packet of terrain change data. - /// - /// The packet to handle. + /// @param packet The packet to handle. void ReceiveTerrainChangeMsg(RakNet::Packet* packet); - /// /// Receive and handle a packet of post-effect data. - /// - /// The packet to handle. + /// @param packet The packet to handle. void ReceivePostEffectsMsg(RakNet::Packet* packet); - /// /// Receive and handle a packet of sound event data. - /// - /// The packet to handle. + /// @param packet The packet to handle. void ReceiveSoundEventsMsg(RakNet::Packet* packet); - /// /// Receive and handle a packet of music event data. - /// - /// The packet to handle. + /// @param packet The packet to handle. void ReceiveMusicEventsMsg(RakNet::Packet* packet); #pragma endregion #pragma region Drawing - /// /// - /// - /// + /// @param targetBitmap void DrawBackgrounds(BITMAP* targetBitmap); - /// /// - /// - /// + /// @param frame void DrawPostEffects(int frame); - /// /// - /// - /// - /// - /// + /// @param frameNumber + /// @param useInterlacing + /// @param clearFramebuffer void DrawFrame(int frameNumber, bool useInterlacing, bool clearFramebuffer); #pragma endregion - /// /// Gets the ping time between the client and the server. - /// - /// The ping time between the client and the server. + /// @return The ping time between the client and the server. int GetPing() const { return IsConnectedAndRegistered() ? m_Client->GetLastPing(m_ServerID) : 0; } - /// /// Clears all the member variables of this NetworkClient, effectively resetting the members of this abstraction level only. - /// void Clear(); // Disallow the use of some implicit methods. diff --git a/Source/Managers/NetworkServer.cpp b/Source/Managers/NetworkServer.cpp index c004e44263..1d8a7eb886 100644 --- a/Source/Managers/NetworkServer.cpp +++ b/Source/Managers/NetworkServer.cpp @@ -25,8 +25,6 @@ namespace RTE { - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void NetworkServer::BackgroundSendThreadFunction(NetworkServer* server, short player) { const int sleepTime = 1000000 / server->m_EncodingFps; while (server->IsServerModeEnabled() && server->IsPlayerConnected(player)) { @@ -46,8 +44,6 @@ namespace RTE { server->SetThreadExitReason(player, NetworkServer::THREAD_FINISH); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void NetworkServer::Clear() { m_SleepWhenIdle = false; m_SimSleepWhenIdle = false; @@ -147,8 +143,6 @@ namespace RTE { m_LastPackedReceived = nullptr; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int NetworkServer::Initialize() { m_IsInServerMode = false; m_ServerPort = ""; @@ -191,8 +185,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void NetworkServer::Destroy() { // Send a signal that server is going to shutdown m_IsInServerMode = false; @@ -218,8 +210,6 @@ namespace RTE { Clear(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool NetworkServer::ReadyForSimulation() { short playersReady = 0; short playersTotal = 0; @@ -236,8 +226,6 @@ namespace RTE { return playersReady >= playersTotal; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void NetworkServer::SetServerPort(const std::string& newPort) { bool useDefault = false; for (const char& stringChar: newPort) { @@ -250,8 +238,6 @@ namespace RTE { m_ServerPort = useDefault ? "8000" : newPort; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void NetworkServer::Start() { RakNet::SocketDescriptor socketDescriptors[1]; socketDescriptors[0].port = atoi(m_ServerPort.c_str()); @@ -299,8 +285,6 @@ namespace RTE { m_Server->SetUnreliableTimeout(50); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void NetworkServer::LockScene(bool isLocked) { for (int i = 0; i < c_MaxClients; i++) { if (isLocked) { @@ -311,8 +295,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void NetworkServer::ResetScene() { m_SceneID++; for (int i = 0; i < c_MaxClients; i++) { @@ -323,8 +305,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void NetworkServer::RegisterTerrainChange(NetworkTerrainChange terrainChange) { if (m_IsInServerMode) { for (short player = 0; player < c_MaxClients; player++) { @@ -337,8 +317,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - unsigned char NetworkServer::GetPacketIdentifier(RakNet::Packet* packet) const { if (packet == 0) { return 255; @@ -351,8 +329,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void NetworkServer::ReceiveNewIncomingConnection(RakNet::Packet* packet) { std::string msg; RakNet::SystemAddress clientID; @@ -399,16 +375,12 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void NetworkServer::SendAcceptedMsg(short player) { MsgAccepted msg; msg.Id = ID_SRV_ACCEPTED; m_Server->Send((const char*)&msg, sizeof(MsgAccepted), HIGH_PRIORITY, RELIABLE_SEQUENCED, 0, m_ClientConnections[player].ClientId, false); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void NetworkServer::ReceiveDisconnection(RakNet::Packet* packet) { std::string msg = "ID_CONNECTION_LOST from"; msg += packet->systemAddress.ToString(true); @@ -430,8 +402,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void NetworkServer::ReceiveRegisterMsg(RakNet::Packet* packet) { std::string msg; const MsgRegister* msgReg = (MsgRegister*)packet->data; @@ -478,8 +448,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void NetworkServer::SendNATServerRegistrationMsg(RakNet::SystemAddress address) { MsgRegisterServer msg = {}; msg.Id = ID_NAT_SERVER_REGISTER_SERVER; @@ -494,8 +462,6 @@ namespace RTE { m_Server->Send((const char*)&msg, payloadSize, IMMEDIATE_PRIORITY, RELIABLE, 0, address, false); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void NetworkServer::ReceiveInputMsg(RakNet::Packet* packet) { const MsgInput* m = (MsgInput*)packet->data; @@ -566,8 +532,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void NetworkServer::ProcessInputMsg(short player, MsgInput msg) { if (player >= 0 && player < c_MaxClients) { Vector input; @@ -608,16 +572,12 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void NetworkServer::ClearInputMessages(short player) { if (player >= 0 && player < c_MaxClients) { m_InputMessages[player].clear(); } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void NetworkServer::SendSoundData(short player) { std::list events; g_AudioMan.GetSoundEvents(player, events); @@ -673,8 +633,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void NetworkServer::SendMusicData(short player) { std::list events; g_AudioMan.GetMusicEvents(player, events); @@ -724,8 +682,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void NetworkServer::SendSceneSetupData(short player) { MsgSceneSetup msgSceneSetup = {}; msgSceneSetup.Id = ID_SRV_SCENE_SETUP; @@ -797,8 +753,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void NetworkServer::ReceiveSceneSetupDataAccepted(RakNet::Packet* packet) { short player = -1; @@ -815,8 +769,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void NetworkServer::SendSceneData(short player) { // Check for congestion RakNet::RakNetStatistics rns; @@ -932,8 +884,6 @@ namespace RTE { SendSceneEndMsg(player); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void NetworkServer::ClearTerrainChangeQueue(short player) { m_Mutex[player].lock(); while (!m_PendingTerrainChanges[player].empty()) { @@ -945,8 +895,6 @@ namespace RTE { m_Mutex[player].unlock(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool NetworkServer::NeedToProcessTerrainChanges(short player) { bool result; @@ -957,8 +905,6 @@ namespace RTE { return result; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void NetworkServer::ProcessTerrainChanges(short player) { m_Mutex[player].lock(); while (!m_PendingTerrainChanges[player].empty()) { @@ -1006,8 +952,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void NetworkServer::SendTerrainChangeMsg(short player, NetworkTerrainChange terrainChange) { if (terrainChange.w == 1 && terrainChange.h == 1) { MsgTerrainChange msg = {}; @@ -1092,8 +1036,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void NetworkServer::ReceiveSceneAcceptedMsg(RakNet::Packet* packet) { for (short player = 0; player < c_MaxClients; player++) { if (m_ClientConnections[player].ClientId == packet->systemAddress) { @@ -1102,16 +1044,12 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void NetworkServer::SendSceneEndMsg(short player) { MsgSceneEnd msg = {}; msg.Id = ID_SRV_SCENE_END; m_Server->Send((const char*)&msg, sizeof(MsgSceneSetup), HIGH_PRIORITY, RELIABLE_ORDERED, 0, m_ClientConnections[player].ClientId, false); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void NetworkServer::CreateBackBuffer(short player, int w, int h) { m_BackBuffer8[player] = create_bitmap_ex(8, w, h); m_BackBufferGUI8[player] = create_bitmap_ex(8, w, h); @@ -1128,8 +1066,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void NetworkServer::ClearBackBuffer(int player, int w, int h) { clear_to_color(m_BackBuffer8[player], ColorKeys::g_MaskColor); clear_to_color(m_BackBufferGUI8[player], ColorKeys::g_MaskColor); @@ -1143,8 +1079,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void NetworkServer::DestroyBackBuffer(short player) { if (m_BackBuffer8) { destroy_bitmap(m_BackBuffer8[player]); @@ -1165,8 +1099,6 @@ namespace RTE { m_PixelLineBuffersGUIPrev[player] = nullptr; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void NetworkServer::SendFrameSetupMsg(short player) { MsgFrameSetup msgFrameSetup; msgFrameSetup.Id = ID_SRV_FRAME_SETUP; @@ -1199,8 +1131,6 @@ namespace RTE { m_SendSceneData[player] = false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void NetworkServer::SendPostEffectData(short player) { std::list effects; g_PostProcessMan.GetNetworkPostEffectsList(player, effects); @@ -1255,8 +1185,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int NetworkServer::SendFrame(short player) { long long currentTicks = g_TimerMan.GetRealTickCount(); double fps = static_cast(m_EncodingFps); @@ -1651,8 +1579,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void NetworkServer::UpdateStats(short player) { long long currentTicks = g_TimerMan.GetRealTickCount(); @@ -1690,8 +1616,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void NetworkServer::DrawStatisticsData() { int midX = g_WindowMan.GetResX() / 2; @@ -1841,8 +1765,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - RakNet::SystemAddress NetworkServer::ConnectBlocking(RakNet::RakPeerInterface* rakPeer, const char* address, unsigned short port) { if (rakPeer->Connect(address, port, 0, 0) != RakNet::CONNECTION_ATTEMPT_STARTED) { return RakNet::UNASSIGNED_SYSTEM_ADDRESS; @@ -1863,8 +1785,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void NetworkServer::Update(bool processInput) { HandleNetworkPackets(); @@ -1967,8 +1887,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void NetworkServer::HandleNetworkPackets() { for (RakNet::Packet* packet = m_Server->Receive(); packet; m_Server->DeallocatePacket(packet), packet = m_Server->Receive()) { m_LastPackedReceived->Reset(); diff --git a/Source/Managers/NetworkServer.h b/Source/Managers/NetworkServer.h index 8a14d3111f..abff481a44 100644 --- a/Source/Managers/NetworkServer.h +++ b/Source/Managers/NetworkServer.h @@ -21,25 +21,19 @@ namespace RTE { class Timer; - /// /// The centralized singleton manager of the network multiplayer server. - /// class NetworkServer : public Singleton { friend class SettingsMan; public: - /// /// - /// enum NetworkServerStats { STAT_CURRENT = 0, STAT_SHOWN, MAX_STAT_RECORDS = 5 }; - /// /// - /// enum ThreadExitReasons { NORMAL = 0, THREAD_FINISH, @@ -49,9 +43,7 @@ namespace RTE { LOCKED }; - /// /// Struct for registering terrain change events for network transmission. - /// struct NetworkTerrainChange { int x; int y; @@ -62,140 +54,98 @@ namespace RTE { }; #pragma region Creation - /// /// Constructor method used to instantiate a NetworkServer object in system memory. This will call Create() so it shouldn't be called after. - /// NetworkServer() { Clear(); Initialize(); } - /// /// Makes the NetworkServer object ready for use. - /// - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Initialize(); #pragma endregion #pragma region Destruction - /// /// Destructor method used to clean up a NetworkServer object before deletion from system memory. - /// ~NetworkServer() { Destroy(); } - /// /// Destroys and resets (through Clear()) the NetworkServer object. - /// void Destroy(); #pragma endregion #pragma region Getters and Setters - /// /// Gets whether server mode is enabled or not. - /// - /// Whether server mode is enabled or not. + /// @return Whether server mode is enabled or not. bool IsServerModeEnabled() const { return m_IsInServerMode; } - /// /// Enables server mode. - /// void EnableServerMode() { m_IsInServerMode = true; } - /// /// - /// - /// + /// @return bool ReadyForSimulation(); - /// /// Gets the network player's name. - /// - /// The player to check for. - /// A string with the network player's name. + /// @param player The player to check for. + /// @return A string with the network player's name. std::string& GetPlayerName(short player) { return m_ClientConnections[player].PlayerName; } - /// /// Gets whether the specified player is connected to the server or not. - /// - /// The player to check for. - /// Whether the player is connected to the server or not. + /// @param player The player to check for. + /// @return Whether the player is connected to the server or not. bool IsPlayerConnected(short player) const { return m_ClientConnections[player].IsActive; } - /// /// Sets the port this server will be using. - /// - /// The new port to set. + /// @param newPort The new port to set. void SetServerPort(const std::string& newPort); - /// /// Sets whether interlacing is used to reduce bandwidth usage or not. - /// - /// Whether to use interlacing or not. + /// @param newMode Whether to use interlacing or not. void SetInterlacingMode(bool newMode) { m_UseInterlacing = newMode; } - /// /// Sets the duration this thread should be put to sleep for in milliseconds. - /// - /// The player to set for. - /// Milliseconds to sleep for. + /// @param player The player to set for. + /// @param msecs Milliseconds to sleep for. void SetMSecsToSleep(short player, int msecs) { m_MSecsToSleep[player] = msecs; }; - /// /// Gets the ping time of the specified player. - /// - /// The player to get for. - /// The ping time of the player. + /// @param player The player to get for. + /// @return The ping time of the player. unsigned short GetPing(short player) const { return m_Ping[player]; } - /// /// Gets whether server puts threads to sleep if it didn't receive anything for 10 seconds to reduce CPU load. - /// - /// Whether threads will be put to sleep when server isn't receiving any data or not. + /// @return Whether threads will be put to sleep when server isn't receiving any data or not. bool GetServerSleepWhenIdle() const { return m_SleepWhenIdle; } - /// /// Gets whether the server will try to put the thread to sleep to reduce CPU load if the sim frame took less time to complete than it should at 30 fps. - /// - /// Whether threads will be put to sleep if server completed frame faster than it normally should or not. + /// @return Whether threads will be put to sleep if server completed frame faster than it normally should or not. bool GetServerSimSleepWhenIdle() const { return m_SimSleepWhenIdle; } #pragma endregion #pragma region Concrete Methods - /// /// Start server, open ports etc. - /// void Start(); - /// /// Updates the state of this NetworkServer. Supposed to be done every frame before drawing. - /// - /// Whether to process packets of player input data or not. + /// @param processInput Whether to process packets of player input data or not. void Update(bool processInput = false); #pragma endregion #pragma region Network Scene Handling - /// /// - /// - /// + /// @param isLocked void LockScene(bool isLocked); - /// /// - /// void ResetScene(); - /// /// - /// - /// + /// @param terrainChange void RegisterTerrainChange(NetworkTerrainChange terrainChange); #pragma endregion protected: - /// /// - /// struct ClientConnection { bool IsActive; //!< RakNet::SystemAddress ClientId; //!< @@ -246,11 +196,9 @@ namespace RTE { bool m_UseDeltaCompression; //!< Whether to use delta compression methods and conserve bandwidth. int m_HighCompressionLevel; //!< Compression level. 10 is optimal, 12 is highest. - /// /// Acceleration factor, higher values consume more bandwidth but less CPU. /// The larger the acceleration value, the faster the algorithm, but also lesser the compression. It's a trade-off. It can be fine tuned, with each successive value providing roughly +~3% to speed. /// An acceleration value of "1" is the same as regular LZ4_compress_default(). Values <= 0 will be replaced by ACCELERATION_DEFAULT(currently == 1, see lz4 documentation). - /// int m_FastAccelerationFactor; bool m_UseInterlacing; //!< Use interlacing to heavily reduce bandwidth usage at the cost of visual degradation (unusable at 30 fps, but may be suitable at 60 fps). @@ -293,10 +241,8 @@ namespace RTE { std::unique_ptr m_LastPackedReceived; //!< - /// /// Transmit frames as blocks instead of lines. Provides better compression at the cost of higher CPU usage. /// Though the compression is quite high it is recommended that Width * Height are less than MTU size or about 1500 bytes or packets may be fragmented by network hardware or dropped completely. - /// bool m_TransmitAsBoxes; int m_BoxWidth; //!< Width of the transmitted CPU block. Different values may improve bandwidth usage. int m_BoxHeight; //!< Height of the transmitted CPU block. Different values may improve bandwidth usage. @@ -344,258 +290,182 @@ namespace RTE { private: #pragma region Thread Handling - /// /// - /// - /// - /// + /// @param server + /// @param player static void BackgroundSendThreadFunction(NetworkServer* server, short player); - /// /// - /// - /// - /// + /// @param player + /// @param reason void SetThreadExitReason(short player, int reason) { m_ThreadExitReason[player] = reason; }; #pragma endregion #pragma region Network Event Handling - /// /// - /// - /// - /// + /// @param packet + /// @return unsigned char GetPacketIdentifier(RakNet::Packet* packet) const; - /// /// - /// - /// + /// @param packet void ReceiveNewIncomingConnection(RakNet::Packet* packet); - /// /// - /// - /// + /// @param player void SendAcceptedMsg(short player); - /// /// - /// - /// + /// @param packet void ReceiveDisconnection(RakNet::Packet* packet); - /// /// - /// - /// + /// @param packet void ReceiveRegisterMsg(RakNet::Packet* packet); - /// /// - /// - /// + /// @param addr void SendNATServerRegistrationMsg(RakNet::SystemAddress address); - /// /// - /// - /// + /// @param packet void ReceiveInputMsg(RakNet::Packet* packet); - /// /// - /// - /// - /// + /// @param player + /// @param msg void ProcessInputMsg(short player, MsgInput msg); - /// /// - /// - /// + /// @param player void ClearInputMessages(short player); - /// /// - /// - /// + /// @param player void SendSoundData(short player); - /// /// - /// - /// + /// @param player void SendMusicData(short player); #pragma endregion #pragma region Network Scene Handling - /// /// - /// - /// - /// + /// @param player + /// @return bool IsSceneAvailable(short player) const { return m_SceneAvailable[player]; } - /// /// - /// - /// - /// + /// @param player + /// @return bool NeedToSendSceneSetupData(short player) const { return m_SendSceneSetupData[player]; } - /// /// - /// - /// + /// @param player void SendSceneSetupData(short player); - /// /// - /// - /// + /// @param packet void ReceiveSceneSetupDataAccepted(RakNet::Packet* packet); - /// /// - /// - /// - /// + /// @param player + /// @return bool NeedToSendSceneData(short player) const { return m_SendSceneData[player]; } - /// /// - /// - /// + /// @param player void SendSceneData(short player); - /// /// - /// - /// + /// @param player void ClearTerrainChangeQueue(short player); - /// /// - /// - /// - /// + /// @param player + /// @return bool NeedToProcessTerrainChanges(short player); - /// /// - /// - /// + /// @param player void ProcessTerrainChanges(short player); - /// /// - /// - /// - /// + /// @param player + /// @param terrainChange void SendTerrainChangeMsg(short player, NetworkTerrainChange terrainChange); - /// /// - /// - /// + /// @param packet void ReceiveSceneAcceptedMsg(RakNet::Packet* packet); - /// /// - /// - /// + /// @param player void SendSceneEndMsg(short player); #pragma endregion #pragma region Network Frame Handling and Drawing - /// /// - /// - /// - /// - /// + /// @param player + /// @param w + /// @param h void CreateBackBuffer(short player, int w, int h); - /// /// - /// - /// - /// - /// + /// @param player + /// @param w + /// @param h void ClearBackBuffer(int player, int w, int h); - /// /// - /// - /// + /// @param player void DestroyBackBuffer(short player); - /// /// - /// - /// + /// @param player void SendFrameSetupMsg(short player); - /// /// - /// - /// - /// + /// @param player + /// @return bool SendFrameData(short player) const { return m_SendFrameData[player]; } - /// /// - /// - /// + /// @param player void SendPostEffectData(short player); - /// /// - /// - /// - /// + /// @param player + /// @return int SendFrame(short player); #pragma endregion #pragma region Network Stats Handling - /// /// - /// - /// + /// @param player void UpdateStats(short player); - /// /// - /// void DrawStatisticsData(); #pragma endregion #pragma region Update Breakdown - /// /// - /// void HandleNetworkPackets(); #pragma endregion - /// /// Gets the Globally Unique Identifier of the server. - /// - /// The GUID of the server. + /// @return The GUID of the server. RakNet::RakNetGUID GetServerGUID() const { return m_Server->GetGuidFromSystemAddress(RakNet::UNASSIGNED_SYSTEM_ADDRESS); } - /// /// - /// - /// - /// - /// - /// + /// @param rakPeer + /// @param address + /// @param port + /// @return RakNet::SystemAddress ConnectBlocking(RakNet::RakPeerInterface* rakPeer, const char* address, unsigned short port); - /// /// Clears all the member variables of this NetworkServer, effectively resetting the members of this abstraction level only. - /// void Clear(); // Disallow the use of some implicit methods. diff --git a/Source/Managers/PerformanceMan.cpp b/Source/Managers/PerformanceMan.cpp index a0e20ea452..50d28a95e0 100644 --- a/Source/Managers/PerformanceMan.cpp +++ b/Source/Managers/PerformanceMan.cpp @@ -13,8 +13,6 @@ namespace RTE { thread_local std::array s_PerfMeasureStart; //!< Current measurement start time in microseconds. thread_local std::array s_PerfMeasureStop; //!< Current measurement stop time in microseconds. - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PerformanceMan::Clear() { m_ShowPerfStats = false; m_AdvancedPerfStats = true; @@ -31,8 +29,6 @@ namespace RTE { m_CurrentPing = 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PerformanceMan::Initialize() { m_SimUpdateTimer = std::make_unique(); @@ -44,21 +40,15 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PerformanceMan::StartPerformanceMeasurement(PerformanceCounters counter) { s_PerfMeasureStart[counter] = g_TimerMan.GetAbsoluteTime(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PerformanceMan::StopPerformanceMeasurement(PerformanceCounters counter) { s_PerfMeasureStop[counter] = g_TimerMan.GetAbsoluteTime(); AddPerformanceSample(counter, s_PerfMeasureStop[counter] - s_PerfMeasureStart[counter]); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PerformanceMan::NewPerformanceSample() { m_Sample++; if (m_Sample >= c_MaxSamples) { @@ -71,8 +61,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PerformanceMan::CalculateSamplePercentages() { for (int counter = 0; counter < PerformanceCounters::PerfCounterCount; ++counter) { int samplePercentage = static_cast(static_cast(m_PerfData[counter][m_Sample]) / static_cast(m_PerfData[counter][PerformanceCounters::SimTotal]) * 100); @@ -80,8 +68,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - uint64_t PerformanceMan::GetPerformanceCounterAverage(PerformanceCounters counter) const { uint64_t totalPerformanceMeasurement = 0; int sample = m_Sample; @@ -95,8 +81,6 @@ namespace RTE { return totalPerformanceMeasurement / c_Average; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PerformanceMan::CalculateTimeAverage(std::deque& timeMeasurements, float& avgResult, float newTimeMeasurement) const { timeMeasurements.emplace_back(newTimeMeasurement); while (timeMeasurements.size() > c_MSPAverageSampleSize) { @@ -109,16 +93,12 @@ namespace RTE { avgResult /= static_cast(timeMeasurements.size()); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PerformanceMan::UpdateMSPF(long long measuredUpdateTime, long long measuredDrawTime) { CalculateTimeAverage(m_MSPUs, m_MSPUAverage, static_cast(measuredUpdateTime / 1000)); CalculateTimeAverage(m_MSPDs, m_MSPDAverage, static_cast(measuredDrawTime / 1000)); CalculateTimeAverage(m_MSPFs, m_MSPFAverage, static_cast((measuredUpdateTime + measuredDrawTime) / 1000)); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PerformanceMan::Draw(BITMAP* bitmapToDrawTo) { if (m_ShowPerfStats) { AllegroBitmap drawBitmap(bitmapToDrawTo); @@ -176,8 +156,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PerformanceMan::DrawPeformanceGraphs(AllegroBitmap& bitmapToDrawTo) { CalculateSamplePercentages(); @@ -228,15 +206,11 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PerformanceMan::DrawCurrentPing() const { AllegroBitmap allegroBitmap(g_FrameMan.GetBackBuffer8()); g_FrameMan.GetLargeFont()->DrawAligned(&allegroBitmap, g_FrameMan.GetBackBuffer8()->w - 25, g_FrameMan.GetBackBuffer8()->h - 14, "PING: " + std::to_string(m_CurrentPing), GUIFont::Right); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PerformanceMan::UpdateSortedScriptTimings(const std::unordered_map& scriptTimings) { std::vector> sortedScriptTimings; for (auto it = scriptTimings.begin(); it != scriptTimings.end(); it++) { diff --git a/Source/Managers/PerformanceMan.h b/Source/Managers/PerformanceMan.h index 2fd695c193..0b1c1bb609 100644 --- a/Source/Managers/PerformanceMan.h +++ b/Source/Managers/PerformanceMan.h @@ -12,16 +12,12 @@ namespace RTE { class AllegroBitmap; - /// /// Singleton manager responsible for all performance stats counting and drawing. - /// class PerformanceMan : public Singleton { friend class SettingsMan; public: - /// /// Enumeration of all available performance counters. - /// enum PerformanceCounters { SimTotal = 0, ActorsAI, @@ -34,105 +30,73 @@ namespace RTE { PerfCounterCount }; - /// /// Used to store Lua script execution timing information. - /// struct ScriptTiming { long long m_Time; int m_CallCount; }; #pragma region Creation - /// /// Constructor method used to instantiate a PerformanceMan object in system memory. Create() should be called before using the object. - /// PerformanceMan() { Clear(); } - /// /// Makes the PerformanceMan object ready for use. - /// void Initialize(); #pragma endregion #pragma region Destruction - /// /// Destructor method used to clean up a PerformanceMan object before deletion from system memory. - /// ~PerformanceMan() { Destroy(); } - /// /// Destroys and resets (through Clear()) the PerformanceMan object. - /// void Destroy() { Clear(); } #pragma endregion #pragma region Getters and Setters - /// /// Tells whether to display the performance stats on-screen or not. - /// - /// Whether to show the performance stats or not. + /// @return Whether to show the performance stats or not. bool IsShowingPerformanceStats() const { return m_ShowPerfStats; } - /// /// Sets whether to display the performance stats on-screen or not. - /// - /// Whether to show the performance stats or not. + /// @param showStats Whether to show the performance stats or not. void ShowPerformanceStats(bool showStats = true) { m_ShowPerfStats = showStats; } - /// /// Tells whether to display the performance graphs on-screen or not. - /// - /// Whether to show the performance graphs or not. + /// @return Whether to show the performance graphs or not. bool AdvancedPerformanceStatsEnabled() const { return m_AdvancedPerfStats; } - /// /// Sets whether to display the performance graphs on-screen or not. - /// - /// Whether to show the performance graphs or not. + /// @param showGraphs Whether to show the performance graphs or not. void ShowAdvancedPerformanceStats(bool showGraphs = true) { m_AdvancedPerfStats = showGraphs; } - /// /// Gets the average of the MSPU reading buffer, calculated each update. - /// - /// The average value of the MSPU reading buffer. + /// @return The average value of the MSPU reading buffer. float GetMSPSUAverage() const { return m_MSPSUAverage; } - /// /// Gets the average of the MSPF reading buffer, calculated each frame. - /// - /// The average value of the MSPF reading buffer. + /// @return The average value of the MSPF reading buffer. float GetMSPFAverage() const { return m_MSPFAverage; } #pragma endregion #pragma region Performance Counter Handling - /// /// Moves sample counter to next sample and clears it's values. - /// void NewPerformanceSample(); - /// /// Saves current absolute time in microseconds as a start of performance measurement. - /// - /// Counter to start measurement for. + /// @param counter Counter to start measurement for. void StartPerformanceMeasurement(PerformanceCounters counter); - /// /// Saves current absolute time in microseconds as an end of performance measurement. The difference is added to the value of current performance sample. - /// - /// Counter to stop and updated measurement for. + /// @param counter Counter to stop and updated measurement for. void StopPerformanceMeasurement(PerformanceCounters counter); - /// /// Sets the current ping value to display. - /// - /// Ping value to display. + /// @param ping Ping value to display. void SetCurrentPing(int ping) { m_CurrentPing = ping; } #pragma endregion #pragma region Concrete Methods - /// /// Clears current performance timings. - /// void ResetPerformanceTimings() { m_MSPSUs.clear(); m_MSPFs.clear(); @@ -140,41 +104,29 @@ namespace RTE { m_MSPDs.clear(); } - /// /// Resets the sim update timer. - /// void ResetSimUpdateTimer() const { m_SimUpdateTimer->Reset(); } - /// /// Updates the frame time measurements and recalculates the averages. Supposed to be done every game loop iteration. - /// - /// The total sim update time measured in the game loop iteration. - /// The total draw time measured in the game loop iteration. + /// @param measuredUpdateTime The total sim update time measured in the game loop iteration. + /// @param measuredDrawTime The total draw time measured in the game loop iteration. void UpdateMSPF(long long measuredUpdateTime, long long measuredDrawTime); - /// /// Updates the individual sim update time measurements and recalculates the average. Supposed to be done every sim update. - /// void UpdateMSPSU() { CalculateTimeAverage(m_MSPSUs, m_MSPSUAverage, static_cast(m_SimUpdateTimer->GetElapsedRealTimeMS())); m_SimUpdateTimer->Reset(); } - /// /// Draws the performance stats to the screen. - /// - /// The BITMAP to draw the performance stats to. + /// @param bitmapToDrawTo The BITMAP to draw the performance stats to. void Draw(BITMAP* bitmapToDrawTo); - /// /// Draws the current ping value to the screen. - /// void DrawCurrentPing() const; #pragma endregion - /// /// Updates m_SortedScriptTimings so PerformanceMan::Draw() can list how long scripts took. - /// void UpdateSortedScriptTimings(const std::unordered_map& scriptTimings); protected: @@ -216,42 +168,30 @@ namespace RTE { private: #pragma region Performance Counter Handling - /// /// Adds provided value to current sample of specified performance counter. - /// - /// Counter to update. - /// Value to add to this counter. + /// @param counter Counter to update. + /// @param value Value to add to this counter. void AddPerformanceSample(PerformanceCounters counter, uint64_t value) { m_PerfData[counter].at(m_Sample) += value; } - /// /// Calculates current sample's percentages from SIM_TOTAL for all performance counters and stores them to m_PerfPercenrages. - /// void CalculateSamplePercentages(); - /// /// Returns an average value of c_Average last samples for specified performance counter. - /// - /// Counter to get average value from. - /// An average value for specified counter. + /// @param counter Counter to get average value from. + /// @return An average value for specified counter. uint64_t GetPerformanceCounterAverage(PerformanceCounters counter) const; #pragma endregion - /// /// Stores the new time measurement into the specified deque, recalculates the average and stores it in the specified variable. - /// - /// The deque of time measurements to store the new measurement in and to recalculate the average with. - /// The variable the recalculated average should be stored in. - /// The new time measurement to store. + /// @param timeMeasurements The deque of time measurements to store the new measurement in and to recalculate the average with. + /// @param avgResult The variable the recalculated average should be stored in. + /// @param newTimeMeasurement The new time measurement to store. void CalculateTimeAverage(std::deque& timeMeasurements, float& avgResult, float newTimeMeasurement) const; - /// /// Draws the performance graphs to the screen. This will be called by Draw() if advanced performance stats are enabled. - /// void DrawPeformanceGraphs(AllegroBitmap& bitmapToDrawTo); - /// /// Clears all the member variables of this PerformanceMan, effectively resetting the members of this abstraction level only. - /// void Clear(); // Disallow the use of some implicit methods. diff --git a/Source/Managers/PostProcessMan.cpp b/Source/Managers/PostProcessMan.cpp index cb6eb649c5..c04a8006bc 100644 --- a/Source/Managers/PostProcessMan.cpp +++ b/Source/Managers/PostProcessMan.cpp @@ -16,8 +16,6 @@ namespace RTE { - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PostProcessMan::Clear() { m_PostScreenEffects.clear(); m_PostSceneEffects.clear(); @@ -41,8 +39,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int PostProcessMan::Initialize() { InitializeGLPointers(); CreateGLBackBuffers(); @@ -72,8 +68,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PostProcessMan::InitializeGLPointers() { glGenTextures(1, &m_BackBuffer8); glGenTextures(1, &m_BackBuffer32); @@ -94,8 +88,6 @@ namespace RTE { glBindVertexArray(0); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PostProcessMan::DestroyGLPointers() { glDeleteTextures(1, &m_BackBuffer8); glDeleteTextures(1, &m_BackBuffer32); @@ -110,8 +102,6 @@ namespace RTE { glDeleteBuffers(1, &m_VertexBuffer); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PostProcessMan::CreateGLBackBuffers() { glBindTexture(GL_TEXTURE_2D, m_BackBuffer8); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, g_FrameMan.GetBackBuffer8()->w, g_FrameMan.GetBackBuffer8()->h, 0, GL_RED, GL_UNSIGNED_BYTE, 0); @@ -131,8 +121,6 @@ namespace RTE { m_ProjectionMatrix = glm::ortho(0.0F, static_cast(g_FrameMan.GetBackBuffer8()->w), 0.0F, static_cast(g_FrameMan.GetBackBuffer8()->h), -1.0F, 1.0F); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PostProcessMan::UpdatePalette() { glBindTexture(GL_TEXTURE_1D, m_Palette8Texture); std::array palette; @@ -148,8 +136,6 @@ namespace RTE { glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PostProcessMan::LazyInitBitmap(BITMAP* bitmap) { m_BitmapTextures.emplace_back(new GLBitmapInfo); glGenTextures(1, &m_BitmapTextures.back()->m_Texture); @@ -163,8 +149,6 @@ namespace RTE { glGenerateMipmap(GL_TEXTURE_2D); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PostProcessMan::Destroy() { for (std::pair tempBitmapEntry: m_TempEffectBitmaps) { destroy_bitmap(tempBitmapEntry.second); @@ -175,8 +159,6 @@ namespace RTE { Clear(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PostProcessMan::AdjustEffectsPosToPlayerScreen(int playerScreen, BITMAP* targetBitmap, const Vector& targetBitmapOffset, std::list& screenRelativeEffectsList, std::list& screenRelativeGlowBoxesList) { int screenOcclusionOffsetX = g_CameraMan.GetScreenOcclusion(playerScreen).GetFloorIntX(); int screenOcclusionOffsetY = g_CameraMan.GetScreenOcclusion(playerScreen).GetFloorIntY(); @@ -203,8 +185,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PostProcessMan::RegisterPostEffect(const Vector& effectPos, BITMAP* effect, size_t hash, int strength, float angle) { // These effects get applied when there's a drawn frame that followed one or more sim updates. // They are not only registered on drawn sim updates; flashes and stuff could be missed otherwise if they occur on undrawn sim updates. @@ -214,8 +194,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool PostProcessMan::GetPostScreenEffectsWrapped(const Vector& boxPos, int boxWidth, int boxHeight, std::list& effectsList, int team) { bool found = false; @@ -248,8 +226,6 @@ namespace RTE { return found; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - BITMAP* PostProcessMan::GetTempEffectBitmap(BITMAP* bitmap) const { // Get the largest dimension of the bitmap and convert it to a multiple of 16, i.e. 16, 32, etc int bitmapSizeNeeded = static_cast(std::ceil(static_cast(std::max(bitmap->w, bitmap->h)) / 16.0F)) * 16; @@ -263,8 +239,6 @@ namespace RTE { return correspondingBitmapSizeEntry->second; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PostProcessMan::RegisterGlowDotEffect(const Vector& effectPos, DotGlowColor color, int strength) { // These effects only apply only once per drawn sim update, and only on the first frame drawn after one or more sim updates if (color != NoDot && g_TimerMan.DrawnSimUpdate() && g_TimerMan.SimUpdatesSinceDrawn() >= 0) { @@ -272,8 +246,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool PostProcessMan::GetGlowAreasWrapped(const Vector& boxPos, int boxWidth, int boxHeight, std::list& areaList) const { bool foundAny = false; Vector intRectPosRelativeToBox; @@ -302,8 +274,6 @@ namespace RTE { return foundAny; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PostProcessMan::GetNetworkPostEffectsList(int whichScreen, std::list& outputList) { ScreenRelativeEffectsMutex.at(whichScreen).lock(); outputList.clear(); @@ -313,8 +283,6 @@ namespace RTE { ScreenRelativeEffectsMutex.at(whichScreen).unlock(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PostProcessMan::SetNetworkPostEffectsList(int whichScreen, std::list& inputList) { ScreenRelativeEffectsMutex.at(whichScreen).lock(); m_ScreenRelativeEffects.at(whichScreen).clear(); @@ -324,8 +292,6 @@ namespace RTE { ScreenRelativeEffectsMutex.at(whichScreen).unlock(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool PostProcessMan::GetPostScreenEffects(Vector boxPos, int boxWidth, int boxHeight, std::list& effectsList, int team) { bool found = false; bool unseen = false; @@ -347,8 +313,6 @@ namespace RTE { return found; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool PostProcessMan::GetPostScreenEffects(int left, int top, int right, int bottom, std::list& effectsList, int team) { bool found = false; bool unseen = false; @@ -368,8 +332,6 @@ namespace RTE { return found; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - BITMAP* PostProcessMan::GetDotGlowEffect(DotGlowColor whichColor) const { switch (whichColor) { case NoDot: @@ -386,8 +348,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - size_t PostProcessMan::GetDotGlowEffectHash(DotGlowColor whichColor) const { switch (whichColor) { case NoDot: @@ -404,8 +364,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PostProcessMan::PostProcess() { UpdatePalette(); @@ -449,8 +407,6 @@ namespace RTE { m_PostScreenEffects.clear(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PostProcessMan::DrawDotGlowEffects() { int startX = 0; int startY = 0; @@ -513,8 +469,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PostProcessMan::DrawPostScreenEffects() { BITMAP* effectBitmap = nullptr; float effectPosX = 0; diff --git a/Source/Managers/PostProcessMan.h b/Source/Managers/PostProcessMan.h index a2dc7a87df..b9c6ce3d69 100644 --- a/Source/Managers/PostProcessMan.h +++ b/Source/Managers/PostProcessMan.h @@ -11,16 +11,12 @@ #define g_PostProcessMan PostProcessMan::Instance() namespace RTE { - /// /// Struct for storing GL information in the BITMAP->extra field. - /// struct GLBitmapInfo { GLuint m_Texture; }; - /// /// Structure for storing a post-process screen effect to be applied at the last stage of 32bpp rendering. - /// struct PostEffect { BITMAP* m_Bitmap = nullptr; //!< The bitmap to blend, not owned. size_t m_BitmapHash = 0; //!< Hash used to transmit glow events over the network. @@ -28,59 +24,41 @@ namespace RTE { int m_Strength = 128; //!< Scalar float for how hard to blend it in, 0 - 255. Vector m_Pos; //!< Post effect position. Can be relative to the scene, or to the screen, depending on context. - /// /// Constructor method used to instantiate a PostEffect object in system memory. - /// PostEffect(const Vector& pos, BITMAP* bitmap, size_t bitmapHash, int strength, float angle) : m_Bitmap(bitmap), m_BitmapHash(bitmapHash), m_Angle(angle), m_Strength(strength), m_Pos(pos) {} }; - /// /// Singleton manager responsible for all 32bpp post-process effect drawing. - /// class PostProcessMan : public Singleton { public: #pragma region Creation - /// /// Constructor method used to instantiate a PostProcessMan object in system memory. Create() should be called before using the object. - /// PostProcessMan() { Clear(); } - /// /// Makes the PostProcessMan object ready for use. - /// - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Initialize(); - /// /// (Re-)Initializes the GL backbuffers to the current render resolution for post-processing. - /// void CreateGLBackBuffers(); #pragma endregion #pragma region Destruction - /// /// Destructor method used to clean up a PostProcessMan object before deletion from system memory. - /// ~PostProcessMan() { Destroy(); } - /// /// Destroys and resets (through Clear()) the PostProcessMan object. - /// void Destroy(); - /// /// Clears the list of registered post-processing screen effects and glow boxes. - /// void ClearScreenPostEffects() { m_PostScreenEffects.clear(); m_PostScreenGlowBoxes.clear(); } - /// /// Clears the list of registered post-processing scene effects and glow areas. - /// void ClearScenePostEffects() { m_PostSceneEffects.clear(); m_GlowAreas.clear(); @@ -88,114 +66,90 @@ namespace RTE { #pragma endregion #pragma region Concrete Methods - /// /// Takes the current state of the 8bpp back-buffer, copies it, and adds post-processing effects on top like glows etc. - /// void PostProcess(); - /// /// Adjusts the offsets of all effects relative to the specified player screen and adds them to the total screen effects list so they can be drawn in PostProcess(). - /// - /// Player screen to adjust effect offsets for. - /// Bitmap representing the player screen. - /// The position of the specified player's draw screen on the backbuffer. - /// List of the specified player's accumulated post effects for this frame. - /// List of the specified player's accumulated glow boxes for this frame. + /// @param playerScreen Player screen to adjust effect offsets for. + /// @param targetBitmap Bitmap representing the player screen. + /// @param targetBitmapOffset The position of the specified player's draw screen on the backbuffer. + /// @param screenRelativeEffectsList List of the specified player's accumulated post effects for this frame. + /// @param screenRelativeGlowBoxesList List of the specified player's accumulated glow boxes for this frame. void AdjustEffectsPosToPlayerScreen(int playerScreen, BITMAP* targetBitmap, const Vector& targetBitmapOffset, std::list& screenRelativeEffectsList, std::list& screenRelativeGlowBoxesList); #pragma endregion #pragma region Post Effect Handling - /// /// Registers a post effect to be added at the very last stage of 32bpp rendering by the FrameMan. - /// - /// The absolute scene coordinates of the center of the effect. - /// A 32bpp BITMAP screen should be drawn centered on the above scene location in the final frame buffer. Ownership is NOT transferred! - /// Hash value of the effect for transmitting over the network. - /// The intensity level this effect should have when blended in post. 0 - 255. - /// The angle this effect should be rotated at in radians. + /// @param effectPos The absolute scene coordinates of the center of the effect. + /// @param effect A 32bpp BITMAP screen should be drawn centered on the above scene location in the final frame buffer. Ownership is NOT transferred! + /// @param hash Hash value of the effect for transmitting over the network. + /// @param strength The intensity level this effect should have when blended in post. 0 - 255. + /// @param angle The angle this effect should be rotated at in radians. void RegisterPostEffect(const Vector& effectPos, BITMAP* effect, size_t hash, int strength = 255, float angle = 0); - /// /// Gets all screen effects that are located within a box in the scene. /// Their coordinates will be returned relative to the upper left corner of the box passed in here. Wrapping of the box will be taken care of. - /// - /// The top left coordinates of the box to get post effects for. - /// The width of the box. - /// The height of the box. - /// The list to add the screen effects that fall within the box to. The coordinates of the effects returned here will be relative to the boxPos passed in above. - /// The team whose unseen layer should obscure the screen effects here. - /// Whether any active post effects were found in that box. + /// @param boxPos The top left coordinates of the box to get post effects for. + /// @param boxWidth The width of the box. + /// @param boxHeight The height of the box. + /// @param effectsList The list to add the screen effects that fall within the box to. The coordinates of the effects returned here will be relative to the boxPos passed in above. + /// @param team The team whose unseen layer should obscure the screen effects here. + /// @return Whether any active post effects were found in that box. bool GetPostScreenEffectsWrapped(const Vector& boxPos, int boxWidth, int boxHeight, std::list& effectsList, int team = -1); - /// /// Gets a temporary bitmap of specified size to rotate post effects in. - /// - /// Size of bitmap to get. - /// Pointer to the temporary bitmap. + /// @param bitmapSize Size of bitmap to get. + /// @return Pointer to the temporary bitmap. BITMAP* GetTempEffectBitmap(BITMAP* bitmap) const; #pragma endregion #pragma region Post Pixel Glow Handling - /// /// Registers a specific IntRect to be post-processed and have special pixel colors lit up by glow effects in it. - /// - /// The IntRect to have special color pixels glow in, in scene coordinates. + /// @param glowArea The IntRect to have special color pixels glow in, in scene coordinates. void RegisterGlowArea(const IntRect& glowArea) { if (g_TimerMan.DrawnSimUpdate() && g_TimerMan.SimUpdatesSinceDrawn() >= 0) { m_GlowAreas.push_back(glowArea); } } - /// /// Creates an IntRect and registers it to be post-processed and have special pixel colors lit up by glow effects in it. - /// - /// The center of the IntRect. - /// The radius around it to add as an area. + /// @param center The center of the IntRect. + /// @param radius The radius around it to add as an area. void RegisterGlowArea(const Vector& center, float radius) { RegisterGlowArea(IntRect(static_cast(center.m_X - radius), static_cast(center.m_Y - radius), static_cast(center.m_X + radius), static_cast(center.m_Y + radius))); } - /// /// Registers a specific glow dot effect to be added at the very last stage of 32bpp rendering by the FrameMan. - /// - /// The absolute scene coordinates of the center of the effect. - /// Which glow dot color to register, see the DotGlowColor enumerator. - /// The intensity level this effect should have when blended in post. 0 - 255. + /// @param effectPos The absolute scene coordinates of the center of the effect. + /// @param color Which glow dot color to register, see the DotGlowColor enumerator. + /// @param strength The intensity level this effect should have when blended in post. 0 - 255. void RegisterGlowDotEffect(const Vector& effectPos, DotGlowColor color, int strength = 255); - /// /// Gets all glow areas that affect anything within a box in the scene. /// Their coordinates will be returned relative to the upper left corner of the box passed in here. Wrapping of the box will be taken care of. - /// - /// The top left coordinates of the box to get post effects for. - /// The width of the box. - /// The height of the box. - /// The list to add the glow Boxes that intersect to. The coordinates of the Boxes returned here will be relative to the boxPos passed in above. - /// Whether any active post effects were found in that box. + /// @param boxPos The top left coordinates of the box to get post effects for. + /// @param boxWidth The width of the box. + /// @param boxHeight The height of the box. + /// @param areaList The list to add the glow Boxes that intersect to. The coordinates of the Boxes returned here will be relative to the boxPos passed in above. + /// @return Whether any active post effects were found in that box. bool GetGlowAreasWrapped(const Vector& boxPos, int boxWidth, int boxHeight, std::list& areaList) const; #pragma endregion #pragma region Network Post Effect Handling - /// /// Copies the specified player's screen relative post effects list of this PostProcessMan to the referenced list. Used for sending post effect data over the network. - /// - /// Which player screen to get list for. - /// Reference to the list of post effects to copy into. + /// @param whichScreen Which player screen to get list for. + /// @param outputList Reference to the list of post effects to copy into. void GetNetworkPostEffectsList(int whichScreen, std::list& outputList); - /// /// Copies the player's screen relative post effects from the referenced list to the list of this PostProcessMan. Used for receiving post effect data over the network. - /// - /// Which player screen to set list for. - /// Reference to the list of post effects to copy from. + /// @param whichScreen Which player screen to set list for. + /// @param inputList Reference to the list of post effects to copy from. void SetNetworkPostEffectsList(int whichScreen, std::list& inputList); #pragma endregion - /// /// Gets the backbuffer texture for indexed drawings. - /// - /// The opengl backbuffer texture for indexed drawings. + /// @return The opengl backbuffer texture for indexed drawings. GLuint GetPostProcessColorBuffer() { return m_BackBuffer32; } protected: @@ -233,82 +187,60 @@ namespace RTE { std::unique_ptr m_PostProcessShader; //!< Shader for drawing bitmap post effects. #pragma region Post Effect Handling - /// /// Gets all screen effects that are located within a box in the scene. Their coordinates will be returned relative to the upper left corner of the box passed in here. - /// - /// The top left coordinates of the box to get post effects for. - /// The width of the box. - /// The height of the box. - /// The list to add the screen effects that fall within the box to. The coordinates of the effects returned here will be relative to the boxPos passed in above. - /// The team whose unseen area should block the glows. - /// Whether any active post effects were found in that box. + /// @param boxPos The top left coordinates of the box to get post effects for. + /// @param boxWidth The width of the box. + /// @param boxHeight The height of the box. + /// @param effectsList The list to add the screen effects that fall within the box to. The coordinates of the effects returned here will be relative to the boxPos passed in above. + /// @param team The team whose unseen area should block the glows. + /// @return Whether any active post effects were found in that box. bool GetPostScreenEffects(Vector boxPos, int boxWidth, int boxHeight, std::list& effectsList, int team = -1); - /// /// Gets all screen effects that are located within a box in the scene. Their coordinates will be returned relative to the upper left corner of the box passed in here. - /// - /// Position of box left plane (X start). - /// Position of box top plane (Y start). - /// Position of box right plane (X end). - /// Position of box bottom plane (Y end). - /// The list to add the screen effects that fall within the box to. The coordinates of the effects returned here will be relative to the boxPos passed in above. - /// The team whose unseen area should block the glows. - /// Whether any active post effects were found in that box. + /// @param left Position of box left plane (X start). + /// @param top Position of box top plane (Y start). + /// @param right Position of box right plane (X end). + /// @param bottom Position of box bottom plane (Y end). + /// @param effectsList The list to add the screen effects that fall within the box to. The coordinates of the effects returned here will be relative to the boxPos passed in above. + /// @param team The team whose unseen area should block the glows. + /// @return Whether any active post effects were found in that box. bool GetPostScreenEffects(int left, int top, int right, int bottom, std::list& effectsList, int team = -1); #pragma endregion #pragma region Post Pixel Glow Handling - /// /// Gets a specific standard dot glow effect for making pixels glow. - /// - /// Which of the dot glow colors to get, see the DotGlowColor enumerator. - /// The requested glow dot BITMAP. + /// @param which Which of the dot glow colors to get, see the DotGlowColor enumerator. + /// @return The requested glow dot BITMAP. BITMAP* GetDotGlowEffect(DotGlowColor whichColor) const; - /// /// Gets the hash value of a specific standard dot glow effect for making pixels glow. - /// - /// Which of the dot glow colors to get, see the DotGlowColor enumerator. - /// The hash value of the requested glow dot BITMAP. + /// @param which Which of the dot glow colors to get, see the DotGlowColor enumerator. + /// @return The hash value of the requested glow dot BITMAP. size_t GetDotGlowEffectHash(DotGlowColor whichColor) const; #pragma endregion #pragma region PostProcess Breakdown - /// /// Draws all the glow dot effects on pixels registered inside glow boxes for this frame. This is called from PostProcess(). - /// void DrawDotGlowEffects(); - /// /// Draws all the glow effects registered for this frame. This is called from PostProcess(). - /// void DrawPostScreenEffects(); #pragma endregion - /// /// Clears all the member variables of this PostProcessMan, effectively resetting the members of this abstraction level only. - /// void Clear(); - /// /// Initializes all the GL pointers used by this PostProcessMan. - /// void InitializeGLPointers(); - /// /// Destroys all the GL pointers used by this PostProcessMan. - /// void DestroyGLPointers(); - /// /// Updates the palette texture with the current palette. - /// void UpdatePalette(); - /// /// Creates and upload a new GL texture. The texture pointer is stored in the BITMAP->extra field. - /// - /// The bitmap to create a texture for. + /// @param bitmap The bitmap to create a texture for. void LazyInitBitmap(BITMAP* bitmap); // Disallow the use of some implicit methods. diff --git a/Source/Managers/PresetMan.cpp b/Source/Managers/PresetMan.cpp index 0ea1bc1a71..2f4df666e9 100644 --- a/Source/Managers/PresetMan.cpp +++ b/Source/Managers/PresetMan.cpp @@ -1,28 +1,16 @@ -////////////////////////////////////////////////////////////////////////////////////////// -// File: PresetMan.cpp -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Source file for the PresetMan class. -// Project: Retro Terrain Engine -// Author(s): Daniel Tabar -// data@datarealms.com -// http://www.datarealms.com - // Suppress compiler warning about unrecognized escape sequence on line 183 #pragma warning(disable : 4129) -////////////////////////////////////////////////////////////////////////////////////////// -// Inclusions of header files - #include "PresetMan.h" #include "DataModule.h" #include "SceneObject.h" #include "Loadout.h" #include "ACraft.h" -//#include "AHuman.h" -//#include "MOPixel.h" -//#include "SLTerrain.h" -//#include "AtomGroup.h" -//#include "Atom.h" +// #include "AHuman.h" +// #include "MOPixel.h" +// #include "SLTerrain.h" +// #include "AtomGroup.h" +// #include "Atom.h" #include "ConsoleMan.h" #include "LoadingScreen.h" @@ -35,12 +23,6 @@ namespace RTE { {c_UserConquestSavesModuleName, "Conquest Saves"}, {c_UserScriptedSavesModuleName, "Scripted Activity Saves"}}}; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Clear - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears all the member variables of this PresetMan, effectively - // resetting the members of this abstraction level only. - void PresetMan::Clear() { m_pDataModules.clear(); m_DataModuleIDs.clear(); @@ -71,11 +53,6 @@ namespace RTE { } */ - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destroys and resets (through Clear()) the PresetMan entity. - void PresetMan::Destroy() { for (std::vector::iterator dmItr = m_pDataModules.begin(); dmItr != m_pDataModules.end(); ++dmItr) { delete (*dmItr); @@ -84,8 +61,6 @@ namespace RTE { Clear(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool PresetMan::LoadDataModule(const std::string& moduleName, bool official, bool userdata, const ProgressCallback& progressCallback) { if (moduleName.empty()) { return false; @@ -135,8 +110,6 @@ namespace RTE { return true; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool PresetMan::LoadAllDataModules() { auto moduleLoadTimerStart = std::chrono::steady_clock::now(); @@ -198,31 +171,16 @@ namespace RTE { return true; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetDataModule - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets a specific loaded DataModule - const DataModule* PresetMan::GetDataModule(int whichModule) { RTEAssert(whichModule >= 0 && whichModule < (int)m_pDataModules.size(), "Tried to access an out of bounds data module number!"); return m_pDataModules[whichModule]; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetDataModuleName - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets a name specific loaded DataModule - const std::string PresetMan::GetDataModuleName(int whichModule) { RTEAssert(whichModule >= 0 && whichModule < (int)m_pDataModules.size(), "Tried to access an out of bounds data module number!"); return m_pDataModules[whichModule]->GetFileName(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetModuleID - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the ID of a loaded DataModule. - int PresetMan::GetModuleID(std::string moduleName) { // Lower-case search name so we can match up against the already-lowercase names in m_DataModuleIDs std::transform(moduleName.begin(), moduleName.end(), moduleName.begin(), ::tolower); @@ -272,8 +230,6 @@ namespace RTE { return -1; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - std::string PresetMan::GetModuleNameFromPath(const std::string& dataPath) const { if (dataPath.empty()) { return ""; @@ -296,8 +252,6 @@ namespace RTE { return moduleName; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int PresetMan::GetModuleIDFromPath(const std::string& dataPath) { if (dataPath.empty()) { return -1; @@ -305,14 +259,10 @@ namespace RTE { return GetModuleID(GetModuleNameFromPath(dataPath)); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool PresetMan::IsModuleOfficial(const std::string& moduleName) const { return std::find(c_OfficialModules.begin(), c_OfficialModules.end(), moduleName) != c_OfficialModules.end(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool PresetMan::IsModuleUserdata(const std::string& moduleName) const { auto userdataModuleItr = std::find_if(c_UserdataModules.begin(), c_UserdataModules.end(), [&moduleName](const auto& userdataModulesEntry) { @@ -321,8 +271,6 @@ namespace RTE { return userdataModuleItr != c_UserdataModules.end(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - std::string PresetMan::GetFullModulePath(const std::string& modulePath) const { // Note: Mods may use mixed path separators, which aren't supported on non Windows systems. // Since Windows supports both forward and backslash separators it's safe to replace all backslashes with forward slashes. @@ -342,25 +290,12 @@ namespace RTE { return (pathTopDir == moduleTopDir) ? modulePathGeneric : moduleTopDir + modulePathGeneric; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: AddEntityPreset - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Adds an Entity instance's pointer and name associations to the - // internal list of already read in Entity:s. Ownership is NOT transferred! - // If there already is an instance defined, nothing happens. If there - // is not, a clone is made of the passed-in Entity and added to the library. - bool PresetMan::AddEntityPreset(Entity* pEntToAdd, int whichModule, bool overwriteSame, std::string readFromFile) { RTEAssert(whichModule >= 0 && whichModule < (int)m_pDataModules.size(), "Tried to access an out of bounds data module number!"); return m_pDataModules[whichModule]->AddEntityPreset(pEntToAdd, overwriteSame, readFromFile); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetEntityPreset - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets a previously read in (defined) Entity, by type and instance name. - const Entity* PresetMan::GetEntityPreset(std::string type, std::string preset, int whichModule) { RTEAssert(whichModule < (int)m_pDataModules.size(), "Tried to access an out of bounds data module number!"); @@ -397,16 +332,6 @@ namespace RTE { return pRetEntity; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetEntityPreset - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Reads an instance of an Entity that will be used as preset - // to later on be used to generate more instances of the same state. - // Will check if there was already one of the same class and instance - // name read in previously, and will return that one if found, or - // add the newly read in one to this PresetMan's list if not found to - // exist there previously. Ownership is NOT transferred! - const Entity* PresetMan::GetEntityPreset(Reader& reader) { // The reader is aware of which DataModule it is reading within int whichModule = reader.GetReadModuleID(); @@ -454,13 +379,6 @@ namespace RTE { return pReturnPreset; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ReadReflectedPreset - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Reads an preset of an Entity and tries to add it to the list of - // read-in presets. Regardless of whether there is a name collision, - // the read-in preset will be returned, ownership TRANSFERRED! - Entity* PresetMan::ReadReflectedPreset(Reader& reader) { // The reader is aware of which DataModule it's reading within int whichModule = reader.GetReadModuleID(); @@ -495,11 +413,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetAllOfType - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Adds to a list all previously read in (defined) Entitys, by type. - bool PresetMan::GetAllOfType(std::list& entityList, std::string type, int whichModule) { if (type.empty()) return false; @@ -521,12 +434,6 @@ namespace RTE { return foundAny; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetAllOfTypeInModuleSpace - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Adds to a list all previously read in (defined) Entitys which are - // of a specific type, and only exist in a specific module space. - bool PresetMan::GetAllOfTypeInModuleSpace(std::list& entityList, std::string type, int whichModuleSpace) { if (type.empty()) return false; @@ -549,8 +456,6 @@ namespace RTE { return foundAny; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool PresetMan::GetAllOfGroups(std::list& entityList, const std::vector& groups, const std::string& type, int whichModule) { RTEAssert(!groups.empty(), "Looking for empty groups in PresetMan::GetAllOfGroups!"); bool foundAny = false; @@ -566,8 +471,6 @@ namespace RTE { return foundAny; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool PresetMan::GetAllNotOfGroups(std::list& entityList, const std::vector& groups, const std::string& type, int whichModule) { if (groups.empty()) { RTEAbort("Looking for empty groups in PresetMan::GetAllNotOfGroups!"); @@ -588,12 +491,6 @@ namespace RTE { return foundAny; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetRandomOfGroup - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns a previously read in (defined) Entity which is randomly - // selected from a specific group. - Entity* PresetMan::GetRandomOfGroup(std::string group, std::string type, int whichModule) { RTEAssert(!group.empty(), "Looking for empty group!"); @@ -631,12 +528,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetRandomOfGroupFromTech - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns a previously read in (defined) Entity which is randomly - // selected from a specific group. - Entity* PresetMan::GetRandomBuyableOfGroupFromTech(std::string group, std::string type, int whichModule) { RTEAssert(!group.empty(), "Looking for empty group!"); @@ -730,13 +621,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetAllOfGroupInModuleSpace - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Adds to a list all previously read in (defined) Entitys which are - // associated with a specific group, and only exist in a specific module - // space. - bool PresetMan::GetAllOfGroupInModuleSpace(std::list& entityList, std::string group, std::string type, int whichModuleSpace) { RTEAssert(!group.empty(), "Looking for empty group!"); @@ -758,13 +642,6 @@ namespace RTE { return foundAny; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetRandomOfGroupInModuleSpace - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns a previously read in (defined) Entity which is associated with - // a specific group, randomly selected and only exist in a specific module - // space. - Entity* PresetMan::GetRandomOfGroupInModuleSpace(std::string group, std::string type, int whichModuleSpace) { RTEAssert(!group.empty(), "Looking for empty group!"); @@ -802,11 +679,6 @@ namespace RTE { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetEntityDataLocation - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the data file path of a previously read in (defined) Entity. - std::string PresetMan::GetEntityDataLocation(std::string type, std::string preset, int whichModule) { RTEAssert(whichModule < (int)m_pDataModules.size(), "Tried to access an out of bounds data module number!"); @@ -835,8 +707,6 @@ namespace RTE { return pRetPath; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PresetMan::ReloadAllScripts() const { g_LuaMan.ClearUserModuleCache(); for (const DataModule* dataModule: m_pDataModules) { @@ -846,8 +716,6 @@ namespace RTE { g_ConsoleMan.PrintString("SYSTEM: Scripts reloaded!"); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool PresetMan::ReloadEntityPreset(const std::string& presetName, const std::string& className, const std::string& moduleName, bool storeReloadedPresetDataForQuickReloading) { if (className.empty() || presetName.empty()) { g_ConsoleMan.PrintString("ERROR: Trying to reload Entity preset without specifying preset name or type!"); @@ -895,8 +763,6 @@ namespace RTE { return true; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool PresetMan::QuickReloadEntityPreset() { for (const std::string& entityPresetInfoEntry: m_LastReloadedEntityPresetInfo) { if (entityPresetInfoEntry.empty()) { @@ -907,25 +773,12 @@ namespace RTE { return ReloadEntityPreset(m_LastReloadedEntityPresetInfo[0], m_LastReloadedEntityPresetInfo[1], m_LastReloadedEntityPresetInfo[2]); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: AddMaterialMapping - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Adds a Material mapping local to a DataModule. This is used for when - // multiple DataModule:s are loading conflicting Material:s, and need to - // resolve the conflicts by mapping their materials to ID's different than - // those specified in the data files. - bool PresetMan::AddMaterialMapping(int fromID, int toID, int whichModule) { RTEAssert(whichModule >= m_OfficialModuleCount && whichModule < m_pDataModules.size(), "Tried to make a material mapping in an offical or out-of-bounds DataModule!"); return m_pDataModules[whichModule]->AddMaterialMapping(fromID, toID); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: RegisterGroup - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Registers the existence of an Entity group, and in which module. - void PresetMan::RegisterGroup(std::string newGroup, int whichModule) { RTEAssert(whichModule >= 0 && whichModule < (int)m_pDataModules.size(), "Tried to access an out of bounds data module number!"); @@ -938,11 +791,6 @@ namespace RTE { m_pDataModules[whichModule]->RegisterGroup(newGroup); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetGroups - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the list of all groups registered in a specific module. - bool PresetMan::GetGroups(std::list& groupList, int whichModule, std::string withType) const { RTEAssert(whichModule < (int)m_pDataModules.size(), "Tried to access an out of bounds data module number!"); @@ -981,12 +829,6 @@ namespace RTE { return foundAny; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetModuleSpaceGroups - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Fills out a list with all groups registered in all official, PLUS a - // a specific non-official module as well. - bool PresetMan::GetModuleSpaceGroups(std::list& groupList, int whichModule, std::string withType) const { RTEAssert(whichModule < (int)m_pDataModules.size(), "Tried to access an out of bounds data module number!"); @@ -1024,20 +866,10 @@ namespace RTE { return foundAny; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetLoadout - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Creates and returns actor defined in the specified loadout. - Actor* PresetMan::GetLoadout(std::string loadoutName, std::string module, bool spawnDropShip) { return GetLoadout(loadoutName, GetModuleID(module), spawnDropShip); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetLoadout - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Creates and returns actor defined in the specified loadout. - Actor* PresetMan::GetLoadout(std::string loadoutName, int moduleNumber, bool spawnDropShip) { if (spawnDropShip) { // Find the Loadout that this Deployment is referring to @@ -1072,8 +904,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PresetMan::FindAndExtractZippedModules() const { for (const std::filesystem::directory_entry& directoryEntry: std::filesystem::directory_iterator(System::GetWorkingDirectory() + System::GetModDirectory())) { std::string zippedModulePath = std::filesystem::path(directoryEntry).generic_string(); diff --git a/Source/Managers/PresetMan.h b/Source/Managers/PresetMan.h index b58bc08c8b..f4400cf6e2 100644 --- a/Source/Managers/PresetMan.h +++ b/Source/Managers/PresetMan.h @@ -1,18 +1,11 @@ #ifndef _RTEPRESETMAN_ #define _RTEPRESETMAN_ -////////////////////////////////////////////////////////////////////////////////////////// -// File: PresetMan.h -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Header file for the PresetMan class. -// Project: Retro Terrain Engine -// Author(s): Daniel Tabar -// data@datarealms.com -// http://www.datarealms.com - -////////////////////////////////////////////////////////////////////////////////////////// -// Inclusions of header files - +/// Header file for the PresetMan class. +/// @author Daniel Tabar +/// data@datarealms.com +/// http://www.datarealms.com +/// Inclusions of header files #include "Entity.h" #include "Singleton.h" @@ -23,497 +16,332 @@ namespace RTE { class Actor; class DataModule; - ////////////////////////////////////////////////////////////////////////////////////////// - // Class: PresetMan - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: The singleton manager of all presets of Entity:s in the RTE. - // The presets serve as a respository of Entity instances with specific - // and unique and initial runtime data. - // Parent(s): Singleton, Serializable. - // Class history: 12/25/2001 PresetMan created. - // Class history: 05/30/2008 Changed name to PresetMan. - + /// The singleton manager of all presets of Entity:s in the RTE. + /// The presets serve as a respository of Entity instances with specific + /// and unique and initial runtime data. class PresetMan : public Singleton { friend struct ManagerLuaBindings; - ////////////////////////////////////////////////////////////////////////////////////////// - // Public member variable, method and friend function declarations - + /// Public member variable, method and friend function declarations public: - ////////////////////////////////////////////////////////////////////////////////////////// - // Constructor: PresetMan - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Constructor method used to instantiate a PresetMan entity in system - // memory. Create() should be called before using the entity. - // Arguments: None. - + /// Constructor method used to instantiate a PresetMan entity in system + /// memory. Create() should be called before using the entity. PresetMan() { Clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Destructor: ~PresetMan - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destructor method used to clean up a PresetMan entity before deletion - // from system memory. - // Arguments: None. - + /// Destructor method used to clean up a PresetMan entity before deletion + /// from system memory. ~PresetMan() { Destroy(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes the PresetMan entity ready for use. - // Arguments: None. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Makes the PresetMan entity ready for use. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Initialize() { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Reset - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Resets the entire PresetMan, including its inherited members, to - // their default settings or values. - // Arguments: None. - // Return value: None. - + /// Resets the entire PresetMan, including its inherited members, to + /// their default settings or values. void Reset() { Clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destroys and resets (through Clear()) the PresetMan entity. - // Arguments: None. - // Return value: None. - + /// Destroys and resets (through Clear()) the PresetMan entity. void Destroy(); - /// /// Reads an entire DataModule and adds it to this. NOTE that official modules can't be loaded after any non-official ones! - /// - /// The module name to read, e.g. "Base.rte". - /// Whether this module is 'official' or third party. If official, it has to not have any name conflicts with any other official module. - /// Whether this module is a userdata module. If true, will be treated as an unofficial module. - /// A function pointer to a function that will be called and sent a string with information about the progress of this DataModule's creation. - /// Whether the DataModule was read and added correctly. + /// @param moduleName The module name to read, e.g. "Base.rte". + /// @param official Whether this module is 'official' or third party. If official, it has to not have any name conflicts with any other official module. + /// @param userdata Whether this module is a userdata module. If true, will be treated as an unofficial module. + /// @param progressCallback A function pointer to a function that will be called and sent a string with information about the progress of this DataModule's creation. + /// @return Whether the DataModule was read and added correctly. bool LoadDataModule(const std::string& moduleName, bool official, bool userdata = false, const ProgressCallback& progressCallback = nullptr); - /// /// Reads an entire DataModule and adds it to this. NOTE that official modules can't be loaded after any non-official ones! - /// - /// The module name to read, e.g. "Base.rte". - /// Whether the DataModule was read and added correctly. + /// @param moduleName The module name to read, e.g. "Base.rte". + /// @return Whether the DataModule was read and added correctly. bool LoadDataModule(const std::string& moduleName) { return LoadDataModule(moduleName, false); } - /// /// Loads all the official data modules individually with LoadDataModule, then proceeds to look for any non-official modules and loads them as well. - /// - /// + /// @return bool LoadAllDataModules(); - /// /// Sets the single module to be loaded after the official modules. This will be the ONLY non-official module to be loaded. - /// - /// Name of the module to load. + /// @param moduleName Name of the module to load. void SetSingleModuleToLoad(std::string moduleName) { m_SingleModuleToLoad = moduleName; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetDataModule - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets a specific loaded DataModule - // Arguments: The ID of the module to get. - // Return value: The requested DataModule. Ownership is NOT transferred! - + /// Gets a specific loaded DataModule + /// @param whichModule The ID of the module to get. (default: 0) + /// @return The requested DataModule. Ownership is NOT transferred! const DataModule* GetDataModule(int whichModule = 0); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetDataModuleName - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets a name specific loaded DataModule - // Arguments: The ID of the module to get. - // Return value: The requested DataModule name. - + /// Gets a name specific loaded DataModule + /// @param whichModule The ID of the module to get. (default: 0) + /// @return The requested DataModule name. const std::string GetDataModuleName(int whichModule = 0); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetModuleID - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the ID of a loaded DataModule. - // Arguments: The name of the DataModule to get the ID from, including the ".rte" - // Return value: The requested ID. If no module of the name was found, -1 will be returned. - + /// Gets the ID of a loaded DataModule. + /// @param moduleName The name of the DataModule to get the ID from, including the ".rte" + /// @return The requested ID. If no module of the name was found, -1 will be returned. int GetModuleID(std::string moduleName); - /// /// Gets the Name of a loaded DataModule, from a full data file path. - /// - /// The full path to a data file inside the data module id you want to get. - /// The requested Name. If no module of the name was found, "" will be returned. + /// @param dataPath The full path to a data file inside the data module id you want to get. + /// @return The requested Name. If no module of the name was found, "" will be returned. std::string GetModuleNameFromPath(const std::string& dataPath) const; - /// /// Gets the ID of a loaded DataModule from a full data file path. - /// - /// The full path to a data file inside the data module ID you want to get. - /// The requested ID. If no module of the name was found, -1 will be returned. + /// @param dataPath The full path to a data file inside the data module ID you want to get. + /// @return The requested ID. If no module of the name was found, -1 will be returned. int GetModuleIDFromPath(const std::string& dataPath); - /// /// Returns whether or not the module is vanilla. - /// - /// The name of the module to check, in the form "[moduleName].rte" - /// True if the module is an official data module, otherwise false. + /// @param moduleName The name of the module to check, in the form "[moduleName].rte" + /// @return True if the module is an official data module, otherwise false. bool IsModuleOfficial(const std::string& moduleName) const; - /// /// Returns whether or not the module is vanilla. - /// - /// The name of the module to check, in the form "[moduleName].rte" - /// True if the module is a listed user data module, otherwise false. + /// @param moduleName The name of the module to check, in the form "[moduleName].rte" + /// @return True if the module is a listed user data module, otherwise false. bool IsModuleUserdata(const std::string& moduleName) const; - /// /// Returns the Full path to the module including Data/, Userdata/ or Mods/. - /// - /// The Path to be completed. - /// The complete path to the file, including Data/, Userdata/ or Mods/ based on whether or not it's part of an official module or userdata. + /// @param modulePath The Path to be completed. + /// @return The complete path to the file, including Data/, Userdata/ or Mods/ based on whether or not it's part of an official module or userdata. std::string GetFullModulePath(const std::string& modulePath) const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetTotalModuleCount - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the total number of modules loaded so far, official or not. - // Arguments: None. - // Return value: The number of modules loaded so far, both official and non. - + /// Gets the total number of modules loaded so far, official or not. + /// @return The number of modules loaded so far, both official and non. int GetTotalModuleCount() { return m_pDataModules.size(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetOfficialModuleCount - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the total number of OFFICIAL modules loaded so far. - // Arguments: None. - // Return value: The number of official modules loaded so far. - + /// Gets the total number of OFFICIAL modules loaded so far. + /// @return The number of official modules loaded so far. int GetOfficialModuleCount() { return m_OfficialModuleCount; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: AddEntityPreset - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Adds an Entity instance's pointer and name associations to the - // internal list of already read in Entity:s. Ownership is NOT transferred! - // If there already is an instance defined, nothing happens. If there - // is not, a clone is made of the passed-in Entity and added to the library. - // Arguments: A pointer to the Entity derived instance to add. It should be created - // from a Reader. Ownership is NOT transferred! - // Which module to add the entity to. - // Whether to overwrite if an instance of the EXACT same TYPE and name - // was found. If one of the same name but not the exact type, false - // is returned regardless and nothing will have been added. - // The file this instance was read from, or where it should be written. - // If "Same" is passed as the file path read from, an overwritten instance - // will keep the old one's file location entry. - // Return value: Whether or not a copy of the passed-in instance was successfully inserted - // into the module. False will be returned if there already was an instance - // of that class and instance name inserted previously, unless overwritten. - + /// Adds an Entity instance's pointer and name associations to the + /// internal list of already read in Entity:s. Ownership is NOT transferred! + /// If there already is an instance defined, nothing happens. If there + /// is not, a clone is made of the passed-in Entity and added to the library. + /// @param pEntToAdd A pointer to the Entity derived instance to add. It should be created + /// from a Reader. Ownership is NOT transferred! + /// @param whichModule Which module to add the entity to. (default: 0) + /// @param overwriteSame Whether to overwrite if an instance of the EXACT same TYPE and name (default: false) + /// was found. If one of the same name but not the exact type, false + /// is returned regardless and nothing will have been added. + /// @param readFromFile The file this instance was read from, or where it should be written. (default: "Same") + /// If "Same" is passed as the file path read from, an overwritten instance + /// will keep the old one's file location entry. + /// @return Whether or not a copy of the passed-in instance was successfully inserted + /// into the module. False will be returned if there already was an instance + /// of that class and instance name inserted previously, unless overwritten. bool AddEntityPreset(Entity* pEntToAdd, int whichModule = 0, bool overwriteSame = false, std::string readFromFile = "Same"); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetEntityPreset - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets a previously read in (defined) Entity, by type and instance name. - // Arguments: The type name of the derived Entity. Ownership is NOT transferred! - // The instance name of the derived Entity instance. - // Which module to try to get the entity from. If it's not found there, - // the official modules will be searched also. -1 means search ALL modules! - // Return value: A pointer to the requested Entity instance. 0 if no Entity with that - // derived type or instance name was found. Ownership is NOT transferred! - + /// Gets a previously read in (defined) Entity, by type and instance name. + /// @param type The type name of the derived Entity. Ownership is NOT transferred! + /// @param preset The instance name of the derived Entity instance. + /// @param whichModule Which module to try to get the entity from. If it's not found there, (default: -1) + /// the official modules will be searched also. -1 means search ALL modules! + /// @return A pointer to the requested Entity instance. 0 if no Entity with that + /// derived type or instance name was found. Ownership is NOT transferred! const Entity* GetEntityPreset(std::string type, std::string preset, int whichModule = -1); // Helper for passing in string module name instead of ID const Entity* GetEntityPreset(std::string type, std::string preset, std::string module) { return GetEntityPreset(type, preset, GetModuleID(module)); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetEntityPreset - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Reads an instance of an Entity that will be used as preset - // to later on be used to generate more instances of the same state. - // Will check if there was already one of the same class and instance - // name read in previously, and will return that one if found, or - // add the newly read in one to this PresetMan's list if not found to - // exist there previously. Ownership is NOT transferred! - // Arguments: The Reader which is about to read in an instance reference. It'll make - // this look in the same module as it's reading from. - // Return value: A const pointer to the Entity instance read in. 0 if there was an - // error, or the instance name was 'None'. Ownership is NOT transferred! - + /// Reads an instance of an Entity that will be used as preset + /// to later on be used to generate more instances of the same state. + /// Will check if there was already one of the same class and instance + /// name read in previously, and will return that one if found, or + /// add the newly read in one to this PresetMan's list if not found to + /// exist there previously. Ownership is NOT transferred! + /// @param reader The Reader which is about to read in an instance reference. It'll make + /// this look in the same module as it's reading from. + /// @return A const pointer to the Entity instance read in. 0 if there was an + /// error, or the instance name was 'None'. Ownership is NOT transferred! const Entity* GetEntityPreset(Reader& reader); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ReadReflectedPreset - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Reads a preset of an Entity and tries to add it to the list of - // read-in instances. Regardless of whether there is a name collision, - // the read-in preset will be returned, ownership TRANSFERRED! - // Arguments: The Reader which is about to read in a preset. - // Return value: A pointer to the Entity preset read in. 0 if there was an - // error, or the instance name was 'None'. Ownership IS transferred! - + /// Reads a preset of an Entity and tries to add it to the list of + /// read-in instances. Regardless of whether there is a name collision, + /// the read-in preset will be returned, ownership TRANSFERRED! + /// @param reader The Reader which is about to read in a preset. + /// @return A pointer to the Entity preset read in. 0 if there was an + /// error, or the instance name was 'None'. Ownership IS transferred! Entity* ReadReflectedPreset(Reader& reader); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetAllOfType - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Adds to a list all previously read in (defined) Entitys, by type. - // Arguments: Reference to a list which will get all matching Entity:s added to it. - // Ownership of the list or the Entitys placed in it are NOT transferred! - // The type name of the Entitys you want. - // Whether to only get those of one specific DataModule (0-n), or all (-1). - // Return value: Whether any Entity:s were found and added to the list. - + /// Adds to a list all previously read in (defined) Entitys, by type. + /// @param entityList Reference to a list which will get all matching Entity:s added to it. + /// @param type Ownership of the list or the Entitys placed in it are NOT transferred! + /// @param whichModule The type name of the Entitys you want. (default: -1) + /// Whether to only get those of one specific DataModule (0-n), or all (-1). + /// @return Whether any Entity:s were found and added to the list. bool GetAllOfType(std::list& entityList, std::string type, int whichModule = -1); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetAllOfTypeInModuleSpace - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Adds to a list all previously read in (defined) Entitys which are - // of a specific type, and only exist in a specific module space. - // Arguments: Reference to a list which will get all matching Entity:s added to it. - // Ownership of the list or the Entitys placed in it are NOT transferred! - // The type name of the Entitys you want. - // Which module to get the instances for, in addition to all groups in - // official modules loaded earlier than the one specified here. -1 means - // get ALL groups ever reg'd. - // Return value: Whether any Entity:s were found and added to the list. - + /// Adds to a list all previously read in (defined) Entitys which are + /// of a specific type, and only exist in a specific module space. + /// @param entityList Reference to a list which will get all matching Entity:s added to it. + /// @param type Ownership of the list or the Entitys placed in it are NOT transferred! + /// @param whichModuleSpace The type name of the Entitys you want. + /// Which module to get the instances for, in addition to all groups in + /// official modules loaded earlier than the one specified here. -1 means + /// get ALL groups ever reg'd. + /// @return Whether any Entity:s were found and added to the list. bool GetAllOfTypeInModuleSpace(std::list& entityList, std::string type, int whichModuleSpace); - /// /// Adds to a list all previously read in (defined) Entities which are associated with a specific group. - /// - /// Reference to a list which will get all matching Entities added to it. Ownership of the list or the Entities placed in it are NOT transferred! - /// The group to look for. "All" will look in all. - /// The name of the least common denominator type of the Entities you want. "All" will look at all types. - /// Whether to only get those of one specific DataModule (0-n), or all (-1). - /// Whether any Entities were found and added to the list. + /// @param entityList Reference to a list which will get all matching Entities added to it. Ownership of the list or the Entities placed in it are NOT transferred! + /// @param group The group to look for. "All" will look in all. + /// @param type The name of the least common denominator type of the Entities you want. "All" will look at all types. + /// @param whichModule Whether to only get those of one specific DataModule (0-n), or all (-1). + /// @return Whether any Entities were found and added to the list. bool GetAllOfGroup(std::list& entityList, const std::string& group, const std::string& type = "All", int whichModule = -1) { return GetAllOfGroups(entityList, {group}, type, whichModule); } - /// /// Adds to a list all previously read in (defined) Entities which are associated with several specific groups. - /// - /// Reference to a list which will get all matching Entities added to it. Ownership of the list or the Entities placed in it are NOT transferred! - /// The groups to look for. "All" will look in all. - /// The name of the least common denominator type of the Entities you want. "All" will look at all types. - /// Whether to only get those of one specific DataModule (0-n), or all (-1). - /// Whether any Entities were found and added to the list. + /// @param entityList Reference to a list which will get all matching Entities added to it. Ownership of the list or the Entities placed in it are NOT transferred! + /// @param groups The groups to look for. "All" will look in all. + /// @param type The name of the least common denominator type of the Entities you want. "All" will look at all types. + /// @param whichModule Whether to only get those of one specific DataModule (0-n), or all (-1). + /// @return Whether any Entities were found and added to the list. bool GetAllOfGroups(std::list& entityList, const std::vector& groups, const std::string& type = "All", int whichModule = -1); - /// /// Adds to a list all previously read in (defined) Entities which are not associated with a specific group. - /// - /// Reference to a list which will get all matching Entities added to it. Ownership of the list or the Entities placed in it are NOT transferred! - /// The group to exclude. - /// The name of the least common denominator type of the Entities you want. "All" will look at all types. - /// Whether to only get those of one specific DataModule (0-n), or all (-1). - /// Whether any Entities were found and added to the list. + /// @param entityList Reference to a list which will get all matching Entities added to it. Ownership of the list or the Entities placed in it are NOT transferred! + /// @param group The group to exclude. + /// @param type The name of the least common denominator type of the Entities you want. "All" will look at all types. + /// @param whichModule Whether to only get those of one specific DataModule (0-n), or all (-1). + /// @return Whether any Entities were found and added to the list. bool GetAllNotOfGroup(std::list& entityList, const std::string& group, const std::string& type = "All", int whichModule = -1) { return GetAllNotOfGroups(entityList, {group}, type, whichModule); } - /// /// Adds to a list all previously read in (defined) Entities which are not associated with several specific groups. - /// - /// Reference to a list which will get all matching Entities added to it. Ownership of the list or the Entities placed in it are NOT transferred! - /// The groups to exclude. - /// The name of the least common denominator type of the Entities you want. "All" will look at all types. - /// Whether to only get those of one specific DataModule (0-n), or all (-1). - /// Whether any Entities were found and added to the list. + /// @param entityList Reference to a list which will get all matching Entities added to it. Ownership of the list or the Entities placed in it are NOT transferred! + /// @param groups The groups to exclude. + /// @param type The name of the least common denominator type of the Entities you want. "All" will look at all types. + /// @param whichModule Whether to only get those of one specific DataModule (0-n), or all (-1). + /// @return Whether any Entities were found and added to the list. bool GetAllNotOfGroups(std::list& entityList, const std::vector& groups, const std::string& type = "All", int whichModule = -1); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetRandomOfGroup - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns a previously read in (defined) Entity which is randomly - // selected from a specific group. - // Arguments: The group to randomly select an Entity from. "All" will look in all. - // The name of the least common denominator type of the Entitys you want. - // "All" will look at all types. - // Whether to only get those of one specific DataModule (0-n), or all (-1). - // Return value: The Entity preset that was randomly selected. Ownership is NOT transferred! - + /// Returns a previously read in (defined) Entity which is randomly + /// selected from a specific group. + /// @param group The group to randomly select an Entity from. "All" will look in all. + /// @param type The name of the least common denominator type of the Entitys you want. (default: "All") + /// "All" will look at all types. + /// @param whichModule Whether to only get those of one specific DataModule (0-n), or all (-1). (default: -1) + /// @return The Entity preset that was randomly selected. Ownership is NOT transferred! Entity* GetRandomOfGroup(std::string group, std::string type = "All", int whichModule = -1); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetRandomOfGroupFromTech - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns a previously read in (defined) Entity which is randomly - // selected from a specific group only if it belongs to some tech. - // Arguments: The group to randomly select an Entity from. "All" will look in all. - // The name of the least common denominator type of the Entitys you want. - // "All" will look at all types. - // Whether to only get those of one specific DataModule (0-n), or all (-1) - // or all modules uncluding non-tech ones. - // Return value: The Entity preset that was randomly selected. Ownership is NOT transferred! - + /// Returns a previously read in (defined) Entity which is randomly + /// selected from a specific group only if it belongs to some tech. + /// @param group The group to randomly select an Entity from. "All" will look in all. + /// @param type The name of the least common denominator type of the Entitys you want. (default: "All") + /// "All" will look at all types. + /// @param whichModule Whether to only get those of one specific DataModule (0-n), or all (-1) (default: -1) + /// or all modules uncluding non-tech ones. + /// @return The Entity preset that was randomly selected. Ownership is NOT transferred! Entity* GetRandomBuyableOfGroupFromTech(std::string group, std::string type = "All", int whichModule = -1); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetAllOfGroupInModuleSpace - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Adds to a list all previously read in (defined) Entitys which are - // associated with a specific group, and only exist in a specific module - // space. - // Arguments: Reference to a list which will get all matching Entity:s added to it. - // Ownership of the list or the Entitys placed in it are NOT transferred! - // The group to look for. "All" will look in all. - // The name of the least common denominator type of the Entitys you want. - // "All" will look at all types. - // Which module to get the instances for, in addition to all groups in - // official modules loaded earlier than the one specified here. -1 means - // get ALL groups ever reg'd. - // Return value: Whether any Entity:s were found and added to the list. - + /// Adds to a list all previously read in (defined) Entitys which are + /// associated with a specific group, and only exist in a specific module + /// space. + /// @param entityList Reference to a list which will get all matching Entity:s added to it. + /// @param group Ownership of the list or the Entitys placed in it are NOT transferred! + /// @param type The group to look for. "All" will look in all. + /// @param whichModuleSpace The name of the least common denominator type of the Entitys you want. + /// "All" will look at all types. + /// Which module to get the instances for, in addition to all groups in + /// official modules loaded earlier than the one specified here. -1 means + /// get ALL groups ever reg'd. + /// @return Whether any Entity:s were found and added to the list. bool GetAllOfGroupInModuleSpace(std::list& entityList, std::string group, std::string type, int whichModuleSpace); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetRandomOfGroupInModuleSpace - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns a previously read in (defined) Entity which is associated with - // a specific group, randomly selected and only exist in a specific module - // space. - // Arguments: Ownership of the list or the Entitys placed in it are NOT transferred! - // The group to randomly select from. "All" will look in all. - // The name of the least common denominator type of the Entity:s you want. - // "All" will look at all types. - // Which module to get the instances for, in addition to all groups in - // official modules loaded earlier than the one specified here. -1 means - // get ALL groups ever reg'd. - // Return value: The randomly select preset, if any was found with thse search params. - // Ownership is NOT transferred! - + /// Returns a previously read in (defined) Entity which is associated with + /// a specific group, randomly selected and only exist in a specific module + /// space. + /// @param group Ownership of the list or the Entitys placed in it are NOT transferred! + /// @param type The group to randomly select from. "All" will look in all. + /// @param whichModuleSpace The name of the least common denominator type of the Entity:s you want. + /// "All" will look at all types. + /// Which module to get the instances for, in addition to all groups in + /// official modules loaded earlier than the one specified here. -1 means + /// get ALL groups ever reg'd. + /// @return The randomly select preset, if any was found with thse search params. + /// Ownership is NOT transferred! Entity* GetRandomOfGroupInModuleSpace(std::string group, std::string type, int whichModuleSpace); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetEntityDataLocation - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the data file path of a previously read in (defined) Entity. - // Arguments: The type name of the derived Entity. Ownership is NOT transferred! - // The preset name of the derived Entity preset. - // Which module to try to get the entity from. If it's not found there, - // the official modules will be searched also. - // Return value: The file path of the data file that the specified Entity was read from. - // If no Entity of that description was found, "" is returned. - + /// Gets the data file path of a previously read in (defined) Entity. + /// @param type The type name of the derived Entity. Ownership is NOT transferred! + /// @param preset The preset name of the derived Entity preset. + /// @param whichModule Which module to try to get the entity from. If it's not found there, + /// the official modules will be searched also. + /// @return The file path of the data file that the specified Entity was read from. + /// If no Entity of that description was found, "" is returned. std::string GetEntityDataLocation(std::string type, std::string preset, int whichModule); - /// /// Reloads all scripted Entity Presets with the latest version of their respective script files. - /// void ReloadAllScripts() const; - /// /// Reloads an Entity preset and all related presets with the latest version of their respective files. /// Stores the passed in Entity preset info for later re-use in PresetMan::QuickReloadEntityPreset. - /// - /// The name of the preset to reload. - /// The type of the preset to reload, to avoid any ambiguity. - /// The DataModule the preset to reload is defined in. - /// Whether or not to store the reloaded entity preset data for quick reloading. - /// Whether reloading the preset was successful. + /// @param presetName The name of the preset to reload. + /// @param className The type of the preset to reload, to avoid any ambiguity. + /// @param dataModule The DataModule the preset to reload is defined in. + /// @param storeReloadedPresetDataForQuickReloading Whether or not to store the reloaded entity preset data for quick reloading. + /// @return Whether reloading the preset was successful. bool ReloadEntityPreset(const std::string& presetName, const std::string& className, const std::string& dataModule, bool storeReloadedPresetDataForQuickReloading = true); - /// /// Reloads the previously reloaded Entity preset and all related presets with the latest version of their respective files. - /// - /// Whether reloading the preset was successful. + /// @return Whether reloading the preset was successful. bool QuickReloadEntityPreset(); - /// /// Gets whether or not ReloadEntityPreset was called this update. - /// - /// Whether or not ReloadEntityPreset was called this update. + /// @return Whether or not ReloadEntityPreset was called this update. bool GetReloadEntityPresetCalledThisUpdate() const { return m_ReloadEntityPresetCalledThisUpdate; } - /// /// Resets whether or not ReloadEntityPreset was called this update. - /// void ClearReloadEntityPresetCalledThisUpdate() { m_ReloadEntityPresetCalledThisUpdate = false; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: AddMaterialMapping - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Adds a Material mapping local to a DataModule. This is used for when - // multiple DataModule:s are loading conflicting Material:s, and need to - // resolve the conflicts by mapping their materials to ID's different than - // those specified in the data files. - // Arguments: The material ID to map from. - // The material ID to map to. - // The ID of the DataModule we are making the mapping for. This should be - // a non-official module as mapping shouldn't be needed in the official - // modules. - // Return value: Whether this created a new mapping which didn't override a previous - // material mapping. - + /// Adds a Material mapping local to a DataModule. This is used for when + /// multiple DataModule:s are loading conflicting Material:s, and need to + /// resolve the conflicts by mapping their materials to ID's different than + /// those specified in the data files. + /// @param fromID The material ID to map from. + /// @param toID The material ID to map to. + /// @param whichModule The ID of the DataModule we are making the mapping for. This should be + /// a non-official module as mapping shouldn't be needed in the official + /// modules. + /// @return Whether this created a new mapping which didn't override a previous + /// material mapping. bool AddMaterialMapping(int fromID, int toID, int whichModule); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: RegisterGroup - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Registers the existence of an Entity group, and in which module. - // Arguments: The group to register. - // The ID of the module in which at least one entity of this group can be - // found. - // global register. - // Return value: None. - + /// Registers the existence of an Entity group, and in which module. + /// @param newGroup The group to register. + /// @param whichModule The ID of the module in which at least one entity of this group can be + /// found. + /// global register. void RegisterGroup(std::string newGroup, int whichModule); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetGroups - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Fills out a list with all groups registered in a specific module. - // Arguments: The list that all found groups will be ADDED to. OWNERSHIP IS NOT TRANSFERRED! - // Which module to get the groups for. -1 means get ALL groups ever reg'd. - // Pass a type name here and only groups with entitys of that type will be - // be included. "All" means don't consider what types are in the groups. - // Return value: Whether any groups were found and thus added to the list. - + /// Fills out a list with all groups registered in a specific module. + /// @param groupList The list that all found groups will be ADDED to. OWNERSHIP IS NOT TRANSFERRED! + /// @param whichModule Which module to get the groups for. -1 means get ALL groups ever reg'd. (default: -1) + /// @param withType Pass a type name here and only groups with entitys of that type will be (default: "All") + /// be included. "All" means don't consider what types are in the groups. + /// @return Whether any groups were found and thus added to the list. bool GetGroups(std::list& groupList, int whichModule = -1, std::string withType = "All") const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetModuleSpaceGroups - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Fills out a list with all groups registered in all official modules, - // PLUS a specific non-official module as well. - // Arguments: The list that all found groups will be ADDED to. OWNERSHIP IS NOT TRANSFERRED! - // Which module to get the groups for, in addition to all groups in - // official modules loaded earlier than the one specified here. -1 means - // get ALL groups ever reg'd. - // Pass a type name here and only groups with entitys of that type will be - // be included. "All" means don't consider what types are in the groups. - // Return value: Whether any groups were found and thus added to the list. - + /// Fills out a list with all groups registered in all official modules, + /// PLUS a specific non-official module as well. + /// @param groupList The list that all found groups will be ADDED to. OWNERSHIP IS NOT TRANSFERRED! + /// @param whichModule Which module to get the groups for, in addition to all groups in + /// official modules loaded earlier than the one specified here. -1 means + /// get ALL groups ever reg'd. + /// @param withType Pass a type name here and only groups with entitys of that type will be (default: "All") + /// be included. "All" means don't consider what types are in the groups. + /// @return Whether any groups were found and thus added to the list. bool GetModuleSpaceGroups(std::list& groupList, int whichModule, std::string withType = "All") const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetLoadout - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Creates and returns actor defined in the specified loadout. - // Arguments: Loadout preset name, module name, whether or not spawn delivery craft defined for that loadout - // Return value: Created actor if matching loadout was found or 0. OWNERSHIP IS TRANSFERED. - + /// Creates and returns actor defined in the specified loadout. + /// @param loadoutName Loadout preset name, module name, whether or not spawn delivery craft defined for that loadout + /// @return Created actor if matching loadout was found or 0. OWNERSHIP IS TRANSFERED. Actor* GetLoadout(std::string loadoutName, std::string module, bool spawnDropShip); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetLoadout - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Creates and returns actor defined in the specified loadout. - // Arguments: Loadout preset name, module id, whether or not spawn delivery craft defined for that loadout - // Return value: Created actor if matching loadout was found or 0. OWNERSHIP IS TRANSFERED. - + /// Creates and returns actor defined in the specified loadout. + /// @param loadoutName Loadout preset name, module id, whether or not spawn delivery craft defined for that loadout + /// @return Created actor if matching loadout was found or 0. OWNERSHIP IS TRANSFERED. Actor* GetLoadout(std::string loadoutName, int moduleNumber, bool spawnDropShip); - ////////////////////////////////////////////////////////////////////////////////////////// - // Protected member variable and method declarations - + /// Protected member variable and method declarations protected: // Owned and loaded DataModule:s std::vector m_pDataModules; @@ -532,9 +360,7 @@ namespace RTE { // This is just a handy total of all the groups registered in all the individual DataModule:s std::list m_TotalGroupRegister; - ////////////////////////////////////////////////////////////////////////////////////////// - // Private member variable and method declarations - + /// Private member variable and method declarations private: static const std::array c_OfficialModules; // Array storing the names of all the official modules. static const std::array, 3> c_UserdataModules; // Array storing the names of all the userdata modules. @@ -542,19 +368,11 @@ namespace RTE { std::array m_LastReloadedEntityPresetInfo; //!< Array storing the last reloaded Entity preset info (ClassName, PresetName and DataModule). Used for quick reloading via key combination. bool m_ReloadEntityPresetCalledThisUpdate; //!< A flag for whether or not ReloadEntityPreset was called this update. - /// /// Iterates through the working directory to find any files matching the zipped module package extension (.rte.zip) and proceeds to extract them. - /// void FindAndExtractZippedModules() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Clear - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears all the member variables of this PresetMan, effectively - // resetting the members of this abstraction level only. - // Arguments: None. - // Return value: None. - + /// Clears all the member variables of this PresetMan, effectively + /// resetting the members of this abstraction level only. void Clear(); // Disallow the use of some implicit methods. diff --git a/Source/Managers/PrimitiveMan.cpp b/Source/Managers/PrimitiveMan.cpp index a29d08d63a..3e44b3d478 100644 --- a/Source/Managers/PrimitiveMan.cpp +++ b/Source/Managers/PrimitiveMan.cpp @@ -9,8 +9,6 @@ namespace RTE { - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - std::unique_ptr PrimitiveMan::MakeUniqueOfAppropriateTypeFromPrimitiveRawPtr(GraphicalPrimitive* primitive) { switch (primitive->GetPrimitiveType()) { case GraphicalPrimitive::PrimitiveType::Line: @@ -48,15 +46,11 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PrimitiveMan::SchedulePrimitive(std::unique_ptr&& primitive) { std::lock_guard lock(m_Mutex); m_ScheduledPrimitives.emplace_back(std::move(primitive)); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PrimitiveMan::SchedulePrimitivesForBlendedDrawing(DrawBlendMode blendMode, int blendAmountR, int blendAmountG, int blendAmountB, int blendAmountA, const std::vector& primitives) { if (blendMode < DrawBlendMode::NoBlend || blendMode >= DrawBlendMode::BlendModeCount) { g_ConsoleMan.PrintString("ERROR: Encountered invalid blending mode when attempting to draw primitives! Drawing will be skipped! See the DrawBlendMode enumeration for valid modes."); @@ -74,8 +68,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PrimitiveMan::DrawLinePrimitive(int player, const Vector& startPos, const Vector& endPos, unsigned char color, int thickness) { if (thickness > 1) { Vector dirVector = g_SceneMan.ShortestDistance(startPos, endPos, g_SceneMan.SceneWrapsX()).SetMagnitude(static_cast(thickness - 1) / 2.0F).Perpendicularize(); @@ -91,164 +83,110 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PrimitiveMan::DrawArcPrimitive(const Vector& centerPos, float startAngle, float endAngle, int radius, unsigned char color) { SchedulePrimitive(std::make_unique(-1, centerPos, startAngle, endAngle, radius, 1, color)); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PrimitiveMan::DrawArcPrimitive(const Vector& centerPos, float startAngle, float endAngle, int radius, unsigned char color, int thickness) { SchedulePrimitive(std::make_unique(-1, centerPos, startAngle, endAngle, radius, thickness, color)); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PrimitiveMan::DrawArcPrimitive(int player, const Vector& centerPos, float startAngle, float endAngle, int radius, unsigned char color) { SchedulePrimitive(std::make_unique(player, centerPos, startAngle, endAngle, radius, 1, color)); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PrimitiveMan::DrawArcPrimitive(int player, const Vector& centerPos, float startAngle, float endAngle, int radius, unsigned char color, int thickness) { SchedulePrimitive(std::make_unique(player, centerPos, startAngle, endAngle, radius, thickness, color)); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PrimitiveMan::DrawSplinePrimitive(const Vector& startPos, const Vector& guideA, const Vector& guideB, const Vector& endPos, unsigned char color) { SchedulePrimitive(std::make_unique(-1, startPos, guideA, guideB, endPos, color)); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PrimitiveMan::DrawSplinePrimitive(int player, const Vector& startPos, const Vector& guideA, const Vector& guideB, const Vector& endPos, unsigned char color) { SchedulePrimitive(std::make_unique(player, startPos, guideA, guideB, endPos, color)); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PrimitiveMan::DrawBoxPrimitive(const Vector& topLeftPos, const Vector& bottomRightPos, unsigned char color) { SchedulePrimitive(std::make_unique(-1, topLeftPos, bottomRightPos, color)); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PrimitiveMan::DrawBoxPrimitive(int player, const Vector& topLeftPos, const Vector& bottomRightPos, unsigned char color) { SchedulePrimitive(std::make_unique(player, topLeftPos, bottomRightPos, color)); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PrimitiveMan::DrawBoxFillPrimitive(const Vector& topLeftPos, const Vector& bottomRightPos, unsigned char color) { SchedulePrimitive(std::make_unique(-1, topLeftPos, bottomRightPos, color)); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PrimitiveMan::DrawBoxFillPrimitive(int player, const Vector& topLeftPos, const Vector& bottomRightPos, unsigned char color) { SchedulePrimitive(std::make_unique(player, topLeftPos, bottomRightPos, color)); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PrimitiveMan::DrawRoundedBoxPrimitive(const Vector& topLeftPos, const Vector& bottomRightPos, int cornerRadius, unsigned char color) { SchedulePrimitive(std::make_unique(-1, topLeftPos, bottomRightPos, cornerRadius, color)); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PrimitiveMan::DrawRoundedBoxPrimitive(int player, const Vector& topLeftPos, const Vector& bottomRightPos, int cornerRadius, unsigned char color) { SchedulePrimitive(std::make_unique(player, topLeftPos, bottomRightPos, cornerRadius, color)); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PrimitiveMan::DrawRoundedBoxFillPrimitive(const Vector& topLeftPos, const Vector& bottomRightPos, int cornerRadius, unsigned char color) { SchedulePrimitive(std::make_unique(-1, topLeftPos, bottomRightPos, cornerRadius, color)); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PrimitiveMan::DrawRoundedBoxFillPrimitive(int player, const Vector& topLeftPos, const Vector& bottomRightPos, int cornerRadius, unsigned char color) { SchedulePrimitive(std::make_unique(player, topLeftPos, bottomRightPos, cornerRadius, color)); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PrimitiveMan::DrawCirclePrimitive(const Vector& centerPos, int radius, unsigned char color) { SchedulePrimitive(std::make_unique(-1, centerPos, radius, color)); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PrimitiveMan::DrawCirclePrimitive(int player, const Vector& centerPos, int radius, unsigned char color) { SchedulePrimitive(std::make_unique(player, centerPos, radius, color)); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PrimitiveMan::DrawCircleFillPrimitive(const Vector& centerPos, int radius, unsigned char color) { SchedulePrimitive(std::make_unique(-1, centerPos, radius, color)); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PrimitiveMan::DrawCircleFillPrimitive(int player, const Vector& centerPos, int radius, unsigned char color) { SchedulePrimitive(std::make_unique(player, centerPos, radius, color)); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PrimitiveMan::DrawEllipsePrimitive(const Vector& centerPos, int horizRadius, int vertRadius, unsigned char color) { SchedulePrimitive(std::make_unique(-1, centerPos, horizRadius, vertRadius, color)); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PrimitiveMan::DrawEllipsePrimitive(int player, const Vector& centerPos, int horizRadius, int vertRadius, unsigned char color) { SchedulePrimitive(std::make_unique(player, centerPos, horizRadius, vertRadius, color)); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PrimitiveMan::DrawEllipseFillPrimitive(const Vector& centerPos, int horizRadius, int vertRadius, unsigned char color) { SchedulePrimitive(std::make_unique(-1, centerPos, horizRadius, vertRadius, color)); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PrimitiveMan::DrawEllipseFillPrimitive(int player, const Vector& centerPos, int horizRadius, int vertRadius, unsigned char color) { SchedulePrimitive(std::make_unique(player, centerPos, horizRadius, vertRadius, color)); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PrimitiveMan::DrawTrianglePrimitive(const Vector& pointA, const Vector& pointB, const Vector& pointC, unsigned char color) { SchedulePrimitive(std::make_unique(-1, pointA, pointB, pointC, color)); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PrimitiveMan::DrawTrianglePrimitive(int player, const Vector& pointA, const Vector& pointB, const Vector& pointC, unsigned char color) { SchedulePrimitive(std::make_unique(player, pointA, pointB, pointC, color)); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PrimitiveMan::DrawTriangleFillPrimitive(const Vector& pointA, const Vector& pointB, const Vector& pointC, unsigned char color) { SchedulePrimitive(std::make_unique(-1, pointA, pointB, pointC, color)); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PrimitiveMan::DrawTriangleFillPrimitive(int player, const Vector& pointA, const Vector& pointB, const Vector& pointC, unsigned char color) { SchedulePrimitive(std::make_unique(player, pointA, pointB, pointC, color)); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PrimitiveMan::DrawPolygonOrPolygonFillPrimitive(int player, const Vector& startPos, unsigned char color, const std::vector& vertices, bool filled) { if (vertices.size() < 2) { g_ConsoleMan.PrintString("ERROR: Polygon primitive should have at least 2 vertices! Drawing will be skipped!"); @@ -261,52 +199,36 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PrimitiveMan::DrawTextPrimitive(const Vector& start, const std::string& text, bool isSmall, int alignment) { SchedulePrimitive(std::make_unique(-1, start, text, isSmall, alignment, 0)); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PrimitiveMan::DrawTextPrimitive(const Vector& start, const std::string& text, bool isSmall, int alignment, float rotAngle) { SchedulePrimitive(std::make_unique(-1, start, text, isSmall, alignment, rotAngle)); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PrimitiveMan::DrawTextPrimitive(int player, const Vector& start, const std::string& text, bool isSmall, int alignment) { SchedulePrimitive(std::make_unique(player, start, text, isSmall, alignment, 0)); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PrimitiveMan::DrawTextPrimitive(int player, const Vector& start, const std::string& text, bool isSmall, int alignment, float rotAngle) { SchedulePrimitive(std::make_unique(player, start, text, isSmall, alignment, rotAngle)); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PrimitiveMan::DrawBitmapPrimitive(int player, const Vector& centerPos, const MOSprite* moSprite, float rotAngle, int frame, bool hFlipped, bool vFlipped) { SchedulePrimitive(std::make_unique(player, centerPos, moSprite, rotAngle, frame, hFlipped, vFlipped)); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PrimitiveMan::DrawBitmapPrimitive(int player, const Vector& centerPos, const std::string& filePath, float rotAngle, bool hFlipped, bool vFlipped) { SchedulePrimitive(std::make_unique(player, centerPos, filePath, rotAngle, hFlipped, vFlipped)); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PrimitiveMan::DrawIconPrimitive(int player, const Vector& centerPos, Entity* entity) { if (const MOSprite* moSprite = dynamic_cast(entity)) { SchedulePrimitive(std::make_unique(player, centerPos, moSprite->GetGraphicalIcon(), 0, false, false)); } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PrimitiveMan::DrawPrimitives(int player, BITMAP* targetBitmap, const Vector& targetPos) const { ZoneScoped; diff --git a/Source/Managers/PrimitiveMan.h b/Source/Managers/PrimitiveMan.h index e8deb56db9..99cfbf3ea9 100644 --- a/Source/Managers/PrimitiveMan.h +++ b/Source/Managers/PrimitiveMan.h @@ -10,474 +10,374 @@ namespace RTE { class Entity; - /// /// Singleton manager responsible for all primitive drawing. - /// class PrimitiveMan : public Singleton { public: #pragma region Creation - /// /// Constructor method used to instantiate a PrimitiveMan object in system memory. - /// PrimitiveMan() { ClearPrimitivesQueue(); } #pragma endregion #pragma region Destruction - /// /// Delete all scheduled primitives, called on every FrameMan sim update. - /// void ClearPrimitivesQueue() { m_ScheduledPrimitives.clear(); } #pragma endregion #pragma region Primitive Drawing - /// /// Draws all stored primitives on the screen for specified player. - /// - /// Player to draw for. - /// Bitmap to draw on. - /// Position to draw. + /// @param player Player to draw for. + /// @param targetBitmap Bitmap to draw on. + /// @param targetPos Position to draw. void DrawPrimitives(int player, BITMAP* targetBitmap, const Vector& targetPos) const; #pragma endregion #pragma region Primitive Draw Scheduling - /// /// Schedule to draw multiple primitives of varying type with blending enabled. - /// - /// The blending mode to use when drawing each primitive. - /// The blending amount for the Red channel. 0-100. - /// The blending amount for the Green channel. 0-100. - /// The blending amount for the Blue channel. 0-100. - /// The blending amount for the Alpha channel. 0-100. - /// A vector of primitives to schedule drawing for. + /// @param blendMode The blending mode to use when drawing each primitive. + /// @param blendAmountR The blending amount for the Red channel. 0-100. + /// @param blendAmountG The blending amount for the Green channel. 0-100. + /// @param blendAmountB The blending amount for the Blue channel. 0-100. + /// @param blendAmountA The blending amount for the Alpha channel. 0-100. + /// @param primitives A vector of primitives to schedule drawing for. void SchedulePrimitivesForBlendedDrawing(DrawBlendMode blendMode, int blendAmountR, int blendAmountG, int blendAmountB, int blendAmountA, const std::vector& primitives); - /// /// Schedule to draw a line primitive. - /// - /// Start position of primitive in scene coordinates. - /// End position of primitive in scene coordinates. - /// Color to draw primitive with. + /// @param startPos Start position of primitive in scene coordinates. + /// @param endPos End position of primitive in scene coordinates. + /// @param color Color to draw primitive with. void DrawLinePrimitive(const Vector& startPos, const Vector& endPos, unsigned char color) { DrawLinePrimitive(-1, startPos, endPos, color, 1); } - /// /// Schedule to draw a line primitive with the option to change thickness. - /// - /// Start position of primitive in scene coordinates. - /// End position of primitive in scene coordinates. - /// Color to draw primitive with. - /// Thickness of the line in pixels. + /// @param startPos Start position of primitive in scene coordinates. + /// @param endPos End position of primitive in scene coordinates. + /// @param color Color to draw primitive with. + /// @param thickness Thickness of the line in pixels. void DrawLinePrimitive(const Vector& startPos, const Vector& endPos, unsigned char color, int thickness) { DrawLinePrimitive(-1, startPos, endPos, color, thickness); } - /// /// Schedule to draw a line primitive visible only to a specified player. - /// - /// Player screen to draw primitive on. - /// Start position of primitive in scene coordinates. - /// End position of primitive in scene coordinates. - /// Color to draw primitive with. + /// @param player Player screen to draw primitive on. + /// @param startPos Start position of primitive in scene coordinates. + /// @param endPos End position of primitive in scene coordinates. + /// @param color Color to draw primitive with. void DrawLinePrimitive(int player, const Vector& startPos, const Vector& endPos, unsigned char color) { DrawLinePrimitive(player, startPos, endPos, color, 1); } - /// /// Schedule to draw a line primitive visible only to a specified player with the option to change thickness. - /// - /// Player screen to draw primitive on. - /// Start position of primitive in scene coordinates. - /// End position of primitive in scene coordinates. - /// Color to draw primitive with. - /// Thickness of the line in pixels. + /// @param player Player screen to draw primitive on. + /// @param startPos Start position of primitive in scene coordinates. + /// @param endPos End position of primitive in scene coordinates. + /// @param color Color to draw primitive with. + /// @param thickness Thickness of the line in pixels. void DrawLinePrimitive(int player, const Vector& startPos, const Vector& endPos, unsigned char color, int thickness); - /// /// Schedule to draw an arc primitive. - /// - /// Position of primitive's center in scene coordinates. - /// The angle from which the arc drawing begins. - /// The angle at which the arc drawing ends. - /// Radius of the arc primitive. - /// Color to draw primitive with. + /// @param centerPos Position of primitive's center in scene coordinates. + /// @param startAngle The angle from which the arc drawing begins. + /// @param endAngle The angle at which the arc drawing ends. + /// @param radius Radius of the arc primitive. + /// @param color Color to draw primitive with. void DrawArcPrimitive(const Vector& centerPos, float startAngle, float endAngle, int radius, unsigned char color); - /// /// Schedule to draw an arc primitive with the option to change thickness. - /// - /// Position of primitive's center in scene coordinates. - /// The angle from which the arc drawing begins. - /// The angle at which the arc drawing ends. - /// Radius of the arc primitive. - /// Color to draw primitive with. - /// Thickness of the arc in pixels. + /// @param centerPos Position of primitive's center in scene coordinates. + /// @param startAngle The angle from which the arc drawing begins. + /// @param endAngle The angle at which the arc drawing ends. + /// @param radius Radius of the arc primitive. + /// @param color Color to draw primitive with. + /// @param thickness Thickness of the arc in pixels. void DrawArcPrimitive(const Vector& centerPos, float startAngle, float endAngle, int radius, unsigned char color, int thickness); - /// /// Schedule to draw an arc primitive visible only to a specified player. - /// - /// Player screen to draw primitive on. - /// Position of primitive's center in scene coordinates. - /// The angle from which the arc drawing begins. - /// The angle at which the arc drawing ends. - /// Radius of the arc primitive. - /// Color to draw primitive with. + /// @param player Player screen to draw primitive on. + /// @param centerPos Position of primitive's center in scene coordinates. + /// @param startAngle The angle from which the arc drawing begins. + /// @param endAngle The angle at which the arc drawing ends. + /// @param radius Radius of the arc primitive. + /// @param color Color to draw primitive with. void DrawArcPrimitive(int player, const Vector& centerPos, float startAngle, float endAngle, int radius, unsigned char color); - /// /// Schedule to draw an arc primitive visible only to a specified player with the option to change thickness. - /// - /// Player screen to draw primitive on. - /// Position of primitive's center in scene coordinates. - /// The angle from which the arc drawing begins. - /// The angle at which the arc drawing ends. - /// Radius of the arc primitive. - /// Color to draw primitive with. - /// Thickness of the arc in pixels. + /// @param player Player screen to draw primitive on. + /// @param centerPos Position of primitive's center in scene coordinates. + /// @param startAngle The angle from which the arc drawing begins. + /// @param endAngle The angle at which the arc drawing ends. + /// @param radius Radius of the arc primitive. + /// @param color Color to draw primitive with. + /// @param thickness Thickness of the arc in pixels. void DrawArcPrimitive(int player, const Vector& centerPos, float startAngle, float endAngle, int radius, unsigned char color, int thickness); - /// /// Schedule to draw a Bezier spline primitive. - /// - /// Start position of primitive in scene coordinates. - /// The first guide point that controls the curve of the spline. The spline won't necessarily pass through this point, but it will affect it's shape. - /// The second guide point that controls the curve of the spline. The spline won't necessarily pass through this point, but it will affect it's shape. - /// End position of primitive in scene coordinates. - /// Color to draw primitive with. + /// @param startPos Start position of primitive in scene coordinates. + /// @param guideA The first guide point that controls the curve of the spline. The spline won't necessarily pass through this point, but it will affect it's shape. + /// @param guideB The second guide point that controls the curve of the spline. The spline won't necessarily pass through this point, but it will affect it's shape. + /// @param endPos End position of primitive in scene coordinates. + /// @param color Color to draw primitive with. void DrawSplinePrimitive(const Vector& startPos, const Vector& guideA, const Vector& guideB, const Vector& endPos, unsigned char color); - /// /// Schedule to draw a Bezier spline primitive visible only to a specified player. - /// - /// Player screen to draw primitive on. - /// Start position of primitive in scene coordinates. - /// The first guide point that controls the curve of the spline. The spline won't necessarily pass through this point, but it will affect it's shape. - /// The second guide point that controls the curve of the spline. The spline won't necessarily pass through this point, but it will affect it's shape. - /// End position of primitive in scene coordinates. - /// Color to draw primitive with. + /// @param player Player screen to draw primitive on. + /// @param startPos Start position of primitive in scene coordinates. + /// @param guideA The first guide point that controls the curve of the spline. The spline won't necessarily pass through this point, but it will affect it's shape. + /// @param guideB The second guide point that controls the curve of the spline. The spline won't necessarily pass through this point, but it will affect it's shape. + /// @param endPos End position of primitive in scene coordinates. + /// @param color Color to draw primitive with. void DrawSplinePrimitive(int player, const Vector& startPos, const Vector& guideA, const Vector& guideB, const Vector& endPos, unsigned char color); - /// /// Schedule to draw a box primitive. - /// - /// Start position of primitive in scene coordinates. Top left corner. - /// End position of primitive in scene coordinates. Bottom right corner. - /// Color to draw primitive with. + /// @param topLeftPos Start position of primitive in scene coordinates. Top left corner. + /// @param bottomRightPos End position of primitive in scene coordinates. Bottom right corner. + /// @param color Color to draw primitive with. void DrawBoxPrimitive(const Vector& topLeftPos, const Vector& bottomRightPos, unsigned char color); - /// /// Schedule to draw a box primitive visible only to a specified player. - /// - /// Player screen to draw primitive on. - /// Start position of primitive in scene coordinates. Top left corner. - /// End position of primitive in scene coordinates. Bottom right corner. - /// Color to draw primitive with. + /// @param player Player screen to draw primitive on. + /// @param topLeftPos Start position of primitive in scene coordinates. Top left corner. + /// @param bottomRightPos End position of primitive in scene coordinates. Bottom right corner. + /// @param color Color to draw primitive with. void DrawBoxPrimitive(int player, const Vector& topLeftPos, const Vector& bottomRightPos, unsigned char color); - /// /// Schedule to draw a filled box primitive. - /// - /// Start position of primitive in scene coordinates. Top left corner. - /// End position of primitive in scene coordinates. Bottom right corner. - /// Color to draw primitive with. + /// @param topLeftPos Start position of primitive in scene coordinates. Top left corner. + /// @param bottomRightPos End position of primitive in scene coordinates. Bottom right corner. + /// @param color Color to draw primitive with. void DrawBoxFillPrimitive(const Vector& topLeftPos, const Vector& bottomRightPos, unsigned char color); - /// /// Schedule to draw a filled box primitive visible only to a specified player. - /// - /// Player screen to draw primitive on. - /// Start position of primitive in scene coordinates. Top left corner. - /// End position of primitive in scene coordinates. Bottom right corner. - /// Color to draw primitive with. + /// @param player Player screen to draw primitive on. + /// @param topLeftPos Start position of primitive in scene coordinates. Top left corner. + /// @param bottomRightPos End position of primitive in scene coordinates. Bottom right corner. + /// @param color Color to draw primitive with. void DrawBoxFillPrimitive(int player, const Vector& topLeftPos, const Vector& bottomRightPos, unsigned char color); - /// /// Schedule to draw a rounded box primitive. - /// - /// Start position of primitive in scene coordinates. Top left corner. - /// End position of primitive in scene coordinates. Bottom right corner. - /// The radius of the corners of the box. Smaller radius equals sharper corners. - /// Color to draw primitive with. + /// @param topLeftPos Start position of primitive in scene coordinates. Top left corner. + /// @param bottomRightPos End position of primitive in scene coordinates. Bottom right corner. + /// @param cornerRadius The radius of the corners of the box. Smaller radius equals sharper corners. + /// @param color Color to draw primitive with. void DrawRoundedBoxPrimitive(const Vector& topLeftPos, const Vector& bottomRightPos, int cornerRadius, unsigned char color); - /// /// Schedule to draw a rounded box primitive visible only to a specified player. - /// - /// Player screen to draw primitive on. - /// Start position of primitive in scene coordinates. Top left corner. - /// End position of primitive in scene coordinates. Bottom right corner. - /// The radius of the corners of the box. Smaller radius equals sharper corners. - /// Color to draw primitive with. + /// @param player Player screen to draw primitive on. + /// @param topLeftPos Start position of primitive in scene coordinates. Top left corner. + /// @param bottomRightPos End position of primitive in scene coordinates. Bottom right corner. + /// @param cornerRadius The radius of the corners of the box. Smaller radius equals sharper corners. + /// @param color Color to draw primitive with. void DrawRoundedBoxPrimitive(int player, const Vector& topLeftPos, const Vector& bottomRightPos, int cornerRadius, unsigned char color); - /// /// Schedule to draw a filled rounded box primitive. - /// - /// Start position of primitive in scene coordinates. Top left corner. - /// End position of primitive in scene coordinates. Bottom right corner. - /// The radius of the corners of the box. Smaller radius equals sharper corners. - /// Color to draw primitive with. + /// @param topLeftPos Start position of primitive in scene coordinates. Top left corner. + /// @param bottomRightPos End position of primitive in scene coordinates. Bottom right corner. + /// @param cornerRadius The radius of the corners of the box. Smaller radius equals sharper corners. + /// @param color Color to draw primitive with. void DrawRoundedBoxFillPrimitive(const Vector& topLeftPos, const Vector& bottomRightPos, int cornerRadius, unsigned char color); - /// /// Schedule to draw a filled rounded box primitive visible only to a specified player. - /// - /// Player screen to draw primitive on. - /// Start position of primitive in scene coordinates. Top left corner. - /// End position of primitive in scene coordinates. Bottom right corner. - /// The radius of the corners of the box. Smaller radius equals sharper corners. - /// Color to draw primitive with. + /// @param player Player screen to draw primitive on. + /// @param topLeftPos Start position of primitive in scene coordinates. Top left corner. + /// @param bottomRightPos End position of primitive in scene coordinates. Bottom right corner. + /// @param cornerRadius The radius of the corners of the box. Smaller radius equals sharper corners. + /// @param color Color to draw primitive with. void DrawRoundedBoxFillPrimitive(int player, const Vector& topLeftPos, const Vector& bottomRightPos, int cornerRadius, unsigned char color); - /// /// Schedule to draw a circle primitive. - /// - /// Position of primitive's center in scene coordinates. - /// Radius of circle primitive. - /// Color to draw primitive with. + /// @param centerPos Position of primitive's center in scene coordinates. + /// @param radius Radius of circle primitive. + /// @param color Color to draw primitive with. void DrawCirclePrimitive(const Vector& centerPos, int radius, unsigned char color); - /// /// Schedule to draw a circle primitive visible only to a specified player. - /// - /// Player screen to draw primitive on. - /// Position of primitive's center in scene coordinates. - /// Radius of circle primitive. - /// Color to draw primitive with. + /// @param player Player screen to draw primitive on. + /// @param centerPos Position of primitive's center in scene coordinates. + /// @param radius Radius of circle primitive. + /// @param color Color to draw primitive with. void DrawCirclePrimitive(int player, const Vector& centerPos, int radius, unsigned char color); - /// /// Schedule to draw a filled circle primitive. - /// - /// Position of primitive's center in scene coordinates. - /// Radius of circle primitive. - /// Color to fill primitive with. + /// @param centerPos Position of primitive's center in scene coordinates. + /// @param radius Radius of circle primitive. + /// @param color Color to fill primitive with. void DrawCircleFillPrimitive(const Vector& centerPos, int radius, unsigned char color); - /// /// Schedule to draw a filled circle primitive visible only to a specified player. - /// - /// Player screen to draw primitive on. - /// Position of primitive's center in scene coordinates. - /// Radius of circle primitive. - /// Color to fill primitive with. + /// @param player Player screen to draw primitive on. + /// @param centerPos Position of primitive's center in scene coordinates. + /// @param radius Radius of circle primitive. + /// @param color Color to fill primitive with. void DrawCircleFillPrimitive(int player, const Vector& centerPos, int radius, unsigned char color); - /// /// Schedule to draw an ellipse primitive. - /// - /// Position of primitive's center in scene coordinates. - /// Horizontal radius of the ellipse primitive. - /// Vertical radius of the ellipse primitive. - /// Color to draw primitive with. + /// @param centerPos Position of primitive's center in scene coordinates. + /// @param horizRadius Horizontal radius of the ellipse primitive. + /// @param vertRadius Vertical radius of the ellipse primitive. + /// @param color Color to draw primitive with. void DrawEllipsePrimitive(const Vector& centerPos, int horizRadius, int vertRadius, unsigned char color); - /// /// Schedule to draw an ellipse primitive visible only to a specified player. - /// - /// Player screen to draw primitive on. - /// Position of primitive's center in scene coordinates. - /// Horizontal radius of the ellipse primitive. - /// Vertical radius of the ellipse primitive. - /// Color to draw primitive with. + /// @param player Player screen to draw primitive on. + /// @param centerPos Position of primitive's center in scene coordinates. + /// @param horizRadius Horizontal radius of the ellipse primitive. + /// @param vertRadius Vertical radius of the ellipse primitive. + /// @param color Color to draw primitive with. void DrawEllipsePrimitive(int player, const Vector& centerPos, int horizRadius, int vertRadius, unsigned char color); - /// /// Schedule to draw a filled ellipse primitive. - /// - /// Position of primitive's center in scene coordinates. - /// Horizontal radius of the ellipse primitive. - /// Vertical radius of the ellipse primitive. - /// Color to fill primitive with. + /// @param centerPos Position of primitive's center in scene coordinates. + /// @param horizRadius Horizontal radius of the ellipse primitive. + /// @param vertRadius Vertical radius of the ellipse primitive. + /// @param color Color to fill primitive with. void DrawEllipseFillPrimitive(const Vector& centerPos, int horizRadius, int vertRadius, unsigned char color); - /// /// Schedule to draw a filled ellipse primitive visible only to a specified player. - /// - /// Player screen to draw primitive on. - /// Position of primitive's center in scene coordinates. - /// Horizontal radius of the ellipse primitive. - /// Vertical radius of the ellipse primitive. - /// Color to fill primitive with. + /// @param player Player screen to draw primitive on. + /// @param centerPos Position of primitive's center in scene coordinates. + /// @param horizRadius Horizontal radius of the ellipse primitive. + /// @param vertRadius Vertical radius of the ellipse primitive. + /// @param color Color to fill primitive with. void DrawEllipseFillPrimitive(int player, const Vector& centerPos, int horizRadius, int vertRadius, unsigned char color); - /// /// Schedule to draw a triangle primitive. - /// - /// Position of the first point of the triangle in scene coordinates. - /// Position of the second point of the triangle in scene coordinates. - /// Position of the third point of the triangle in scene coordinates. - /// Color to fill primitive with. + /// @param pointA Position of the first point of the triangle in scene coordinates. + /// @param pointB Position of the second point of the triangle in scene coordinates. + /// @param pointC Position of the third point of the triangle in scene coordinates. + /// @param color Color to fill primitive with. void DrawTrianglePrimitive(const Vector& pointA, const Vector& pointB, const Vector& pointC, unsigned char color); - /// /// Schedule to draw a triangle primitive visible only to a specified player. - /// - /// Player screen to draw primitive on. - /// Position of the first point of the triangle in scene coordinates. - /// Position of the second point of the triangle in scene coordinates. - /// Position of the third point of the triangle in scene coordinates. - /// Color to fill primitive with. + /// @param player Player screen to draw primitive on. + /// @param pointA Position of the first point of the triangle in scene coordinates. + /// @param pointB Position of the second point of the triangle in scene coordinates. + /// @param pointC Position of the third point of the triangle in scene coordinates. + /// @param color Color to fill primitive with. void DrawTrianglePrimitive(int player, const Vector& pointA, const Vector& pointB, const Vector& pointC, unsigned char color); - /// /// Schedule to draw a filled triangle primitive. - /// - /// Position of the first point of the triangle in scene coordinates. - /// Position of the second point of the triangle in scene coordinates. - /// Position of the third point of the triangle in scene coordinates. - /// Color to fill primitive with. + /// @param pointA Position of the first point of the triangle in scene coordinates. + /// @param pointB Position of the second point of the triangle in scene coordinates. + /// @param pointC Position of the third point of the triangle in scene coordinates. + /// @param color Color to fill primitive with. void DrawTriangleFillPrimitive(const Vector& pointA, const Vector& pointB, const Vector& pointC, unsigned char color); - /// /// Schedule to draw a filled triangle primitive visible only to a specified player. - /// - /// Player screen to draw primitive on. - /// Position of the first point of the triangle in scene coordinates. - /// Position of the second point of the triangle in scene coordinates. - /// Position of the third point of the triangle in scene coordinates. - /// Color to fill primitive with. + /// @param player Player screen to draw primitive on. + /// @param pointA Position of the first point of the triangle in scene coordinates. + /// @param pointB Position of the second point of the triangle in scene coordinates. + /// @param pointC Position of the third point of the triangle in scene coordinates. + /// @param color Color to fill primitive with. void DrawTriangleFillPrimitive(int player, const Vector& pointA, const Vector& pointB, const Vector& pointC, unsigned char color); - /// /// Schedule to draw a polygon primitive visible only to a specified player. - /// - /// Player screen to draw primitive on, or -1 for all players. - /// Start position of the primitive in scene coordinates. - /// Color to draw primitive with. - /// A vector containing the positions of the vertices of the polygon, relative to the center position. - /// Whether a PolygonFillPrimitive should be scheduled instead of PolygonPrimitive. + /// @param player Player screen to draw primitive on, or -1 for all players. + /// @param startPos Start position of the primitive in scene coordinates. + /// @param color Color to draw primitive with. + /// @param vertices A vector containing the positions of the vertices of the polygon, relative to the center position. + /// @param filled Whether a PolygonFillPrimitive should be scheduled instead of PolygonPrimitive. void DrawPolygonOrPolygonFillPrimitive(int player, const Vector& startPos, unsigned char color, const std::vector& vertices, bool filled); - /// /// Schedule to draw a text primitive. - /// - /// Start position of primitive in scene coordinates. - /// Text string to draw. - /// Use small or large font. True for small font. - /// Alignment of text. + /// @param start Start position of primitive in scene coordinates. + /// @param text Text string to draw. + /// @param isSmall Use small or large font. True for small font. + /// @param alignment Alignment of text. void DrawTextPrimitive(const Vector& start, const std::string& text, bool isSmall, int alignment); - /// /// Schedule to draw a text primitive. - /// - /// Start position of primitive in scene coordinates. - /// Text string to draw. - /// Use small or large font. True for small font. - /// Alignment of text. - /// Angle to rotate text in radians. + /// @param start Start position of primitive in scene coordinates. + /// @param text Text string to draw. + /// @param isSmall Use small or large font. True for small font. + /// @param alignment Alignment of text. + /// @param rotAngle Angle to rotate text in radians. void DrawTextPrimitive(const Vector& start, const std::string& text, bool isSmall, int alignment, float rotAngle); - /// /// Schedule to draw a text primitive visible only to a specified player. - /// - /// Player screen to draw primitive on. - /// Start position of primitive in scene coordinates. - /// Text string to draw. - /// Use small or large font. True for small font. - /// Alignment of text. + /// @param player Player screen to draw primitive on. + /// @param start Start position of primitive in scene coordinates. + /// @param text Text string to draw. + /// @param isSmall Use small or large font. True for small font. + /// @param alignment Alignment of text. void DrawTextPrimitive(int player, const Vector& start, const std::string& text, bool isSmall, int alignment); - /// /// Schedule to draw a text primitive visible only to a specified player. - /// - /// Player screen to draw primitive on. - /// Start position of primitive in scene coordinates. - /// Text string to draw. - /// Use small or large font. True for small font. - /// Alignment of text. - /// Angle to rotate text in radians. + /// @param player Player screen to draw primitive on. + /// @param start Start position of primitive in scene coordinates. + /// @param text Text string to draw. + /// @param isSmall Use small or large font. True for small font. + /// @param alignment Alignment of text. + /// @param rotAngle Angle to rotate text in radians. void DrawTextPrimitive(int player, const Vector& start, const std::string& text, bool isSmall, int alignment, float rotAngle); - /// /// Schedule to draw a bitmap primitive. - /// - /// Position of primitive's center in scene coordinates. - /// A MOSprite to draw BITMAP from. - /// Rotation angle in radians. - /// Frame to draw. + /// @param centerPos Position of primitive's center in scene coordinates. + /// @param moSprite A MOSprite to draw BITMAP from. + /// @param rotAngle Rotation angle in radians. + /// @param frame Frame to draw. void DrawBitmapPrimitive(const Vector& centerPos, const MOSprite* moSprite, float rotAngle, int frame) { DrawBitmapPrimitive(-1, centerPos, moSprite, rotAngle, frame, false, false); } - /// /// Schedule to draw a bitmap primitive with the option to flip the primitive horizontally and vertically. - /// - /// Position of primitive's center in scene coordinates. - /// A MOSprite to draw BITMAP from. - /// Rotation angle in radians. - /// Frame to draw. - /// Whether to flip the sprite horizontally. - /// Whether to flip the sprite vertically. + /// @param centerPos Position of primitive's center in scene coordinates. + /// @param moSprite A MOSprite to draw BITMAP from. + /// @param rotAngle Rotation angle in radians. + /// @param frame Frame to draw. + /// @param hFlipped Whether to flip the sprite horizontally. + /// @param vFlipped Whether to flip the sprite vertically. void DrawBitmapPrimitive(const Vector& centerPos, const MOSprite* moSprite, float rotAngle, int frame, bool hFlipped, bool vFlipped) { DrawBitmapPrimitive(-1, centerPos, moSprite, rotAngle, frame, hFlipped, vFlipped); } - /// /// Schedule to draw a bitmap primitive visible only to a specified player. - /// - /// Player screen to draw primitive on. - /// Position of primitive's center in scene coordinates. - /// A MOSprite to draw BITMAP from. - /// Rotation angle in radians. - /// Frame to draw. + /// @param player Player screen to draw primitive on. + /// @param centerPos Position of primitive's center in scene coordinates. + /// @param moSprite A MOSprite to draw BITMAP from. + /// @param rotAngle Rotation angle in radians. + /// @param frame Frame to draw. void DrawBitmapPrimitive(int player, const Vector& centerPos, const MOSprite* moSprite, float rotAngle, int frame) { DrawBitmapPrimitive(player, centerPos, moSprite, rotAngle, frame, false, false); } - /// /// Schedule to draw a bitmap primitive visible only to a specified player with the option to flip the primitive horizontally or vertically. - /// - /// Player screen to draw primitive on. - /// Position of primitive's center in scene coordinates. - /// A MOSprite to draw BITMAP from. - /// Rotation angle in radians. - /// Frame to draw. - /// Whether to flip the sprite horizontally. - /// Whether to flip the sprite vertically. + /// @param player Player screen to draw primitive on. + /// @param centerPos Position of primitive's center in scene coordinates. + /// @param moSprite A MOSprite to draw BITMAP from. + /// @param rotAngle Rotation angle in radians. + /// @param frame Frame to draw. + /// @param hFlipped Whether to flip the sprite horizontally. + /// @param vFlipped Whether to flip the sprite vertically. void DrawBitmapPrimitive(int player, const Vector& centerPos, const MOSprite* moSprite, float rotAngle, int frame, bool hFlipped, bool vFlipped); - /// /// Schedule to draw a bitmap primitive. - /// - /// Position of primitive's center in scene coordinates. - /// Path to the bitmap to draw. - /// Rotation angle in radians. + /// @param centerPos Position of primitive's center in scene coordinates. + /// @param filePath Path to the bitmap to draw. + /// @param rotAngle Rotation angle in radians. void DrawBitmapPrimitive(const Vector& centerPos, const std::string& filePath, float rotAngle) { DrawBitmapPrimitive(-1, centerPos, filePath, rotAngle, false, false); } - /// /// Schedule to draw a bitmap primitive with the option to flip the primitive horizontally and vertically. - /// - /// Position of primitive's center in scene coordinates. - /// An entity to draw sprite from. - /// Rotation angle in radians. - /// Whether to flip the sprite horizontally. - /// Whether to flip the sprite vertically. + /// @param centerPos Position of primitive's center in scene coordinates. + /// @param filePath An entity to draw sprite from. + /// @param rotAngle Rotation angle in radians. + /// @param hFlipped Whether to flip the sprite horizontally. + /// @param vFlipped Whether to flip the sprite vertically. void DrawBitmapPrimitive(const Vector& centerPos, const std::string& filePath, float rotAngle, bool hFlipped, bool vFlipped) { DrawBitmapPrimitive(-1, centerPos, filePath, rotAngle, hFlipped, vFlipped); } - /// /// Schedule to draw a bitmap primitive visible only to a specified player. - /// - /// Player screen to draw primitive on. - /// Position of primitive's center in scene coordinates. - /// Path to the bitmap to draw. - /// Rotation angle in radians. + /// @param player Player screen to draw primitive on. + /// @param centerPos Position of primitive's center in scene coordinates. + /// @param filePath Path to the bitmap to draw. + /// @param rotAngle Rotation angle in radians. void DrawBitmapPrimitive(int player, const Vector& centerPos, const std::string& filePath, float rotAngle) { DrawBitmapPrimitive(player, centerPos, filePath, rotAngle, false, false); } - /// /// Schedule to draw a bitmap primitive visible only to a specified player with the option to flip the primitive horizontally or vertically. - /// - /// Player screen to draw primitive on. - /// Position of primitive's center in scene coordinates. - /// Path to the bitmap to draw. - /// Rotation angle in radians. - /// Whether to flip the sprite horizontally. - /// Whether to flip the sprite vertically. + /// @param player Player screen to draw primitive on. + /// @param centerPos Position of primitive's center in scene coordinates. + /// @param filePath Path to the bitmap to draw. + /// @param rotAngle Rotation angle in radians. + /// @param hFlipped Whether to flip the sprite horizontally. + /// @param vFlipped Whether to flip the sprite vertically. void DrawBitmapPrimitive(int player, const Vector& centerPos, const std::string& filePath, float rotAngle, bool hFlipped, bool vFlipped); - /// /// Schedule to draw the GUI icon of an object. - /// - /// Position of primitive's center in scene coordinates. - /// An entity to draw sprite from. + /// @param centerPos Position of primitive's center in scene coordinates. + /// @param entity An entity to draw sprite from. void DrawIconPrimitive(const Vector& centerPos, Entity* entity) { DrawIconPrimitive(-1, centerPos, entity); } - /// /// Schedule to draw the GUI icon of an object, visible only to a specified player. - /// - /// Player screen to draw primitive on. - /// Position of primitive's center in scene coordinates. - /// An entity to draw sprite from. + /// @param player Player screen to draw primitive on. + /// @param centerPos Position of primitive's center in scene coordinates. + /// @param entity An entity to draw sprite from. void DrawIconPrimitive(int player, const Vector& centerPos, Entity* entity); #pragma endregion @@ -486,18 +386,14 @@ namespace RTE { std::deque> m_ScheduledPrimitives; //!< List of graphical primitives scheduled to draw this frame, cleared every frame during FrameMan::Draw(). private: - /// /// Constructs a unique_ptr of the appropriate derived type from the passed in GraphicalPrimitive raw pointer. /// This is used for preparing primitives constructed in Lua for scheduling. - /// - /// Raw pointer to the GraphicalPrimitive object to make unique. - /// A unique_ptr of the appropriate derived GraphicalPrimitive type. Ownership is transferred! + /// @param primitive Raw pointer to the GraphicalPrimitive object to make unique. + /// @return A unique_ptr of the appropriate derived GraphicalPrimitive type. Ownership is transferred! std::unique_ptr MakeUniqueOfAppropriateTypeFromPrimitiveRawPtr(GraphicalPrimitive* primitive); - /// /// Safely schedules a primite to draw in a thread-safe manner. - /// - /// A unique ptr of the primitive to schedule for drawing. + /// @param primitive A unique ptr of the primitive to schedule for drawing. void SchedulePrimitive(std::unique_ptr&& primitive); // Disallow the use of some implicit methods. diff --git a/Source/Managers/SceneMan.cpp b/Source/Managers/SceneMan.cpp index a668f79532..f96fc580ff 100644 --- a/Source/Managers/SceneMan.cpp +++ b/Source/Managers/SceneMan.cpp @@ -1,14 +1,3 @@ -////////////////////////////////////////////////////////////////////////////////////////// -// File: SceneMan.cpp -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Source file for the SceneMan class. -// Project: Retro Terrain Engine -// Author(s): Daniel Tabar -// data@datarealms.com -// http://www.datarealms.com - -////////////////////////////////////////////////////////////////////////////////////////// -// Inclusions of header files #include "NetworkServer.h" #include "NetworkClient.h" @@ -47,8 +36,6 @@ namespace RTE { // Stored as a thread-local instead of in the class, because multithreaded Lua scripts will interfere otherwise thread_local Vector s_LastRayHitPos; - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SceneMan::Clear() { m_DefaultSceneName = "Tutorial Bunker"; m_pSceneToLoad = nullptr; @@ -82,8 +69,6 @@ namespace RTE { m_ScrapCompactingHeight = 25; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SceneMan::Initialize() const { // Can't create these earlier in the static declaration because allegro_init needs to be called before create_bitmap m_IntermediateSettlingBitmaps = { @@ -99,8 +84,6 @@ namespace RTE { {512, create_bitmap_ex(8, 512, 512)}}; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int SceneMan::Create(std::string readerFile) { Reader* reader = new Reader(); if (reader->Create(readerFile.c_str())) @@ -112,8 +95,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - Material* SceneMan::AddMaterialCopy(Material* mat) { Material* matCopy = dynamic_cast(mat->Clone()); if (matCopy) @@ -122,8 +103,6 @@ namespace RTE { return matCopy; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int SceneMan::LoadScene(Scene* pNewScene, bool placeObjects, bool placeUnits) { if (!pNewScene) { return -1; @@ -205,8 +184,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int SceneMan::SetSceneToLoad(std::string sceneName, bool placeObjects, bool placeUnits) { // Use the name passed in to load the preset requested const Scene* pSceneRef = dynamic_cast(g_PresetMan.GetEntityPreset("Scene", sceneName)); @@ -222,8 +199,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int SceneMan::LoadScene() { // In case we have no set Scene reference to load from, do something graceful about it if (!m_pSceneToLoad) { @@ -241,8 +216,6 @@ namespace RTE { return LoadScene(dynamic_cast(m_pSceneToLoad->Clone()), m_PlaceObjects, m_PlaceUnits); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int SceneMan::LoadScene(std::string sceneName, bool placeObjects, bool placeUnits) { // First retrieve and set up the preset reference int error = SetSceneToLoad(sceneName, placeObjects, placeUnits); @@ -253,8 +226,6 @@ namespace RTE { return error; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int SceneMan::ReadProperty(const std::string_view& propName, Reader& reader) { StartPropertyList(return Serializable::ReadProperty(propName, reader)); @@ -307,8 +278,6 @@ namespace RTE { EndPropertyList; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int SceneMan::Save(Writer& writer) const { g_ConsoleMan.PrintString("ERROR: Tried to save SceneMan, screen does not make sense"); @@ -321,8 +290,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SceneMan::Destroy() { for (int i = 0; i < c_PaletteEntriesNumber; ++i) delete m_apMatPalette[i]; @@ -343,8 +310,6 @@ namespace RTE { Clear(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - Vector SceneMan::GetSceneDim() const { if (m_pCurrentScene) { RTEAssert(m_pCurrentScene->GetTerrain() && m_pCurrentScene->GetTerrain()->GetBitmap(), "Trying to get terrain info before there is a scene or terrain!"); @@ -353,8 +318,6 @@ namespace RTE { return Vector(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int SceneMan::GetSceneWidth() const { if (g_NetworkClient.IsConnectedAndRegistered()) { return g_NetworkClient.GetSceneWidth(); @@ -365,8 +328,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int SceneMan::GetSceneHeight() const { // RTEAssert(m_pCurrentScene, "Trying to get terrain info before there is a scene or terrain!"); if (m_pCurrentScene) @@ -374,8 +335,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool SceneMan::SceneWrapsX() const { if (g_NetworkClient.IsConnectedAndRegistered()) { return g_NetworkClient.SceneWrapsX(); @@ -386,16 +345,12 @@ namespace RTE { return false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool SceneMan::SceneWrapsY() const { if (m_pCurrentScene) return m_pCurrentScene->WrapsY(); return false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - Directions SceneMan::GetSceneOrbitDirection() const { if (m_pCurrentScene) { SLTerrain* terrain = m_pCurrentScene->GetTerrain(); @@ -407,8 +362,6 @@ namespace RTE { return Directions::Up; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - SLTerrain* SceneMan::GetTerrain() { // RTEAssert(m_pCurrentScene, "Trying to get terrain matter before there is a scene or terrain!"); if (m_pCurrentScene) { @@ -418,27 +371,19 @@ namespace RTE { return nullptr; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - BITMAP* SceneMan::GetMOColorBitmap() const { return m_pMOColorLayer->GetBitmap(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - BITMAP* SceneMan::GetDebugBitmap() const { RTEAssert(m_pDebugLayer, "Tried to get debug bitmap but debug layer doesn't exist. Note that the debug layer is only created under certain circumstances."); return m_pDebugLayer->GetBitmap(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - BITMAP* SceneMan::GetMOIDBitmap() const { return m_pMOIDLayer->GetBitmap(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // TEMP! bool SceneMan::MOIDClearCheck() { BITMAP* pMOIDMap = m_pMOIDLayer->GetBitmap(); @@ -456,8 +401,6 @@ namespace RTE { return true; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - unsigned char SceneMan::GetTerrMatter(int pixelX, int pixelY) { RTEAssert(m_pCurrentScene, "Trying to get terrain matter before there is a scene or terrain!"); @@ -484,8 +427,6 @@ namespace RTE { return getpixel(pTMatBitmap, pixelX, pixelY); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - MOID SceneMan::GetMOIDPixel(int pixelX, int pixelY, int ignoreTeam) { WrapPosition(pixelX, pixelY); @@ -516,8 +457,6 @@ namespace RTE { return moid; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - Material const* SceneMan::GetMaterial(const std::string& matName) { std::map::iterator itr = m_MatNameMap.find(matName); if (itr == m_MatNameMap.end()) { @@ -527,15 +466,11 @@ namespace RTE { return m_apMatPalette.at((*itr).second); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - Vector SceneMan::GetGlobalAcc() const { RTEAssert(m_pCurrentScene, "Trying to get terrain matter before there is a scene or terrain!"); return m_pCurrentScene->GetGlobalAcc(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SceneMan::LockScene() { // RTEAssert(!m_pCurrentScene->IsLocked(), "Hey, locking already locked scene!"); if (m_pCurrentScene && !m_pCurrentScene->IsLocked()) { @@ -545,8 +480,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SceneMan::UnlockScene() { // RTEAssert(m_pCurrentScene->IsLocked(), "Hey, unlocking already unlocked scene!"); if (m_pCurrentScene && m_pCurrentScene->IsLocked()) { @@ -556,15 +489,11 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool SceneMan::SceneIsLocked() const { RTEAssert(m_pCurrentScene, "Trying to check if scene is locked before there is a scene or terrain!"); return m_pCurrentScene->IsLocked(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SceneMan::RegisterDrawing(const BITMAP* bitmap, int moid, int left, int top, int right, int bottom) { if (m_pMOColorLayer && m_pMOColorLayer->GetBitmap() == bitmap) { m_pMOColorLayer->RegisterDrawing(left, top, right, bottom); @@ -581,16 +510,12 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SceneMan::RegisterDrawing(const BITMAP* bitmap, int moid, const Vector& center, float radius) { if (radius != 0.0F) { RegisterDrawing(bitmap, moid, static_cast(std::floor(center.m_X - radius)), static_cast(std::floor(center.m_Y - radius)), static_cast(std::floor(center.m_X + radius)), static_cast(std::floor(center.m_Y + radius))); } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SceneMan::ClearAllMOIDDrawings() { #ifdef DRAW_MOID_LAYER m_pMOIDLayer->ClearBitmap(g_NoMOID); @@ -599,8 +524,6 @@ namespace RTE { #endif } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool SceneMan::WillPenetrate(const int posX, const int posY, const Vector& impulse) { @@ -614,8 +537,6 @@ namespace RTE { return impulse.MagnitudeIsGreaterThan(integrity); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int SceneMan::RemoveOrphans(int posX, int posY, int radius, int maxArea, bool remove) { if (radius > MAXORPHANRADIUS) radius = MAXORPHANRADIUS; @@ -630,8 +551,6 @@ namespace RTE { return area; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int SceneMan::RemoveOrphans(int posX, int posY, int centerPosX, int centerPosY, int accumulatedArea, int radius, int maxArea, bool remove) { @@ -717,8 +636,6 @@ namespace RTE { return area; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SceneMan::RegisterTerrainChange(int x, int y, int w, int h, unsigned char color, bool back) { if (!g_NetworkServer.IsServerModeEnabled()) return; @@ -815,8 +732,6 @@ namespace RTE { g_NetworkServer.RegisterTerrainChange(tc); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool SceneMan::TryPenetrate(int posX, int posY, const Vector& impulse, @@ -967,8 +882,6 @@ namespace RTE { return false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - MovableObject* SceneMan::DislodgePixel(int posX, int posY) { int materialID = getpixel(m_pCurrentScene->GetTerrain()->GetMaterialBitmap(), posX, posY); if (materialID <= MaterialColorKeys::g_MaterialAir) { @@ -999,8 +912,6 @@ namespace RTE { return pixelMO; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SceneMan::MakeAllUnseen(Vector pixelSize, const int team) { RTEAssert(m_pCurrentScene, "Messing with scene before the scene exists!"); if (team < Activity::TeamOne || team >= Activity::MaxTeamCount) @@ -1009,8 +920,6 @@ namespace RTE { m_pCurrentScene->FillUnseenLayer(pixelSize, team); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool SceneMan::LoadUnseenLayer(std::string bitmapPath, int team) { ContentFile bitmapFile(bitmapPath.c_str()); SceneLayer* pUnseenLayer = new SceneLayer(); @@ -1024,8 +933,6 @@ namespace RTE { return true; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool SceneMan::AnythingUnseen(const int team) { RTEAssert(m_pCurrentScene, "Checking scene before the scene exists when checking if anything is unseen!"); @@ -1033,8 +940,6 @@ namespace RTE { // TODO: Actually check all pixels on the map too? } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - Vector SceneMan::GetUnseenResolution(const int team) const { RTEAssert(m_pCurrentScene, "Checking scene before the scene exists when getting unseen resolution!"); if (team < Activity::TeamOne || team >= Activity::MaxTeamCount) @@ -1047,8 +952,6 @@ namespace RTE { return Vector(1, 1); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool SceneMan::IsUnseen(const int posX, const int posY, const int team) { RTEAssert(m_pCurrentScene, "Checking scene before the scene exists when checking if a position is unseen!"); if (team < Activity::TeamOne || team >= Activity::MaxTeamCount) @@ -1066,8 +969,6 @@ namespace RTE { return false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool SceneMan::RevealUnseen(const int posX, const int posY, const int team) { RTEAssert(m_pCurrentScene, "Checking scene before the scene exists when revealing an unseen position!"); if (team < Activity::TeamOne || team >= Activity::MaxTeamCount) @@ -1098,8 +999,6 @@ namespace RTE { return false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool SceneMan::RestoreUnseen(const int posX, const int posY, const int team) { RTEAssert(m_pCurrentScene, "Checking scene before the scene exists when making a position unseen!"); if (team < Activity::TeamOne || team >= Activity::MaxTeamCount) @@ -1130,8 +1029,6 @@ namespace RTE { return false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SceneMan::RevealUnseenBox(const int posX, const int posY, const int width, const int height, const int team) { RTEAssert(m_pCurrentScene, "Checking scene before the scene exists when revealing an unseen area!"); if (team < Activity::TeamOne || team >= Activity::MaxTeamCount) @@ -1151,8 +1048,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SceneMan::RestoreUnseenBox(const int posX, const int posY, const int width, const int height, const int team) { RTEAssert(m_pCurrentScene, "Checking scene before the scene exists when making an area unseen!"); if (team < Activity::TeamOne || team >= Activity::MaxTeamCount) @@ -1172,8 +1067,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // TODO Every raycast should use some shared line drawing method (or maybe something more efficient if it exists, that needs looking into) instead of having a ton of duplicated code. bool SceneMan::CastUnseenRay(int team, const Vector& start, const Vector& ray, Vector& endPos, int strengthLimit, int skip, bool reveal) { if (!m_pCurrentScene->GetUnseenLayer(team)) @@ -1270,20 +1163,14 @@ namespace RTE { return affectedAny; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool SceneMan::CastSeeRay(int team, const Vector& start, const Vector& ray, Vector& endPos, int strengthLimit, int skip) { return CastUnseenRay(team, start, ray, endPos, strengthLimit, skip, true); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool SceneMan::CastUnseeRay(int team, const Vector& start, const Vector& ray, Vector& endPos, int strengthLimit, int skip) { return CastUnseenRay(team, start, ray, endPos, strengthLimit, skip, false); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool SceneMan::CastMaterialRay(const Vector& start, const Vector& ray, unsigned char material, Vector& result, int skip, bool wrap) { int hitCount = 0, error, dom, sub, domSteps, skipped = skip; @@ -1366,8 +1253,6 @@ namespace RTE { return foundPixel; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - float SceneMan::CastMaterialRay(const Vector& start, const Vector& ray, unsigned char material, int skip) { Vector result; if (CastMaterialRay(start, ray, material, result, skip)) { @@ -1380,8 +1265,6 @@ namespace RTE { return -1; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool SceneMan::CastNotMaterialRay(const Vector& start, const Vector& ray, unsigned char material, Vector& result, int skip, bool checkMOs) { int hitCount = 0, error, dom, sub, domSteps, skipped = skip; int intPos[2], delta[2], delta2[2], increment[2]; @@ -1463,8 +1346,6 @@ namespace RTE { return foundPixel; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - float SceneMan::CastNotMaterialRay(const Vector& start, const Vector& ray, unsigned char material, int skip, bool checkMOs) { Vector result; if (CastNotMaterialRay(start, ray, material, result, skip, checkMOs)) { @@ -1477,8 +1358,6 @@ namespace RTE { return -1; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - float SceneMan::CastStrengthSumRay(const Vector& start, const Vector& end, int skip, unsigned char ignoreMaterial) { Vector ray = g_SceneMan.ShortestDistance(start, end); float strengthSum = 0; @@ -1560,14 +1439,10 @@ namespace RTE { return strengthSum; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - float SceneMan::CastMaxStrengthRay(const Vector& start, const Vector& end, int skip, unsigned char ignoreMaterial) { return CastMaxStrengthRayMaterial(start, end, skip, ignoreMaterial)->GetIntegrity(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - const Material* SceneMan::CastMaxStrengthRayMaterial(const Vector& start, const Vector& end, int skip, unsigned char ignoreMaterial) { Vector ray = g_SceneMan.ShortestDistance(start, end); const Material* strongestMaterial = GetMaterialFromID(MaterialColorKeys::g_MaterialAir); @@ -1651,8 +1526,6 @@ namespace RTE { return strongestMaterial; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool SceneMan::CastStrengthRay(const Vector& start, const Vector& ray, float strength, Vector& result, int skip, unsigned char ignoreMaterial, bool wrap) { int hitCount = 0, error, dom, sub, domSteps, skipped = skip; int intPos[2], delta[2], delta2[2], increment[2]; @@ -1746,8 +1619,6 @@ namespace RTE { return foundPixel; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool SceneMan::CastWeaknessRay(const Vector& start, const Vector& ray, float strength, Vector& result, int skip, bool wrap) { int hitCount = 0, error, dom, sub, domSteps, skipped = skip; int intPos[2], delta[2], delta2[2], increment[2]; @@ -1838,8 +1709,6 @@ namespace RTE { return foundPixel; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - MOID SceneMan::CastMORay(const Vector& start, const Vector& ray, MOID ignoreMOID, int ignoreTeam, unsigned char ignoreMaterial, bool ignoreAllTerrain, int skip) { int hitCount = 0, error, dom, sub, domSteps, skipped = skip; int intPos[2], delta[2], delta2[2], increment[2]; @@ -1950,8 +1819,6 @@ namespace RTE { return g_NoMOID; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool SceneMan::CastFindMORay(const Vector& start, const Vector& ray, MOID targetMOID, Vector& resultPos, unsigned char ignoreMaterial, bool ignoreAllTerrain, int skip) { int hitCount = 0, error, dom, sub, domSteps, skipped = skip; int intPos[2], delta[2], delta2[2], increment[2]; @@ -2044,8 +1911,6 @@ namespace RTE { return false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - float SceneMan::CastObstacleRay(const Vector& start, const Vector& ray, Vector& obstaclePos, Vector& freePos, MOID ignoreMOID, int ignoreTeam, unsigned char ignoreMaterial, int skip) { int hitCount = 0, error, dom, sub, domSteps, skipped = skip; int intPos[2], delta[2], delta2[2], increment[2]; @@ -2174,15 +2039,11 @@ namespace RTE { return -1.0F; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - const Vector& SceneMan::GetLastRayHitPos() { // The absolute end position of the last ray cast return s_LastRayHitPos; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - float SceneMan::FindAltitude(const Vector& from, int max, int accuracy, bool fromSceneOrbitDirection) { // TODO: Also make this avoid doors Vector temp(from); @@ -2206,16 +2067,12 @@ namespace RTE { return orbitDirection == Directions::Up ? result : g_SceneMan.GetSceneHeight() - result; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool SceneMan::OverAltitude(const Vector& point, int threshold, int accuracy) { Vector temp(point); ForceBounds(temp); return g_SceneMan.CastNotMaterialRay(temp, Vector(0, threshold), g_MaterialAir, accuracy) < 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - Vector SceneMan::MovePointToGround(const Vector& from, int maxAltitude, int accuracy) { // Todo, instead of a nograv area maybe best to tag certain areas as NoGrav. As otherwise it's tricky to keep track of when things are removed if (m_pCurrentScene) { @@ -2240,8 +2097,6 @@ namespace RTE { return groundPoint; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool SceneMan::IsWithinBounds(const int pixelX, const int pixelY, const int margin) { if (m_pCurrentScene) return m_pCurrentScene->GetTerrain()->IsWithinBounds(pixelX, pixelY, margin); @@ -2249,15 +2104,11 @@ namespace RTE { return false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool SceneMan::ForceBounds(int& posX, int& posY) { RTEAssert(m_pCurrentScene, "Trying to access scene before there is one!"); return m_pCurrentScene->GetTerrain()->ForceBounds(posX, posY); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool SceneMan::ForceBounds(Vector& pos) { RTEAssert(m_pCurrentScene, "Trying to access scene before there is one!"); @@ -2272,15 +2123,11 @@ namespace RTE { return wrapped; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool SceneMan::WrapPosition(int& posX, int& posY) { RTEAssert(m_pCurrentScene, "Trying to access scene before there is one!"); return m_pCurrentScene->GetTerrain()->WrapPosition(posX, posY); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool SceneMan::WrapPosition(Vector& pos) { RTEAssert(m_pCurrentScene, "Trying to access scene before there is one!"); @@ -2295,8 +2142,6 @@ namespace RTE { return wrapped; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - Vector SceneMan::SnapPosition(const Vector& pos, bool snap) { Vector snappedPos = pos; @@ -2308,8 +2153,6 @@ namespace RTE { return snappedPos; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - Vector SceneMan::ShortestDistance(Vector pos1, Vector pos2, bool checkBounds) { if (!m_pCurrentScene) return Vector(); @@ -2346,8 +2189,6 @@ namespace RTE { return distance; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - float SceneMan::ShortestDistanceX(float val1, float val2, bool checkBounds, int direction) { if (!m_pCurrentScene) return 0; @@ -2384,8 +2225,6 @@ namespace RTE { return distance; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - float SceneMan::ShortestDistanceY(float val1, float val2, bool checkBounds, int direction) { if (!m_pCurrentScene) return 0; @@ -2422,8 +2261,6 @@ namespace RTE { return distance; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool SceneMan::ObscuredPoint(int x, int y, int team) { bool obscured = m_pCurrentScene->GetTerrain()->GetPixel(x, y) != g_MaterialAir || GetMOIDPixel(x, y, Activity::NoTeam) != g_NoMOID; @@ -2433,8 +2270,6 @@ namespace RTE { return obscured; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int SceneMan::WrapRect(const IntRect& wrapRect, std::list& outputList) { // Always add at least one copy of the unwrapped rect int addedTimes = 1; @@ -2479,8 +2314,6 @@ namespace RTE { return addedTimes; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int SceneMan::WrapBox(const Box& wrapBox, std::list& outputList) { // Unflip the input box, or checking will be tedious Box flipBox(wrapBox); @@ -2525,8 +2358,6 @@ namespace RTE { return addedTimes; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool SceneMan::AddSceneObject(SceneObject* sceneObject) { bool result = false; if (sceneObject) { @@ -2544,8 +2375,6 @@ namespace RTE { return result; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SceneMan::Update(int screenId) { ZoneScoped; @@ -2585,8 +2414,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SceneMan::Draw(BITMAP* targetBitmap, BITMAP* targetGUIBitmap, const Vector& targetPos, bool skipBackgroundLayers, bool skipTerrain) { ZoneScoped; @@ -2677,8 +2504,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SceneMan::ClearMOColorLayer() { m_pMOColorLayer->ClearBitmap(g_MaskColor); if (m_pDebugLayer) { @@ -2686,8 +2511,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SceneMan::ClearSeenPixels() { if (!m_pCurrentScene) return; @@ -2696,14 +2519,10 @@ namespace RTE { m_pCurrentScene->ClearSeenPixels(team); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SceneMan::ClearCurrentScene() { m_pCurrentScene = nullptr; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - BITMAP* SceneMan::GetIntermediateBitmapForSettlingIntoTerrain(int moDiameter) const { int bitmapSizeNeeded = static_cast(std::ceil(static_cast(moDiameter) / 16.0F)) * 16; for (const auto& [bitmapSize, bitmapPtr]: m_IntermediateSettlingBitmaps) { diff --git a/Source/Managers/SceneMan.h b/Source/Managers/SceneMan.h index e4a781aee1..c61b5c2835 100644 --- a/Source/Managers/SceneMan.h +++ b/Source/Managers/SceneMan.h @@ -1,18 +1,11 @@ #ifndef _RTESCENEMAN_ #define _RTESCENEMAN_ -////////////////////////////////////////////////////////////////////////////////////////// -// File: SceneMan.h -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Header file for the SceneMan class. -// Project: Retro Terrain Engine -// Author(s): Daniel Tabar -// data@datarealms.com -// http://www.datarealms.com - -////////////////////////////////////////////////////////////////////////////////////////// -// Inclusions of header files - +/// Header file for the SceneMan class. +/// @author Daniel Tabar +/// data@datarealms.com +/// http://www.datarealms.com +/// Inclusions of header files #include "Serializable.h" #include "Timer.h" #include "Box.h" @@ -50,543 +43,318 @@ namespace RTE { #define SCENESNAPSIZE 12 #define MAXORPHANRADIUS 11 - ////////////////////////////////////////////////////////////////////////////////////////// - // Class: SceneMan - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: The singleton manager of all terrain and backgrounds in the RTE. - // Parent(s): Singleton, Serializable. - // Class history: 12/25/2001 SceneMan created. - + /// The singleton manager of all terrain and backgrounds in the RTE. class SceneMan : public Singleton, public Serializable { friend class SettingsMan; - ////////////////////////////////////////////////////////////////////////////////////////// - // Public member variable, method and friend function declarations - + /// Public member variable, method and friend function declarations public: SerializableClassNameGetter; SerializableOverrideMethods; - ////////////////////////////////////////////////////////////////////////////////////////// - // Constructor: SceneMan - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Constructor method used to instantiate a SceneMan object in system - // memory. Create() should be called before using the object. - // Arguments: None. - + /// Constructor method used to instantiate a SceneMan object in system + /// memory. Create() should be called before using the object. SceneMan() { m_pOrphanSearchBitmap = 0; Clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Destructor: ~SceneMan - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destructor method used to clean up a SceneMan object before deletion - // from system memory. - // Arguments: None. - + /// Destructor method used to clean up a SceneMan object before deletion + /// from system memory. ~SceneMan() { Destroy(); } - /// /// Makes the SceneMan object ready for use. - /// void Initialize() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes the SceneMan object ready for use. - // Arguments: A string with the filepath to a Reader file from screen this SceneMan's - // data should be created. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Makes the SceneMan object ready for use. + /// @param readerFile A string with the filepath to a Reader file from screen this SceneMan's + /// data should be created. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Create(std::string readerFile); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetDefaultSceneName - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the instance name of the default Scene to be loaded if nothing - // else is available. - // Arguments: The default scene instance name. - // Return value: None. - + /// Sets the instance name of the default Scene to be loaded if nothing + /// else is available. + /// @param defaultSceneName The default scene instance name. void SetDefaultSceneName(std::string defaultSceneName) { m_DefaultSceneName = defaultSceneName; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetDefaultSceneName - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the name of the default A to be loaded if nothing - // else is available. - // Arguments: None. - // Return value: The default Scene instance name. - + /// Gets the name of the default A to be loaded if nothing + /// else is available. + /// @return The default Scene instance name. std::string GetDefaultSceneName() const { return m_DefaultSceneName; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: LoadScene - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Actually loads a new Scene into memory. has to be done before using - // this object. - // Arguments: The instance of the Scene, ownership IS transferred! - // Whether the scene should actually apply all its SceneObject:s placed - // in its definition. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Actually loads a new Scene into memory. has to be done before using + /// this object. + /// @param pNewScene The instance of the Scene, ownership IS transferred! + /// @param placeObjects Whether the scene should actually apply all its SceneObject:s placed (default: true) + /// in its definition. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int LoadScene(Scene* pNewScene, bool placeObjects = true, bool placeUnits = true); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetSceneToLoad - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Stores a Scene reference to be loaded later into the SceneMan. - // Arguments: The instance reference of the Scene, ownership IS NOT (!!) transferred! - // Whether the scene should actually apply all its SceneObject:s placed - // in its definition. - // Return value: None. - + /// Stores a Scene reference to be loaded later into the SceneMan. + /// @param pLoadScene The instance reference of the Scene, ownership IS NOT (!!) transferred! + /// @param placeObjects Whether the scene should actually apply all its SceneObject:s placed (default: true) + /// in its definition. void SetSceneToLoad(const Scene* pLoadScene, bool placeObjects = true, bool placeUnits = true) { m_pSceneToLoad = pLoadScene; m_PlaceObjects = placeObjects; m_PlaceUnits = placeUnits; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetSceneToLoad - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets a scene to load later, by preset name. - // Arguments: The name of the Scene preset instance to load. - // Whether the scene should actually apply all its SceneObject:s placed - // in its definition. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Sets a scene to load later, by preset name. + /// @param sceneName The name of the Scene preset instance to load. + /// @param placeObjects Whether the scene should actually apply all its SceneObject:s placed (default: true) + /// in its definition. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int SetSceneToLoad(std::string sceneName, bool placeObjects = true, bool placeUnits = true); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetSceneToLoad - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the stored Scene reference to be loaded later into the SceneMan. - // Arguments: None. - // Return value: The instance reference of the Scene, ownership IS NOT (!!) transferred! - + /// Gets the stored Scene reference to be loaded later into the SceneMan. + /// @return The instance reference of the Scene, ownership IS NOT (!!) transferred! const Scene* GetSceneToLoad() { return m_pSceneToLoad; } - /// /// Gets whether objects are placed when the Scene is initially started. Used for saving/loading games. - /// - /// Whether objects are placed when the Scene is initially started. + /// @return Whether objects are placed when the Scene is initially started. bool GetPlaceObjectsOnLoad() const { return m_PlaceObjects; } - /// /// Gets whether units are placed when the Scene is initially started. Used for saving/loading games. - /// - /// Whether units are placed when the Scene is initially started. + /// @return Whether units are placed when the Scene is initially started. bool GetPlaceUnitsOnLoad() const { return m_PlaceUnits; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: LoadScene - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Actually loads the Scene set to be loaded in SetSceneToLoad. - // Arguments: None. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Actually loads the Scene set to be loaded in SetSceneToLoad. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int LoadScene(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: LoadScene - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Loads a Scene right now, by preset name. - // Arguments: The name of the Scene preset instance to load. - // Whether the scene should actually apply all its SceneObject:s placed - // in its definition. - // Whether the scene should actually deploy all units placed in its definition. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Loads a Scene right now, by preset name. + /// @param sceneName The name of the Scene preset instance to load. + /// @param placeObjects Whether the scene should actually apply all its SceneObject:s placed (default: true) + /// in its definition. + /// @param placeUnits Whether the scene should actually deploy all units placed in its definition. (default: true) + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int LoadScene(std::string sceneName, bool placeObjects = true, bool placeUnits = true); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: LoadScene - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Loads a Scene right now, by preset name. - // Arguments: The name of the Scene preset instance to load. - // Whether the scene should actually apply all its SceneObject:s placed - // in its definition. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Loads a Scene right now, by preset name. + /// @param sceneName The name of the Scene preset instance to load. + /// @param placeObjects Whether the scene should actually apply all its SceneObject:s placed (default: true) { return LoadScene(sceneName) + /// in its definition. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int LoadScene(std::string sceneName, bool placeObjects = true) { return LoadScene(sceneName, placeObjects, true); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Reset - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Resets the entire SceneMan, including its inherited members, to - // their default settings or values. - // Arguments: None. - // Return value: None. - + /// Resets the entire SceneMan, including its inherited members, to + /// their default settings or values. void Reset() override { Clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destroys and resets (through Clear()) the SceneMan object. - // Arguments: None. - // Return value: None. - + /// Destroys and resets (through Clear()) the SceneMan object. void Destroy(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetScene - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the currently loaded scene, if any. - // Arguments: None. - // Return value: The scene, ownership IS NOT TRANSFERRED! - + /// Gets the currently loaded scene, if any. + /// @return The scene, ownership IS NOT TRANSFERRED! Scene* GetScene() const { return m_pCurrentScene; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetSceneDim - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the total dimensions (width and height) of the scene, in pixels. - // Arguments: None. - // Return value: A Vector describing the scene dimensions. - + /// Gets the total dimensions (width and height) of the scene, in pixels. + /// @return A Vector describing the scene dimensions. Vector GetSceneDim() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetSceneWidth - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the total width of the scene, in pixels. - // Arguments: None. - // Return value: An int describing the scene width. - + /// Gets the total width of the scene, in pixels. + /// @return An int describing the scene width. int GetSceneWidth() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetSceneHeight - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the total height of the scene, in pixels. - // Arguments: None. - // Return value: An int describing the scene width. - + /// Gets the total height of the scene, in pixels. + /// @return An int describing the scene width. int GetSceneHeight() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetMaterialPalette - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets access to the whole material palette array of 256 entries. - // Arguments: None. - // Return value: A const reference to the material palette array. - + /// Gets access to the whole material palette array of 256 entries. + /// @return A const reference to the material palette array. const std::array& GetMaterialPalette() const { return m_apMatPalette; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetMaterial - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets a specific material by name. Ownership is NOT transferred! - // Arguments: The string name of the Material to get. - // Return value: A pointer to the requested material, or 0 if no material with that - // name was found. - + /// Gets a specific material by name. Ownership is NOT transferred! + /// @param matName The string name of the Material to get. + /// @return A pointer to the requested material, or 0 if no material with that + /// name was found. Material const* GetMaterial(const std::string& matName); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetMaterialFromID - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets a specific material from the material palette. Ownership is NOT - // transferred! - // Arguments: The unsigned char index specifying screen material to get (0-255). - // Return value: A reference to the requested material. OWNERSHIP IS NOT TRANSFERRED! - + /// Gets a specific material from the material palette. Ownership is NOT + /// transferred! + /// @param screen The unsigned char index specifying screen material to get (0-255). + /// @return A reference to the requested material. OWNERSHIP IS NOT TRANSFERRED! Material const* GetMaterialFromID(unsigned char screen) { return screen >= 0 && screen < c_PaletteEntriesNumber && m_apMatPalette[screen] ? m_apMatPalette[screen] : m_apMatPalette[g_MaterialAir]; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SceneWrapsX - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Indicates whether the scene wraps its scrolling around the X axis. - // Arguments: None. - // Return value: Whether the scene wraps around the X axis or not. - + /// Indicates whether the scene wraps its scrolling around the X axis. + /// @return Whether the scene wraps around the X axis or not. bool SceneWrapsX() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SceneWrapsY - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Indicates whether the scene wraps its scrolling around the Y axis. - // Arguments: None. - // Return value: Whether the scene wraps around the Y axis or not. - + /// Indicates whether the scene wraps its scrolling around the Y axis. + /// @return Whether the scene wraps around the Y axis or not. bool SceneWrapsY() const; - /// /// Gets the orbit direction for the current scene. - /// - /// The orbit direction for the current scene. + /// @return The orbit direction for the current scene. Directions GetSceneOrbitDirection() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetTerrain - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the SLTerrain, or 0 if no scene is loaded. - // Arguments: None. - // Return value: A pointer to the SLTerrain. Ownership is NOT transferred! - + /// Gets the SLTerrain, or 0 if no scene is loaded. + /// @return A pointer to the SLTerrain. Ownership is NOT transferred! SLTerrain* GetTerrain(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetMOColorBitmap - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the bitmap of the intermediary collection SceneLayer that all - // MovableObject:s draw themselves onto before it itself gets drawn onto - // the screen back buffer. - // Arguments: None. - // Return value: A BITMAP pointer to the MO bitmap. Ownership is NOT transferred! - + /// Gets the bitmap of the intermediary collection SceneLayer that all + /// MovableObject:s draw themselves onto before it itself gets drawn onto + /// the screen back buffer. + /// @return A BITMAP pointer to the MO bitmap. Ownership is NOT transferred! BITMAP* GetMOColorBitmap() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetDebugBitmap - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the bitmap of the SceneLayer that debug graphics is drawn onto. - // Will only return valid BITMAP if building with DEBUG_BUILD. - // Arguments: None. - // Return value: A BITMAP pointer to the debug bitmap. Ownership is NOT transferred! - + /// Gets the bitmap of the SceneLayer that debug graphics is drawn onto. + /// Will only return valid BITMAP if building with DEBUG_BUILD. + /// @return A BITMAP pointer to the debug bitmap. Ownership is NOT transferred! BITMAP* GetDebugBitmap() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetMOIDBitmap - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the bitmap of the SceneLayer that all MovableObject:s draw thir - // current (for the frame only!) MOID's onto. - // Arguments: None. - // Return value: A BITMAP pointer to the MO bitmap. Ownership is NOT transferred! - + /// Gets the bitmap of the SceneLayer that all MovableObject:s draw thir + /// current (for the frame only!) MOID's onto. + /// @return A BITMAP pointer to the MO bitmap. Ownership is NOT transferred! BITMAP* GetMOIDBitmap() const; // TEMP! - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: MOIDClearCheck - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes sure the MOID bitmap layer is completely of NoMOID color. - // If found to be not, dumps MOID layer and the FG actor color layer for - // debugging. - // Arguments: None. - // Return value: Was it clear? - + /// Makes sure the MOID bitmap layer is completely of NoMOID color. + /// If found to be not, dumps MOID layer and the FG actor color layer for + /// debugging. + /// @return Was it clear? bool MOIDClearCheck(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetLayerDrawMode - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the current drawing mode of the SceneMan. - // Arguments: None. - // Return value: The current layer draw mode, see the LayerDrawMode enumeration for the - // different possible mode settings. - + /// Gets the current drawing mode of the SceneMan. + /// @return The current layer draw mode, see the LayerDrawMode enumeration for the + /// different possible mode settings. int GetLayerDrawMode() const { return m_LayerDrawMode; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetTerrMatter - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets a specific pixel from the total material representation of - // this Scene. LockScene() must be called before using this method. - // Arguments: The X and Y coordinates of screen material pixel to get. - // Return value: An unsigned char specifying the requested pixel's material index. - + /// Gets a specific pixel from the total material representation of + /// this Scene. LockScene() must be called before using this method. + /// @param pixelX The X and Y coordinates of screen material pixel to get. + /// @return An unsigned char specifying the requested pixel's material index. unsigned char GetTerrMatter(int pixelX, int pixelY); - /// /// Gets a MOID from pixel coordinates in the Scene. LockScene() must be called before using this method. - /// - /// The X coordinate of the Scene pixel to test. - /// The Y coordinate of the Scene pixel to test. - /// The team to ignore. - /// The MOID currently at the specified pixel coordinates. + /// @param pixelX The X coordinate of the Scene pixel to test. + /// @param pixelY The Y coordinate of the Scene pixel to test. + /// @param ignoreTeam The team to ignore. + /// @return The MOID currently at the specified pixel coordinates. MOID GetMOIDPixel(int pixelX, int pixelY, int ignoreTeam); - /// /// Gets a MOID from pixel coordinates in the Scene. LockScene() must be called before using this method. - /// - /// The X coordinate of the Scene pixel to test. - /// The Y coordinate of the Scene pixel to test. - /// The MOID currently at the specified pixel coordinates. + /// @param pixelX The X coordinate of the Scene pixel to test. + /// @param pixelY The Y coordinate of the Scene pixel to test. + /// @return The MOID currently at the specified pixel coordinates. MOID GetMOIDPixel(int pixelX, int pixelY) { return GetMOIDPixel(pixelX, pixelY, Activity::NoTeam); } - /// /// Gets this Scene's MOID SpatialPartitionGrid. - /// - /// This Scene's MOID SpatialPartitionGrid. + /// @return This Scene's MOID SpatialPartitionGrid. const SpatialPartitionGrid& GetMOIDGrid() const { return m_MOIDsGrid; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetGlobalAcc - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the global acceleration (in m/s^2) that is applied to all movable - // objects' velocities during every frame. Typically models gravity. - // Arguments: None. - // Return value: A Vector describing the global acceleration. - + /// Gets the global acceleration (in m/s^2) that is applied to all movable + /// objects' velocities during every frame. Typically models gravity. + /// @return A Vector describing the global acceleration. Vector GetGlobalAcc() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetOzPerKg - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets how many Ounces there are in a metric Kilogram - // Arguments: None. - // Return value: A float describing the Oz/Kg ratio. - + /// Gets how many Ounces there are in a metric Kilogram + /// @return A float describing the Oz/Kg ratio. float GetOzPerKg() const { return 35.27396; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetKgPerOz - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets how many metric Kilograms there are in an Ounce. - // Arguments: None. - // Return value: A float describing the Kg/Oz ratio. - + /// Gets how many metric Kilograms there are in an Ounce. + /// @return A float describing the Kg/Oz ratio. float GetKgPerOz() const { return 0.02834952; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetLayerDrawMode - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the drawing mode of the SceneMan, to easily view what's going on - // in the different internal SceneLayer:s. - // Arguments: The layer mode to draw in, see the LayerDrawMode enumeration for the - // different possible settings. - // Return value: None. - + /// Sets the drawing mode of the SceneMan, to easily view what's going on + /// in the different internal SceneLayer:s. + /// @param mode The layer mode to draw in, see the LayerDrawMode enumeration for the + /// different possible settings. void SetLayerDrawMode(int mode) { m_LayerDrawMode = mode; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: LockScene - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Locks all dynamic internal scene bitmaps so that manipulaitons of the - // scene's color and matter representations can take place. - // Doing it in a separate method like this is more efficient because - // many bitmap manipulaitons can be performed between a lock and unlock. - // UnlockScene() should always be called after accesses are completed. - // Arguments: None. - // Return value: None. - + /// Locks all dynamic internal scene bitmaps so that manipulaitons of the + /// scene's color and matter representations can take place. + /// Doing it in a separate method like this is more efficient because + /// many bitmap manipulaitons can be performed between a lock and unlock. + /// UnlockScene() should always be called after accesses are completed. void LockScene(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: UnlockScene - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Unlocks the scene's bitmaps and prevents access to display memory. - // Doing it in a separate method like this is more efficient because - // many bitmap accesses can be performed between a lock and an unlock. - // UnlockScene() should only be called after LockScene(). - // Arguments: None. - // Return value: None. - + /// Unlocks the scene's bitmaps and prevents access to display memory. + /// Doing it in a separate method like this is more efficient because + /// many bitmap accesses can be performed between a lock and an unlock. + /// UnlockScene() should only be called after LockScene(). void UnlockScene(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SceneIsLocked - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Indicates whether the entire scene is currently locked or not. - // Arguments: None. - // Return value: Whether the entire scene is currently locked or not. - + /// Indicates whether the entire scene is currently locked or not. + /// @return Whether the entire scene is currently locked or not. bool SceneIsLocked() const; - /// /// Registers an area to be drawn upon, so it can be tracked and cleared later. - /// - /// The bitmap being drawn upon. - /// The MOID, if we're drawing MOIDs. - /// The left boundary of the draw area. - /// The top boundary of the drawn area. - /// The right boundary of the draw area. - /// The bottom boundary of the draw area. + /// @param bitmap The bitmap being drawn upon. + /// @param moid The MOID, if we're drawing MOIDs. + /// @param left The left boundary of the draw area. + /// @param top The top boundary of the drawn area. + /// @param right The right boundary of the draw area. + /// @param bottom The bottom boundary of the draw area. void RegisterDrawing(const BITMAP* bitmap, int moid, int left, int top, int right, int bottom); - /// /// Registers an area of to be drawn upon, so it can be tracked and cleared later. - /// - /// The bitmap being drawn upon. - /// The MOID, if we're drawing MOIDs. - /// The centre position of the drawn area. - /// The radius of the drawn area. + /// @param bitmap The bitmap being drawn upon. + /// @param moid The MOID, if we're drawing MOIDs. + /// @param center The centre position of the drawn area. + /// @param radius The radius of the drawn area. void RegisterDrawing(const BITMAP* bitmap, int moid, const Vector& center, float radius); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ClearAllMOIDDrawings - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears all registered drawn areas of the MOID layer to the g_NoMOID - // color and clears the registrations too. Should be done each sim update. - // Arguments: None. - // Return value: None. - + /// Clears all registered drawn areas of the MOID layer to the g_NoMOID + /// color and clears the registrations too. Should be done each sim update. void ClearAllMOIDDrawings(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: WillPenetrate - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Test whether a pixel of the scene would be knocked loose and - // turned into a MO by another particle of a certain material going at a - // certain velocity. Scene needs to be locked to do this! - // Arguments: The X and Y coords of the scene pixel that is collided with. - // The velocity of the incoming particle. - // The mass of the incoming particle. - // Return value: A bool indicating wether the scene pixel would be knocked loose or - // not. If the pixel location specified happens to be of the air - // material (0) false will be returned here. - + /// Test whether a pixel of the scene would be knocked loose and + /// turned into a MO by another particle of a certain material going at a + /// certain velocity. Scene needs to be locked to do this! + /// @param posX The X and Y coords of the scene pixel that is collided with. + /// @param posY The velocity of the incoming particle. + /// @param velocity The mass of the incoming particle. + /// @return A bool indicating wether the scene pixel would be knocked loose or + /// not. If the pixel location specified happens to be of the air + /// material (0) false will be returned here. bool WillPenetrate(const int posX, const int posY, const Vector& velocity, const float mass) { return WillPenetrate(posX, posY, velocity * mass); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: WillPenetrate - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Test whether a pixel of the scene would be knocked loose and - // turned into a MO by a certian impulse force. Scene needs to be locked - // to do this! - // Arguments: The X and Y coords of the scene pixel that is collided with. - // The impulse force vector, in Kg * m/s. - // Return value: A bool indicating wether the scene pixel would be knocked loose or - // not. If the pixel location specified happens to be of the air - // material (0) false will be returned here. - + /// Test whether a pixel of the scene would be knocked loose and + /// turned into a MO by a certian impulse force. Scene needs to be locked + /// to do this! + /// @param posX The X and Y coords of the scene pixel that is collided with. + /// @param posY The impulse force vector, in Kg * m/s. + /// @return A bool indicating wether the scene pixel would be knocked loose or + /// not. If the pixel location specified happens to be of the air + /// material (0) false will be returned here. bool WillPenetrate(const int posX, const int posY, const Vector& impulse); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: TryPenetrate - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Calculate whether a pixel of the scene would be knocked loose and - // turned into a MO by another particle of a certain material going at a - // certain velocity. If so, the incoming particle will knock loose the - // specified pixel in the scene and momentarily take its place. - // Scene needs to be locked to do this! - // Arguments: The X and Y coord of the scene pixel that is to be collided with. - // The impulse force exerted on the terrain pixel. If this magnitude - // exceeds the strength threshold of the material of the terrain pixel - // hit, the terrain pixel will be knocked loose an turned into an MO. - // The velocity of the the point hitting the terrain here. - // A float reference screen will be set to the factor with screen to - // multiply the collision velocity to get the resulting retardation - // (negative acceleration) that occurs when a penetration happens. - // The normalized probability ratio between 0.0 and 1.0 that determines - // the chance of a penetration to remove a pixel from the scene and - // thus replace it with and air pixel. 1.0 = always, 0.0 = never. - // How many consecutive penetrations in a row immediately before this try. - // The size of the area to look for orphaned terrain elements. - // Max area or orphaned area to remove. - // Orphan area removal trigger rate. - // Return value: A bool indicating wether the scene pixel was knocked loose or not. - // If the pixel location specified happens to be of the air material (0) - // false will be returned here. - + /// Calculate whether a pixel of the scene would be knocked loose and + /// turned into a MO by another particle of a certain material going at a + /// certain velocity. If so, the incoming particle will knock loose the + /// specified pixel in the scene and momentarily take its place. + /// Scene needs to be locked to do this! + /// @param posX The X and Y coord of the scene pixel that is to be collided with. + /// @param posY The impulse force exerted on the terrain pixel. If this magnitude + /// exceeds the strength threshold of the material of the terrain pixel + /// hit, the terrain pixel will be knocked loose an turned into an MO. + /// @param impulse The velocity of the the point hitting the terrain here. + /// @param velocity A float reference screen will be set to the factor with screen to + /// multiply the collision velocity to get the resulting retardation + /// (negative acceleration) that occurs when a penetration happens. + /// @param retardation The normalized probability ratio between 0.0 and 1.0 that determines + /// the chance of a penetration to remove a pixel from the scene and + /// thus replace it with and air pixel. 1.0 = always, 0.0 = never. + /// @param airRatio How many consecutive penetrations in a row immediately before this try. + /// @param numPenetrations The size of the area to look for orphaned terrain elements. (default: 0) + /// @param removeOrphansRadius Max area or orphaned area to remove. (default: 0) + /// @param removeOrphansMaxArea Orphan area removal trigger rate. (default: 0) + /// @return A bool indicating wether the scene pixel was knocked loose or not. + /// If the pixel location specified happens to be of the air material (0) + /// false will be returned here. bool TryPenetrate(int posX, int posY, const Vector& impulse, @@ -598,33 +366,25 @@ namespace RTE { const int removeOrphansMaxArea = 0, const float removeOrphansRate = 0.0); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: RemoveOrphans - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns the area of an orphaned region at specified coordinates. - // Arguments: Coordinates to check for region, whether the orphaned region should be converted into MOPixels and region removed. - // Area of orphaned object calculated during recursve function call to check if we're out of limits - // Size of the are to look for orphaned objects - // Max area of orphaned object to remove - // Whether to actually remove orphaned pixels or not - // Whether to clear internal terrain tracking bitmap or not - // Return value: The area of orphaned region at posX,posY - + /// Returns the area of an orphaned region at specified coordinates. + /// @param posX Coordinates to check for region, whether the orphaned region should be converted into MOPixels and region removed. + /// @param posY Area of orphaned object calculated during recursve function call to check if we're out of limits + /// @param radius Size of the are to look for orphaned objects + /// @param maxArea Max area of orphaned object to remove + /// @param remove Whether to actually remove orphaned pixels or not (default: false) + /// Whether to clear internal terrain tracking bitmap or not + /// @return The area of orphaned region at posX,posY int RemoveOrphans(int posX, int posY, int radius, int maxArea, bool remove = false); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: RemoveOrphans - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns the area of an orphaned region at specified coordinates. - // Arguments: Coordinates to check for region, whether the orphaned region should be converted into MOPixels and region removed. - // Coordinates of initial terrain penetration to check, which serves as a center of orphaned object detection. - // Area of orphaned object calculated during recursve function call to check if we're out of limits - // Size of the are to look for orphaned objects - // Max area of orphaned object to remove - // Whether to actually remove orphaned pixels or not - // Whether to clear internal terrain tracking bitmap or not - // Return value: The area of orphaned region at posX,posY - + /// Returns the area of an orphaned region at specified coordinates. + /// @param posX Coordinates to check for region, whether the orphaned region should be converted into MOPixels and region removed. + /// @param posY Coordinates of initial terrain penetration to check, which serves as a center of orphaned object detection. + /// @param centerPosX Area of orphaned object calculated during recursve function call to check if we're out of limits + /// @param centerPosY Size of the are to look for orphaned objects + /// @param accumulatedArea Max area of orphaned object to remove + /// @param radius Whether to actually remove orphaned pixels or not + /// @param maxArea Whether to clear internal terrain tracking bitmap or not + /// @return The area of orphaned region at posX,posY int RemoveOrphans(int posX, int posY, int centerPosX, @@ -634,568 +394,402 @@ namespace RTE { int maxArea, bool remove = false); - /// /// Removes a pixel from the terrain and adds it to MovableMan. - /// - /// The X coordinate of the terrain pixel. - /// The Y coordinate of the terrain pixel. - /// The newly dislodged pixel, if one was found. + /// @param posX The X coordinate of the terrain pixel. + /// @param posX The Y coordinate of the terrain pixel. + /// @return The newly dislodged pixel, if one was found. MovableObject* DislodgePixel(int posX, int posY); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: MakeAllUnseen - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets one team's view of the scene to be unseen, using a generated map - // of a specific resolution chunkiness. - // Arguments: The dimensions of the pixels that should make up the unseen layer. - // The team we're talking about. - // Return value: None. - + /// Sets one team's view of the scene to be unseen, using a generated map + /// of a specific resolution chunkiness. + /// @param pixelSize The dimensions of the pixels that should make up the unseen layer. + /// @param team The team we're talking about. void MakeAllUnseen(Vector pixelSize, const int team); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: MakeAllSeen - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets one team's view of the scene to be all seen. - // Arguments: The team we're talking about. - // Return value: None. - + /// Sets one team's view of the scene to be all seen. + /// @param team The team we're talking about. void MakeAllSeen(const int team); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: LoadUnseenLayer - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Loads a bitmap from file and use it as the unseen layer for a team. - // Arguments: The path to the bitmap to use as the unseen layer. - // Which team we're talking about. - // Return value: Whether the loading was successful or not. - + /// Loads a bitmap from file and use it as the unseen layer for a team. + /// @param bitmapPath The path to the bitmap to use as the unseen layer. + /// @param team Which team we're talking about. + /// @return Whether the loading was successful or not. bool LoadUnseenLayer(std::string bitmapPath, const int team); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: AnythingUnseen - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Tells whether a team has anything still unseen on the scene. - // Arguments: The team we're talking about. - // Return value: A bool indicating whether that team has anyhting yet unseen. - + /// Tells whether a team has anything still unseen on the scene. + /// @param team The team we're talking about. + /// @return A bool indicating whether that team has anyhting yet unseen. bool AnythingUnseen(const int team); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetUnseenResolution - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Shows what the resolution factor of the unseen map to the entire Scene - // is, in both axes. - // Arguments: The team we're talking about. - // Return value: A vector witht he factors in each element representing the factors. - + /// Shows what the resolution factor of the unseen map to the entire Scene + /// is, in both axes. + /// @param team The team we're talking about. + /// @return A vector witht he factors in each element representing the factors. Vector GetUnseenResolution(const int team) const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: IsUnseen - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Checks whether a pixel is in an unseen area on of a specific team. - // Arguments: The X and Y coords of the scene pixel that is to be checked. - // The team we're talking about. - // Return value: A bool indicating whether that point is yet unseen. - + /// Checks whether a pixel is in an unseen area on of a specific team. + /// @param posX The X and Y coords of the scene pixel that is to be checked. + /// @param posY The team we're talking about. + /// @return A bool indicating whether that point is yet unseen. bool IsUnseen(const int posX, const int posY, const int team); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: RevealUnseen - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Reveals a pixel on the unseen map for a specific team, if there is any. - // Arguments: The X and Y coord of the scene pixel that is to be revealed. - // The team to reveal for. - // Return value: A bool indicating whether there was an unseen pixel revealed there. - + /// Reveals a pixel on the unseen map for a specific team, if there is any. + /// @param posX The X and Y coord of the scene pixel that is to be revealed. + /// @param posY The team to reveal for. + /// @return A bool indicating whether there was an unseen pixel revealed there. bool RevealUnseen(const int posX, const int posY, const int team); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: RestoreUnseen - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Hides a pixel on the unseen map for a specific team, if there is any. - // Arguments: The X and Y coord of the scene pixel that is to be revealed. - // The team to hide for. - // Return value: A bool indicating whether there was a seen pixel hidden there. - + /// Hides a pixel on the unseen map for a specific team, if there is any. + /// @param posX The X and Y coord of the scene pixel that is to be revealed. + /// @param posY The team to hide for. + /// @return A bool indicating whether there was a seen pixel hidden there. bool RestoreUnseen(const int posX, const int posY, const int team); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: RevealUnseenBox - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Reveals a box on the unseen map for a specific team, if there is any. - // Arguments: The X and Y coords of the upper left corner of the box to be revealed. - // The width and height of the box to be revealed, in scene units (pixels) - // The team to reveal for. - // Return value: None. - + /// Reveals a box on the unseen map for a specific team, if there is any. + /// @param posX The X and Y coords of the upper left corner of the box to be revealed. + /// @param posY The width and height of the box to be revealed, in scene units (pixels) + /// @param width The team to reveal for. void RevealUnseenBox(const int posX, const int posY, const int width, const int height, const int team); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: RestoreUnseenBox - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Restores a box on the unseen map for a specific team, if there is any. - // Arguments: The X and Y coords of the upper left corner of the box to be revealed. - // The width and height of the box to be restored, in scene units (pixels) - // The team to restore for. - // Return value: None. - + /// Restores a box on the unseen map for a specific team, if there is any. + /// @param posX The X and Y coords of the upper left corner of the box to be revealed. + /// @param posY The width and height of the box to be restored, in scene units (pixels) + /// @param width The team to restore for. void RestoreUnseenBox(const int posX, const int posY, const int width, const int height, const int team); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: CastUnseenRay - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Traces along a vector and reveals or hides pixels on the unseen layer of a team - // as long as the accumulated material strengths traced through the terrain - // don't exceed a specific value. - // Arguments: The team to see for. - // The starting position. - // The vector to trace along. - // A Vector that will be set to the position of where the sight ray was - // terminated. If it reached the end, it will be set to the end of the ray. - // The material strength limit where - // For every pixel checked along the line, how many to skip between them - // for optimization reasons. 0 = every pixel is checked. - // Whether the ray should reveal or restore unseen layer - // Return value: Whether any unseen pixels were revealed as a result of this seeing. - + /// Traces along a vector and reveals or hides pixels on the unseen layer of a team + /// as long as the accumulated material strengths traced through the terrain + /// don't exceed a specific value. + /// @param team The team to see for. + /// @param start The starting position. + /// @param ray The vector to trace along. + /// @param endPos A Vector that will be set to the position of where the sight ray was + /// terminated. If it reached the end, it will be set to the end of the ray. + /// @param strengthLimit The material strength limit where + /// @param skip For every pixel checked along the line, how many to skip between them + /// for optimization reasons. 0 = every pixel is checked. + /// @param reveal Whether the ray should reveal or restore unseen layer + /// @return Whether any unseen pixels were revealed as a result of this seeing. bool CastUnseenRay(int team, const Vector& start, const Vector& ray, Vector& endPos, int strengthLimit, int skip, bool reveal); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: CastSeeRay - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Traces along a vector and reveals pixels on the unseen layer of a team - // as long as the accumulated material strengths traced through the terrain - // don't exceed a specific value. - // Arguments: The team to see for. - // The starting position. - // The vector to trace along. - // A Vector that will be set to the position of where the sight ray was - // terminated. If it reached the end, it will be set to the end of the ray. - // The material strength limit where - // For every pixel checked along the line, how many to skip between them - // for optimization reasons. 0 = every pixel is checked. - // Return value: Whether any unseen pixels were revealed as a result of this seeing. - + /// Traces along a vector and reveals pixels on the unseen layer of a team + /// as long as the accumulated material strengths traced through the terrain + /// don't exceed a specific value. + /// @param team The team to see for. + /// @param start The starting position. + /// @param ray The vector to trace along. + /// @param endPos A Vector that will be set to the position of where the sight ray was + /// terminated. If it reached the end, it will be set to the end of the ray. + /// @param strengthLimit The material strength limit where + /// @param skip For every pixel checked along the line, how many to skip between them (default: 0) + /// for optimization reasons. 0 = every pixel is checked. + /// @return Whether any unseen pixels were revealed as a result of this seeing. bool CastSeeRay(int team, const Vector& start, const Vector& ray, Vector& endPos, int strengthLimit, int skip = 0); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: CastUnseeRay - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Traces along a vector and hides pixels on the unseen layer of a team - // as long as the accumulated material strengths traced through the terrain - // don't exceed a specific value. - // Arguments: The team to see for. - // The starting position. - // The vector to trace along. - // A Vector that will be set to the position of where the sight ray was - // terminated. If it reached the end, it will be set to the end of the ray. - // The material strength limit where - // For every pixel checked along the line, how many to skip between them - // for optimization reasons. 0 = every pixel is checked. - // Return value: Whether any unseen pixels were revealed as a result of this seeing. - + /// Traces along a vector and hides pixels on the unseen layer of a team + /// as long as the accumulated material strengths traced through the terrain + /// don't exceed a specific value. + /// @param team The team to see for. + /// @param start The starting position. + /// @param ray The vector to trace along. + /// @param endPos A Vector that will be set to the position of where the sight ray was + /// terminated. If it reached the end, it will be set to the end of the ray. + /// @param strengthLimit The material strength limit where + /// @param skip For every pixel checked along the line, how many to skip between them (default: 0) + /// for optimization reasons. 0 = every pixel is checked. + /// @return Whether any unseen pixels were revealed as a result of this seeing. bool CastUnseeRay(int team, const Vector& start, const Vector& ray, Vector& endPos, int strengthLimit, int skip = 0); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: CastMaterialRay - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Traces along a vector and gets the location of the first encountered - // pixel of a specific material in the terrain. - // Arguments: The starting position. - // The vector to trace along. - // The material ID to look for. - // A reference to the vector screen will be filled out with the absolute - // location of the found terrain pixel of the above material. - // For every pixel checked along the line, how many to skip between them - // for optimization reasons. 0 = every pixel is checked. - // Whetehr the ray should wrap around the scene if it crosses a seam. - // Return value: Whether the material was found along the ray. If not, the fourth - // parameter will not have been altered (and may still not be 0!) - + /// Traces along a vector and gets the location of the first encountered + /// pixel of a specific material in the terrain. + /// @param start The starting position. + /// @param ray The vector to trace along. + /// @param material The material ID to look for. + /// @param result A reference to the vector screen will be filled out with the absolute + /// location of the found terrain pixel of the above material. + /// @param skip For every pixel checked along the line, how many to skip between them (default: 0) + /// for optimization reasons. 0 = every pixel is checked. + /// @param wrap Whetehr the ray should wrap around the scene if it crosses a seam. (default: true) + /// @return Whether the material was found along the ray. If not, the fourth + /// parameter will not have been altered (and may still not be 0!) bool CastMaterialRay(const Vector& start, const Vector& ray, unsigned char material, Vector& result, int skip = 0, bool wrap = true); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: CastMaterialRay - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Traces along a vector and returns how far along that ray there is an - // encounter with a pixel of a specific material in the terrain. - // Arguments: The starting position. - // The vector to trace along. - // The material ID to look for. - // For every pixel checked along the line, how many to skip between them - // for optimization reasons. 0 = every pixel is checked. - // Return value: How far along, in pixel units, the ray the material pixel was encountered. - // If no pixel of the right material was found, < 0 is returned. - + /// Traces along a vector and returns how far along that ray there is an + /// encounter with a pixel of a specific material in the terrain. + /// @param start The starting position. + /// @param ray The vector to trace along. + /// @param material The material ID to look for. + /// @param skip For every pixel checked along the line, how many to skip between them (default: 0) + /// for optimization reasons. 0 = every pixel is checked. + /// @return How far along, in pixel units, the ray the material pixel was encountered. + /// If no pixel of the right material was found, < 0 is returned. float CastMaterialRay(const Vector& start, const Vector& ray, unsigned char material, int skip = 0); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: CastNotMaterialRay - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Traces along a vector and gets the location of the first encountered - // pixel that is NOT of a specific material in the scene's terrain. - // Arguments: The starting position. - // The vector to trace along. - // The material ID to find something OTHER than. - // A reference to the vector screen will be filled out with the absolute - // location of the found terrain pixel of the above material. - // For every pixel checked along the line, how many to skip between them - // for optimization reasons. 0 = every pixel is checked. - // Whether to check for MO layer collisions as well, not just terrain. - // Return value: Whether the a pixel other than the material was found along the ray. - // If not, the fourth parameter will not have been altered (and may still not be 0!) - + /// Traces along a vector and gets the location of the first encountered + /// pixel that is NOT of a specific material in the scene's terrain. + /// @param start The starting position. + /// @param ray The vector to trace along. + /// @param material The material ID to find something OTHER than. + /// @param result A reference to the vector screen will be filled out with the absolute + /// location of the found terrain pixel of the above material. + /// @param skip For every pixel checked along the line, how many to skip between them (default: 0) + /// for optimization reasons. 0 = every pixel is checked. + /// @param checkMOs Whether to check for MO layer collisions as well, not just terrain. (default: false) + /// @return Whether the a pixel other than the material was found along the ray. + /// If not, the fourth parameter will not have been altered (and may still not be 0!) bool CastNotMaterialRay(const Vector& start, const Vector& ray, unsigned char material, Vector& result, int skip = 0, bool checkMOs = false); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: CastNotMaterialRay - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Traces along a vector and returns how far along that ray there is an - // encounter with a pixel of OTHER than a specific material in the terrain. - // Arguments: The starting position. - // The vector to trace along. - // The material ID to find something OTHER than. - // For every pixel checked along the line, how many to skip between them - // for optimization reasons. 0 = every pixel is checked. - // Whether to check for MO layer collisions as well, not just terrain. - // Return value: How far along, in pixel units, the ray the pixel of any other material - // was encountered. If no pixel of the right material was found, < 0 is returned. - + /// Traces along a vector and returns how far along that ray there is an + /// encounter with a pixel of OTHER than a specific material in the terrain. + /// @param start The starting position. + /// @param ray The vector to trace along. + /// @param material The material ID to find something OTHER than. + /// @param skip For every pixel checked along the line, how many to skip between them (default: 0) + /// for optimization reasons. 0 = every pixel is checked. + /// @param checkMOs Whether to check for MO layer collisions as well, not just terrain. (default: false) + /// @return How far along, in pixel units, the ray the pixel of any other material + /// was encountered. If no pixel of the right material was found, < 0 is returned. float CastNotMaterialRay(const Vector& start, const Vector& ray, unsigned char material, int skip = 0, bool checkMOs = false); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: CastStrengthSumRay - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Traces along a vector and returns how the sum of all encountered pixels' - // material strength values. This will take wrapping into account. - // Arguments: The starting position. - // The ending position. - // For every pixel checked along the line, how many to skip between them - // for optimization reasons. 0 = every pixel is checked. - // A material ID to ignore, IN ADDITION to Air. - // Return value: The sum of all encountered pixels' material strength vales. So if it was - // all Air, then 0 is returned (Air's strength value is 0). - + /// Traces along a vector and returns how the sum of all encountered pixels' + /// material strength values. This will take wrapping into account. + /// @param start The starting position. + /// @param end The ending position. + /// @param skip For every pixel checked along the line, how many to skip between them (default: 0) + /// for optimization reasons. 0 = every pixel is checked. + /// @param ignoreMaterial A material ID to ignore, IN ADDITION to Air. (default: g_MaterialAir) + /// @return The sum of all encountered pixels' material strength vales. So if it was + /// all Air, then 0 is returned (Air's strength value is 0). float CastStrengthSumRay(const Vector& start, const Vector& end, int skip = 0, unsigned char ignoreMaterial = g_MaterialAir); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: CastMaxStrengthRay - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Traces along a vector and returns the strongest of all encountered pixels' - // material strength values. - // This will take wrapping into account. - // Arguments: The starting position. - // The ending position. - // For every pixel checked along the line, how many to skip between them - // for optimization reasons. 0 = every pixel is checked. - // A material ID to ignore, IN ADDITION to Air. This defaults to doors, for legacy script purposes - // Return value: The max of all encountered pixels' material strength vales. So if it was - // all Air, then 0 is returned (Air's strength value is 0). - + /// Traces along a vector and returns the strongest of all encountered pixels' + /// material strength values. + /// This will take wrapping into account. + /// @param start The starting position. + /// @param end The ending position. + /// @param skip For every pixel checked along the line, how many to skip between them + /// for optimization reasons. 0 = every pixel is checked. + /// @param ignoreMaterial A material ID to ignore, IN ADDITION to Air. This defaults to doors, for legacy script purposes + /// @return The max of all encountered pixels' material strength vales. So if it was + /// all Air, then 0 is returned (Air's strength value is 0). // We use two accessors instead of default parameters, for lua compat float CastMaxStrengthRay(const Vector& start, const Vector& end, int skip, unsigned char ignoreMaterial); float CastMaxStrengthRay(const Vector& start, const Vector& end, int skip) { return CastMaxStrengthRay(start, end, skip, g_MaterialDoor); }; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: CastMaxStrengthRayMaterial - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Traces along a vector and returns the strongest of all encountered pixels' materials - // This will take wrapping into account. - // Arguments: The starting position. - // The ending position. - // For every pixel checked along the line, how many to skip between them - // for optimization reasons. 0 = every pixel is checked. - // A material ID to ignore, IN ADDITION to Air. - // Return value: The strongest material encountered + /// Traces along a vector and returns the strongest of all encountered pixels' materials + /// This will take wrapping into account. + /// @param start The starting position. + /// @param end The ending position. + /// @param skip For every pixel checked along the line, how many to skip between them + /// for optimization reasons. 0 = every pixel is checked. + /// @param ignoreMaterial A material ID to ignore, IN ADDITION to Air. + /// @return The strongest material encountered const Material* CastMaxStrengthRayMaterial(const Vector& start, const Vector& end, int skip, unsigned char ignoreMaterial); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: CastStrengthRay - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Traces along a vector and shows where along that ray there is an - // encounter with a pixel of a material with strength more than or equal - // to a specific value. - // Arguments: The starting position. - // The vector to trace along. - // The strength value of screen any found to be equal or more than will - // terminate the ray. - // A reference to the vector screen will be filled out with the absolute - // location of the found terrain pixel of less than or equal to above strength. - // For every pixel checked along the line, how many to skip between them - // for optimization reasons. 0 = every pixel is checked. - // A material ID to ignore, IN ADDITION to Air. - // Whetehr the ray should wrap around the scene if it crosses a seam. - // Return value: Whether a material of equal or more strength was found along the ray. - // If not, the fourth parameter have been set to last position of the ray. - + /// Traces along a vector and shows where along that ray there is an + /// encounter with a pixel of a material with strength more than or equal + /// to a specific value. + /// @param start The starting position. + /// @param ray The vector to trace along. + /// @param strength The strength value of screen any found to be equal or more than will + /// terminate the ray. + /// @param result A reference to the vector screen will be filled out with the absolute + /// location of the found terrain pixel of less than or equal to above strength. + /// @param skip For every pixel checked along the line, how many to skip between them (default: 0) + /// for optimization reasons. 0 = every pixel is checked. + /// @param ignoreMaterial A material ID to ignore, IN ADDITION to Air. (default: g_MaterialAir) + /// @param wrap Whetehr the ray should wrap around the scene if it crosses a seam. (default: true) + /// @return Whether a material of equal or more strength was found along the ray. + /// If not, the fourth parameter have been set to last position of the ray. bool CastStrengthRay(const Vector& start, const Vector& ray, float strength, Vector& result, int skip = 0, unsigned char ignoreMaterial = g_MaterialAir, bool wrap = true); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: CastWeaknessRay - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Traces along a vector and shows where along that ray there is an - // encounter with a pixel of a material with strength less than or equal - // to a specific value. - // Arguments: The starting position. - // The vector to trace along. - // The strength value of screen any found to be equal or less than will - // terminate the ray. - // A reference to the vector screen will be filled out with the absolute - // location of the found terrain pixel of less than or equal to above strength. - // For every pixel checked along the line, how many to skip between them - // for optimization reasons. 0 = every pixel is checked. - // Whetehr the ray should wrap around the scene if it crosses a seam. - // Return value: Whether a material of equal or less strength was found along the ray. - // If not, the fourth parameter have been set to last position of the ray. - + /// Traces along a vector and shows where along that ray there is an + /// encounter with a pixel of a material with strength less than or equal + /// to a specific value. + /// @param start The starting position. + /// @param ray The vector to trace along. + /// @param strength The strength value of screen any found to be equal or less than will + /// terminate the ray. + /// @param result A reference to the vector screen will be filled out with the absolute + /// location of the found terrain pixel of less than or equal to above strength. + /// @param skip For every pixel checked along the line, how many to skip between them (default: 0) + /// for optimization reasons. 0 = every pixel is checked. + /// @param wrap Whetehr the ray should wrap around the scene if it crosses a seam. (default: true) + /// @return Whether a material of equal or less strength was found along the ray. + /// If not, the fourth parameter have been set to last position of the ray. bool CastWeaknessRay(const Vector& start, const Vector& ray, float strength, Vector& result, int skip = 0, bool wrap = true); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: CastMORay - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Traces along a vector and returns MOID of the first non-ignored - // non-NoMOID MO encountered. If a non-air terrain pixel is encountered - // first, g_NoMOID will be returned. - // Arguments: The starting position. - // The vector to trace along. - // An MOID to ignore. Any child MO's of this MOID will also be ignored. - // To enable ignoring of all MOIDs associated with an object of a specific - // team which also has team ignoring enabled itself. - // A specific material ID to ignore hits with. - // Whether to ignore all terrain hits or not. - // For every pixel checked along the line, how many to skip between them - // for optimization reasons. 0 = every pixel is checked. - // Return value: The MOID of the hit non-ignored MO, or g_NoMOID if terrain or no MO was hit. - + /// Traces along a vector and returns MOID of the first non-ignored + /// non-NoMOID MO encountered. If a non-air terrain pixel is encountered + /// first, g_NoMOID will be returned. + /// @param start The starting position. + /// @param ray The vector to trace along. + /// @param ignoreMOID An MOID to ignore. Any child MO's of this MOID will also be ignored. (default: g_NoMOID) + /// @param ignoreTeam To enable ignoring of all MOIDs associated with an object of a specific (default: Activity::NoTeam) + /// team which also has team ignoring enabled itself. + /// @param ignoreMaterial A specific material ID to ignore hits with. (default: 0) + /// @param ignoreAllTerrain Whether to ignore all terrain hits or not. (default: false) + /// @param skip For every pixel checked along the line, how many to skip between them (default: 0) + /// for optimization reasons. 0 = every pixel is checked. + /// @return The MOID of the hit non-ignored MO, or g_NoMOID if terrain or no MO was hit. MOID CastMORay(const Vector& start, const Vector& ray, MOID ignoreMOID = g_NoMOID, int ignoreTeam = Activity::NoTeam, unsigned char ignoreMaterial = 0, bool ignoreAllTerrain = false, int skip = 0); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: CastFindMORay - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Traces along a vector and shows where a specific MOID has been found. - // Arguments: The starting position. - // The vector to trace along. - // An MOID to find. Any child MO's of this MOID will also be found. ------------ ??? - // A reference to the vector screen will be filled out with the absolute - // location of the found MO pixel of the above MOID. - // A specific material ID to ignore hits with. - // Whether to ignore all terrain hits or not. - // For every pixel checked along the line, how many to skip between them - // for optimization reasons. 0 = every pixel is checked. - // Return value: Whether the target MOID was found along the ray or not. - + /// Traces along a vector and shows where a specific MOID has been found. + /// @param start The starting position. + /// @param ray The vector to trace along. + /// @param targetMOID An MOID to find. Any child MO's of this MOID will also be found. ------------ ??? + /// @param resultPos A reference to the vector screen will be filled out with the absolute + /// location of the found MO pixel of the above MOID. + /// @param ignoreMaterial A specific material ID to ignore hits with. (default: 0) + /// @param ignoreAllTerrain Whether to ignore all terrain hits or not. (default: false) + /// @param skip For every pixel checked along the line, how many to skip between them (default: 0) + /// for optimization reasons. 0 = every pixel is checked. + /// @return Whether the target MOID was found along the ray or not. bool CastFindMORay(const Vector& start, const Vector& ray, MOID targetMOID, Vector& resultPos, unsigned char ignoreMaterial = 0, bool ignoreAllTerrain = false, int skip = 0); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: CastObstacleRay - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Traces along a vector and returns the length of how far the trace went - // without hitting any non-ignored terrain material or MOID at all. - // Arguments: The starting position. - // The vector to trace along. - // A reference to the vector screen will be filled out with the absolute - // location of the first obstacle, or the end of the ray if none was hit. - // A reference to the vector screen will be filled out with the absolute - // location of the last free position before hitting an obstacle, or the - // end of the ray if none was hit. This is only altered if thre are any - // free pixels encountered. - // An MOID to ignore. Any child MO's of this MOID will also be ignored. - // To enable ignoring of all MOIDs associated with an object of a specific - // team which also has team ignoring enabled itself. - // A specific material ID to ignore hits with. - // For every pixel checked along the line, how many to skip between them - // for optimization reasons. 0 = every pixel is checked. - // Return value: How far along, in pixel units, the ray the pixel of any obstacle was - // encountered. If no pixel of the right material was found, < 0 is returned. - // If an obstacle on the starting position was encountered, 0 is returned. - + /// Traces along a vector and returns the length of how far the trace went + /// without hitting any non-ignored terrain material or MOID at all. + /// @param start The starting position. + /// @param ray The vector to trace along. + /// @param obstaclePos A reference to the vector screen will be filled out with the absolute + /// location of the first obstacle, or the end of the ray if none was hit. + /// @param freePos A reference to the vector screen will be filled out with the absolute + /// location of the last free position before hitting an obstacle, or the + /// end of the ray if none was hit. This is only altered if thre are any + /// free pixels encountered. + /// @param ignoreMOID An MOID to ignore. Any child MO's of this MOID will also be ignored. (default: g_NoMOID) + /// @param ignoreTeam To enable ignoring of all MOIDs associated with an object of a specific (default: Activity::NoTeam) + /// team which also has team ignoring enabled itself. + /// @param ignoreMaterial A specific material ID to ignore hits with. (default: 0) + /// @param skip For every pixel checked along the line, how many to skip between them (default: 0) + /// for optimization reasons. 0 = every pixel is checked. + /// @return How far along, in pixel units, the ray the pixel of any obstacle was + /// encountered. If no pixel of the right material was found, < 0 is returned. + /// If an obstacle on the starting position was encountered, 0 is returned. float CastObstacleRay(const Vector& start, const Vector& ray, Vector& obstaclePos, Vector& freePos, MOID ignoreMOID = g_NoMOID, int ignoreTeam = Activity::NoTeam, unsigned char ignoreMaterial = 0, int skip = 0); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetLastRayHitPos - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the abosulte pos of where the last cast ray hit somehting. - // Arguments: None. - // Return value: A vector with the absolute pos of where the last ray cast hit somehting. - + /// Gets the abosulte pos of where the last cast ray hit somehting. + /// @return A vector with the absolute pos of where the last ray cast hit somehting. const Vector& GetLastRayHitPos(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: FindAltitude - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Calculates the altitide of a certain point above the terrain, measured - // in pixels. - // Arguments: The max altitude you care to check for. 0 Means check the whole scene's height. - // The accuracy within screen measurement is acceptable. Higher number - // here means less calculation. - // Return value: The altitude over the terrain, in pixels. - + /// Calculates the altitide of a certain point above the terrain, measured + /// in pixels. + /// @param from The max altitude you care to check for. 0 Means check the whole scene's height. + /// @param max The accuracy within screen measurement is acceptable. Higher number + /// here means less calculation. + /// @return The altitude over the terrain, in pixels. float FindAltitude(const Vector& from, int max, int accuracy, bool fromSceneOrbitDirection); float FindAltitude(const Vector& from, int max, int accuracy) { return FindAltitude(from, max, accuracy, false); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: OverAltitude - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Calculates the altitide of a certain point above the terrain, measured - // in pixels, and then tells if that point is over a certain value. - // Arguments: The altitude threshold you want to check for. - // The accuracy within screen measurement is acceptable. Higher number - // here means less costly. - // Return value: Whether the point is over the threshold altitude or not. - + /// Calculates the altitide of a certain point above the terrain, measured + /// in pixels, and then tells if that point is over a certain value. + /// @param point The altitude threshold you want to check for. + /// @param threshold The accuracy within screen measurement is acceptable. Higher number + /// here means less costly. + /// @return Whether the point is over the threshold altitude or not. bool OverAltitude(const Vector& point, int threshold, int accuracy = 0); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: MovePointToGround - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Takes an arbitrary point in the air and calculates it to be straight - // down at a certain maximum distance from the ground. - // Arguments: The point to start from. Should be in the air, or the same point will - // be returned (null operation) - // The max altitude in px you want the point to be above the ground. - // The accuracy within screen measurement is acceptable. Higher number - // here means less calculation. - // Return value: The new point screen is no higher than accuracy + max altitude over - // the terrain. - + /// Takes an arbitrary point in the air and calculates it to be straight + /// down at a certain maximum distance from the ground. + /// @param from The point to start from. Should be in the air, or the same point will + /// be returned (null operation) + /// @param maxAltitude The max altitude in px you want the point to be above the ground. (default: 0) + /// @param accuracy The accuracy within screen measurement is acceptable. Higher number (default: 0) + /// here means less calculation. + /// @return The new point screen is no higher than accuracy + max altitude over + /// the terrain. Vector MovePointToGround(const Vector& from, int maxAltitude = 0, int accuracy = 0); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: IsWithinBounds - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns whether the integer coordinates passed in are within the - // bounds of the current Scene, considering its wrapping. - // Arguments: Int coordinates. - // A margin - // Return value: Whether within bounds or not, considering wrapping. - + /// Returns whether the integer coordinates passed in are within the + /// bounds of the current Scene, considering its wrapping. + /// @param pixelX Int coordinates. + /// @param pixelY A margin + /// @return Whether within bounds or not, considering wrapping. bool IsWithinBounds(const int pixelX, const int pixelY, const int margin = 0); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ForceBounds - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Wraps or bounds a position coordinate if it is off bounds of the - // Scene, depending on the wrap settings of this Scene. - // Arguments: The X and Y coordinates of the position to wrap, if needed. - // Return value: Whether wrapping was performed or not. (Does not report on bounding) - + /// Wraps or bounds a position coordinate if it is off bounds of the + /// Scene, depending on the wrap settings of this Scene. + /// @param posX The X and Y coordinates of the position to wrap, if needed. + /// @return Whether wrapping was performed or not. (Does not report on bounding) bool ForceBounds(int& posX, int& posY); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ForceBounds - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Wraps or bounds a position coordinate if it is off bounds of the - // Scene, depending on the wrap settings of this Scene. - // Arguments: The vector coordinates of the position to wrap, if needed. - // Return value: Whether wrapping was performed or not. (Does not report on bounding) - + /// Wraps or bounds a position coordinate if it is off bounds of the + /// Scene, depending on the wrap settings of this Scene. + /// @param pos The vector coordinates of the position to wrap, if needed. + /// @return Whether wrapping was performed or not. (Does not report on bounding) bool ForceBounds(Vector& pos); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: WrapPosition - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Only wraps a position coordinate if it is off bounds of the Scene - // and wrapping in the corresponding axes are turned on. - // Arguments: The X and Y coordinates of the position to wrap, if needed. - // Return value: Whether wrapping was performed or not. - + /// Only wraps a position coordinate if it is off bounds of the Scene + /// and wrapping in the corresponding axes are turned on. + /// @param posX The X and Y coordinates of the position to wrap, if needed. + /// @return Whether wrapping was performed or not. bool WrapPosition(int& posX, int& posY); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: WrapPosition - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Only wraps a position coordinate if it is off bounds of the Scene - // and wrapping in the corresponding axes are turned on. - // Arguments: The vector coordinates of the position to wrap, if needed. - // Return value: Whether wrapping was performed or not. - + /// Only wraps a position coordinate if it is off bounds of the Scene + /// and wrapping in the corresponding axes are turned on. + /// @param pos The vector coordinates of the position to wrap, if needed. + /// @return Whether wrapping was performed or not. bool WrapPosition(Vector& pos); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SnapPosition - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns a position snapped to the current scene grid. - // Arguments: The vector coordinates of the position to snap. - // Whether to actually snap or not. This is useful for cleaner toggle code. - // Return value: The new snapped position. - + /// Returns a position snapped to the current scene grid. + /// @param pos The vector coordinates of the position to snap. + /// @param snap Whether to actually snap or not. This is useful for cleaner toggle code. (default: true) + /// @return The new snapped position. Vector SnapPosition(const Vector& pos, bool snap = true); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ShortestDistance - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Calculates the shortest distance between two points in scene - // coordinates, taking into account all wrapping and out of bounds of the - // two points. - // Arguments: The two Vector coordinates of the two positions to find the shortest - // distance between. - // Whether to check if the passed in points are outside the scene, and to - // wrap them if they are. - // Return value: The resulting vector screen shows the shortest distance, spanning over - // wrapping borders etc. Basically the ideal pos2 - pos1. - + /// Calculates the shortest distance between two points in scene + /// coordinates, taking into account all wrapping and out of bounds of the + /// two points. + /// @param pos1 The two Vector coordinates of the two positions to find the shortest + /// distance between. + /// @param pos2 Whether to check if the passed in points are outside the scene, and to + /// wrap them if they are. + /// @return The resulting vector screen shows the shortest distance, spanning over + /// wrapping borders etc. Basically the ideal pos2 - pos1. Vector ShortestDistance(Vector pos1, Vector pos2, bool checkBounds = false); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ShortestDistanceX - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Calculates the shortest distance between two x values in scene - // coordinates, taking into account all wrapping and out of bounds of the - // two values. - // Arguments: The X coordinates of the two values to find the shortest distance between. - // Whether to check if the passed in points are outside the scene, and to - // wrap them if they are. - // Whether to constrain the distance to only be in a certain direction: - // 0 means no constraint, < 0 means only look in the negative dir, etc. - // If the scene doesn't wrap in the constraint's direction, the constraint - // will be ignored. - // Return value: The resulting X value screen shows the shortest distance, spanning over - // wrapping borders etc. Basically the ideal val2 - val1. - + /// Calculates the shortest distance between two x values in scene + /// coordinates, taking into account all wrapping and out of bounds of the + /// two values. + /// @param val1 The X coordinates of the two values to find the shortest distance between. + /// @param val2 Whether to check if the passed in points are outside the scene, and to + /// wrap them if they are. + /// @param checkBounds Whether to constrain the distance to only be in a certain direction: (default: false) + /// 0 means no constraint, < 0 means only look in the negative dir, etc. + /// @param direction If the scene doesn't wrap in the constraint's direction, the constraint (default: 0) + /// will be ignored. + /// @return The resulting X value screen shows the shortest distance, spanning over + /// wrapping borders etc. Basically the ideal val2 - val1. float ShortestDistanceX(float val1, float val2, bool checkBounds = false, int direction = 0); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ShortestDistanceY - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Calculates the shortest distance between two Y values in scene - // coordinates, taking into account all wrapping and out of bounds of the - // two values. - // Arguments: The Y coordinates of the two values to find the shortest distance between. - // Whether to check if the passed in points are outside the scene, and to - // wrap them if they are. - // Whether to constrain the distance to only be in a certain direction: - // 0 means no constraint, < 0 means only look in the negative dir, etc. - // If the scene doesn't wrap in the constraint's direction, the constraint - // will be ignored. - // Return value: The resulting Y value screen shows the shortest distance, spanning over - // wrapping borders etc. Basically the ideal val2 - val1. - + /// Calculates the shortest distance between two Y values in scene + /// coordinates, taking into account all wrapping and out of bounds of the + /// two values. + /// @param val1 The Y coordinates of the two values to find the shortest distance between. + /// @param val2 Whether to check if the passed in points are outside the scene, and to + /// wrap them if they are. + /// @param checkBounds Whether to constrain the distance to only be in a certain direction: (default: false) + /// 0 means no constraint, < 0 means only look in the negative dir, etc. + /// @param direction If the scene doesn't wrap in the constraint's direction, the constraint (default: 0) + /// will be ignored. + /// @return The resulting Y value screen shows the shortest distance, spanning over + /// wrapping borders etc. Basically the ideal val2 - val1. float ShortestDistanceY(float val1, float val2, bool checkBounds = false, int direction = 0); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ObscuredPoint - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Tells whether a point on the scene is obscured by MOID or Terrain - // non-air material. - // Arguments: The point on the scene to check. - // Wheter to also check for unseen areas of a specific team. -1 means - // don't check this. - // Return value: Whether that point is obscured/obstructed or not. - + /// Tells whether a point on the scene is obscured by MOID or Terrain + /// non-air material. + /// @param point The point on the scene to check. + /// @param team Wheter to also check for unseen areas of a specific team. -1 means (default: -1) { return ObscuredPoint(point.GetFloorIntX()) + /// don't check this. + /// @return Whether that point is obscured/obstructed or not. bool ObscuredPoint(Vector& point, int team = -1) { return ObscuredPoint(point.GetFloorIntX(), point.GetFloorIntY()); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ObscuredPoint - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Tells whether a point on the scene is obscured by MOID or Terrain - // non-air material. - // Arguments: The point on the scene to check. - // Wheter to also check for unseen areas of a specific team. -1 means - // don't check this. - // Return value: Whether that point is obscured/obstructed or not. - + /// Tells whether a point on the scene is obscured by MOID or Terrain + /// non-air material. + /// @param x The point on the scene to check. + /// @param y Wheter to also check for unseen areas of a specific team. -1 means + /// don't check this. + /// @return Whether that point is obscured/obstructed or not. bool ObscuredPoint(int x, int y, int team = -1); /* @@ -1210,137 +804,84 @@ namespace RTE { bool SceneRectsIntersect(int x, int y); */ - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: WrapRect - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Takes a rect and adds all possible wrapped appearances of that rect - // to a passed-in list. IF if a passed in rect straddles the seam of a - // wrapped scene axis, it will be added twice to the output list. If it - // doesn't straddle any seam, it will be only added once. - // Arguments: The IntRect to check for wrapping of and add to the output list below. - // A reference to a list of IntRect:s that will only be added to, never - // cleared. - // Return value: How many additions of the passed in rect was added to the list. 1 if - // no wrapping need was detected, up to 4 possible (if straddling both seams) - + /// Takes a rect and adds all possible wrapped appearances of that rect + /// to a passed-in list. IF if a passed in rect straddles the seam of a + /// wrapped scene axis, it will be added twice to the output list. If it + /// doesn't straddle any seam, it will be only added once. + /// @param wrapRect The IntRect to check for wrapping of and add to the output list below. + /// @param outputList A reference to a list of IntRect:s that will only be added to, never + /// cleared. + /// @return How many additions of the passed in rect was added to the list. 1 if + /// no wrapping need was detected, up to 4 possible (if straddling both seams) int WrapRect(const IntRect& wrapRect, std::list& outputList); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: WrapBox - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Takes a Box and adds all possible scenewrapped appearances of that Box - // to a passed-in list. IF if a passed in rect straddles the seam of a - // wrapped scene axis, it will be added twice to the output list. If it - // doesn't straddle any seam, it will be only added once. - // Arguments: The IntRect to check for wrapping of and add to the output list below. - // A reference to a list of IntRect:s that will only be added to, never - // cleared. - // Return value: How many additions of the passed in Box was added to the list. 1 if - // no wrapping need was detected, up to 4 possible (if straddling both seams) - + /// Takes a Box and adds all possible scenewrapped appearances of that Box + /// to a passed-in list. IF if a passed in rect straddles the seam of a + /// wrapped scene axis, it will be added twice to the output list. If it + /// doesn't straddle any seam, it will be only added once. + /// @param wrapBox The IntRect to check for wrapping of and add to the output list below. + /// @param outputList A reference to a list of IntRect:s that will only be added to, never + /// cleared. + /// @return How many additions of the passed in Box was added to the list. 1 if + /// no wrapping need was detected, up to 4 possible (if straddling both seams) int WrapBox(const Box& wrapBox, std::list& outputList); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: AddSceneObject - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Takes any scene object and adds it to the scene in the appropriate way. - // If it's a TerrainObject, then it gets applied to the terrain, if it's - // an MO, it gets added to the correct type group in MovableMan. - // Arguments: The SceneObject to add. Ownership IS transferred! - // Return value: Whether the SceneObject was successfully added or not. Either way, - // ownership was transferred. If no success, the object was deleted. - + /// Takes any scene object and adds it to the scene in the appropriate way. + /// If it's a TerrainObject, then it gets applied to the terrain, if it's + /// an MO, it gets added to the correct type group in MovableMan. + /// @param pObject The SceneObject to add. Ownership IS transferred! + /// @return Whether the SceneObject was successfully added or not. Either way, + /// ownership was transferred. If no success, the object was deleted. bool AddSceneObject(SceneObject* pObject); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Update - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the state of this SceneMan. Supposed to be done every frame - // before drawing. - // Arguments: Which screen to update for. - // Return value: None. - + /// Updates the state of this SceneMan. Supposed to be done every frame + /// before drawing. + /// @param screenId Which screen to update for. (default: 0) void Update(int screenId = 0); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Draw - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws this SceneMan's current graphical representation to a - // BITMAP of choice. - // Arguments: A pointer to a BITMAP to draw on, appropriately sized for the split - // screen segment. - // The offset into the scene where the target bitmap's upper left corner - // is located. - // Return value: None. - + /// Draws this SceneMan's current graphical representation to a + /// BITMAP of choice. + /// @param targetBitmap A pointer to a BITMAP to draw on, appropriately sized for the split + /// screen segment. + /// @param targetGUIBitmap The offset into the scene where the target bitmap's upper left corner + /// is located. void Draw(BITMAP* targetBitmap, BITMAP* targetGUIBitmap, const Vector& targetPos = Vector(), bool skipBackgroundLayers = false, bool skipTerrain = false); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ClearMOColorLayer - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears the color MO layer. Should be done every frame. - // Arguments: None. - // Return value: None. - + /// Clears the color MO layer. Should be done every frame. void ClearMOColorLayer(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ClearSeenPixels - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears the list of pixels on the unseen map that have been revealed. - // Arguments: None. - // Return value: None. - + /// Clears the list of pixels on the unseen map that have been revealed. void ClearSeenPixels(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: AddMaterialCopy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Creates a copy of passed material and stores it into internal vector - // to make sure there's only one material owner - // Arguments: Material to add. - // Return value: Pointer to stored material. - + /// Creates a copy of passed material and stores it into internal vector + /// to make sure there's only one material owner + /// @param mat Material to add. + /// @return Pointer to stored material. Material* AddMaterialCopy(Material* mat); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: RegisterTerrainChange - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Registers terrain change event for the network server to be then sent to clients. - // Arguments: x,y - scene coordinates of change, w,h - size of the changed region, - // color - changed color for one-pixel events, - // back - if true, then background bitmap was changed if false then foreground. - // Return value: None. - + /// Registers terrain change event for the network server to be then sent to clients. + /// @param x,y - scene coordinates of change, w,h - size of the changed region, + /// color - changed color for one-pixel events, + /// back - if true, then background bitmap was changed if false then foreground. void RegisterTerrainChange(int x, int y, int w, int h, unsigned char color, bool back); - /// /// Gets an intermediate bitmap that is used for drawing a settled MovableObject into the terrain. - /// - /// The diameter of the MovableObject to calculate the required bitmap size. - /// Pointer to the temp BITMAP of the appropriate size. Ownership is NOT transferred! + /// @param moDiameter The diameter of the MovableObject to calculate the required bitmap size. + /// @return Pointer to the temp BITMAP of the appropriate size. Ownership is NOT transferred! BITMAP* GetIntermediateBitmapForSettlingIntoTerrain(int moDiameter) const; - /// /// Sets the current scene pointer to null - /// void ClearCurrentScene(); - /// /// Gets the maximum height of a column of scrap terrain to collapse, when the bottom pixel is knocked loose. - /// - /// The compacting height of scrap terrain. + /// @return The compacting height of scrap terrain. int GetScrapCompactingHeight() const { return m_ScrapCompactingHeight; } - /// /// Sets the maximum height of a column of scrap terrain to collapse, when the bottom pixel is knocked loose. - /// - /// The new compacting height, in pixels. + /// @param newHeight The new compacting height, in pixels. void SetScrapCompactingHeight(int newHeight) { m_ScrapCompactingHeight = newHeight; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Protected member variable and method declarations - + /// Protected member variable and method declarations protected: static std::vector> m_IntermediateSettlingBitmaps; //!< Intermediate bitmaps of different sizes that are used to draw settled MovableObjects into the terrain. @@ -1402,20 +943,12 @@ namespace RTE { int m_ScrapCompactingHeight; //!< The maximum height of a column of scrap terrain to collapse, when the bottom pixel is knocked loose. - ////////////////////////////////////////////////////////////////////////////////////////// - // Private member variable and method declarations - + /// Private member variable and method declarations private: static const std::string c_ClassName; //!< A string with the friendly-formatted type name of this object. - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Clear - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears all the member variables of this SceneMan, effectively - // resetting the members of this abstraction level only. - // Arguments: None. - // Return value: None. - + /// Clears all the member variables of this SceneMan, effectively + /// resetting the members of this abstraction level only. void Clear(); // Disallow the use of some implicit methods. diff --git a/Source/Managers/SettingsMan.cpp b/Source/Managers/SettingsMan.cpp index f356bfec5f..b7c7956f28 100644 --- a/Source/Managers/SettingsMan.cpp +++ b/Source/Managers/SettingsMan.cpp @@ -15,8 +15,6 @@ namespace RTE { const std::string SettingsMan::c_ClassName = "SettingsMan"; - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SettingsMan::Clear() { m_SettingsPath = System::GetUserdataDirectory() + "Settings.ini"; m_SettingsNeedOverwrite = false; @@ -72,8 +70,6 @@ namespace RTE { m_EnabledGlobalScripts.clear(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int SettingsMan::Initialize() { if (const char* settingsTempPath = std::getenv("CCCP_SETTINGSPATH")) { m_SettingsPath = std::string(settingsTempPath); @@ -105,15 +101,11 @@ namespace RTE { return failureCode; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SettingsMan::UpdateSettingsFile() const { Writer settingsWriter(m_SettingsPath); g_SettingsMan.Save(settingsWriter); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int SettingsMan::ReadProperty(const std::string_view& propName, Reader& reader) { StartPropertyList(return Serializable::ReadProperty(propName, reader)); @@ -235,8 +227,6 @@ namespace RTE { EndPropertyList; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int SettingsMan::Save(Writer& writer) const { Serializable::Save(writer); diff --git a/Source/Managers/SettingsMan.h b/Source/Managers/SettingsMan.h index 240b3ca679..f431c9d8d0 100644 --- a/Source/Managers/SettingsMan.h +++ b/Source/Managers/SettingsMan.h @@ -8,9 +8,7 @@ namespace RTE { - /// /// The singleton manager over the application and misc settings. - /// class SettingsMan : public Singleton, public Serializable { public: @@ -18,510 +16,346 @@ namespace RTE { SerializableOverrideMethods; #pragma region Creation - /// /// Constructor method used to instantiate a SettingsMan object in system memory. Initialize() should be called before using the object. - /// SettingsMan() { Clear(); } - /// /// Makes the SettingsMan object ready for use. - /// - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Initialize(); #pragma endregion #pragma region Destruction - /// /// Resets the entire SettingsMan, including its inherited members, to their default settings or values. - /// void Reset() override { Clear(); } #pragma endregion #pragma region Settings Manager Operations - /// /// Gets whether Settings.ini needs to be overwritten with the complete list of settings or not. Will be true only if Settings.ini was created with default values on first load or after settings delete. - /// - /// Whether Settings.ini needs to be overwritten with the complete list of settings or not. + /// @return Whether Settings.ini needs to be overwritten with the complete list of settings or not. bool SettingsNeedOverwrite() const { return m_SettingsNeedOverwrite; } - /// /// Sets Settings.ini to be overwritten during the boot sequence for overrides to be applied (e.g. resolution validation). - /// void SetSettingsNeedOverwrite() { m_SettingsNeedOverwrite = true; } - /// /// Overwrites the settings file to save changes made from within the game. - /// void UpdateSettingsFile() const; #pragma endregion #pragma region Engine Settings - /// /// Returns whether LuaJit is disabled or not. - /// - /// Whether LuaJIT is disabled or not. + /// @return Whether LuaJIT is disabled or not. bool DisableLuaJIT() const { return m_DisableLuaJIT; } - /// /// Returns the recommended MOID count. If this amount is exceeded then some units may be removed at the start of the activity. - /// - /// Recommended MOID count. + /// @return Recommended MOID count. int RecommendedMOIDCount() const { return m_RecommendedMOIDCount; } - /// /// Gets whether simplified collision detection (reduced MOID layer sampling) is enabled. - /// - /// Whether simplified collision detection is enabled or not. + /// @return Whether simplified collision detection is enabled or not. bool SimplifiedCollisionDetection() const { return m_SimplifiedCollisionDetection; } - /// /// Gets the Scene background layer auto-scaling mode. - /// - /// The Scene background layer auto-scaling mode. 0 for off, 1 for fit screen dimensions and 2 for always upscaled to x2. + /// @return The Scene background layer auto-scaling mode. 0 for off, 1 for fit screen dimensions and 2 for always upscaled to x2. int GetSceneBackgroundAutoScaleMode() const { return m_SceneBackgroundAutoScaleMode; } - /// /// Sets the Scene background layer auto-scaling mode. - /// - /// The new Scene background layer auto-scaling mode. 0 for off, 1 for fit screen dimensions and 2 for always upscaled to x2. + /// @param newMode The new Scene background layer auto-scaling mode. 0 for off, 1 for fit screen dimensions and 2 for always upscaled to x2. void SetSceneBackgroundAutoScaleMode(int newMode) { m_SceneBackgroundAutoScaleMode = std::clamp(newMode, 0, 2); } - /// /// Gets whether faction BuyMenu theme support is disabled. - /// - /// Whether faction BuyMenu theme support is disabled. + /// @return Whether faction BuyMenu theme support is disabled. bool FactionBuyMenuThemesDisabled() const { return m_DisableFactionBuyMenuThemes; } - /// /// Sets whether faction BuyMenu theme support is disabled. - /// - /// Whether faction BuyMenu theme support is disabled or not. + /// @param disable Whether faction BuyMenu theme support is disabled or not. void SetFactionBuyMenuThemesDisabled(bool disable) { m_DisableFactionBuyMenuThemes = disable; } - /// /// Gets whether custom cursor support in faction BuyMenu themes is disabled. - /// - /// Whether faction BuyMenu theme support is disabled. + /// @return Whether faction BuyMenu theme support is disabled. bool FactionBuyMenuThemeCursorsDisabled() const { return m_DisableFactionBuyMenuThemeCursors; } - /// /// Sets whether custom cursor support in faction BuyMenu themes is disabled. - /// - /// Whether custom cursor support in faction BuyMenu themes is disabled or not. + /// @param disable Whether custom cursor support in faction BuyMenu themes is disabled or not. void SetFactionBuyMenuThemeCursorsDisabled(bool disable) { m_DisableFactionBuyMenuThemeCursors = disable; } - /// /// Gets the PathFinder grid node size. - /// - /// The PathFinder grid node size. + /// @return The PathFinder grid node size. int GetPathFinderGridNodeSize() const { return m_PathFinderGridNodeSize; } - /// /// Returns whether or not any experimental settings are used. - /// - /// Whether or not any experimental settings are used. + /// @return Whether or not any experimental settings are used. bool GetAnyExperimentalSettingsEnabled() const { return false; } - /// /// Gets the AI update interval. - /// - /// How often Actor's AI is updated, in simulation updates. + /// @return How often Actor's AI is updated, in simulation updates. int GetAIUpdateInterval() const { return m_AIUpdateInterval; } - /// /// Sets the AI update interval. - /// - /// How often Actor's AI will now be updated, in simulation updates. + /// @param newAIUpdateInterval How often Actor's AI will now be updated, in simulation updates. void SetAIUpdateInterval(int newAIUpdateInterval) { m_AIUpdateInterval = newAIUpdateInterval; } - /// /// Gets how many threaded Lua states we'll use. -1 represents no override, which defaults to the maximum number of concurrent hardware threads. - /// - /// How many threaded Lua states we'll use. + /// @return How many threaded Lua states we'll use. int GetNumberOfLuaStatesOverride() const { return m_NumberOfLuaStatesOverride; } - /// /// Gets whether pathing requests will be forced to immediately complete for the next frame, or if they can take multiple frames to calculate. - /// - /// Whether pathing requests will be forced to immediately complete for the next frame + /// @return Whether pathing requests will be forced to immediately complete for the next frame bool GetForceImmediatePathingRequestCompletion() const { return m_ForceImmediatePathingRequestCompletion; } #pragma endregion #pragma region Gameplay Settings - /// /// Returns true if endless MetaGame mode is enabled. - /// - /// Whether endless mode is enabled via settings. + /// @return Whether endless mode is enabled via settings. bool EndlessMetaGameMode() const { return m_EndlessMetaGameMode; } - /// /// Sets whether endless MetaGame mode is enabled or not. - /// - /// Whether endless MetaGame mode is enabled or not. + /// @param enable Whether endless MetaGame mode is enabled or not. void SetEndlessMetaGameMode(bool enable) { m_EndlessMetaGameMode = enable; } - /// /// Whether we need to play blips when unseen layer is revealed. - /// - /// Whether we need to play blips when unseen layer is revealed. + /// @return Whether we need to play blips when unseen layer is revealed. bool BlipOnRevealUnseen() const { return m_BlipOnRevealUnseen; } - /// /// Sets whether we need to play blips when unseen layer is revealed. - /// - /// New value for Blip on reveal unseen option. + /// @param newValue New value for Blip on reveal unseen option. void SetBlipOnRevealUnseen(bool newValue) { m_BlipOnRevealUnseen = newValue; } - /// /// Gets the range in which devices on Scene will show the pick-up HUD. - /// - /// The range in which devices on Scene will show the pick-up HUD, in pixels. 0 means HUDs are hidden, -1 means unlimited range. + /// @return The range in which devices on Scene will show the pick-up HUD, in pixels. 0 means HUDs are hidden, -1 means unlimited range. float GetUnheldItemsHUDDisplayRange() const { return m_UnheldItemsHUDDisplayRange; } - /// /// Sets the range in which devices on Scene will show the pick-up HUD. - /// - /// The new range in which devices on Scene will show the pick-up HUD, in pixels. 0 means HUDs are hidden, -1 means unlimited range. + /// @param newRadius The new range in which devices on Scene will show the pick-up HUD, in pixels. 0 means HUDs are hidden, -1 means unlimited range. void SetUnheldItemsHUDDisplayRange(float newRadius) { m_UnheldItemsHUDDisplayRange = std::floor(newRadius); } - /// /// Gets whether or not devices on Scene should always show their pick-up HUD when the player is in strategic mode. - /// - /// Whether or not devices on Scene should always show their pick-up HUD when the player is in strategic mode. + /// @return Whether or not devices on Scene should always show their pick-up HUD when the player is in strategic mode. bool AlwaysDisplayUnheldItemsInStrategicMode() const { return m_AlwaysDisplayUnheldItemsInStrategicMode; } - /// /// Sets whether or not devices on Scene should always show their pick-up HUD when the player is in strategic mode. - /// - /// Whether or not devices on Scene should always show their pick-up HUD when the player is in strategic mode. + /// @param shouldShowUnheldItemsInStrategicMode Whether or not devices on Scene should always show their pick-up HUD when the player is in strategic mode. void SetAlwaysDisplayUnheldItemsInStrategicMode(bool shouldShowUnheldItemsInStrategicMode) { m_AlwaysDisplayUnheldItemsInStrategicMode = shouldShowUnheldItemsInStrategicMode; } - /// /// Gets the number of MS a PieSlice with a sub-PieMenu needs to be hovered over for the sub-PieMenu to open. - /// - /// The number of MS a PieSlice with a sub-PieMenu needs to be hovered over for the sub-PieMenu to open. + /// @return The number of MS a PieSlice with a sub-PieMenu needs to be hovered over for the sub-PieMenu to open. int GetSubPieMenuHoverOpenDelay() const { return m_SubPieMenuHoverOpenDelay; } - /// /// Sets the number of MS a PieSlice with a sub-PieMenu needs to be hovered over for the sub-PieMenu to open. - /// - /// The number of MS a PieSlice with a sb-PieMenu needs to be hovered over for the sub-PieMenu to open. + /// @param newSubPieMenuHoverOpenDelay The number of MS a PieSlice with a sb-PieMenu needs to be hovered over for the sub-PieMenu to open. void SetSubPieMenuHoverOpenDelay(int newSubPieMenuHoverOpenDelay) { m_SubPieMenuHoverOpenDelay = newSubPieMenuHoverOpenDelay; } - /// /// Whether red and white flashes appear when brain is damaged. - /// - /// Whether red and white flashes appear when brain is damaged. + /// @return Whether red and white flashes appear when brain is damaged. bool FlashOnBrainDamage() const { return m_FlashOnBrainDamage; } - /// /// Sets whether red and white flashes appear when brain is damaged. - /// - /// New value for Flash on brain damage setting. + /// @param newValue New value for Flash on brain damage setting. void SetFlashOnBrainDamage(bool newValue) { m_FlashOnBrainDamage = newValue; } - /// /// Whether we need to show items from other factions in buy menu GUI. - /// - /// True if we need to show foreign items. + /// @return True if we need to show foreign items. bool ShowForeignItems() const { return m_ShowForeignItems; } - /// /// Set whether we need to show items from other factions in buy menu GUI. - /// - /// If we need to show foreign items. + /// @param newValue If we need to show foreign items. void SetShowForeignItems(bool newValue) { m_ShowForeignItems = newValue; } - /// /// Gets whether the crab bomb effect is enabled or not. - /// - /// Whether the crab bomb effect is enabled or not. False means releasing whatever number of crabs will do nothing except release whatever number of crabs. + /// @return Whether the crab bomb effect is enabled or not. False means releasing whatever number of crabs will do nothing except release whatever number of crabs. bool CrabBombsEnabled() const { return m_EnableCrabBombs; } - /// /// Sets whether the crab bomb effect is enabled or not. - /// - /// Enable the crab bomb effect or not. False means releasing whatever number of crabs will do nothing except release whatever number of crabs. + /// @param enable Enable the crab bomb effect or not. False means releasing whatever number of crabs will do nothing except release whatever number of crabs. void SetCrabBombsEnabled(bool enable) { m_EnableCrabBombs = enable; } - /// /// Gets the number of crabs needed to be released at once to trigger the crab bomb effect. - /// - /// The number of crabs needed to be released at once to trigger the crab bomb effect. + /// @return The number of crabs needed to be released at once to trigger the crab bomb effect. int GetCrabBombThreshold() const { return m_CrabBombThreshold; } - /// /// Sets the number of crabs needed to be released at once to trigger the crab bomb effect. - /// - /// The new number of crabs needed to be released at once to trigger the crab bomb effect. + /// @param newThreshold The new number of crabs needed to be released at once to trigger the crab bomb effect. void SetCrabBombThreshold(int newThreshold) { m_CrabBombThreshold = newThreshold; } - /// /// Gets whether the HUD of enemy Actors is set to be visible to the player or not. - /// - /// Whether the HUD of enemy Actors is visible to the player. + /// @return Whether the HUD of enemy Actors is visible to the player. bool ShowEnemyHUD() const { return m_ShowEnemyHUD; } - /// /// Sets whether the HUD of enemy Actors should to be visible to the player or not. - /// - /// Whether the HUD of enemy Actors should be visible to the player or not. + /// @param showHUD Whether the HUD of enemy Actors should be visible to the player or not. void SetShowEnemyHUD(bool showHUD) { m_ShowEnemyHUD = showHUD; } - /// /// Gets whether smart BuyMenu navigation is enabled, meaning swapping to equipment mode and back will change active tabs in the BuyMenu. - /// - /// Whether smart BuyMenu navigation is enabled or not. + /// @return Whether smart BuyMenu navigation is enabled or not. bool SmartBuyMenuNavigationEnabled() const { return m_EnableSmartBuyMenuNavigation; } - /// /// Sets whether smart BuyMenu navigation is enabled, meaning swapping to equipment mode and back will change active tabs in the BuyMenu. - /// - /// Whether to enable smart BuyMenu navigation or not. + /// @param enable Whether to enable smart BuyMenu navigation or not. void SetSmartBuyMenuNavigation(bool enable) { m_EnableSmartBuyMenuNavigation = enable; } - /// /// Gets whether gold gathered by Actors is automatically added into team funds. - /// - /// Whether gold gathered by Actors is automatically added into team funds. + /// @return Whether gold gathered by Actors is automatically added into team funds. bool GetAutomaticGoldDeposit() const { return m_AutomaticGoldDeposit; } #pragma endregion #pragma region Network Settings - /// /// Gets the player name that is used in network multiplayer matches. - /// - /// String with the network player name. + /// @return String with the network player name. std::string GetPlayerNetworkName() const { return m_PlayerNetworkName; } - /// /// Sets the player name that will be used in network multiplayer matches. - /// - /// String with the new player name to use. + /// @param newName String with the new player name to use. void SetPlayerNetworkName(const std::string& newName) { m_PlayerNetworkName = newName.empty() ? "Dummy" : newName; } - /// /// Gets the LAN server address to connect to. - /// - /// The current LAN server address to connect to. + /// @return The current LAN server address to connect to. std::string GetNetworkServerAddress() const { return m_NetworkServerAddress; } - /// /// Sets the LAN server address to connect to. - /// - /// New LAN server address to connect to. + /// @param newName New LAN server address to connect to. void SetNetworkServerAddress(const std::string& newAddress) { m_NetworkServerAddress = newAddress.empty() ? "127.0.0.1:8000" : newAddress; } - /// /// Gets the NAT punch-through server address. - /// - /// The current NAT punch-through server address to connect to. + /// @return The current NAT punch-through server address to connect to. std::string& GetNATServiceAddress() { return m_NATServiceAddress; } - /// /// Sets the NAT punch-through server address. - /// - /// New NAT punch-through server address to connect to. + /// @param newValue New NAT punch-through server address to connect to. void SetNATServiceAddress(const std::string& newAddress) { m_NATServiceAddress = newAddress.empty() ? "127.0.0.1:61111" : newAddress; } - /// /// Gets the server name used when connecting via NAT punch-through service. - /// - /// Name of the NAT punch-through server. + /// @return Name of the NAT punch-through server. std::string& GetNATServerName() { return m_NATServerName; } - /// /// Sets the server name to use when connecting via NAT punch-through service. - /// - /// New NAT punch-through server name. + /// @param newValue New NAT punch-through server name. void SetNATServerName(const std::string& newName) { m_NATServerName = newName.empty() ? "DefaultServerName" : newName; } - /// /// Gets the server password to use when connecting via NAT punch-through service. - /// - /// The server password to use when connecting via NAT punch-through service. + /// @return The server password to use when connecting via NAT punch-through service. std::string& GetNATServerPassword() { return m_NATServerPassword; } - /// /// Sets the server password to use when connecting via NAT punch-through service. - /// - /// New password to use when connecting via NAT punch-through service. + /// @param newValue New password to use when connecting via NAT punch-through service. void SetNATServerPassword(const std::string& newValue) { m_NATServerPassword = newValue.empty() ? "DefaultServerPassword" : newValue; } - /// /// Gets whether or not experimental multiplayer speedboosts should be used. - /// - /// Whether or not experimental multiplayer speedboosts should be used. + /// @return Whether or not experimental multiplayer speedboosts should be used. bool UseExperimentalMultiplayerSpeedBoosts() const { return m_UseExperimentalMultiplayerSpeedBoosts; } - /// /// Sets whether or not experimental multiplayer speedboosts should be used. - /// - /// Whether or not experimental multiplayer speedboosts should be used. + /// @param newValue Whether or not experimental multiplayer speedboosts should be used. void SetUseExperimentalMultiplayerSpeedBoosts(bool newValue) { m_UseExperimentalMultiplayerSpeedBoosts = newValue; } #pragma endregion #pragma region Editor Settings - /// /// Returns the list of visible assembly groups. - /// - /// List of visible assembly groups. + /// @return List of visible assembly groups. std::list GetVisibleAssemblyGroupsList() const { return m_VisibleAssemblyGroupsList; } - /// /// Whether editors will allow to select Base.rte as a module to save in - /// - /// True of editors are allowed to select Base.rte as a module to save in. + /// @return True of editors are allowed to select Base.rte as a module to save in. bool AllowSavingToBase() const { return m_AllowSavingToBase; } - /// /// Whether we need to show MetaScenes in editors and scenario UI. - /// - /// True if we need to show MetaScenes. + /// @return True if we need to show MetaScenes. bool ShowMetascenes() const { return m_ShowMetaScenes; } #pragma endregion #pragma region Mod and Script Management - /// /// Gets the map of mods which are disabled. - /// - /// Map of mods which are disabled. + /// @return Map of mods which are disabled. std::unordered_map& GetDisabledModsMap() { return m_DisabledMods; } - /// /// Gets whether the specified mod is disabled in the settings. - /// - /// Mod to check. - /// Whether the mod is disabled via settings. + /// @param modModule Mod to check. + /// @return Whether the mod is disabled via settings. bool IsModDisabled(const std::string& modModule) const { return (m_DisabledMods.find(modModule) != m_DisabledMods.end()) ? m_DisabledMods.at(modModule) : false; } - /// /// Gets the map of global scripts which are enabled. - /// - /// Map of global scripts which are enabled. + /// @return Map of global scripts which are enabled. std::unordered_map& GetEnabledGlobalScriptMap() { return m_EnabledGlobalScripts; } - /// /// Gets whether the specified global script is enabled in the settings. - /// - /// Global script to check. - /// Whether the global script is enabled via settings. + /// @param scriptName Global script to check. + /// @return Whether the global script is enabled via settings. bool IsGlobalScriptEnabled(const std::string& scriptName) const { return (m_EnabledGlobalScripts.find(scriptName) != m_EnabledGlobalScripts.end()) ? m_EnabledGlobalScripts.at(scriptName) : false; } #pragma endregion #pragma region Misc Settings - /// /// Gets whether the game intro is set to be skipped on game startup or not. - /// - /// Whether intro is set to be skipped or not. + /// @return Whether intro is set to be skipped or not. bool SkipIntro() const { return m_SkipIntro; } - /// /// Sets whether the game intro should be skipped on game startup or not. - /// - /// Whether to skip game intro or not. + /// @param play Whether to skip game intro or not. void SetSkipIntro(bool play) { m_SkipIntro = play; } - /// /// Gets whether tooltip display on certain UI elements is enabled or not. - /// - /// Whether tooltips are displayed or not. + /// @return Whether tooltips are displayed or not. bool ShowToolTips() const { return m_ShowToolTips; } - /// /// Sets whether to display tooltips on certain UI elements or not. - /// - /// Whether to display tooltips or not. + /// @param showToolTips Whether to display tooltips or not. void SetShowToolTips(bool showToolTips) { m_ShowToolTips = showToolTips; } - /// /// Gets whether to draw AtomGroup visualizations or not. - /// - /// Whether to draw AtomGroup visualizations or not. + /// @return Whether to draw AtomGroup visualizations or not. bool DrawAtomGroupVisualizations() const { return m_DrawAtomGroupVisualizations; } - /// /// Sets whether to draw AtomGroup visualizations or not. - /// - /// Whether to draw AtomGroup visualizations or not. + /// @param drawAtomGroupVisualizations Whether to draw AtomGroup visualizations or not. void SetDrawAtomGroupVisualizations(bool drawAtomGroupVisualizations) { m_DrawAtomGroupVisualizations = drawAtomGroupVisualizations; } - /// /// Gets whether to draw HandGroup and FootGroup visualizations or not. - /// - /// Whether to draw HandGroup and FootGroup visualizations or not. + /// @return Whether to draw HandGroup and FootGroup visualizations or not. bool DrawHandAndFootGroupVisualizations() const { return m_DrawHandAndFootGroupVisualizations; } - /// /// Sets whether to draw HandGroup and FootGroup visualizations or not. - /// - /// Whether to draw HandGroup and FootGroup visualizations or not. + /// @param drawHandAndFootGroupVisualizations Whether to draw HandGroup and FootGroup visualizations or not. void SetDrawHandAndFootGroupVisualizations(bool drawHandAndFootGroupVisualizations) { m_DrawHandAndFootGroupVisualizations = drawHandAndFootGroupVisualizations; } - /// /// Gets whether to draw LimbPath visualizations or not. - /// - /// Whether to draw LimbPath visualizations or not. + /// @return Whether to draw LimbPath visualizations or not. bool DrawLimbPathVisualizations() const { return m_DrawLimbPathVisualizations; } - /// /// Sets whether to draw LimbPath visualizations or not. - /// - /// Whether to draw AtomGroup visualizations or not. + /// @param drawAtomGroupVisualizations Whether to draw AtomGroup visualizations or not. void SetDrawLimbPathVisualizations(bool drawLimbPathVisualizations) { m_DrawLimbPathVisualizations = drawLimbPathVisualizations; } - /// /// Gets whether debug print mode is enabled or not. - /// - /// Whether debug print mode is enabled or not. + /// @return Whether debug print mode is enabled or not. bool PrintDebugInfo() const { return m_PrintDebugInfo; } - /// /// Sets print debug info mode. - /// - /// New debug print mode value. + /// @param printDebugInfo New debug print mode value. void SetPrintDebugInfo(bool printDebugInfo) { m_PrintDebugInfo = printDebugInfo; } - /// /// Gets whether displaying the reader progress report during module loading is disabled or not. - /// - /// Whether the reader progress report is being displayed during module loading or not. + /// @return Whether the reader progress report is being displayed during module loading or not. bool GetLoadingScreenProgressReportDisabled() const { return m_DisableLoadingScreenProgressReport; } - /// /// Sets whether the reader progress report should be displayed during module loading or not. - /// - /// Whether to display the reader progress report during module loading or not. + /// @param disable Whether to display the reader progress report during module loading or not. void SetLoadingScreenProgressReportDisabled(bool disable) { m_DisableLoadingScreenProgressReport = disable; } - /// /// Gets how accurately the reader progress report tells what line it's reading during module loading. - /// - /// How accurately the reader progress report tells what line it's reading during module loading. + /// @return How accurately the reader progress report tells what line it's reading during module loading. int LoadingScreenProgressReportPrecision() const { return m_LoadingScreenProgressReportPrecision; } - /// /// Gets the multiplier value for the transition durations between different menus. - /// - /// The multiplier value for the transition durations between different menus. Lower values equal faster transitions. + /// @return The multiplier value for the transition durations between different menus. Lower values equal faster transitions. float GetMenuTransitionDurationMultiplier() const { return m_MenuTransitionDurationMultiplier; } - /// /// Sets the multiplier value for the transition durations between different menus. - /// - /// New multiplier value for the transition durations between different menus. Lower values equal faster transitions. + /// @param newSpeed New multiplier value for the transition durations between different menus. Lower values equal faster transitions. void SetMenuTransitionDurationMultiplier(float newSpeed) { m_MenuTransitionDurationMultiplier = std::max(0.0F, newSpeed); } - /// /// Gets whether the duration of module loading (extraction included) is being measured or not. For benchmarking purposes. - /// - /// Whether duration is being measured or not. + /// @return Whether duration is being measured or not. bool IsMeasuringModuleLoadTime() const { return m_MeasureModuleLoadTime; } - /// /// Sets whether the duration of module loading (extraction included) should be measured or not. For benchmarking purposes. - /// - /// Whether duration should be measured or not. + /// @param measure Whether duration should be measured or not. void MeasureModuleLoadTime(bool measure) { m_MeasureModuleLoadTime = measure; } #pragma endregion @@ -583,9 +417,7 @@ namespace RTE { std::string m_SettingsPath; //!< String containing the Path to the Settings.ini file. - /// /// Clears all the member variables of this SettingsMan, effectively resetting the members of this abstraction level only. - /// void Clear(); // Disallow the use of some implicit methods. diff --git a/Source/Managers/ThreadMan.cpp b/Source/Managers/ThreadMan.cpp index 42a7ab4c6b..7df1e603d5 100644 --- a/Source/Managers/ThreadMan.cpp +++ b/Source/Managers/ThreadMan.cpp @@ -1,46 +1,18 @@ -////////////////////////////////////////////////////////////////////////////////////////// -// File: ThreadMan.cpp -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Source file for the ThreadMan class. -// Project: Retro Terrain Engine -// Author(s): -// -// - -////////////////////////////////////////////////////////////////////////////////////////// -// Inclusions of header files - #include "ThreadMan.h" using namespace std; namespace RTE { - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Clear - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears all the member variables of this ThreadMan, effectively - // resetting the members of this abstraction level only. - void ThreadMan::Clear() { m_PriorityThreadPool.reset(); m_BackgroundThreadPool.reset(std::thread::hardware_concurrency() / 2); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes the ThreadMan object ready for use. - int ThreadMan::Create() { return 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destroys and resets (through Clear()) the ThreadMan object. - void ThreadMan::Destroy() { Clear(); } diff --git a/Source/Managers/ThreadMan.h b/Source/Managers/ThreadMan.h index 69f2be9b07..5fa41f9aec 100644 --- a/Source/Managers/ThreadMan.h +++ b/Source/Managers/ThreadMan.h @@ -1,18 +1,9 @@ #ifndef _RTEThreadMan_ #define _RTEThreadMan_ -////////////////////////////////////////////////////////////////////////////////////////// -// File: ThreadMan.h -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Header file for the ThreadMan class. -// Project: Retro Terrain Engine -// Author(s): -// -// - -////////////////////////////////////////////////////////////////////////////////////////// -// Inclusions of header files - +/// Header file for the ThreadMan class. +/// Author(s): +/// Inclusions of header files #include "Singleton.h" #define g_ThreadMan ThreadMan::Instance() @@ -20,95 +11,48 @@ namespace RTE { - ////////////////////////////////////////////////////////////////////////////////////////// - // Class: ThreadMan - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: The centralized singleton manager of all threads. - // Parent(s): Singleton - // Class history: 03/29/2014 ThreadMan created. - + /// The centralized singleton manager of all threads. class ThreadMan : public Singleton { - ////////////////////////////////////////////////////////////////////////////////////////// - // Public member variable, method and friend function declarations - + /// Public member variable, method and friend function declarations public: - ////////////////////////////////////////////////////////////////////////////////////////// - // Constructor: ThreadMan - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Constructor method used to instantiate a ThreadMan object in system - // memory. Create() should be called before using the object. - // Arguments: None. - + /// Constructor method used to instantiate a ThreadMan object in system + /// memory. Create() should be called before using the object. ThreadMan() { Clear(); Create(); } - /// /// Makes the TimerMan object ready for use. - /// void Initialize(){}; - ////////////////////////////////////////////////////////////////////////////////////////// - // Destructor: ~ThreadMan - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destructor method used to clean up a ThreadMan object before deletion - // from system memory. - // Arguments: None. - + /// Destructor method used to clean up a ThreadMan object before deletion + /// from system memory. virtual ~ThreadMan() { Destroy(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes the ThreadMan object ready for use. - // Arguments: None. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Makes the ThreadMan object ready for use. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. virtual int Create(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Virtual method: Reset - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Resets the entire ThreadMan, including its inherited members, to - // their default settings or values. - // Arguments: None. - // Return value: None. - + /// Resets the entire ThreadMan, including its inherited members, to + /// their default settings or values. virtual void Reset() { Clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destroys and resets (through Clear()) the ThreadMan object. - // Arguments: None. - // Return value: None. - + /// Destroys and resets (through Clear()) the ThreadMan object. void Destroy(); BS::thread_pool& GetPriorityThreadPool() { return m_PriorityThreadPool; } BS::thread_pool& GetBackgroundThreadPool() { return m_BackgroundThreadPool; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Protected member variable and method declarations - + /// Protected member variable and method declarations protected: - ////////////////////////////////////////////////////////////////////////////////////////// - // Private member variable and method declarations - + /// Private member variable and method declarations private: - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Clear - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears all the member variables of this ThreadMan, effectively - // resetting the members of this abstraction level only. - // Arguments: None. - // Return value: None. - + /// Clears all the member variables of this ThreadMan, effectively + /// resetting the members of this abstraction level only. void Clear(); // Disallow the use of some implicit methods. diff --git a/Source/Managers/TimerMan.cpp b/Source/Managers/TimerMan.cpp index 49b3315572..4a0cad188d 100644 --- a/Source/Managers/TimerMan.cpp +++ b/Source/Managers/TimerMan.cpp @@ -12,8 +12,6 @@ namespace RTE { - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void TimerMan::Clear() { m_StartTime = std::chrono::steady_clock::now(); m_TicksPerSecond = 1000000; @@ -31,7 +29,6 @@ namespace RTE { m_SimPaused = false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void TimerMan::Initialize() { // Get the frequency of ticks/s for this machine m_TicksPerSecond = 1000000; @@ -42,26 +39,18 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - long long TimerMan::GetAbsoluteTime() const { return std::chrono::duration_cast(std::chrono::steady_clock::now().time_since_epoch()).count(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - float TimerMan::GetRealToSimCap() const { return c_RealToSimCap; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - float TimerMan::GetAIDeltaTimeSecs() const { return m_DeltaTimeS * static_cast(g_SettingsMan.GetAIUpdateInterval()); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void TimerMan::ResetTime() { m_StartTime = std::chrono::steady_clock::now(); @@ -74,8 +63,6 @@ namespace RTE { m_TimeScale = 1.0F; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void TimerMan::UpdateSim() { if (TimeForSimUpdate()) { // Transfer ticks from the accumulator to the sim time ticks. @@ -92,8 +79,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void TimerMan::Update() { long long prevTime = m_RealTimeTicks; m_RealTimeTicks = std::chrono::duration_cast(std::chrono::steady_clock::now() - m_StartTime).count(); diff --git a/Source/Managers/TimerMan.h b/Source/Managers/TimerMan.h index b3826bf090..8491f0eb06 100644 --- a/Source/Managers/TimerMan.h +++ b/Source/Managers/TimerMan.h @@ -7,169 +7,119 @@ namespace RTE { - /// /// The centralized singleton manager of all Timers and overall timekeeping in RTE. /// Uses QueryPerformanceCounter for sub-ms resolution timers and the model described in http://www.gaffer.org/game-physics/fix-your-timestep. - /// class TimerMan : public Singleton { public: #pragma region Creation - /// /// Constructor method used to instantiate a TimerMan object in system memory. Initialize() should be called before using this object. - /// TimerMan() { Clear(); Initialize(); }; - /// /// Makes the TimerMan object ready for use. - /// void Initialize(); #pragma endregion #pragma region Destruction - /// /// Destroys and resets (through Clear()) the TimerMan object. - /// void Destroy() { Clear(); } #pragma endregion #pragma region Getters and Setters - /// /// Gets the current time stamp in microseconds unrelated to TimerMan updates. Can be used to measure time intervals during a single frame update. - /// - /// Current time stamp in microseconds. + /// @return Current time stamp in microseconds. long long GetAbsoluteTime() const; - /// /// Sets the sim to be paused, ie no real time ticks will be transferred to the sim accumulator while this is set to true. /// This also clears the accumulator, to avoid the case where the sim may update while paused when behind schedule. - /// - /// Whether the sim should be paused or not. + /// @param pause Whether the sim should be paused or not. void PauseSim(bool pause = false) { m_SimPaused = pause; if (pause) m_SimAccumulator = 0.0F; } - /// /// Tells whether there is enough sim time accumulated to do at least one physics update. - /// - /// Whether there is enough sim time to do a physics update. + /// @return Whether there is enough sim time to do a physics update. bool TimeForSimUpdate() const { return m_SimAccumulator >= m_DeltaTime; } - /// /// Tells whether the current simulation update will be drawn in a frame. Use this to check if it is necessary to draw purely graphical things during the sim update. - /// - /// Whether this is the last sim update before a frame with its results will appear. + /// @return Whether this is the last sim update before a frame with its results will appear. bool DrawnSimUpdate() const { return m_DrawnSimUpdate; } - /// /// Tells how many sim updates have been performed since the last one that ended up being a drawn frame. /// If negative, it means no sim updates have happened, and a same frame will be drawn again. - /// - /// The number of pure sim updates that have happened since the last drawn. + /// @return The number of pure sim updates that have happened since the last drawn. int SimUpdatesSinceDrawn() const { return m_SimUpdatesSinceDrawn; } - /// /// Gets the simulation speed over real time. - /// - /// The value of the simulation speed over real time. + /// @return The value of the simulation speed over real time. float GetSimSpeed() const { return m_SimSpeed; } - /// /// Gets a time scale factor which will be used to speed up or slow down the progress of the simulation time in relation to the real world time. - /// - /// A factor between the real world time, and the simulation time. + /// @return A factor between the real world time, and the simulation time. float GetTimeScale() const { return m_TimeScale; } - /// /// Sets a time scale factor which will be used to speed up or slow down the progress of the simulation time in relation to the real world time. - /// - /// A factor between the real world time, and the simulation time. A value of 2.0 means simulation runs twice as fast as normal. + /// @param timeScale A factor between the real world time, and the simulation time. A value of 2.0 means simulation runs twice as fast as normal. void SetTimeScale(float timeScale = 1.0F) { m_TimeScale = timeScale; } - /// /// Gets the cap of the amount of seconds which can be transferred from the real time to the simulated time in one update. - /// - /// A float describing the current cap in seconds. + /// @return A float describing the current cap in seconds. float GetRealToSimCap() const; - /// /// Gets the number of ticks per second (the resolution of the timer). - /// - /// The number of ticks per second. + /// @return The number of ticks per second. long long GetTicksPerSecond() const { return m_TicksPerSecond; } - /// /// Gets a current global real time measured in ticks from the start of the simulation up to the last Update of this TimerMan. Use TickFrequency to determine how many ticks go in a second. - /// - /// The number of ticks passed since the simulation started. + /// @return The number of ticks passed since the simulation started. long long GetRealTickCount() const { return m_RealTimeTicks; } - /// /// Gets a current global simulation time measured in ticks from the start of the simulation up to the last Update of this TimerMan. Use TickFrequency to determine how many ticks go in a second. - /// - /// The number of ticks passed since the simulation started. + /// @return The number of ticks passed since the simulation started. long long GetSimTickCount() const { return m_SimTimeTicks; } - /// /// Gets a current global simulation time, measured in sim updates, from the start of the simulation up to the last Update of this TimerMan. - /// - /// The number of simulation updates that have occurred since the simulation started. + /// @return The number of simulation updates that have occurred since the simulation started. long long GetSimUpdateCount() const { return m_SimUpdateCount; } - /// /// Gets a current global simulation time measured in ms ticks from the start of the simulation up to the last UpdateSim of this TimerMan. - /// - /// The number of ms passed since the simulation started. + /// @return The number of ms passed since the simulation started. long long GetSimTimeMS() const { return static_cast((static_cast(m_SimTimeTicks) / static_cast(m_TicksPerSecond)) * 0.001F); } - /// /// Gets the current number of ticks that the simulation should be updating with. - /// - /// The current fixed delta time that the simulation should be updating with, in ticks. + /// @return The current fixed delta time that the simulation should be updating with, in ticks. long long GetDeltaTimeTicks() const { return m_DeltaTime; } - /// /// Sets the number of ticks that a simulation update delta time should take. - /// - /// The new delta time in ticks. + /// @param newDelta The new delta time in ticks. void SetDeltaTimeTicks(int newDelta) { m_DeltaTime = newDelta; m_DeltaTimeS = static_cast(m_DeltaTime) / static_cast(m_TicksPerSecond); } - /// /// Gets the current fixed delta time of the simulation updates, in ms. - /// - /// The current fixed delta time that the simulation should be updating with, in ms. + /// @return The current fixed delta time that the simulation should be updating with, in ms. float GetDeltaTimeMS() const { return m_DeltaTimeS * 1000; } - /// /// Gets the current fixed delta time of the simulation updates, in seconds. - /// - /// The current fixed delta time that the simulation should be updating with, in seconds. + /// @return The current fixed delta time that the simulation should be updating with, in seconds. float GetDeltaTimeSecs() const { return m_DeltaTimeS; } - /// /// Gets the current fixed delta time of AI updates, in seconds. - /// - /// The current fixed delta time of AI updates, in seconds. + /// @return The current fixed delta time of AI updates, in seconds. float GetAIDeltaTimeSecs() const; - /// /// Gets the current fixed delta time of AI updates, in ms. - /// - /// The current fixed delta time of AI updates, in ms. + /// @return The current fixed delta time of AI updates, in ms. float GetAIDeltaTimeMS() const { return GetAIDeltaTimeSecs() * 1000; }; - /// /// Sets the number of seconds that a simulation update delta time should take. - /// - /// The new delta time in seconds. + /// @param newDelta The new delta time in seconds. void SetDeltaTimeSecs(float newDelta) { m_DeltaTimeS = newDelta; m_DeltaTime = static_cast(m_DeltaTimeS * static_cast(m_TicksPerSecond)); @@ -177,27 +127,19 @@ namespace RTE { #pragma endregion #pragma region Concrete Methods - /// /// Resets the measured real and simulation times to 0. - /// void ResetTime(); - /// /// Updates the simulation time to represent the current amount of simulation time passed from the start of the simulation up to the last update. - /// void UpdateSim(); - /// /// Updates the real time ticks based on the actual clock time and adds it to the accumulator which the simulation ticks will draw from in whole DeltaTime-sized chunks. - /// void Update(); #pragma endregion #pragma region Network Handling - /// /// Gets the duration the thread should be put to sleep. This is used when ServerSimSleepWhenIdle is true to put the thread to sleep if the sim frame is finished faster than it usually should. - /// - /// The duration the thread should be put to sleep. + /// @return The duration the thread should be put to sleep. long long GetTimeToSleep() const { return (m_DeltaTime - m_SimAccumulator) / 2; }; #pragma endregion @@ -222,9 +164,7 @@ namespace RTE { bool m_SimPaused; //!< Simulation paused; no real time ticks will go to the sim accumulator. private: - /// /// Clears all the member variables of this TimerMan, effectively resetting the members of this abstraction level only. - /// void Clear(); // Disallow the use of some implicit methods. diff --git a/Source/Managers/UInputMan.cpp b/Source/Managers/UInputMan.cpp index 193e189684..88cc3b5bae 100644 --- a/Source/Managers/UInputMan.cpp +++ b/Source/Managers/UInputMan.cpp @@ -24,8 +24,6 @@ namespace RTE { std::vector UInputMan::s_PrevJoystickStates(Players::MaxPlayerCount); std::vector UInputMan::s_ChangedJoystickStates(Players::MaxPlayerCount); - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void UInputMan::Clear() { m_SkipHandlingSpecialInput = false; m_TextInput.clear(); @@ -87,8 +85,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int UInputMan::Initialize() { int numKeys; const Uint8* keyboardState = SDL_GetKeyboardState(&numKeys); @@ -132,8 +128,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void UInputMan::LoadDeviceIcons() { m_DeviceIcons[InputDevice::DEVICE_KEYB_ONLY] = dynamic_cast(g_PresetMan.GetEntityPreset("Icon", "Device Keyboard")); m_DeviceIcons[InputDevice::DEVICE_MOUSE_KEYB] = dynamic_cast(g_PresetMan.GetEntityPreset("Icon", "Device Mouse")); @@ -143,8 +137,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - Vector UInputMan::AnalogMoveValues(int whichPlayer) { Vector moveValues(0, 0); InputDevice device = m_ControlScheme.at(whichPlayer).GetDevice(); @@ -163,8 +155,6 @@ namespace RTE { return moveValues; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - Vector UInputMan::AnalogAimValues(int whichPlayer) { InputDevice device = m_ControlScheme.at(whichPlayer).GetDevice(); @@ -191,8 +181,6 @@ namespace RTE { return aimValues; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - Vector UInputMan::GetMenuDirectional() { Vector allInput(0, 0); for (int player = Players::PlayerOne; player < Players::MaxPlayerCount; ++player) { @@ -239,8 +227,6 @@ namespace RTE { return allInput; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool UInputMan::AnyKeyOrJoyInput() const { bool input = AnyKeyPress(); if (!input) { @@ -249,8 +235,6 @@ namespace RTE { return input; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool UInputMan::AnyPress() const { bool pressed = false; @@ -267,8 +251,6 @@ namespace RTE { return pressed; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool UInputMan::AnyStartPress(bool includeSpacebar) { if (KeyPressed(SDLK_ESCAPE) || (includeSpacebar && KeyPressed(SDLK_SPACE))) { return true; @@ -281,8 +263,6 @@ namespace RTE { return false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool UInputMan::AnyBackPress() { for (int player = Players::PlayerOne; player < Players::MaxPlayerCount; ++player) { if (ElementPressed(player, InputElements::INPUT_BACK)) { @@ -292,8 +272,6 @@ namespace RTE { return false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool UInputMan::AnyKeyPress() const { for (size_t testKey = SDL_SCANCODE_A; testKey < SDL_NUM_SCANCODES; ++testKey) { if (s_PrevKeyStates[testKey] && s_ChangedKeyStates[testKey]) { @@ -303,8 +281,6 @@ namespace RTE { return false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int UInputMan::MouseUsedByPlayer() const { for (int player = Players::PlayerOne; player < Players::MaxPlayerCount; player++) { if (m_ControlScheme[player].GetDevice() == InputDevice::DEVICE_MOUSE_KEYB) { @@ -314,8 +290,6 @@ namespace RTE { return Players::NoPlayer; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void UInputMan::DisableMouseMoving(bool disable) { if (disable) { SDL_SetRelativeMouseMode(SDL_FALSE); @@ -327,8 +301,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - Vector UInputMan::GetMouseMovement(int whichPlayer) const { if (IsInMultiplayerMode() && whichPlayer >= Players::PlayerOne && whichPlayer < Players::MaxPlayerCount) { return m_NetworkAccumulatedRawMouseMovement[whichPlayer]; @@ -339,8 +311,6 @@ namespace RTE { return Vector(0, 0); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void UInputMan::SetMouseValueMagnitude(float magCap, int whichPlayer) { if (IsInMultiplayerMode() && whichPlayer >= Players::PlayerOne && whichPlayer < Players::MaxPlayerCount) { m_NetworkAnalogMoveData[whichPlayer].CapMagnitude(m_MouseTrapRadius * magCap); @@ -348,8 +318,6 @@ namespace RTE { m_AnalogMouseData.SetMagnitude(m_MouseTrapRadius * magCap); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void UInputMan::SetMouseValueAngle(float angle, int whichPlayer) { if (IsInMultiplayerMode() && whichPlayer >= Players::PlayerOne && whichPlayer < Players::MaxPlayerCount) { m_NetworkAnalogMoveData[whichPlayer].SetAbsRadAngle(angle); @@ -357,8 +325,6 @@ namespace RTE { m_AnalogMouseData.SetAbsRadAngle(angle); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void UInputMan::SetMousePos(const Vector& newPos, int whichPlayer) const { // Only mess with the mouse if the original mouse position is not above the screen and may be grabbing the title bar of the game window if (!m_DisableMouseMoving && !m_TrapMousePos && (whichPlayer == Players::NoPlayer || m_ControlScheme.at(whichPlayer).GetDevice() == InputDevice::DEVICE_MOUSE_KEYB)) { @@ -366,8 +332,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool UInputMan::AnyMouseButtonPress() const { for (int button = MouseButtons::MOUSE_LEFT; button < MouseButtons::MAX_MOUSE_BUTTONS; ++button) { if (MouseButtonPressed(button, -1)) { @@ -377,8 +341,6 @@ namespace RTE { return false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void UInputMan::TrapMousePos(bool trap, int whichPlayer) { if (!IsInMultiplayerMode() && (whichPlayer == Players::NoPlayer || m_ControlScheme.at(whichPlayer).GetDevice() == InputDevice::DEVICE_MOUSE_KEYB)) { m_TrapMousePos = trap; @@ -387,8 +349,6 @@ namespace RTE { m_TrapMousePosPerPlayer[whichPlayer] = trap; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void UInputMan::ForceMouseWithinBox(int x, int y, int width, int height, int whichPlayer) const { // Only mess with the mouse if the original mouse position is not above the screen and may be grabbing the title bar of the game window. if (g_WindowMan.AnyWindowHasFocus() && !m_DisableMouseMoving && !m_TrapMousePos && (whichPlayer == Players::NoPlayer || m_ControlScheme[whichPlayer].GetDevice() == InputDevice::DEVICE_MOUSE_KEYB)) { @@ -424,8 +384,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void UInputMan::ForceMouseWithinPlayerScreen(bool force, int whichPlayer) { float resMultiplier = g_WindowMan.GetResMultiplier(); @@ -470,8 +428,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int UInputMan::GetJoystickAxisCount(int whichJoy) const { if (whichJoy >= 0 && whichJoy < s_PrevJoystickStates.size()) { return s_PrevJoystickStates[whichJoy].m_Axis.size(); @@ -479,8 +435,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int UInputMan::WhichJoyButtonHeld(int whichJoy) const { if (whichJoy >= 0 && whichJoy < s_PrevJoystickStates.size()) { for (int button = 0; button < s_PrevJoystickStates[whichJoy].m_Buttons.size(); ++button) { @@ -493,8 +447,6 @@ namespace RTE { return JoyButtons::JOY_NONE; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int UInputMan::WhichJoyButtonPressed(int whichJoy) const { if (whichJoy >= 0 && whichJoy < s_PrevJoystickStates.size()) { for (int button = 0; button < s_PrevJoystickStates[whichJoy].m_Buttons.size(); ++button) { @@ -506,8 +458,6 @@ namespace RTE { return JoyButtons::JOY_NONE; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - float UInputMan::AnalogAxisValue(int whichJoy, int whichAxis) const { if (whichJoy < s_PrevJoystickStates.size() && whichAxis < s_PrevJoystickStates[whichJoy].m_Axis.size()) { if (s_PrevJoystickStates[whichJoy].m_JoystickID != -1) { @@ -518,8 +468,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool UInputMan::AnyJoyInput(bool checkForPresses) const { int gamepadIndex = 0; for (const Gamepad& gamepad: s_PrevJoystickStates) { @@ -546,8 +494,6 @@ namespace RTE { return false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool UInputMan::AnyJoyButtonPress(int whichJoy) const { for (int button = 0; button < s_PrevJoystickStates[whichJoy].m_Buttons.size(); ++button) { if (JoyButtonPressed(whichJoy, button)) { @@ -557,16 +503,12 @@ namespace RTE { return false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - Vector UInputMan::GetNetworkAccumulatedRawMouseMovement(int player) { Vector accumulatedMovement = m_NetworkAccumulatedRawMouseMovement[player]; m_NetworkAccumulatedRawMouseMovement[player].Reset(); return accumulatedMovement; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void UInputMan::ClearNetworkAccumulatedStates() { for (int inputState = InputState::Pressed; inputState < InputState::InputStateCount; inputState++) { for (int element = InputElements::INPUT_L_UP; element < InputElements::INPUT_COUNT; element++) { @@ -575,8 +517,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool UInputMan::GetInputElementState(int whichPlayer, int whichElement, InputState whichState) { if (IsInMultiplayerMode() && whichPlayer >= Players::PlayerOne && whichPlayer < Players::MaxPlayerCount) { return GetNetworkInputElementState(whichPlayer, whichElement, whichState); @@ -618,8 +558,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool UInputMan::GetMenuButtonState(int whichButton, InputState whichState) { for (int player = Players::PlayerOne; player < Players::MaxPlayerCount; ++player) { bool buttonState = false; @@ -638,8 +576,6 @@ namespace RTE { return false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool UInputMan::GetKeyboardButtonState(SDL_Scancode scancodeToTest, InputState whichState) const { if (m_DisableKeyboard && (scancodeToTest >= SDL_SCANCODE_0 && scancodeToTest < SDL_SCANCODE_ESCAPE)) { return false; @@ -657,8 +593,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool UInputMan::GetMouseButtonState(int whichPlayer, int whichButton, InputState whichState) const { if (whichButton < MouseButtons::MOUSE_LEFT || whichButton >= MouseButtons::MAX_MOUSE_BUTTONS) { return false; @@ -704,8 +638,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool UInputMan::GetJoystickButtonState(int whichJoy, int whichButton, InputState whichState) const { if (whichJoy < 0 || whichJoy >= s_PrevJoystickStates.size() || whichButton < 0 || whichButton >= s_PrevJoystickStates[whichJoy].m_Buttons.size()) { return false; @@ -728,8 +660,6 @@ namespace RTE { return false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool UInputMan::GetJoystickDirectionState(int whichJoy, int whichAxis, int whichDir, InputState whichState) const { if (whichJoy < 0 || whichJoy >= s_PrevJoystickStates.size() || whichAxis < 0 || whichAxis >= s_PrevJoystickStates[whichJoy].m_DigitalAxis.size()) { return false; @@ -765,14 +695,10 @@ namespace RTE { return false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void UInputMan::QueueInputEvent(const SDL_Event& inputEvent) { m_EventQueue.emplace_back(inputEvent); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int UInputMan::Update() { m_LastDeviceWhichControlledGUICursor = InputDevice::DEVICE_KEYB_ONLY; @@ -912,8 +838,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void UInputMan::HandleSpecialInput() { // If we launched into editor directly, skip the logic and quit quickly. if (g_ActivityMan.IsSetToLaunchIntoEditor() && KeyPressed(SDLK_ESCAPE)) { @@ -1023,8 +947,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void UInputMan::UpdateMouseInput() { // Detect and store mouse movement input, translated to analog stick emulation int mousePlayer = MouseUsedByPlayer(); @@ -1049,7 +971,6 @@ namespace RTE { } } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void UInputMan::UpdateJoystickAxis(std::vector::iterator device, int axis, int value) { if (device != s_PrevJoystickStates.end()) { @@ -1119,8 +1040,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void UInputMan::UpdateJoystickDigitalAxis() { for (size_t i = 0; i < s_PrevJoystickStates.size(); ++i) { for (size_t axis = 0; axis < s_PrevJoystickStates[i].m_DigitalAxis.size(); ++axis) { @@ -1140,8 +1059,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void UInputMan::HandleGamepadHotPlug(int deviceIndex) { SDL_Joystick* controller = nullptr; int controllerIndex = 0; @@ -1192,7 +1109,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void UInputMan::UpdateNetworkMouseMovement() { for (int player = Players::PlayerOne; player < Players::MaxPlayerCount; player++) { if (!m_NetworkAccumulatedRawMouseMovement[player].IsZero()) { @@ -1219,7 +1135,6 @@ namespace RTE { m_NetworkMouseWheelState[player] = 0; } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void UInputMan::SetNetworkInputElementState(int player, int element, bool newState) { if (element >= InputElements::INPUT_L_UP && element < InputElements::INPUT_COUNT && player >= Players::PlayerOne && player < Players::MaxPlayerCount) { m_NetworkServerChangedInputElementState[player][element] = (newState != m_NetworkServerPreviousInputElementState[player][element]); @@ -1227,7 +1142,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void UInputMan::SetNetworkMouseButtonState(int player, int whichButton, InputState whichState, bool newState) { if (whichButton >= MouseButtons::MOUSE_LEFT && whichButton < MouseButtons::MAX_MOUSE_BUTTONS && player >= Players::PlayerOne && player < Players::MaxPlayerCount) { m_NetworkServerChangedMouseButtonState[player][whichButton] = (newState != m_NetworkServerPreviousMouseButtonState[player][whichButton]); @@ -1235,7 +1149,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void UInputMan::StoreInputEventsForNextUpdate() { // Store pressed and released events to be picked by NetworkClient during its update. These will be cleared after update so we don't care about false but we store the result regardless. for (int inputState = InputState::Pressed; inputState < InputState::InputStateCount; inputState++) { diff --git a/Source/Managers/UInputMan.h b/Source/Managers/UInputMan.h index e2861f2f04..2acd327637 100644 --- a/Source/Managers/UInputMan.h +++ b/Source/Managers/UInputMan.h @@ -18,16 +18,12 @@ namespace RTE { class Icon; - /// /// The singleton manager responsible for handling user input. - /// class UInputMan : public Singleton { friend class SettingsMan; public: - /// /// Enumeration for the mouse cursor actions in menus. - /// enum MenuCursorButtons { MENU_PRIMARY, MENU_SECONDARY, @@ -35,627 +31,452 @@ namespace RTE { }; #pragma region Creation - /// /// Constructor method used to instantiate a UInputMan object in system memory. Create() should be called before using the object. - /// UInputMan() { Clear(); } - /// /// Makes the UInputMan object ready for use. - /// - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Initialize(); #pragma endregion #pragma region Destruction - /// /// Destructor method used to clean up a UInputMan object before deletion from system memory. - /// ~UInputMan() { Destroy(); } - /// /// Destroys and resets (through Clear()) the UInputMan object. - /// void Destroy() { Clear(); } #pragma endregion #pragma region Concrete Methods - /// /// Loads the input device icons from loaded presets. Can't do this during Create() because the presets don't exist so this will be called from MenuMan::Initialize() after modules are loaded. - /// void LoadDeviceIcons(); - /// /// Adds an (input) SDL_Event to the Event queue for processing on Update. - /// - /// The SDL input event to queue. + /// @param inputEvent The SDL input event to queue. void QueueInputEvent(const SDL_Event& inputEvent); - /// /// Updates the state of this UInputMan. Supposed to be done every frame. - /// - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Update(); #pragma endregion #pragma region Control Scheme and Input Mapping Handling - /// /// Sets whether to skip handling any special input (F1-F12, etc.) to avoid shenanigans during manual input mapping. - /// - /// Whether to skip handling special input or not. + /// @param skip Whether to skip handling special input or not. void SetSkipHandlingSpecialInput(bool skip) { m_SkipHandlingSpecialInput = skip; } - /// /// Gets the currently used input device of the specified player. - /// - /// Which player to get input device for. - /// A number value representing the currently used input device of this player. See InputDevice enumeration for values. + /// @param whichPlayer Which player to get input device for. + /// @return A number value representing the currently used input device of this player. See InputDevice enumeration for values. int GetInputDevice(int whichPlayer) const { return m_ControlScheme.at(whichPlayer).GetDevice(); } - /// /// Access a specific player's control scheme. - /// - /// Which player to get the scheme for. - /// A pointer to the requested player's control scheme. Ownership is NOT transferred! + /// @param whichPlayer Which player to get the scheme for. + /// @return A pointer to the requested player's control scheme. Ownership is NOT transferred! InputScheme* GetControlScheme(int whichPlayer) { return IsInMultiplayerMode() ? &m_ControlScheme[Players::PlayerOne] : &m_ControlScheme.at(whichPlayer); } - /// /// Get the current device Icon of a specific player's scheme. - /// - /// Which player to get the scheme device icon of. - /// A const pointer to the requested player's control scheme icon. Ownership is NOT transferred! + /// @param whichPlayer Which player to get the scheme device icon of. + /// @return A const pointer to the requested player's control scheme icon. Ownership is NOT transferred! const Icon* GetSchemeIcon(int whichPlayer) const { return (whichPlayer < Players::PlayerOne || whichPlayer >= Players::MaxPlayerCount) ? nullptr : m_DeviceIcons[m_ControlScheme.at(whichPlayer).GetDevice()]; } - /// /// Get the current device Icon of a specific device. - /// - /// Which device to get the icon of. - /// A const pointer to the requested device's control scheme icon. Ownership is NOT transferred! + /// @param whichDevice Which device to get the icon of. + /// @return A const pointer to the requested device's control scheme icon. Ownership is NOT transferred! const Icon* GetDeviceIcon(int whichDevice) const { return (whichDevice < InputDevice::DEVICE_KEYB_ONLY || whichDevice > InputDevice::DEVICE_GAMEPAD_4) ? nullptr : m_DeviceIcons[whichDevice]; } #pragma endregion #pragma region General Input Handling - /// /// Gets the last device which affected GUI cursor position. - /// - /// The last device which affected GUI cursor position. + /// @return The last device which affected GUI cursor position. InputDevice GetLastDeviceWhichControlledGUICursor() const { return m_LastDeviceWhichControlledGUICursor; } - /// /// Gets the analog moving values of a specific player's control scheme. - /// - /// Which player to check for. - /// The analog axis values ranging between -1.0 to 1.0, in both axes. + /// @param whichPlayer Which player to check for. + /// @return The analog axis values ranging between -1.0 to 1.0, in both axes. Vector AnalogMoveValues(int whichPlayer = 0); - /// /// Gets the analog aiming values of a specific player's control scheme. - /// - /// Which player to check for. - /// The analog axis values ranging between -1.0 to 1.0, in both axes. + /// @param whichPlayer Which player to check for. + /// @return The analog axis values ranging between -1.0 to 1.0, in both axes. Vector AnalogAimValues(int whichPlayer = 0); - /// /// Gets whether a specific input element was held during the last update. - /// - /// Which player to check for. - /// Which element to check for. - /// Whether the element is held or not. + /// @param whichPlayer Which player to check for. + /// @param whichElement Which element to check for. + /// @return Whether the element is held or not. bool ElementHeld(int whichPlayer, int whichElement) { return GetInputElementState(whichPlayer, whichElement, InputState::Held); } - /// /// Gets whether a specific input element was depressed between the last update and the one previous to it. - /// - /// Which player to check for. - /// Which element to check for. - /// Whether the element is pressed or not. + /// @param whichPlayer Which player to check for. + /// @param whichElement Which element to check for. + /// @return Whether the element is pressed or not. bool ElementPressed(int whichPlayer, int whichElement) { return GetInputElementState(whichPlayer, whichElement, InputState::Pressed); } - /// /// Gets whether a specific input element was released between the last update and the one previous to it. - /// - /// Which player to check for. - /// Which element to check for. - /// Whether the element is released or not. + /// @param whichPlayer Which player to check for. + /// @param whichElement Which element to check for. + /// @return Whether the element is released or not. bool ElementReleased(int whichPlayer, int whichElement) { return GetInputElementState(whichPlayer, whichElement, InputState::Released); } - /// /// Gets the generic direction input from any and all players which can affect a shared menu cursor. Normalized to 1.0 max. - /// - /// The vector with the directional input from any or all players. + /// @return The vector with the directional input from any or all players. Vector GetMenuDirectional(); - /// /// Gets whether any generic button with the menu cursor is held down. - /// - /// Which generic menu cursor button to check for. - /// Whether the button is held or not. + /// @param whichButton Which generic menu cursor button to check for. + /// @return Whether the button is held or not. bool MenuButtonHeld(int whichButton) { return GetMenuButtonState(whichButton, InputState::Held); } - /// /// Gets whether any generic button with the menu cursor was pressed between previous update and this. - /// - /// Which generic menu cursor button to check for. - /// Whether the button is pressed or not. + /// @param whichButton Which generic menu cursor button to check for. + /// @return Whether the button is pressed or not. bool MenuButtonPressed(int whichButton) { return GetMenuButtonState(whichButton, InputState::Pressed); } - /// /// Gets whether any generic button with the menu cursor was released between previous update and this. - /// - /// Which generic menu cursor button to check for. - /// Whether the button is released or not. + /// @param whichButton Which generic menu cursor button to check for. + /// @return Whether the button is released or not. bool MenuButtonReleased(int whichButton) { return GetMenuButtonState(whichButton, InputState::Released); } - /// /// Gets whether there is any input at all, keyboard or buttons or D-pad. - /// - /// Whether any buttons of pads are pressed at all. + /// @return Whether any buttons of pads are pressed at all. bool AnyKeyOrJoyInput() const; - /// /// Gets whether there are any key, button, or D-pad presses at all. MUST call Update before calling this for it to work properly! - /// - /// Whether any buttons of pads have been pressed at all since last frame. + /// @return Whether any buttons of pads have been pressed at all since last frame. bool AnyPress() const; - /// /// Gets whether there are any start key/button presses at all. MUST call Update before calling this for it to work properly! - /// - /// Whether to check for space bar presses or not. - /// Whether any start buttons or keys have been pressed at all since last frame. + /// @param includeSpacebar Whether to check for space bar presses or not. + /// @return Whether any start buttons or keys have been pressed at all since last frame. bool AnyStartPress(bool includeSpacebar = true); - /// /// Gets whether there are any back button presses at all. MUST call Update before calling this for it to work properly! - /// - /// Whether any back buttons have been pressed at all since last frame. + /// @return Whether any back buttons have been pressed at all since last frame. bool AnyBackPress(); - /// /// Gets the state of the Ctrl key. - /// - /// The state of the Ctrl key. + /// @return The state of the Ctrl key. bool FlagCtrlState() const { return ((SDL_GetModState() & KMOD_CTRL) > 0) ? true : false; } - /// /// Gets the state of the Alt key. - /// - /// The state of the Alt key. + /// @return The state of the Alt key. bool FlagAltState() const { return ((SDL_GetModState() & KMOD_ALT) > 0) ? true : false; } - /// /// Gets the state of the Shift key. - /// - /// The state of the Shift key. + /// @return The state of the Shift key. bool FlagShiftState() const { return ((SDL_GetModState() & KMOD_SHIFT) > 0) ? true : false; } #pragma endregion #pragma region Keyboard Handling - /// /// Temporarily disables most of the keyboard keys. This is used when typing into a dialog box is required. - /// - /// Whether to disable most keys or not. + /// @param disable Whether to disable most keys or not. void DisableKeys(bool disable = true) { m_DisableKeyboard = disable; } - /// /// Gets whether a key is being held right now, by scancode. - /// - /// A scancode to test. See SDL_Scancode enumeration. - /// Whether the key is held or not. + /// @param scancodeToTest A scancode to test. See SDL_Scancode enumeration. + /// @return Whether the key is held or not. bool KeyHeld(SDL_Scancode scancodeToTest) const { return GetKeyboardButtonState(scancodeToTest, InputState::Held); } - /// /// Gets whether a key is being held right now, by keycode. - /// - /// A keycode to test. See SDL_KeyCode enumeration. - /// Whether the key is held or not. + /// @param keycodeToTest A keycode to test. See SDL_KeyCode enumeration. + /// @return Whether the key is held or not. bool KeyHeld(SDL_Keycode keycodeToTest) const { return KeyHeld(SDL_GetScancodeFromKey(keycodeToTest)); } - /// /// Gets whether a key was pressed between the last update and the one previous to it, by scancode. - /// - /// A scancode to test. See SDL_Scancode enumeration. - /// Whether the key is pressed or not. + /// @param scancodeToTest A scancode to test. See SDL_Scancode enumeration. + /// @return Whether the key is pressed or not. bool KeyPressed(SDL_Scancode scancodeToTest) const { return GetKeyboardButtonState(scancodeToTest, InputState::Pressed); } - /// /// Gets whether a key was pressed between the last update and the one previous to it, by keycode. - /// - /// A keycode to test. See SDL_KeyCode enumeration. - /// Whether the key is pressed or not. + /// @param keycodeToTest A keycode to test. See SDL_KeyCode enumeration. + /// @return Whether the key is pressed or not. bool KeyPressed(SDL_Keycode keycodeToTest) const { return KeyPressed(SDL_GetScancodeFromKey(keycodeToTest)); } - /// /// Gets whether a key was released between the last update and the one previous to it, by scancode. - /// - /// A scancode to test. See SDL_Scancode enumeration. - /// Whether the key is released or not. + /// @param scancodeToTest A scancode to test. See SDL_Scancode enumeration. + /// @return Whether the key is released or not. bool KeyReleased(SDL_Scancode scancodeToTest) const { return GetKeyboardButtonState(scancodeToTest, InputState::Released); } - /// /// Gets whether a key was released between the last update and the one previous to it, by keycode. - /// - /// A keycode to test. See SDL_KeyCode enumeration. - /// Whether the key is released or not. + /// @param keycodeToTest A keycode to test. See SDL_KeyCode enumeration. + /// @return Whether the key is released or not. bool KeyReleased(SDL_Keycode keycodeToTest) const { return KeyReleased(SDL_GetScancodeFromKey(keycodeToTest)); } - /// /// Return true if there are any keyboard button presses at all. - /// - /// Whether any keyboard buttons have been pressed at all since last frame. + /// @return Whether any keyboard buttons have been pressed at all since last frame. bool AnyKeyPress() const; - /// /// Fills the given string with the text input since the last frame (if any). - /// - /// The std::string to fill. - /// Whether there is text input. + /// @param text The std::string to fill. + /// @return Whether there is text input. bool GetTextInput(std::string& text) const { text = m_TextInput; return !m_TextInput.empty(); } - /// /// Returns whether text input events are available. - /// bool HasTextInput() const { return !m_TextInput.empty(); } - /// /// Returns the current text input. - /// - /// The current text input. + /// @return The current text input. const std::string& GetTextInput() const { return m_TextInput; } #pragma endregion #pragma region Mouse Handling - /// /// Reports which player is using the mouse for control at this time if any. - /// - /// Which player is using the mouse. If no one is then -1 is returned. + /// @return Which player is using the mouse. If no one is then -1 is returned. int MouseUsedByPlayer() const; - /// /// Will temporarily disable positioning of the mouse. /// This is so that when focus is switched back to the game window, it avoids having the window fly away because the user clicked the title bar of the window. - /// - /// Whether to disable mouse positioning or not. + /// @param disable Whether to disable mouse positioning or not. void DisableMouseMoving(bool disable = true); - /// /// Get the absolute mouse position in window coordinates. - /// - /// The absolute mouse position. + /// @return The absolute mouse position. Vector GetAbsoluteMousePosition() const { return m_AbsoluteMousePos; } - /// /// Set the absolute mouse position (e.g. for player input mouse movement). Does not move the system cursor. - /// - /// The new mouse position. + /// @param pos The new mouse position. void SetAbsoluteMousePosition(const Vector& pos) { m_AbsoluteMousePos = pos; } - /// /// Gets the relative movement of the mouse since last update. Only returns true if the selected player is actually using the mouse. - /// - /// Which player to get movement for. If the player doesn't use the mouse this always returns a zero vector. - /// The relative mouse movements, in both axes. + /// @param whichPlayer Which player to get movement for. If the player doesn't use the mouse this always returns a zero vector. + /// @return The relative mouse movements, in both axes. Vector GetMouseMovement(int whichPlayer = -1) const; - /// /// Set the mouse's analog emulation output to be of a specific normalized magnitude. - /// - /// The normalized magnitude, between 0 and 1.0. - /// Which player to set magnitude for. Only relevant when in online multiplayer mode. + /// @param magCap The normalized magnitude, between 0 and 1.0. + /// @param whichPlayer Which player to set magnitude for. Only relevant when in online multiplayer mode. void SetMouseValueMagnitude(float magCap, int whichPlayer = Players::NoPlayer); - /// /// Sets the mouse's analog emulation output to be in a specific direction. - /// - /// The direction, in radians. - /// Which player to set magnitude for. Only relevant when in online multiplayer mode. + /// @param angle The direction, in radians. + /// @param whichPlayer Which player to set magnitude for. Only relevant when in online multiplayer mode. void SetMouseValueAngle(float angle, int whichPlayer = Players::NoPlayer); - /// /// Sets the absolute screen position of the mouse cursor. - /// - /// Where to place the mouse. - /// Which player is trying to control the mouse. Only the player with actual control over the mouse will be affected. -1 means do it regardless of player. + /// @param newPos Where to place the mouse. + /// @param whichPlayer Which player is trying to control the mouse. Only the player with actual control over the mouse will be affected. -1 means do it regardless of player. void SetMousePos(const Vector& newPos, int whichPlayer = -1) const; - /// /// Gets mouse sensitivity while in Activity. - /// - /// The current mouse sensitivity. + /// @return The current mouse sensitivity. float GetMouseSensitivity() const { return m_MouseSensitivity; } - /// /// Sets mouse sensitivity while in Activity. - /// - /// New sensitivity value. + /// @param sensitivity New sensitivity value. void SetMouseSensitivity(float sensitivity) { m_MouseSensitivity = std::clamp(sensitivity, 0.1F, 2.0F); } - /// /// Gets whether a mouse button is being held down right now. - /// - /// Which button to check for. - /// Which player to check for. - /// Whether the mouse button is held or not. + /// @param whichButton Which button to check for. + /// @param whichPlayer Which player to check for. + /// @return Whether the mouse button is held or not. bool MouseButtonHeld(int whichButton, int whichPlayer = Players::PlayerOne) const { return GetMouseButtonState(whichPlayer, whichButton, InputState::Held); } - /// /// Gets whether a mouse button was pressed between the last update and the one previous to it. - /// - /// Which button to check for. - /// Which player to check for. - /// Whether the mouse button is pressed or not. + /// @param whichButton Which button to check for. + /// @param whichPlayer Which player to check for. + /// @return Whether the mouse button is pressed or not. bool MouseButtonPressed(int whichButton, int whichPlayer = Players::PlayerOne) const { return GetMouseButtonState(whichPlayer, whichButton, InputState::Pressed); } - /// /// Gets whether a mouse button was released between the last update and the one previous to it. - /// - /// Which button to check for. - /// Which player to check for. - /// Whether the mouse button is released or not. + /// @param whichButton Which button to check for. + /// @param whichPlayer Which player to check for. + /// @return Whether the mouse button is released or not. bool MouseButtonReleased(int whichButton, int whichPlayer = Players::PlayerOne) const { return GetMouseButtonState(whichPlayer, whichButton, InputState::Released); } - /// /// Gets whether the mouse wheel has been moved past the threshold limit in either direction this frame. - /// - /// The direction the mouse wheel has been moved which is past that threshold. 0 means not past, negative means moved down, positive means moved up. + /// @return The direction the mouse wheel has been moved which is past that threshold. 0 means not past, negative means moved down, positive means moved up. int MouseWheelMoved() const { return m_MouseWheelChange; } - /// /// Gets the relative mouse wheel position for the specified player. - /// - /// The player to get mouse wheel position for. - /// The relative mouse wheel position for the specified player. + /// @param player The player to get mouse wheel position for. + /// @return The relative mouse wheel position for the specified player. int MouseWheelMovedByPlayer(int player) const { return (IsInMultiplayerMode() && player >= Players::PlayerOne && player < Players::MaxPlayerCount) ? m_NetworkMouseWheelState[player] : m_MouseWheelChange; } - /// /// Return true if there are any mouse button presses at all. - /// - /// Whether any mouse buttons have been pressed at all since last frame. + /// @return Whether any mouse buttons have been pressed at all since last frame. bool AnyMouseButtonPress() const; - /// /// Sets the mouse to be trapped in the middle of the screen so it doesn't go out and click on other windows etc. /// This is usually used when the cursor is invisible and only relative mouse movements are used. - /// - /// Whether to trap the mouse or not. - /// + /// @param trap Whether to trap the mouse or not. + /// @param whichPlayer /// Which player is trying to control the mouse. /// Only the player with actual control over the mouse will affect its trapping here. -1 means change mouse trapping regardless of player. - /// void TrapMousePos(bool trap = true, int whichPlayer = -1); - /// /// Forces the mouse within a box on the screen. - /// - /// X value of the top left corner of the screen box to keep the mouse within, relative to the top left corner of the player's screen. - /// Y value of the top left corner of the screen box to keep the mouse within, relative to the top left corner of the player's screen. - /// The width of the box. - /// The height of the box. - /// Which player is trying to control the mouse. Only the player with actual control over the mouse will be affected. -1 means do it regardless of player. + /// @param x X value of the top left corner of the screen box to keep the mouse within, relative to the top left corner of the player's screen. + /// @param y Y value of the top left corner of the screen box to keep the mouse within, relative to the top left corner of the player's screen. + /// @param width The width of the box. + /// @param height The height of the box. + /// @param whichPlayer Which player is trying to control the mouse. Only the player with actual control over the mouse will be affected. -1 means do it regardless of player. void ForceMouseWithinBox(int x, int y, int width, int height, int whichPlayer = Players::NoPlayer) const; #pragma endregion #pragma region Joystick Handling - /// /// Gets the number of active joysticks. - /// - /// The number of active joysticks. + /// @return The number of active joysticks. int GetJoystickCount() const { return (m_NumJoysticks > Players::MaxPlayerCount) ? Players::MaxPlayerCount : m_NumJoysticks; } - /// /// Gets the index number of a joystick from InputDevice. Basically just subtract 2 from the passed in value because the Allegro joystick indices are 0-3 and ours are 2-5. - /// - /// The InputDevice to get index from. - /// The corrected index. A non-joystick device will result in an out of range value returned which will not affect any active joysticks. + /// @param device The InputDevice to get index from. + /// @return The corrected index. A non-joystick device will result in an out of range value returned which will not affect any active joysticks. int GetJoystickIndex(InputDevice device) const { return (device >= InputDevice::DEVICE_GAMEPAD_1 && device < InputDevice::DEVICE_COUNT) ? device - InputDevice::DEVICE_GAMEPAD_1 : InputDevice::DEVICE_COUNT; } - /// /// Gets the number of axes of the specified joystick. - /// - /// Joystick to check. - /// The number of axes of the joystick. + /// @param whichJoy Joystick to check. + /// @return The number of axes of the joystick. int GetJoystickAxisCount(int whichJoy) const; - /// /// Gets whether the specified joystick is active. The joystick number does not correspond to the player number. - /// - /// Joystick to check for. - /// Whether the specified joystick is active. + /// @param joystickNumber Joystick to check for. + /// @return Whether the specified joystick is active. bool JoystickActive(int joystickNumber) const { return joystickNumber >= Players::PlayerOne && joystickNumber < Players::MaxPlayerCount && s_PrevJoystickStates[joystickNumber].m_JoystickID != -1; } - /// /// Gets whether a joystick button is being held down right now. - /// - /// Which joystick to check for. - /// Which joystick button to check for. - /// Whether the joystick button is held or not. + /// @param whichJoy Which joystick to check for. + /// @param whichButton Which joystick button to check for. + /// @return Whether the joystick button is held or not. bool JoyButtonHeld(int whichJoy, int whichButton) const { return GetJoystickButtonState(whichJoy, whichButton, InputState::Held); } - /// /// Shows the first joystick button which is currently down. - /// - /// Which joystick to check for. - /// The first button in the sequence of button enumerations that is held at the time of calling this. JOY_NONE means none. + /// @param whichJoy Which joystick to check for. + /// @return The first button in the sequence of button enumerations that is held at the time of calling this. JOY_NONE means none. int WhichJoyButtonHeld(int whichJoy) const; - /// /// Gets whether a joystick button was pressed between the last update and the one previous to it. - /// - /// Which joystick to check for. - /// Which joystick button to check for. - /// Whether the joystick button is pressed or not. + /// @param whichJoy Which joystick to check for. + /// @param whichButton Which joystick button to check for. + /// @return Whether the joystick button is pressed or not. bool JoyButtonPressed(int whichJoy, int whichButton) const { return GetJoystickButtonState(whichJoy, whichButton, InputState::Pressed); } - /// /// Shows the first joystick button which was pressed down since last frame. - /// - /// Which joystick to check for. - /// The first button in the sequence of button enumerations that is pressed since the previous frame. JOY_NONE means none. + /// @param whichJoy Which joystick to check for. + /// @return The first button in the sequence of button enumerations that is pressed since the previous frame. JOY_NONE means none. int WhichJoyButtonPressed(int whichJoy) const; - /// /// Gets whether a joystick button was released between the last update and the one previous to it. - /// - /// Which joystick to check for. - /// Which joystick button to check for. - /// Whether the joystick button is released or not. + /// @param whichJoy Which joystick to check for. + /// @param whichButton Which joystick button to check for. + /// @return Whether the joystick button is released or not. bool JoyButtonReleased(int whichJoy, int whichButton) const { return GetJoystickButtonState(whichJoy, whichButton, InputState::Released); } - /// /// Gets whether a joystick axis is being held down in a specific direction right now. Two adjacent directions can be held down to produce diagonals. - /// - /// Which joystick to check for. - /// Which joystick stick axis to check for. - /// Which direction to check for. - /// Whether the stick axis is held in the specified direction or not. + /// @param whichJoy Which joystick to check for. + /// @param whichAxis Which joystick stick axis to check for. + /// @param whichDir Which direction to check for. + /// @return Whether the stick axis is held in the specified direction or not. bool JoyDirectionHeld(int whichJoy, int whichAxis, int whichDir) const { return GetJoystickDirectionState(whichJoy, whichAxis, whichDir, InputState::Held); } - /// /// Gets whether a joystick axis direction was pressed between the last update and the one previous to it. - /// - /// Which joystick to check for. - /// Which joystick stick axis to check for. - /// Which direction to check for. - /// Whether the stick axis is pressed or not. + /// @param whichJoy Which joystick to check for. + /// @param whichAxis Which joystick stick axis to check for. + /// @param whichDir Which direction to check for. + /// @return Whether the stick axis is pressed or not. bool JoyDirectionPressed(int whichJoy, int whichAxis, int whichDir) const { return GetJoystickDirectionState(whichJoy, whichAxis, whichDir, InputState::Pressed); } - /// /// Gets whether a joystick axis direction was released between the last update and the one previous to it. - /// - /// Which joystick to check for. - /// Which joystick stick axis to check for. - /// Which direction to check for. - /// Whether the stick axis is released or not. + /// @param whichJoy Which joystick to check for. + /// @param whichAxis Which joystick stick axis to check for. + /// @param whichDir Which direction to check for. + /// @return Whether the stick axis is released or not. bool JoyDirectionReleased(int whichJoy, int whichAxis, int whichDir) const { return GetJoystickDirectionState(whichJoy, whichAxis, whichDir, InputState::Released); } - /// /// Gets the normalized value of a certain joystick's stick's axis. - /// - /// Which joystick to check for. - /// Which joystick stick axis to check for. - /// The analog axis value ranging between -1.0 to 1.0, or 0.0 to 1.0 if it's a throttle type control. + /// @param whichJoy Which joystick to check for. + /// @param whichAxis Which joystick stick axis to check for. + /// @return The analog axis value ranging between -1.0 to 1.0, or 0.0 to 1.0 if it's a throttle type control. float AnalogAxisValue(int whichJoy = 0, int whichAxis = 0) const; - /// /// Gets whether there is any joystick input at all, buttons or D-pad. - /// - /// Whether to check specifically for presses since last frame. - /// Whether any buttons of pads are pressed at all or since the last frame. + /// @param checkForPresses Whether to check specifically for presses since last frame. + /// @return Whether any buttons of pads are pressed at all or since the last frame. bool AnyJoyInput(bool checkForPresses = false) const; - /// /// Return true if there are any joystick presses at all, buttons or D-pad. - /// - /// Whether any buttons or pads have been pressed at all since last frame. + /// @return Whether any buttons or pads have been pressed at all since last frame. bool AnyJoyPress() const { return AnyJoyInput(true); } - /// /// Gets whether there are any joystick button presses at all, but not D-pad input, for a specific joystick. - /// - /// Which joystick to check for. - /// Whether any joystick buttons have been pressed at all since last frame, of a specific joystick. + /// @param whichJoy Which joystick to check for. + /// @return Whether any joystick buttons have been pressed at all since last frame, of a specific joystick. bool AnyJoyButtonPress(int whichJoy) const; #pragma endregion #pragma region Network Handling - /// /// Returns true if manager is in multiplayer mode. - /// - /// True if in multiplayer mode. + /// @return True if in multiplayer mode. bool IsInMultiplayerMode() const { return m_OverrideInput; } - /// /// Sets the multiplayer mode flag. - /// - /// Whether this manager should operate in multiplayer mode. + /// @param value Whether this manager should operate in multiplayer mode. void SetMultiplayerMode(bool value) { m_OverrideInput = value; } - /// /// Gets the position of the mouse for a player during network multiplayer. - /// - /// The player to get for. - /// The position of the mouse for the specified player + /// @param player The player to get for. + /// @return The position of the mouse for the specified player Vector GetNetworkAccumulatedRawMouseMovement(int player); - /// /// Sets the position of the mouse for a player during network multiplayer. - /// - /// The player to set for. - /// The new position of the mouse. + /// @param player The player to set for. + /// @param input The new position of the mouse. void SetNetworkMouseMovement(int player, const Vector& input) { m_NetworkAccumulatedRawMouseMovement[player] += input; } - /// /// Sets whether an input element is held by a player during network multiplayer. - /// - /// Which player to set for. - /// Which input element to set for. - /// The new state of the input element. True or false. + /// @param player Which player to set for. + /// @param element Which input element to set for. + /// @param state The new state of the input element. True or false. void SetNetworkInputElementState(int player, int element, bool state); - /// /// Sets whether a mouse button is held by a player during network multiplayer. - /// - /// Which player to set for. - /// Which mouse button to set for. - /// The new state of the mouse button. True or false. + /// @param player Which player to set for. + /// @param whichButton Which mouse button to set for. + /// @param state The new state of the mouse button. True or false. void SetNetworkMouseButtonHeldState(int player, int whichButton, bool state) { SetNetworkMouseButtonState(player, whichButton, InputState::Held, state); } - /// /// Sets whether a mouse button is pressed by a player during network multiplayer. - /// - /// Which player to set for. - /// Which mouse button to set for. - /// The new state of the mouse button. True or false. + /// @param player Which player to set for. + /// @param whichButton Which mouse button to set for. + /// @param state The new state of the mouse button. True or false. void SetNetworkMouseButtonPressedState(int player, int whichButton, bool state) { SetNetworkMouseButtonState(player, whichButton, InputState::Pressed, state); } - /// /// Sets whether a mouse button is released by a player during network multiplayer. - /// - /// Which player to set for. - /// Which mouse button to set for. - /// The new state of the mouse button. True or false. + /// @param player Which player to set for. + /// @param whichButton Which mouse button to set for. + /// @param state The new state of the mouse button. True or false. void SetNetworkMouseButtonReleasedState(int player, int whichButton, bool state) { SetNetworkMouseButtonState(player, whichButton, InputState::Released, state); } - /// /// Sets the state of the mouse wheel for a player during network multiplayer. - /// - /// The player to set for. - /// The new state of the mouse wheel. + /// @param player The player to set for. + /// @param state The new state of the mouse wheel. void SetNetworkMouseWheelState(int player, int state) { if (player >= Players::PlayerOne && player < Players::MaxPlayerCount) { m_NetworkMouseWheelState[player] += state; } } - /// /// Gets whether the specified input element is pressed during network multiplayer. - /// - /// The input element to check for. - /// Whether the specified input element is pressed or not. + /// @param element The input element to check for. + /// @return Whether the specified input element is pressed or not. bool NetworkAccumulatedElementPressed(int element) const { return NetworkAccumulatedElementState(element, InputState::Pressed); } - /// /// Gets whether the specified input element is released during network multiplayer. - /// - /// The input element to check for. - /// Whether the specified input element is released or not. + /// @param element The input element to check for. + /// @return Whether the specified input element is released or not. bool NetworkAccumulatedElementReleased(int element) const { return NetworkAccumulatedElementState(element, InputState::Released); } - /// /// Clears all the accumulated input element states. - /// void ClearNetworkAccumulatedStates(); #pragma endregion private: - /// /// Enumeration for the different states an input element or button can be in. - /// enum InputState { Held, Pressed, @@ -701,10 +522,8 @@ namespace RTE { bool m_DisableKeyboard; //!< Temporarily disable all keyboard input reading. bool m_DisableMouseMoving; //!< Temporary disable for positioning the mouse, for when the game window is not in focus. - /// /// This is set when focus is switched back to the game window and will cause the m_DisableMouseMoving to switch to false when the mouse button is RELEASED. /// This is to avoid having the window fly away because the user clicked the title bar. - /// bool m_PrepareToEnableMouseMoving; bool m_NetworkAccumulatedElementState[InputElements::INPUT_COUNT][InputState::InputStateCount]; //!< The state of a client input element during network multiplayer. @@ -725,146 +544,108 @@ namespace RTE { static constexpr int c_AxisDigitalReleasedThreshold = c_AxisDigitalPressedThreshold - 100; //!< Digital Axis release threshold, to debounce values. #pragma region Mouse Handling - /// /// Forces the mouse within a specific player's screen area. /// Player 1 will always be in the upper-left corner, Player 3 will always be in the lower-left corner, Player 4 will always be in the lower-right quadrant. /// Player 2 will either be in the lower-left corner or the upper-right corner depending on vertical/horizontal splitting. - /// - /// Which player's screen to constrain the mouse to. Only the player with actual control over the mouse will be affected. + /// @param whichPlayer Which player's screen to constrain the mouse to. Only the player with actual control over the mouse will be affected. void ForceMouseWithinPlayerScreen(bool force, int whichPlayer); #pragma endregion #pragma region Input State Handling - /// /// Gets whether an input element is in the specified state. - /// - /// Which player to check for. See Players enumeration. - /// Which element to check for. See InputElements enumeration. - /// Which state to check for. See InputState enumeration. - /// Whether the element is in the specified state or not. + /// @param whichPlayer Which player to check for. See Players enumeration. + /// @param whichElement Which element to check for. See InputElements enumeration. + /// @param whichState Which state to check for. See InputState enumeration. + /// @return Whether the element is in the specified state or not. bool GetInputElementState(int whichPlayer, int whichElement, InputState whichState); bool GetNetworkInputElementState(int whichPlayer, int whichElement, InputState whichState); - /// /// Gets whether any generic button with the menu cursor is in the specified state. - /// - /// Which menu button to check for. See MenuButtons enumeration. - /// Which state to check for. See InputState enumeration. - /// Whether the menu button is in the specified state or not. + /// @param whichButton Which menu button to check for. See MenuButtons enumeration. + /// @param whichState Which state to check for. See InputState enumeration. + /// @return Whether the menu button is in the specified state or not. bool GetMenuButtonState(int whichButton, InputState whichState); - /// /// Gets whether a keyboard key is in the specified state. - /// - /// A scancode to test. See SDL_Scancode enumeration. - /// Which state to check for. See InputState enumeration. - /// Whether the keyboard key is in the specified state or not. + /// @param scancodeToTest A scancode to test. See SDL_Scancode enumeration. + /// @param whichState Which state to check for. See InputState enumeration. + /// @return Whether the keyboard key is in the specified state or not. bool GetKeyboardButtonState(SDL_Scancode scancodeToTest, InputState whichState) const; - /// /// Gets whether a mouse button is in the specified state. - /// - /// Which player to check for. See Players enumeration. - /// Which mouse button to check for. See MouseButtons enumeration. - /// Which state to check for. See InputState enumeration. - /// Whether the mouse button is in the specified state or not. + /// @param whichPlayer Which player to check for. See Players enumeration. + /// @param whichButton Which mouse button to check for. See MouseButtons enumeration. + /// @param whichState Which state to check for. See InputState enumeration. + /// @return Whether the mouse button is in the specified state or not. bool GetMouseButtonState(int whichPlayer, int whichButton, InputState whichState) const; - /// /// Gets whether a multiplayer mouse button is in the specified state. - /// - /// Which player to check for. See Players enumeration. - /// Which mouse button to check for. See MouseButtons enumeration. - /// Which state to check for. See InputState enumeration. - /// Whether the mouse button is in the specified state or not. + /// @param whichPlayer Which player to check for. See Players enumeration. + /// @param whichButton Which mouse button to check for. See MouseButtons enumeration. + /// @param whichState Which state to check for. See InputState enumeration. + /// @return Whether the mouse button is in the specified state or not. bool GetNetworkMouseButtonState(int whichPlayer, int whichButton, InputState whichState) const; - /// /// Gets whether a joystick button is in the specified state. - /// - /// Which joystick to check for. - /// Which joystick button to check for. See JoyButtons enumeration. - /// Which state to check for. See InputState enumeration. - /// Whether the joystick button is in the specified state or not. + /// @param whichJoy Which joystick to check for. + /// @param whichButton Which joystick button to check for. See JoyButtons enumeration. + /// @param whichState Which state to check for. See InputState enumeration. + /// @return Whether the joystick button is in the specified state or not. bool GetJoystickButtonState(int whichJoy, int whichButton, InputState whichState) const; - /// /// Gets whether a joystick axis direction is in the specified state or not. - /// - /// Which joystick to check for. - /// Which joystick stick axis to check for. - /// Which direction to check for. See JoyDirections enumeration. - /// Which state to check for. See InputState enumeration. - /// Whether the joystick stick axis is in the specified state or not. + /// @param whichJoy Which joystick to check for. + /// @param whichAxis Which joystick stick axis to check for. + /// @param whichDir Which direction to check for. See JoyDirections enumeration. + /// @param whichState Which state to check for. See InputState enumeration. + /// @return Whether the joystick stick axis is in the specified state or not. bool GetJoystickDirectionState(int whichJoy, int whichAxis, int whichDir, InputState whichState) const; - /// /// Sets a mouse button for a player to the specified state during network multiplayer. - /// - /// Which player to set for. See Players enumeration. - /// Which mouse button to set for. See MouseButtons enumeration. - /// Which input state to set. See InputState enumeration. - /// The new state of the specified InputState. True or false. + /// @param player Which player to set for. See Players enumeration. + /// @param whichButton Which mouse button to set for. See MouseButtons enumeration. + /// @param whichState Which input state to set. See InputState enumeration. + /// @param newState The new state of the specified InputState. True or false. void SetNetworkMouseButtonState(int player, int whichButton, InputState whichState, bool newState); - /// /// Gets whether an input element is in the specified state during network multiplayer. - /// - /// Which element to check for. See InputElements enumeration. - /// Which state to check for. See InputState enumeration. - /// Whether the element is in the specified state or not. + /// @param element Which element to check for. See InputElements enumeration. + /// @param whichState Which state to check for. See InputState enumeration. + /// @return Whether the element is in the specified state or not. bool NetworkAccumulatedElementState(int element, InputState whichState) const { return (element < InputElements::INPUT_L_UP || element >= InputElements::INPUT_COUNT) ? false : m_NetworkAccumulatedElementState[element][whichState]; } #pragma endregion #pragma region Update Breakdown - /// /// Capture and handle special key shortcuts and combinations. This is called from Update(). - /// void HandleSpecialInput(); - /// /// Handles the mouse input in network multiplayer. This is called from Update(). - /// void UpdateNetworkMouseMovement(); - /// /// Clear all NetworkServerChanged* arrays. - /// void ClearNetworkChangedState(); - /// /// Handles the mouse input. This is called from Update(). - /// void UpdateMouseInput(); - /// /// Handles a joystick axis input. This is called from Update(). - /// void UpdateJoystickAxis(std::vector::iterator device, int axis, int newValue); - /// /// Updates simulated digital joystick axis. This is called from Update(). - /// void UpdateJoystickDigitalAxis(); - /// /// Connect a joystick or gamepad device and add it to the joystick list if a slot is available (up to max player count). - /// - /// The device index (generated by the connected event or a value up to SDL_NumJoysticks()). + /// @param deviceIndex The device index (generated by the connected event or a value up to SDL_NumJoysticks()). void HandleGamepadHotPlug(int deviceIndex); - /// /// Stores all the input events that happened during this update to be compared to in the next update. This is called from Update(). - /// void StoreInputEventsForNextUpdate(); #pragma endregion - /// /// Clears all the member variables of this UInputMan, effectively resetting the members of this abstraction level only. - /// void Clear(); // Disallow the use of some implicit methods. diff --git a/Source/Managers/WindowMan.cpp b/Source/Managers/WindowMan.cpp index c767770663..25fb28391d 100644 --- a/Source/Managers/WindowMan.cpp +++ b/Source/Managers/WindowMan.cpp @@ -30,8 +30,6 @@ namespace RTE { void SDLContextDeleter::operator()(SDL_GLContext context) const { SDL_GL_DeleteContext(context); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void WindowMan::Clear() { m_EventQueue.clear(); m_FocusEventsDispatchedByMovingBetweenWindows = false; @@ -67,22 +65,16 @@ namespace RTE { m_UseMultiDisplays = false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void WindowMan::ClearMultiDisplayData() { m_MultiDisplayTextureOffsets.clear(); m_MultiDisplayProjections.clear(); m_MultiDisplayWindows.clear(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - WindowMan::WindowMan() { Clear(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - WindowMan::~WindowMan() = default; void WindowMan::Destroy() { @@ -93,8 +85,6 @@ namespace RTE { glDeleteFramebuffers(1, &m_ScreenBufferFBO); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void WindowMan::Initialize() { m_NumDisplays = SDL_GetNumVideoDisplays(); @@ -129,8 +119,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void WindowMan::CreatePrimaryWindow() { std::string windowTitle = "Cortex Command Community Project"; @@ -222,8 +210,6 @@ namespace RTE { TracyGpuContext; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void WindowMan::CreateBackBufferTexture() { glBindTexture(GL_TEXTURE_2D, m_BackBuffer32Texture); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, m_ResX, m_ResY, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr); @@ -235,8 +221,6 @@ namespace RTE { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int WindowMan::GetWindowResX() { int w, h; SDL_GL_GetDrawableSize(m_PrimaryWindow.get(), &w, &h); @@ -263,8 +247,6 @@ namespace RTE { SDL_GL_SetSwapInterval(sdlEnableVSync); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void WindowMan::UpdatePrimaryDisplayInfo() { m_PrimaryWindowDisplayIndex = SDL_GetWindowDisplayIndex(m_PrimaryWindow.get()); @@ -302,8 +284,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void WindowMan::MapDisplays(bool updatePrimaryDisplayInfo) { auto setSingleDisplayMode = [this](const std::string& errorMsg = "") { m_MaxResX = m_PrimaryWindowDisplayWidth; @@ -403,8 +383,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void WindowMan::ValidateResolution(int& resX, int& resY, float& resMultiplier) const { if (resX < c_MinResX || resY < c_MinResY) { resX = c_MinResX; @@ -438,8 +416,6 @@ namespace RTE { m_PrimaryWindowViewport = std::make_unique(offsetX, windowH - offsetY - height, width, height); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void WindowMan::AttemptToRevertToPreviousResolution(bool revertToDefaults) { auto setDefaultResSettings = [this]() { m_ResX = c_DefaultResX; @@ -472,8 +448,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void WindowMan::ChangeResolution(int newResX, int newResY, float newResMultiplier, bool fullscreen, bool displaysAlreadyMapped) { if (m_ResX == newResX && m_ResY == newResY && glm::epsilonEqual(m_ResMultiplier, newResMultiplier, glm::epsilon()) && m_Fullscreen == fullscreen) { @@ -538,8 +512,6 @@ namespace RTE { g_ConsoleMan.PrintString("SYSTEM: " + std::string(!recoveredToPreviousSettings ? "Switched to different resolution." : "Failed to switch to different resolution. Reverted to previous settings.")); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void WindowMan::ToggleFullscreen() { bool fullscreen = !m_Fullscreen; @@ -569,8 +541,6 @@ namespace RTE { SetViewportLetterboxed(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool WindowMan::ChangeResolutionToMultiDisplayFullscreen(float resMultiplier) { if (!m_CanMultiDisplayFullscreen) { return false; @@ -628,8 +598,6 @@ namespace RTE { return true; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void WindowMan::DisplaySwitchIn(SDL_Window* windowThatShouldTakeInputFocus) const { g_UInputMan.DisableMouseMoving(false); g_UInputMan.DisableKeys(false); @@ -647,8 +615,6 @@ namespace RTE { SDL_ShowCursor(SDL_DISABLE); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void WindowMan::DisplaySwitchOut() const { g_UInputMan.DisableMouseMoving(true); g_UInputMan.DisableKeys(true); @@ -658,8 +624,6 @@ namespace RTE { SDL_SetCursor(nullptr); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void WindowMan::QueueWindowEvent(const SDL_Event& windowEvent) { if (g_UInputMan.IsInMultiplayerMode()) { return; @@ -667,8 +631,6 @@ namespace RTE { m_EventQueue.emplace_back(windowEvent); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void WindowMan::Update() { // Some bullshit we have to deal with to correctly focus windows in multi-display fullscreen so mouse binding/unbinding works correctly. Not relevant for single window. // This is SDL's fault for not having handling to raise a window so it's top-most without taking focus of it. @@ -722,8 +684,6 @@ namespace RTE { m_EventQueue.clear(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void WindowMan::ClearRenderer() { glBindFramebuffer(GL_FRAMEBUFFER, 0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); @@ -735,8 +695,6 @@ namespace RTE { m_DrawPostProcessBuffer = false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void WindowMan::UploadFrame() { TracyGpuZone("Upload Frame"); glDisable(GL_DEPTH_TEST); diff --git a/Source/Managers/WindowMan.h b/Source/Managers/WindowMan.h index 711bb0ebd7..491779b81e 100644 --- a/Source/Managers/WindowMan.h +++ b/Source/Managers/WindowMan.h @@ -34,217 +34,147 @@ namespace RTE { void operator()(void* context) const; }; - /// /// The singleton manager over the game window and display of frames. - /// class WindowMan : public Singleton { friend class SettingsMan; public: #pragma region Creation - /// /// Constructor method used to instantiate a WindowMan object in system memory. Initialize() should be called before using the object. - /// WindowMan(); - /// /// Makes the WindowMan object ready for use. - /// void Initialize(); #pragma endregion #pragma region Destruction - /// /// Destructor method used to clean up a WindowMan object before deletion from system memory. - /// ~WindowMan(); - /// /// Clean up GL pointers. - /// void Destroy(); #pragma endregion #pragma region Getters and Setters - /// /// Gets a pointer to the primary game window. OWNERSHIP IS NOT TRANSFERRED! - /// - /// Pointer to the primary game window. + /// @return Pointer to the primary game window. SDL_Window* GetWindow() const { return m_PrimaryWindow.get(); } - /// /// Gets whether any of the game windows is currently in focus. - /// - /// Whether any of the game windows is currently in focus. + /// @return Whether any of the game windows is currently in focus. bool AnyWindowHasFocus() const { return m_AnyWindowHasFocus; } - /// /// Gets the maximum horizontal resolution the game can be resized to. - /// - /// The maximum horizontal resolution the game can be resized to. + /// @return The maximum horizontal resolution the game can be resized to. int GetMaxResX() const { return m_MaxResX; } - /// /// Gets the maximum vertical resolution the game can be resized to. - /// - /// The maximum vertical resolution the game can be resized to. + /// @return The maximum vertical resolution the game can be resized to. int GetMaxResY() const { return m_MaxResY; } - /// /// Gets the horizontal resolution the game is currently sized at. - /// - /// The horizontal resolution the game is currently sized at, in pixels. + /// @return The horizontal resolution the game is currently sized at, in pixels. int GetResX() const { return m_ResX; } - /// /// Gets the vertical resolution the game is currently sized at. - /// - /// The vertical resolution the game is currently sized at, in pixels. + /// @return The vertical resolution the game is currently sized at, in pixels. int GetResY() const { return m_ResY; } - /// /// Gets the horizontal resolution the game window is currently sized at, in pixels. - /// - /// The horizontal resolution the game window is currently sized at, in pixels. + /// @return The horizontal resolution the game window is currently sized at, in pixels. int GetWindowResX(); - /// /// Gets the vertical resolution the game window is currently sized at, in pixels. - /// - /// The vertical resolution the game window is currently sized at, in pixels. + /// @return The vertical resolution the game window is currently sized at, in pixels. int GetWindowResY(); - /// /// Gets how many times the game resolution is currently being multiplied and the backbuffer stretched across for better readability. - /// - /// What multiple the game resolution is currently sized at. + /// @return What multiple the game resolution is currently sized at. float GetResMultiplier() const { return m_ResMultiplier; } - /// /// Gets whether VSync is enabled. - /// - /// Whether VSync is enabled. + /// @return Whether VSync is enabled. bool GetVSyncEnabled() const { return m_EnableVSync; } - /// /// Sets whether VSync is enabled. - /// - /// Whether to enable VSync. + /// @param enable Whether to enable VSync. void SetVSyncEnabled(bool enable); - /// /// Gets whether the game window is currently in fullscreen. - /// - /// Whether the game window is currently in fullscreen. + /// @return Whether the game window is currently in fullscreen. bool IsFullscreen() { return m_Fullscreen; } - /// /// Gets whether the multi-display arrangement should be used or whether only the display the main window is currently positioned at should be used for fullscreen. - /// - /// Whether the multi-display arrangement is used. + /// @return Whether the multi-display arrangement is used. bool GetUseMultiDisplays() const { return m_UseMultiDisplays; } - /// /// Sets whether the multi-display arrangement should be used or whether only the display the main window is currently positioned at should be used for fullscreen. - /// - /// Whether the multi-display arrangement should be used + /// @param use Whether the multi-display arrangement should be used void SetUseMultiDisplays(bool use) { m_UseMultiDisplays = use; } - /// /// Checks whether the current resolution settings fully cover all the available displays. - /// - /// Whether the current resolution settings fully cover all the available displays. + /// @return Whether the current resolution settings fully cover all the available displays. bool FullyCoversAllDisplays() const { return m_NumDisplays > 1 && (m_ResX * m_ResMultiplier == m_MaxResX) && (m_ResY * m_ResMultiplier == m_MaxResY); } - /// /// Gets the absolute left-most position in the OS display arrangement. Used for correcting mouse position in multi-display fullscreen when the left-most display is not primary. - /// - /// The absolute left-most position in the OS display arrangement. + /// @return The absolute left-most position in the OS display arrangement. int GetDisplayArrangementAbsOffsetX() const { return std::abs(m_DisplayArrangementLeftMostOffset); } - /// /// Gets the absolute top-most position in the OS display arrangement. Used for correcting mouse position in multi-display fullscreen when the left-most display is not primary. - /// - /// The absolute top-most position in the OS display arrangement. + /// @return The absolute top-most position in the OS display arrangement. int GetDisplayArrangementAbsOffsetY() const { return std::abs(m_DisplayArrangementTopMostOffset); } - /// /// Get the screen buffer texture. - /// - /// The screen buffer texture. + /// @return The screen buffer texture. GLuint GetScreenBufferTexture() const { return m_ScreenBufferTexture; } #pragma endregion #pragma region Resolution Change Handling - /// /// Attempts to figure our what the hell the OS display arrangement is and what are the resolution capabilities for single or multi-display fullscreen. - /// - /// Whether to update the stored info of the display the primary window is currently positioned at. + /// @param updatePrimaryDisplayInfo Whether to update the stored info of the display the primary window is currently positioned at. void MapDisplays(bool updatePrimaryDisplayInfo = true); - /// /// Gets the horizontal resolution of the display the primary game window is currently positioned at. - /// - /// The horizontal resolution of the display the primary game window is currently positioned at. + /// @return The horizontal resolution of the display the primary game window is currently positioned at. int GetPrimaryWindowDisplayWidth() const { return m_PrimaryWindowDisplayWidth; } - /// /// Gets the vertical resolution of the display the primary game window is currently positioned at. - /// - /// The vertical resolution of the display the primary game window is currently positioned at. + /// @return The vertical resolution of the display the primary game window is currently positioned at. int GetPrimaryWindowDisplayHeight() const { return m_PrimaryWindowDisplayHeight; } - /// /// Gets whether the game resolution was changed. - /// - /// Whether the game resolution was changed. + /// @return Whether the game resolution was changed. bool ResolutionChanged() const { return m_ResolutionChanged; } - /// /// Switches the game resolution to the specified dimensions. - /// - /// New width to resize to. - /// New height to resize to. - /// Whether the new resolution should be upscaled. - /// Whether to skip mapping displays because they were already mapped elsewhere. + /// @param newResX New width to resize to. + /// @param newResY New height to resize to. + /// @param upscaled Whether the new resolution should be upscaled. + /// @param displaysAlreadyMapped Whether to skip mapping displays because they were already mapped elsewhere. void ChangeResolution(int newResX, int newResY, float newResMultiplier = 1.0f, bool fullscreen = false, bool displaysAlreadyMapped = false); - /// /// Toggles between windowed and fullscreen mode (single display). - /// void ToggleFullscreen(); - /// /// Completes the resolution change by resetting the flag. - /// void CompleteResolutionChange() { m_ResolutionChanged = false; } #pragma endregion #pragma region Concrete Methods - /// /// Adds an SDL_Event to the Event queue for processing on Update. - /// - /// The SDL window event to queue. + /// @param windowEvent The SDL window event to queue. void QueueWindowEvent(const SDL_Event& windowEvent); - /// /// Updates the state of this WindowMan. - /// void Update(); - /// /// Clears the primary renderer, or all the renderers if in multi-display fullscreen. - /// void ClearRenderer(); - /// /// Set this Frame to draw the game. To be set before UploadFrame. Resets on ClearRenderer. - /// void DrawPostProcessBuffer() { m_DrawPostProcessBuffer = true; } - /// /// Copies the BackBuffer32 content to GPU and shows it on screen. - /// void UploadFrame(); #pragma endregion @@ -301,93 +231,67 @@ namespace RTE { bool m_DrawPostProcessBuffer; //!< Whether to draw the PostProcessBuffer while not in Activity. Resets on Frame Clear. #pragma region Initialize Breakdown - /// /// Creates the main game window. - /// void CreatePrimaryWindow(); - /// /// Initializes all opengl objects (textures, vbo, vao, and fbo). - /// void InitializeOpenGL(); - /// /// Creates the main game window renderer's drawing surface. - /// void CreateBackBufferTexture(); #pragma endregion #pragma region Resolution Handling void SetViewportLetterboxed(); - /// /// Updates the stored info of the display the primary window is currently positioned at. - /// void UpdatePrimaryDisplayInfo(); - /// /// Gets the maximum available window bounds for a decorated window on the specified display. /// May not provide accurate results if the window is in fullscreen or has just been created. - /// - /// The display to get the bounds for. - /// The maximum available window bounds for a decorated window on the specified display. + /// @param display The display to get the bounds for. + /// @return The maximum available window bounds for a decorated window on the specified display. SDL_Rect GetUsableBoundsWithDecorations(int display); - /// /// Calculates whether the given resolution and multiplier would create a maximized window. - /// - /// Game window width to check. - /// Game window height to check. - /// Game window resolution multiplier to check. - /// Whether the given resolution and multiplier create a maximized window. + /// @param resX Game window width to check. + /// @param resY Game window height to check. + /// @param resMultiplier Game window resolution multiplier to check. + /// @return Whether the given resolution and multiplier create a maximized window. bool IsResolutionMaximized(int resX, int resY, float resMultiplier); - /// /// Checks whether the passed in resolution settings make sense. If not, overrides them to prevent crashes or unexpected behavior. - /// - /// Game window width to check. - /// Game window height to check. - /// Game window resolution multiplier to check. + /// @param resX Game window width to check. + /// @param resY Game window height to check. + /// @param resMultiplier Game window resolution multiplier to check. void ValidateResolution(int& resX, int& resY, float& resMultiplier) const; - /// /// Attempts to revert to the previous resolution settings if the new ones failed for whatever reason. Will recursively attempt to revert to defaults if previous settings fail as well. - /// - /// Whether to attempt to revert to defaults. Will be set by this. + /// @param revertToDefaults Whether to attempt to revert to defaults. Will be set by this. void AttemptToRevertToPreviousResolution(bool revertToDefaults = false); #pragma endregion #pragma region Multi - Display Handling - /// /// Clears all the multi-display data, resetting the game to a single-window-single-display state. - /// void ClearMultiDisplayData(); - /// /// Resize the window to enable fullscreen on multiple displays, using the arrangement info gathered during display mapping. - /// - /// Requested resolution multiplier. - /// Whether all displays were created successfully. + /// @param resMultiplier Requested resolution multiplier. + /// @return Whether all displays were created successfully. bool ChangeResolutionToMultiDisplayFullscreen(float resMultiplier); #pragma endregion #pragma region Display Switch Handling - /// /// Handles focus gain when switching back to the game window. - /// - /// The window that should take focus of input after all the windows are raised. This is only relevant in multi-display fullscreen. + /// @param windowThatShouldTakeInputFocus The window that should take focus of input after all the windows are raised. This is only relevant in multi-display fullscreen. void DisplaySwitchIn(SDL_Window* windowThatShouldTakeInputFocus) const; - /// /// Handles focus loss when switching away from the game window. /// Will temporarily disable positioning of the mouse so that when focus is switched back to the game window, the game window won't fly away because the user clicked the title bar of the window. - /// void DisplaySwitchOut() const; #pragma endregion - /// /// Clears all the member variables of this WindowMan, effectively resetting the members of this abstraction level only. - /// void Clear(); // Disallow the use of some implicit methods. diff --git a/Source/Menus/AreaEditorGUI.cpp b/Source/Menus/AreaEditorGUI.cpp index 3bbbeafc05..5f16678f31 100644 --- a/Source/Menus/AreaEditorGUI.cpp +++ b/Source/Menus/AreaEditorGUI.cpp @@ -1,15 +1,3 @@ -////////////////////////////////////////////////////////////////////////////////////////// -// File: AreaEditorGUI.cpp -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Implementation file for the AreaEditorGUI class -// Project: GUI Library -// Author(s): Daniel Tabar -// dtabar@datArealms.com -// http://www.datArealms.com - -////////////////////////////////////////////////////////////////////////////////////////// -// Inclusions of header files - #include "AreaEditorGUI.h" #include "CameraMan.h" @@ -30,12 +18,6 @@ using namespace RTE; -////////////////////////////////////////////////////////////////////////////////////////// -// Method: Clear -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Clears all the member variables of this AreaEditorGUI, effectively -// resetting the members of this abstraction level only. - void AreaEditorGUI::Clear() { m_pController = 0; m_FullFeatured = false; @@ -57,11 +39,6 @@ void AreaEditorGUI::Clear() { m_pBoxToBlink = 0; } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: Create -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Makes the AreaEditorGUI Area ready for use. - int AreaEditorGUI::Create(Controller* pController, bool fullFeatured, int whichModuleSpace) { RTEAssert(pController, "No controller sent to AreaEditorGUI on creation!"); m_pController = pController; @@ -96,55 +73,26 @@ int AreaEditorGUI::Create(Controller* pController, bool fullFeatured, int whichM return 0; } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: Destroy -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Destroys and resets (through Clear()) the AreaEditorGUI Area. - void AreaEditorGUI::Destroy() { delete m_pPicker; Clear(); } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: SetController -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Sets the controller used by this. The ownership of the controller is -// NOT transferred! - void AreaEditorGUI::SetController(Controller* pController) { m_pController = pController; m_PieMenu->SetMenuController(pController); m_pPicker->SetController(pController); } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: SetPosOnScreen -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Sets where on the screen that this GUI is being drawn to. If upper -// left corner, then 0, 0. This will affect the way the mouse is positioned -// etc. - void AreaEditorGUI::SetPosOnScreen(int newPosX, int newPosY) { m_pPicker->SetPosOnScreen(newPosX, newPosY); } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: GetActivatedPieSlice -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Gets any Pie menu slice command activated last update. - PieSlice::SliceType AreaEditorGUI::GetActivatedPieSlice() const { return m_PieMenu->GetPieCommand(); } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: SetCurrentArea -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Sets the currently selected Area of this Editor. Ownership IS NOT -// transferred! - void AreaEditorGUI::SetCurrentArea(Scene::Area* pArea) { if (!pArea) return; @@ -163,21 +111,10 @@ void AreaEditorGUI::SetCurrentArea(Scene::Area* pArea) { } } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: UpdatePickerList -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Updates the list that the GUI's Area picker has, from the current -// scene state. - void AreaEditorGUI::UpdatePickerList(std::string selectAreaName) { m_pPicker->UpdateAreasList(selectAreaName); } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: Update -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Updates the state of this Menu each frame - void AreaEditorGUI::Update() { // Update the user controller // m_pController->Update(); @@ -524,11 +461,6 @@ void AreaEditorGUI::Update() { g_CameraMan.SetScrollTarget(m_CursorPos, 0.3, g_ActivityMan.GetActivity()->ScreenOfPlayer(m_pController->GetPlayer())); } -////////////////////////////////////////////////////////////////////////////////////////// -// Virtual Method: Draw -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Draws the menu - void AreaEditorGUI::Draw(BITMAP* pTargetBitmap, const Vector& targetPos) const { // Done or can't, so don't draw the UI if (!m_pCurrentArea || m_EditorGUIMode == DONEEDITING) diff --git a/Source/Menus/AreaEditorGUI.h b/Source/Menus/AreaEditorGUI.h index 0bbe2f0bef..0263f1fbd2 100644 --- a/Source/Menus/AreaEditorGUI.h +++ b/Source/Menus/AreaEditorGUI.h @@ -1,19 +1,12 @@ #ifndef _AREAEDITORGUI_ #define _AREAEDITORGUI_ -////////////////////////////////////////////////////////////////////////////////////////// -// File: AreaEditorGUI.h -////////////////////////////////////////////////////////////////////////////////////////// -// Description: AreaEditorGUI class -// Project: GUI Library -// Author(s): Daniel Tabar -// dtabar@datarealms.com -// http://www.datarealms.com - -////////////////////////////////////////////////////////////////////////////////////////// -// Inclusions of header files - -//#include "FrameMan.h" +/// AreaEditorGUI class +/// @author Daniel Tabar +/// dtabar@datarealms.com +/// http://www.datarealms.com +/// Inclusions of header files +// #include "FrameMan.h" #include "Scene.h" #include "Timer.h" #include "Vector.h" @@ -28,18 +21,10 @@ namespace RTE { class AreaPickerGUI; class PieMenu; - ////////////////////////////////////////////////////////////////////////////////////////// - // Class: AreaEditorGUI - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: A full menu system that represents the scene editing GUI for Cortex Command - // Parent(s): None. - // Class history: 7/08/2007 AreaEditorGUI Created. - + /// A full menu system that represents the scene editing GUI for Cortex Command class AreaEditorGUI { - ////////////////////////////////////////////////////////////////////////////////////////// - // Public member variable, method and friend function declarations - + /// Public member variable, method and friend function declarations public: // Different modes of this editor enum EditorGUIMode { @@ -53,175 +38,87 @@ namespace RTE { EDITORGUIMODECOUNT }; - ////////////////////////////////////////////////////////////////////////////////////////// - // Constructor: AreaEditorGUI - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Constructor method used to instantiate a AreaEditorGUI Area in system - // memory. Create() should be called before using the Area. - // Arguments: None. - + /// Constructor method used to instantiate a AreaEditorGUI Area in system + /// memory. Create() should be called before using the Area. AreaEditorGUI() { Clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Destructor: ~AreaEditorGUI - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destructor method used to clean up a AreaEditorGUI Area before deletion - // from system memory. - // Arguments: None. - + /// Destructor method used to clean up a AreaEditorGUI Area before deletion + /// from system memory. ~AreaEditorGUI() { Destroy(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes the AreaEditorGUI Area ready for use. - // Arguments: A poitner to a Controller which will control this Menu. Ownership is - // NOT TRANSFERRED! - // Whether the editor should have all the features enabled, like load/save - // and undo capabilities. - // Which module space that this eidtor will be able to pick Areas from. - // -1 means all modules. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Makes the AreaEditorGUI Area ready for use. + /// @param pController A poitner to a Controller which will control this Menu. Ownership is + /// @param fullFeatured NOT TRANSFERRED! (default: false) + /// @param whichModuleSpace Whether the editor should have all the features enabled, like load/save (default: -1) + /// and undo capabilities. + /// Which module space that this eidtor will be able to pick Areas from. + /// -1 means all modules. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Create(Controller* pController, bool fullFeatured = false, int whichModuleSpace = -1); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Reset - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Resets the entire AreaEditorGUI, including its inherited members, to - // their default settings or values. - // Arguments: None. - // Return value: None. - + /// Resets the entire AreaEditorGUI, including its inherited members, to + /// their default settings or values. void Reset() { Clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destroys and resets (through Clear()) the AreaEditorGUI Area. - // Arguments: None. - // Return value: None. - + /// Destroys and resets (through Clear()) the AreaEditorGUI Area. void Destroy(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetController - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the controller used by this. The ownership of the controller is - // NOT transferred! - // Arguments: The new controller for this menu. Ownership is NOT transferred - // Return value: None. - + /// Sets the controller used by this. The ownership of the controller is + /// NOT transferred! + /// @param pController The new controller for this menu. Ownership is NOT transferred void SetController(Controller* pController); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetPosOnScreen - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets where on the screen that this GUI is being drawn to. If upper - // left corner, then 0, 0. This will affect the way the mouse is positioned - // etc. - // Arguments: The new screen position of this entire GUI. - + /// Sets where on the screen that this GUI is being drawn to. If upper + /// left corner, then 0, 0. This will affect the way the mouse is positioned + /// etc. + /// @param newPosX The new screen position of this entire GUI. void SetPosOnScreen(int newPosX, int newPosY); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetCursorPos - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the absolute scene coordinates of the cursor of this Editor. - // Arguments: The new cursor position in absolute scene units. - // Return value: None. - + /// Sets the absolute scene coordinates of the cursor of this Editor. + /// @param newCursorPos The new cursor position in absolute scene units. void SetCursorPos(const Vector& newCursorPos) { m_CursorPos = newCursorPos; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetActivatedPieSlice - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets any Pie menu slice command activated last update. - // Arguments: None. - // Return value: The enum'd int of any slice activated. See the PieSlice::SliceType enum. - + /// Gets any Pie menu slice command activated last update. + /// @return The enum'd int of any slice activated. See the PieSlice::SliceType enum. PieSlice::SliceType GetActivatedPieSlice() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetCurrentArea - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the currently selected Area of this Editor. Ownership IS NOT - // transferred! - // Arguments: The new area for this to work with, if any. OWNERSHIP IS NOT TRANSFERRED! - // Return value: None. - + /// Sets the currently selected Area of this Editor. Ownership IS NOT + /// transferred! + /// @param pArea The new area for this to work with, if any. OWNERSHIP IS NOT TRANSFERRED! void SetCurrentArea(Scene::Area* pArea); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetCurrentArea - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the currently held Area in the cursor of this Editor. Ownership - // IS NOT transferred! - // Arguments: None. - // Return value: The currently held Area, if any. OWNERSHIP IS NOT TRANSFERRED! - + /// Gets the currently held Area in the cursor of this Editor. Ownership + /// IS NOT transferred! + /// @return The currently held Area, if any. OWNERSHIP IS NOT TRANSFERRED! Scene::Area* GetCurrentArea() { return m_pCurrentArea; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetEditorMode - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the current mode of this editor. - // Arguments: The new mode to set to, see the EditorGUIMode enum. - // Return value: None. - + /// Sets the current mode of this editor. + /// @param newMode The new mode to set to, see the EditorGUIMode enum. void SetEditorGUIMode(EditorGUIMode newMode) { m_EditorGUIMode = newMode; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetEditorMode - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the current mode of this editor. - // Arguments: None. - // Return value: The current mode this is set to; see the EditorGUIMode enum. - + /// Gets the current mode of this editor. + /// @return The current mode this is set to; see the EditorGUIMode enum. EditorGUIMode GetEditorGUIMode() const { return m_EditorGUIMode; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: EditMade - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Shows whether an edit on the scene was made in the last Update. - // Arguments: None. - // Return value: Whether any edit was made. - + /// Shows whether an edit on the scene was made in the last Update. + /// @return Whether any edit was made. bool EditMade() const { return m_EditMade; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: UpdatePickerList - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the list that the GUI's Area picker has, from the current - // scene state. - // Arguments: The name of the Area to leave selected after the list is updated. - // Return value: None. - + /// Updates the list that the GUI's Area picker has, from the current + /// scene state. + /// @param selectAreaName The name of the Area to leave selected after the list is updated. (default: "") void UpdatePickerList(std::string selectAreaName = ""); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Update - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the state of this Menu each frame - // Arguments: None. - // Return value: None. - + /// Updates the state of this Menu each frame void Update(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Draw - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws the editor - // Arguments: The bitmap to draw on. - // The absolute position of the target bitmap's upper left corner in the scene. - // Return value: None. - + /// Draws the editor + /// @param pTargetBitmap The bitmap to draw on. + /// @param targetPos The absolute position of the target bitmap's upper left corner in the scene. (default: Vector()) void Draw(BITMAP* pTargetBitmap, const Vector& targetPos = Vector()) const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Protected member variable and method declarations - + /// Protected member variable and method declarations protected: enum BlinkMode { NOBLINK = 0, @@ -269,18 +166,10 @@ namespace RTE { // Currently placed scene Area to make blink when drawing it. NOT OWNED. const Box* m_pBoxToBlink; - ////////////////////////////////////////////////////////////////////////////////////////// - // Private member variable and method declarations - + /// Private member variable and method declarations private: - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Clear - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears all the member variables of this AreaEditorGUI, effectively - // resetting the members of this abstraction level only. - // Arguments: None. - // Return value: None. - + /// Clears all the member variables of this AreaEditorGUI, effectively + /// resetting the members of this abstraction level only. void Clear(); // Disallow the use of some implicit methods. diff --git a/Source/Menus/AreaPickerGUI.cpp b/Source/Menus/AreaPickerGUI.cpp index 808da95add..699168bedc 100644 --- a/Source/Menus/AreaPickerGUI.cpp +++ b/Source/Menus/AreaPickerGUI.cpp @@ -1,15 +1,3 @@ -////////////////////////////////////////////////////////////////////////////////////////// -// File: AreaPickerGUI.cpp -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Implementation file for the AreaPickerGUI class -// Project: GUI Library -// Author(s): Daniel Tabar -// dtabar@datarealms.com -// http://www.datarealms.com - -////////////////////////////////////////////////////////////////////////////////////////// -// Inclusions of header files - #include "AreaPickerGUI.h" #include "CameraMan.h" @@ -38,12 +26,6 @@ using namespace RTE; BITMAP* RTE::AreaPickerGUI::s_pCursor = 0; -////////////////////////////////////////////////////////////////////////////////////////// -// Method: Clear -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Clears all the member variables of this AreaPickerGUI, effectively -// resetting the members of this abstraction level only. - void AreaPickerGUI::Clear() { m_pController = 0; m_pGUIScreen = 0; @@ -63,11 +45,6 @@ void AreaPickerGUI::Clear() { m_CursorPos.Reset(); } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: Create -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Makes the AreaPickerGUI area ready for use. - int AreaPickerGUI::Create(Controller* pController, std::string onlyOfType) { RTEAssert(pController, "No controller sent to AreaPickerGUI on creation!"); m_pController = pController; @@ -131,11 +108,6 @@ int AreaPickerGUI::Create(Controller* pController, std::string onlyOfType) { return 0; } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: Destroy -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Destroys and resets (through Clear()) the AreaPickerGUI area. - void AreaPickerGUI::Destroy() { delete m_pGUIController; delete m_pGUIInput; @@ -144,11 +116,6 @@ void AreaPickerGUI::Destroy() { Clear(); } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: SetEnabled -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Enables or disables the menu. This will animate it in and out of view. - void AreaPickerGUI::SetEnabled(bool enable) { if (enable && m_PickerEnabled != ENABLED && m_PickerEnabled != ENABLING) { // If we're not split screen horizontally, then stretch out the layout for all the relevant controls @@ -183,22 +150,10 @@ void AreaPickerGUI::SetEnabled(bool enable) { } } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: SetPosOnScreen -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Sets where on the screen that this GUI is being drawn to. If upper -// left corner, then 0, 0. This will affect the way the mouse is positioned -// etc. - void AreaPickerGUI::SetPosOnScreen(int newPosX, int newPosY) { m_pGUIController->SetPosOnScreen(newPosX, newPosY); } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: GetNextArea -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Gets the next area in the areas list, even if the picker is disabled. - Scene::Area* AreaPickerGUI::GetNextArea() { m_SelectedAreaIndex++; // Loop around @@ -215,11 +170,6 @@ Scene::Area* AreaPickerGUI::GetNextArea() { return 0; } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: GetPrevArea -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Gets the prev area in the areas list, even if the picker is disabled. - Scene::Area* AreaPickerGUI::GetPrevArea() { m_SelectedAreaIndex--; // Loop around @@ -236,12 +186,6 @@ Scene::Area* AreaPickerGUI::GetPrevArea() { return 0; } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: UpdateAreasList -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Adds all areas of a specific type already defined in PresetMan -// to the current Areas list - void AreaPickerGUI::UpdateAreasList(std::string selectAreaName) { m_pAreasList->ClearList(); @@ -267,11 +211,6 @@ void AreaPickerGUI::UpdateAreasList(std::string selectAreaName) { } } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: Update -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Updates the state of this Menu each frame - void AreaPickerGUI::Update() { // Enable mouse input if the controller allows it m_pGUIController->EnableMouse(m_pController->IsMouseControlled()); @@ -491,11 +430,6 @@ void AreaPickerGUI::Update() { } } -////////////////////////////////////////////////////////////////////////////////////////// -// Virtual Method: Draw -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Draws the menu - void AreaPickerGUI::Draw(BITMAP* drawBitmap) const { AllegroScreen drawScreen(drawBitmap); m_pGUIController->Draw(&drawScreen); diff --git a/Source/Menus/AreaPickerGUI.h b/Source/Menus/AreaPickerGUI.h index fe55f3b7f8..759189a2fd 100644 --- a/Source/Menus/AreaPickerGUI.h +++ b/Source/Menus/AreaPickerGUI.h @@ -1,19 +1,12 @@ #ifndef _AREAPICKERGUI_ #define _AREAPICKERGUI_ -////////////////////////////////////////////////////////////////////////////////////////// -// File: AreaPickerGUI.h -////////////////////////////////////////////////////////////////////////////////////////// -// Description: AreaPickerGUI class -// Project: GUI Library -// Author(s): Daniel Tabar -// dtabar@datarealms.com -// http://www.datarealms.com - -////////////////////////////////////////////////////////////////////////////////////////// -// Inclusions of header files - -//#include "FrameMan.h" +/// AreaPickerGUI class +/// @author Daniel Tabar +/// dtabar@datarealms.com +/// http://www.datarealms.com +/// Inclusions of header files +// #include "FrameMan.h" #include "Timer.h" #include "Controller.h" #include "Scene.h" @@ -31,189 +24,91 @@ namespace RTE { class GUIButton; class GUILabel; - ////////////////////////////////////////////////////////////////////////////////////////// - // Class: AreaPickerGUI - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: A GUI for picking isntance areas in Cortex Command - // Parent(s): None. - // Class history: 7/16/2007 AreaPickerGUI Created. - + /// A GUI for picking isntance areas in Cortex Command class AreaPickerGUI { - ////////////////////////////////////////////////////////////////////////////////////////// - // Public member variable, method and friend function declarations - + /// Public member variable, method and friend function declarations public: - ////////////////////////////////////////////////////////////////////////////////////////// - // Constructor: AreaPickerGUI - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Constructor method used to instantiate a AreaPickerGUI area in system - // memory. Create() should be called before using the area. - // Arguments: None. - + /// Constructor method used to instantiate a AreaPickerGUI area in system + /// memory. Create() should be called before using the area. AreaPickerGUI() { Clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Destructor: ~AreaPickerGUI - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destructor method used to clean up a AreaPickerGUI area before deletion - // from system memory. - // Arguments: None. - + /// Destructor method used to clean up a AreaPickerGUI area before deletion + /// from system memory. ~AreaPickerGUI() { Destroy(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes the AreaPickerGUI area ready for use. - // Arguments: A poitner to a Controller which will control this Menu. Ownership is - // NOT TRANSFERRED! - // Which lowest common denominator type to be showing. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Makes the AreaPickerGUI area ready for use. + /// @param pController A poitner to a Controller which will control this Menu. Ownership is + /// @param onlyOfType NOT TRANSFERRED! (default: "All") + /// Which lowest common denominator type to be showing. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Create(Controller* pController, std::string onlyOfType = "All"); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Reset - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Resets the entire AreaPickerGUI, including its inherited members, to - // their default settings or values. - // Arguments: None. - // Return value: None. - + /// Resets the entire AreaPickerGUI, including its inherited members, to + /// their default settings or values. void Reset() { Clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destroys and resets (through Clear()) the AreaPickerGUI area. - // Arguments: None. - // Return value: None. - + /// Destroys and resets (through Clear()) the AreaPickerGUI area. void Destroy(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetController - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the controller used by this. The ownership of the controller is - // NOT transferred! - // Arguments: The new controller for this menu. Ownership is NOT transferred - // Return value: None. - + /// Sets the controller used by this. The ownership of the controller is + /// NOT transferred! + /// @param pController The new controller for this menu. Ownership is NOT transferred void SetController(Controller* pController) { m_pController = pController; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetEnabled - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Enables or disables the menu. This will animate it in and out of view. - // Arguments: Whether to enable or disable the menu. - // Return value: None. - + /// Enables or disables the menu. This will animate it in and out of view. + /// @param enable Whether to enable or disable the menu. (default: true) void SetEnabled(bool enable = true); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: IsEnabled - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Reports whether the menu is enabled or not. - // Arguments: None. - // Return value: None. - + /// Reports whether the menu is enabled or not. bool IsEnabled() const { return m_PickerEnabled == ENABLED || m_PickerEnabled == ENABLING; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: IsVisible - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Reports whether the menu is at all visible or not. - // Arguments: None. - // Return value: None. - + /// Reports whether the menu is at all visible or not. bool IsVisible() const { return m_PickerEnabled != DISABLED; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetPosOnScreen - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets where on the screen that this GUI is being drawn to. If upper - // left corner, then 0, 0. This will affect the way the mouse is positioned - // etc. - // Arguments: The new screen position of this entire GUI. - + /// Sets where on the screen that this GUI is being drawn to. If upper + /// left corner, then 0, 0. This will affect the way the mouse is positioned + /// etc. + /// @param newPosX The new screen position of this entire GUI. void SetPosOnScreen(int newPosX, int newPosY); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: AreaPicked - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Reports whether and which Area has been picked by the player. This - // may happen even though the player isn't done with the picker. (ie - // a different area is picked each time the user selects something else - // in the areas list). - // Arguments: None. - // Return value: Whether an area has been picked bt the player. 0 if not. Ownership - // is NOT transferred! - + /// Reports whether and which Area has been picked by the player. This + /// may happen even though the player isn't done with the picker. (ie + /// a different area is picked each time the user selects something else + /// in the areas list). + /// @return Whether an area has been picked bt the player. 0 if not. Ownership + /// is NOT transferred! Scene::Area* AreaPicked() { return m_pPickedArea; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: DonePicking - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Reports whether the user has finished using the picker, and the final - // picked Area is returned. - // Arguments: None. - // Return value: Whether an area has been positively and finally picked bt the player. - // 0 if not. Ownership is NOT transferred! - + /// Reports whether the user has finished using the picker, and the final + /// picked Area is returned. + /// @return Whether an area has been positively and finally picked bt the player. + /// 0 if not. Ownership is NOT transferred! Scene::Area* DonePicking() { return !IsEnabled() && m_pPickedArea ? m_pPickedArea : 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetNextArea - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the next area in the areas list, even if the picker is disabled. - // Arguments: None. - // Return value: The next area in the picker list, looping around if necessary. - // 0 if no area can be selected. OWNERSHIP IS NOT TRANSFERRED! - + /// Gets the next area in the areas list, even if the picker is disabled. + /// @return The next area in the picker list, looping around if necessary. + /// 0 if no area can be selected. OWNERSHIP IS NOT TRANSFERRED! Scene::Area* GetNextArea(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetPrevArea - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the prev area in the areas list, even if the picker is disabled. - // Arguments: None. - // Return value: The prev area in the picker list, looping around if necessary. - // 0 if no area can be selected. OWNERSHIP IS NOT TRANSFERRED! - + /// Gets the prev area in the areas list, even if the picker is disabled. + /// @return The prev area in the picker list, looping around if necessary. + /// 0 if no area can be selected. OWNERSHIP IS NOT TRANSFERRED! Scene::Area* GetPrevArea(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: UpdateAreasList - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Adds all areas of the currently selected group to the Areas list. - // Arguments: The name of the Area to leave selected after the list is updated. - // Return value: None. - + /// Adds all areas of the currently selected group to the Areas list. + /// @param selectAreaName The name of the Area to leave selected after the list is updated. (default: "") void UpdateAreasList(std::string selectAreaName = ""); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Update - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the state of this Menu each frame - // Arguments: None. - // Return value: None. - + /// Updates the state of this Menu each frame void Update(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Draw - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws the menu - // Arguments: The bitmap to draw on. - // Return value: None. - + /// Draws the menu + /// @param drawBitmap The bitmap to draw on. void Draw(BITMAP* drawBitmap) const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Protected member variable and method declarations - + /// Protected member variable and method declarations protected: enum PickerEnabled { ENABLING = 0, @@ -261,18 +156,10 @@ namespace RTE { // Screen position of the cursor Vector m_CursorPos; - ////////////////////////////////////////////////////////////////////////////////////////// - // Private member variable and method declarations - + /// Private member variable and method declarations private: - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Clear - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears all the member variables of this AreaPickerGUI, effectively - // resetting the members of this abstraction level only. - // Arguments: None. - // Return value: None. - + /// Clears all the member variables of this AreaPickerGUI, effectively + /// resetting the members of this abstraction level only. void Clear(); // Disallow the use of some implicit methods. diff --git a/Source/Menus/AssemblyEditorGUI.cpp b/Source/Menus/AssemblyEditorGUI.cpp index a766194884..a529d6c620 100644 --- a/Source/Menus/AssemblyEditorGUI.cpp +++ b/Source/Menus/AssemblyEditorGUI.cpp @@ -1,15 +1,3 @@ -////////////////////////////////////////////////////////////////////////////////////////// -// File: AssemblyEditorGUI.cpp -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Implementation file for the AssemblyEditorGUI class -// Project: GUI Library -// Author(s): Daniel Tabar -// dtabar@datarealms.com -// http://www.datarealms.com - -////////////////////////////////////////////////////////////////////////////////////////// -// Inclusions of header files - #include "AssemblyEditorGUI.h" #include "CameraMan.h" @@ -44,12 +32,6 @@ using namespace RTE; BITMAP* AssemblyEditorGUI::s_pValidPathDot = 0; BITMAP* AssemblyEditorGUI::s_pInvalidPathDot = 0; -////////////////////////////////////////////////////////////////////////////////////////// -// Method: Clear -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Clears all the member variables of this AssemblyEditorGUI, effectively -// resetting the members of this abstraction level only. - void AssemblyEditorGUI::Clear() { m_pController = 0; m_FeatureSet = ONLOADEDIT; @@ -84,11 +66,6 @@ void AssemblyEditorGUI::Clear() { m_CurrentAssemblyName.clear(); } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: Create -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Makes the AssemblyEditorGUI object ready for use. - int AssemblyEditorGUI::Create(Controller* pController, FeatureSets featureSet, int whichModuleSpace, int nativeTechModule, float foreignCostMult) { RTEAssert(pController, "No controller sent to AssemblyEditorGUI on creation!"); m_pController = pController; @@ -152,11 +129,6 @@ int AssemblyEditorGUI::Create(Controller* pController, FeatureSets featureSet, i return 0; } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: Destroy -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Destroys and resets (through Clear()) the AssemblyEditorGUI object. - void AssemblyEditorGUI::Destroy() { delete m_pPicker; delete m_pCurrentObject; @@ -165,35 +137,16 @@ void AssemblyEditorGUI::Destroy() { Clear(); } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: SetController -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Sets the controller used by this. The ownership of the controller is -// NOT transferred! - void AssemblyEditorGUI::SetController(Controller* pController) { m_pController = pController; m_PieMenu->SetMenuController(pController); m_pPicker->SetController(pController); } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: SetPosOnScreen -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Sets where on the screen that this GUI is being drawn to. If upper -// left corner, then 0, 0. This will affect the way the mouse is positioned -// etc. - void AssemblyEditorGUI::SetPosOnScreen(int newPosX, int newPosY) { m_pPicker->SetPosOnScreen(newPosX, newPosY); } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: SetCurrentObject -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Sets the new Object to be held at the cursor of this Editor. Ownership -// IS transferred! - bool AssemblyEditorGUI::SetCurrentObject(SceneObject* pNewObject) { if (m_pCurrentObject == pNewObject) return true; @@ -220,31 +173,14 @@ bool AssemblyEditorGUI::SetCurrentObject(SceneObject* pNewObject) { return true; } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: GetActivatedPieSlice -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Gets any Pie menu slice command activated last update. - PieSlice::SliceType AssemblyEditorGUI::GetActivatedPieSlice() const { return m_PieMenu->GetPieCommand(); } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: SetModuleSpace -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Sets which DataModule space to be picking objects from. If -1, then -// let the player pick from all loaded modules. - void AssemblyEditorGUI::SetModuleSpace(int moduleSpaceID) { m_pPicker->SetModuleSpace(moduleSpaceID); } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: SetNativeTechModule -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Sets which DataModule ID should be treated as the native tech of the -// user of this menu. - void AssemblyEditorGUI::SetNativeTechModule(int whichModule) { if (whichModule >= 0 && whichModule < g_PresetMan.GetTotalModuleCount()) { m_NativeTechModule = whichModule; @@ -252,35 +188,16 @@ void AssemblyEditorGUI::SetNativeTechModule(int whichModule) { } } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: SetForeignCostMultiplier -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Sets the multiplier of the cost of any foreign Tech items. - void AssemblyEditorGUI::SetForeignCostMultiplier(float newMultiplier) { m_ForeignCostMult = newMultiplier; m_pPicker->SetForeignCostMultiplier(m_ForeignCostMult); } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: TestBrainResidence -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Checks whether the resident brain is currently placed into a valid -// location in this scene, based on whether there is a clear path to the -// sky above it. This forces the editor into place brain mode with the -// current resident brain if the current placement is no bueno. It also -// removes the faulty brain from residence in the scene! - bool AssemblyEditorGUI::TestBrainResidence(bool noBrainIsOK) { // Brain is fine, leave it be return false; } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: Update -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Updates the state of this Menu each frame - void AssemblyEditorGUI::Update() { // Update the user controller // m_pController->Update(); @@ -859,11 +776,6 @@ void AssemblyEditorGUI::Update() { } } -////////////////////////////////////////////////////////////////////////////////////////// -// Virtual Method: Draw -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Draws the menu - void AssemblyEditorGUI::Draw(BITMAP* pTargetBitmap, const Vector& targetPos) const { // Done, so don't draw the UI if (m_EditorGUIMode == DONEEDITING) @@ -937,12 +849,6 @@ void AssemblyEditorGUI::Draw(BITMAP* pTargetBitmap, const Vector& targetPos) con m_PieMenu->Draw(pTargetBitmap, targetPos); } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: UpdateBrainPath -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Updates the brain path to the current resident brain, if any. If -// there's none, the path is cleared. - bool AssemblyEditorGUI::UpdateBrainPath() { // First see if we have a brain in hand if (m_pCurrentObject && m_pCurrentObject->IsInGroup("Brains")) { diff --git a/Source/Menus/AssemblyEditorGUI.h b/Source/Menus/AssemblyEditorGUI.h index 934e6d9c8d..8c92223549 100644 --- a/Source/Menus/AssemblyEditorGUI.h +++ b/Source/Menus/AssemblyEditorGUI.h @@ -1,19 +1,12 @@ #ifndef _ASSEMBLYEDITORGUI_ #define _ASSEMBLYEDITORGUI_ -////////////////////////////////////////////////////////////////////////////////////////// -// File: AssemblyEditorGUI.h -////////////////////////////////////////////////////////////////////////////////////////// -// Description: AssemblyEditorGUI class -// Project: GUI Library -// Author(s): Daniel Tabar -// dtabar@datarealms.com -// http://www.datarealms.com - -////////////////////////////////////////////////////////////////////////////////////////// -// Inclusions of header files - -//#include "FrameMan.h" +/// AssemblyEditorGUI class +/// @author Daniel Tabar +/// dtabar@datarealms.com +/// http://www.datarealms.com +/// Inclusions of header files +// #include "FrameMan.h" #include "Timer.h" #include "Vector.h" #include "BunkerAssemblyScheme.h" @@ -29,18 +22,10 @@ namespace RTE { class ObjectPickerGUI; class PieMenu; - ////////////////////////////////////////////////////////////////////////////////////////// - // Class: AssemblyEditorGUI - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: A full menu system that represents the scene editing GUI for Cortex Command - // Parent(s): None. - // Class history: 7/08/2007 AssemblyEditorGUI Created. - + /// A full menu system that represents the scene editing GUI for Cortex Command class AssemblyEditorGUI { - ////////////////////////////////////////////////////////////////////////////////////////// - // Public member variable, method and friend function declarations - + /// Public member variable, method and friend function declarations public: enum FeatureSets { ONLOADEDIT = 0 @@ -58,257 +43,130 @@ namespace RTE { EDITORGUIMODECOUNT }; - ////////////////////////////////////////////////////////////////////////////////////////// - // Constructor: AssemblyEditorGUI - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Constructor method used to instantiate a AssemblyEditorGUI object in system - // memory. Create() should be called before using the object. - // Arguments: None. - + /// Constructor method used to instantiate a AssemblyEditorGUI object in system + /// memory. Create() should be called before using the object. AssemblyEditorGUI() { Clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Destructor: ~AssemblyEditorGUI - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destructor method used to clean up a AssemblyEditorGUI object before deletion - // from system memory. - // Arguments: None. - + /// Destructor method used to clean up a AssemblyEditorGUI object before deletion + /// from system memory. ~AssemblyEditorGUI() { Destroy(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes the AssemblyEditorGUI object ready for use. - // Arguments: A poitner to a Controller which will control this Menu. Ownership is - // NOT TRANSFERRED! - // Whether the editor should have all the features enabled, like load/save - // and undo capabilities. - // Which module space that this eidtor will be able to pick objects from. - // -1 means all modules. - // Which Tech module that will be presented as the native one to the player. - // The multiplier of all foreign techs' costs. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Makes the AssemblyEditorGUI object ready for use. + /// @param pController A poitner to a Controller which will control this Menu. Ownership is + /// @param featureSet NOT TRANSFERRED! (default: ONLOADEDIT) + /// @param whichModuleSpace Whether the editor should have all the features enabled, like load/save (default: -1) + /// and undo capabilities. + /// @param nativeTechModule Which module space that this eidtor will be able to pick objects from. (default: 0) + /// -1 means all modules. + /// @param foreignCostMult Which Tech module that will be presented as the native one to the player. (default: 1.0) + /// The multiplier of all foreign techs' costs. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Create(Controller* pController, FeatureSets featureSet = ONLOADEDIT, int whichModuleSpace = -1, int nativeTechModule = 0, float foreignCostMult = 1.0); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Reset - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Resets the entire AssemblyEditorGUI, including its inherited members, to - // their default settings or values. - // Arguments: None. - // Return value: None. - + /// Resets the entire AssemblyEditorGUI, including its inherited members, to + /// their default settings or values. void Reset() { Clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destroys and resets (through Clear()) the AssemblyEditorGUI object. - // Arguments: None. - // Return value: None. - + /// Destroys and resets (through Clear()) the AssemblyEditorGUI object. void Destroy(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetController - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the controller used by this. The ownership of the controller is - // NOT transferred! - // Arguments: The new controller for this menu. Ownership is NOT transferred - // Return value: None. - + /// Sets the controller used by this. The ownership of the controller is + /// NOT transferred! + /// @param pController The new controller for this menu. Ownership is NOT transferred void SetController(Controller* pController); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetPosOnScreen - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets where on the screen that this GUI is being drawn to. If upper - // left corner, then 0, 0. This will affect the way the mouse is positioned - // etc. - // Arguments: The new screen position of this entire GUI. - + /// Sets where on the screen that this GUI is being drawn to. If upper + /// left corner, then 0, 0. This will affect the way the mouse is positioned + /// etc. + /// @param newPosX The new screen position of this entire GUI. void SetPosOnScreen(int newPosX, int newPosY); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetCursorPos - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the absolute scene coordinates of the cursor of this Editor. - // Arguments: The new cursor position in absolute scene units. - // Return value: None. - + /// Sets the absolute scene coordinates of the cursor of this Editor. + /// @param newCursorPos The new cursor position in absolute scene units. void SetCursorPos(const Vector& newCursorPos) { m_CursorPos = newCursorPos; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetCurrentObject - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the new Object to be held at the cursor of this Editor. Ownership - // IS transferred! - // Arguments: The new Object to be held by the cursor. Ownership IS transferred! - // Return value: Whether the cursor holds a valid object after setting. - + /// Sets the new Object to be held at the cursor of this Editor. Ownership + /// IS transferred! + /// @param pNewObject The new Object to be held by the cursor. Ownership IS transferred! + /// @return Whether the cursor holds a valid object after setting. bool SetCurrentObject(SceneObject* pNewObject); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetActivatedPieSlice - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets any Pie menu slice command activated last update. - // Arguments: None. - // Return value: The enum'd int of any slice activated. See the PieSlice::SliceType enum. - + /// Gets any Pie menu slice command activated last update. + /// @return The enum'd int of any slice activated. See the PieSlice::SliceType enum. PieSlice::SliceType GetActivatedPieSlice() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetCurrentObject - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the currently held Object in the cursor of this Editor. Ownership - // IS NOT transferred! - // Arguments: None. - // Return value: The currently held object, if any. OWNERSHIP IS NOT TRANSFERRED! - + /// Gets the currently held Object in the cursor of this Editor. Ownership + /// IS NOT transferred! + /// @return The currently held object, if any. OWNERSHIP IS NOT TRANSFERRED! const SceneObject* GetCurrentObject() const { return m_pCurrentObject; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetEditorMode - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the current mode of this editor. - // Arguments: The new mode to set to, see the EditorGUIMode enum. - // Return value: None. - + /// Sets the current mode of this editor. + /// @param newMode The new mode to set to, see the EditorGUIMode enum. void SetEditorGUIMode(EditorGUIMode newMode) { m_EditorGUIMode = newMode; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetEditorMode - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the current mode of this editor. - // Arguments: None. - // Return value: The current mode this is set to; see the EditorGUIMode enum. - + /// Gets the current mode of this editor. + /// @return The current mode this is set to; see the EditorGUIMode enum. EditorGUIMode GetEditorGUIMode() const { return m_EditorGUIMode; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetModuleSpace - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets which DataModule space to be picking objects from. If -1, then - // let the player pick from all loaded modules. - // Arguments: The ID of the module to let the player pick objects from. All official - // modules' objects will alwayws be presented, in addition to the one - // passed in here. - // Return value: None. - + /// Sets which DataModule space to be picking objects from. If -1, then + /// let the player pick from all loaded modules. + /// @param moduleSpaceID The ID of the module to let the player pick objects from. All official (default: -1) + /// modules' objects will alwayws be presented, in addition to the one + /// passed in here. void SetModuleSpace(int moduleSpaceID = -1); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetNativeTechModule - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets which DataModule ID should be treated as the native tech of the - // user of this menu. - // Arguments: The module ID to set as the native one. 0 means everything is native. - // Return value: None. - + /// Sets which DataModule ID should be treated as the native tech of the + /// user of this menu. + /// @param whichModule The module ID to set as the native one. 0 means everything is native. void SetNativeTechModule(int whichModule); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetForeignCostMultiplier - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the multiplier of the cost of any foreign Tech items. - // Arguments: The scalar multiplier of the costs of foreign Tech items. - // Return value: None. - + /// Sets the multiplier of the cost of any foreign Tech items. + /// @param newMultiplier The scalar multiplier of the costs of foreign Tech items. void SetForeignCostMultiplier(float newMultiplier); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: EditMade - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Shows whether an edit on the scene was made in the last Update. - // Arguments: None. - // Return value: Whether any edit was made. - + /// Shows whether an edit on the scene was made in the last Update. + /// @return Whether any edit was made. bool EditMade() const { return m_EditMade; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: TestBrainResidence - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Checks whether the resident brain is currently placed into a valid - // location in this scene, based on whether there is a clear path to the - // sky above it. This forces the editor into place brain mode with the - // current resident brain if the current placement is no bueno. It also - // removes the faulty brain from residence in the scene! - // Arguments: Whether it's OK if we dont' have a brain right now - ie don't force - // into isntallation mode if no brain was found. - // Return value: Whether a resident brain was found, AND found in a valid location! - + /// Checks whether the resident brain is currently placed into a valid + /// location in this scene, based on whether there is a clear path to the + /// sky above it. This forces the editor into place brain mode with the + /// current resident brain if the current placement is no bueno. It also + /// removes the faulty brain from residence in the scene! + /// @param noBrainIsOK Whether it's OK if we dont' have a brain right now - ie don't force (default: false) + /// into isntallation mode if no brain was found. + /// @return Whether a resident brain was found, AND found in a valid location! bool TestBrainResidence(bool noBrainIsOK = false); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Update - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the state of this Menu each frame - // Arguments: None. - // Return value: None. - + /// Updates the state of this Menu each frame void Update(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Draw - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws the editor - // Arguments: The bitmap to draw on. - // The absolute position of the target bitmap's upper left corner in the scene. - // Return value: None. - + /// Draws the editor + /// @param pTargetBitmap The bitmap to draw on. + /// @param targetPos The absolute position of the target bitmap's upper left corner in the scene. (default: Vector()) void Draw(BITMAP* pTargetBitmap, const Vector& targetPos = Vector()) const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetCurrentAssemblyScheme - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns a pointer to currently selected assembly scheme - // Arguments: None. - // Return value: Pointer to current assembly scheme. - + /// Returns a pointer to currently selected assembly scheme + /// @return Pointer to current assembly scheme. BunkerAssemblyScheme* GetCurrentAssemblyScheme() { return m_pCurrentScheme; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetCurrentAssemblyName - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns the name of currently edited assembly - // Arguments: None. - // Return value: Name of currently edited assembly. - + /// Returns the name of currently edited assembly + /// @return Name of currently edited assembly. std::string GetCurrentAssemblyName() { return m_CurrentAssemblyName; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetCurrentAssemblyScheme - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets new name of currently edited assembly - // Arguments: New name for assembly. - // Return value: None. - + /// Sets new name of currently edited assembly + /// @param newName New name for assembly. void SetCurrentAssemblyName(std::string newName) { m_CurrentAssemblyName = newName; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Protected member variable and method declarations - + /// Protected member variable and method declarations protected: - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: UpdatePieMenu - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the PieMenu config based ont eh current editor state. - // Arguments: None. - // Return value: None. - + /// Updates the PieMenu config based ont eh current editor state. void UpdatePieMenu(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: UpdateBrainPath - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the brain path to the current brain in cursor or resident - // in the scene, if any. If there's none, the path is cleared. - // Arguments: None. - // Return value: Whether a resident brain was found in the scene. - + /// Updates the brain path to the current brain in cursor or resident + /// in the scene, if any. If there's none, the path is cleared. + /// @return Whether a resident brain was found in the scene. bool UpdateBrainPath(); enum BlinkMode { @@ -387,18 +245,10 @@ namespace RTE { // Edited assembly name std::string m_CurrentAssemblyName; - ////////////////////////////////////////////////////////////////////////////////////////// - // Private member variable and method declarations - + /// Private member variable and method declarations private: - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Clear - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears all the member variables of this AssemblyEditorGUI, effectively - // resetting the members of this abstraction level only. - // Arguments: None. - // Return value: None. - + /// Clears all the member variables of this AssemblyEditorGUI, effectively + /// resetting the members of this abstraction level only. void Clear(); // Disallow the use of some implicit methods. diff --git a/Source/Menus/BuyMenuGUI.cpp b/Source/Menus/BuyMenuGUI.cpp index 9a8f6a9251..0842a8fdbe 100644 --- a/Source/Menus/BuyMenuGUI.cpp +++ b/Source/Menus/BuyMenuGUI.cpp @@ -1,15 +1,3 @@ -////////////////////////////////////////////////////////////////////////////////////////// -// File: BuyMenuGUI.cpp -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Implementation file for the BuyMenuGUI class -// Project: GUI Library -// Author(s): Daniel Tabar -// dtabar@datarealms.com -// http://www.datarealms.com - -////////////////////////////////////////////////////////////////////////////////////////// -// Inclusions of header files - #include "BuyMenuGUI.h" #include "CameraMan.h" @@ -50,12 +38,6 @@ BITMAP* RTE::BuyMenuGUI::s_pCursor = 0; const std::string BuyMenuGUI::c_DefaultBannerImagePath = "Base.rte/GUIs/BuyMenu/BuyMenuBanner.png"; const std::string BuyMenuGUI::c_DefaultLogoImagePath = "Base.rte/GUIs/BuyMenu/BuyMenuLogo.png"; -////////////////////////////////////////////////////////////////////////////////////////// -// Method: Clear -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Clears all the member variables of this BuyMenuGUI, effectively -// resetting the members of this abstraction level only. - void BuyMenuGUI::Clear() { m_pController = 0; m_pGUIScreen = 0; @@ -132,11 +114,6 @@ void BuyMenuGUI::Clear() { m_LastEquipmentTab = SHIELDS; } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: Create -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Makes the BuyMenuGUI object ready for use. - int BuyMenuGUI::Create(Controller* pController) { RTEAssert(pController, "No controller sent to BuyMenyGUI on creation!"); m_pController = pController; @@ -290,11 +267,6 @@ int BuyMenuGUI::Create(Controller* pController) { return 0; } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: Destroy -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Destroys and resets (through Clear()) the BuyMenuGUI object. - void BuyMenuGUI::Destroy() { delete m_pGUIController; delete m_pGUIInput; @@ -305,38 +277,28 @@ void BuyMenuGUI::Destroy() { Clear(); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void BuyMenuGUI::SetBannerImage(const std::string& imagePath) { ContentFile bannerFile((imagePath.empty() ? c_DefaultBannerImagePath : imagePath).c_str()); m_Banner->SetDrawImage(new AllegroBitmap(bannerFile.GetAsBitmap())); m_Banner->SetDrawType(GUICollectionBox::Image); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void BuyMenuGUI::SetLogoImage(const std::string& imagePath) { ContentFile logoFile((imagePath.empty() ? c_DefaultLogoImagePath : imagePath).c_str()); m_Logo->SetDrawImage(new AllegroBitmap(logoFile.GetAsBitmap())); m_Logo->SetDrawType(GUICollectionBox::Image); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void BuyMenuGUI::ClearCartList() { m_pCartList->ClearList(); m_ListItemIndex = 0; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void BuyMenuGUI::AddCartItem(const std::string& name, const std::string& rightText, GUIBitmap* pBitmap, const Entity* pEntity, const int extraIndex) { m_pCartList->AddItem(name, rightText, pBitmap, pEntity, extraIndex); UpdateItemNestingLevels(); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void BuyMenuGUI::DuplicateCartItem(const int itemIndex) { if (m_pCartList->GetItemList()->empty()) { return; @@ -378,8 +340,6 @@ void BuyMenuGUI::DuplicateCartItem(const int itemIndex) { m_pCartList->SetSelectedIndex(itemIndex); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool BuyMenuGUI::LoadAllLoadoutsFromFile() { // First clear out all loadouts m_Loadouts.clear(); @@ -474,13 +434,6 @@ bool BuyMenuGUI::LoadAllLoadoutsFromFile() { return true; } -////////////////////////////////////////////////////////////////////////////////////////// -// Virtual Method: SaveAllLoadoutsToFile -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Saves all the loadouts to appropriate file on disk. Does NOT save -// any named presets which will be loaded from the standard preset -// loadouts first anyway. - bool BuyMenuGUI::SaveAllLoadoutsToFile() { // Nothing to save if (m_Loadouts.empty()) @@ -513,11 +466,6 @@ bool BuyMenuGUI::SaveAllLoadoutsToFile() { return true; } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: SetEnabled -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Enables or disables the menu. This will animate it in and out of view. - void BuyMenuGUI::SetEnabled(bool enable) { if (enable && m_MenuEnabled != ENABLED && m_MenuEnabled != ENABLING) { if (g_FrameMan.IsInMultiplayerMode()) { @@ -584,22 +532,10 @@ void BuyMenuGUI::SetEnabled(bool enable) { } } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: SetPosOnScreen -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Sets where on the screen that this GUI is being drawn to. If upper -// left corner, then 0, 0. This will affect the way the mouse is positioned -// etc. - void BuyMenuGUI::SetPosOnScreen(int newPosX, int newPosY) { m_pGUIController->SetPosOnScreen(newPosX, newPosY); } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: SetMetaPlayer -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Sets which MetaPlayer uses this menu, if any. - void BuyMenuGUI::SetMetaPlayer(int metaPlayer) { if (metaPlayer >= Players::PlayerOne && metaPlayer < g_MetaMan.GetPlayerCount()) { m_MetaPlayer = metaPlayer; @@ -608,8 +544,6 @@ void BuyMenuGUI::SetMetaPlayer(int metaPlayer) { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void BuyMenuGUI::SetNativeTechModule(int whichModule) { if (whichModule >= 0 && whichModule < g_PresetMan.GetTotalModuleCount()) { m_NativeTechModule = whichModule; @@ -639,12 +573,6 @@ void BuyMenuGUI::SetNativeTechModule(int whichModule) { } } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: SetModuleExpanded -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Sets whether a data module shown in the item menu should be expanded -// or not. - void BuyMenuGUI::SetModuleExpanded(int whichModule, bool expanded) { int moduleCount = g_PresetMan.GetTotalModuleCount(); if (whichModule > 0 && whichModule < moduleCount) { @@ -659,11 +587,6 @@ void BuyMenuGUI::SetModuleExpanded(int whichModule, bool expanded) { } } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: GetOrderList -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Return the list of things currently in the purchase order list box. - bool BuyMenuGUI::GetOrderList(std::list& listToFill) const { if (m_pCartList->GetItemList()->empty()) return false; @@ -742,8 +665,6 @@ float BuyMenuGUI::GetTotalCost(bool includeDelivery) const { return totalCost; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - float BuyMenuGUI::GetTotalOrderMass() const { float totalMass = 0.0F; @@ -759,8 +680,6 @@ float BuyMenuGUI::GetTotalOrderMass() const { return totalMass; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - float BuyMenuGUI::GetCraftMass() { float totalMass = 0; @@ -771,13 +690,6 @@ float BuyMenuGUI::GetCraftMass() { return totalMass; } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: GetTotalOrderPassengers -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Return the total number of passengers in the order box. -// Arguments: None. -// Return value: The total number of passengers. - int BuyMenuGUI::GetTotalOrderPassengers() const { int passengers = 0; for (std::vector::iterator itr = m_pCartList->GetItemList()->begin(); itr != m_pCartList->GetItemList()->end(); ++itr) { @@ -790,8 +702,6 @@ int BuyMenuGUI::GetTotalOrderPassengers() const { return passengers; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void BuyMenuGUI::EnableEquipmentSelection(bool enabled) { if (enabled != m_SelectingEquipment && g_SettingsMan.SmartBuyMenuNavigationEnabled()) { m_SelectingEquipment = enabled; @@ -816,8 +726,6 @@ void BuyMenuGUI::EnableEquipmentSelection(bool enabled) { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void BuyMenuGUI::UpdateItemNestingLevels() { const int ownedDeviceOffsetX = 8; @@ -835,8 +743,6 @@ void BuyMenuGUI::UpdateItemNestingLevels() { m_pCartList->BuildBitmap(false, true); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void BuyMenuGUI::RefreshTabDisabledStates() { bool smartBuyMenuNavigationDisabled = !g_SettingsMan.SmartBuyMenuNavigationEnabled(); m_pCategoryTabs[CRAFT]->SetEnabled(smartBuyMenuNavigationDisabled || !m_SelectingEquipment); @@ -849,13 +755,6 @@ void BuyMenuGUI::RefreshTabDisabledStates() { m_pCategoryTabs[SETS]->SetEnabled(smartBuyMenuNavigationDisabled || !m_SelectingEquipment); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -////////////////////////////////////////////////////////////////////////////////////////// -// Method: Update -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Updates the state of this Menu each frame - void BuyMenuGUI::Update() { // Enable mouse input if the controller allows it m_pGUIController->EnableMouse(m_pController->IsMouseControlled()); @@ -1900,8 +1799,6 @@ void BuyMenuGUI::Update() { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void BuyMenuGUI::Draw(BITMAP* drawBitmap) const { AllegroScreen drawScreen(drawBitmap); m_pGUIController->Draw(&drawScreen); @@ -1964,11 +1861,6 @@ void BuyMenuGUI::FocusChange() } */ -////////////////////////////////////////////////////////////////////////////////////////// -// Virtual Method: CategoryChange -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Makes sure all things that to happen when category is changed, happens. - void BuyMenuGUI::CategoryChange(bool focusOnCategoryTabs) { // Re-set the GUI manager's focus on the tabs if we're supposed to // We don't want to do that if we're just refreshing the same category, like in the case of of expanding a module group item @@ -2081,11 +1973,6 @@ void BuyMenuGUI::CategoryChange(bool focusOnCategoryTabs) { m_pShopList->ScrollToSelected(); } -////////////////////////////////////////////////////////////////////////////////////////// -// Virtual Method: SaveCurrentLoadout -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Saves the current loadout into a Set. - void BuyMenuGUI::SaveCurrentLoadout() { Loadout newSet; @@ -2109,11 +1996,6 @@ void BuyMenuGUI::SaveCurrentLoadout() { m_pSaveButton->SetFocus(); } -////////////////////////////////////////////////////////////////////////////////////////// -// Virtual Method: DeployLoadout -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Loads the loadout set into the cart, replacing whatever's there now. - bool BuyMenuGUI::DeployLoadout(int index) { if (index < 0 || index >= m_Loadouts.size()) return false; @@ -2196,8 +2078,6 @@ bool BuyMenuGUI::DeployLoadout(int index) { return true; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void BuyMenuGUI::AddObjectsToItemList(std::vector>& moduleList, const std::string& type, const std::vector& groups, bool excludeGroups) { while (moduleList.size() < g_PresetMan.GetTotalModuleCount()) { moduleList.emplace_back(); @@ -2291,11 +2171,6 @@ void BuyMenuGUI::AddObjectsToItemList(std::vector>& moduleLis } } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: AddPresetsToItemList -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Adds all loadout presets' representations to the item GUI list. - void BuyMenuGUI::AddPresetsToItemList() { GUIBitmap* pItemBitmap = 0; std::string loadoutLabel; @@ -2344,15 +2219,11 @@ void BuyMenuGUI::AddPresetsToItemList() { } } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void BuyMenuGUI::UpdateTotalCostLabel(int whichTeam) { std::string display = "Cost: " + RoundFloatToPrecision(GetTotalOrderCost(), 0, 2) + "/" + RoundFloatToPrecision(g_ActivityMan.GetActivity()->GetTeamFunds(whichTeam), 0); m_pCostLabel->SetText(display); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void BuyMenuGUI::UpdateTotalMassLabel(const ACraft* pCraft, GUILabel* pLabel) const { if (!pLabel) { return; @@ -2371,8 +2242,6 @@ void BuyMenuGUI::UpdateTotalMassLabel(const ACraft* pCraft, GUILabel* pLabel) co pLabel->SetText(display); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void BuyMenuGUI::UpdateTotalPassengersLabel(const ACraft* pCraft, GUILabel* pLabel) const { if (!pLabel) { return; @@ -2391,8 +2260,6 @@ void BuyMenuGUI::UpdateTotalPassengersLabel(const ACraft* pCraft, GUILabel* pLab pLabel->SetText(display); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void BuyMenuGUI::TryPurchase() { int player = m_pController->GetPlayer(); // Switch to the Craft category to give the user a hint diff --git a/Source/Menus/BuyMenuGUI.h b/Source/Menus/BuyMenuGUI.h index 626837d480..5b084e2834 100644 --- a/Source/Menus/BuyMenuGUI.h +++ b/Source/Menus/BuyMenuGUI.h @@ -1,19 +1,12 @@ #ifndef _BUYMENUGUI_ #define _BUYMENUGUI_ -////////////////////////////////////////////////////////////////////////////////////////// -// File: BuyMenuGUI.h -////////////////////////////////////////////////////////////////////////////////////////// -// Description: BuyMenuGUI class -// Project: GUI Library -// Author(s): Daniel Tabar -// dtabar@datarealms.com -// http://www.datarealms.com - -////////////////////////////////////////////////////////////////////////////////////////// -// Inclusions of header files - -//#include "FrameMan.h" +/// BuyMenuGUI class +/// @author Daniel Tabar +/// dtabar@datarealms.com +/// http://www.datarealms.com +/// Inclusions of header files +// #include "FrameMan.h" #include "Timer.h" #include "Controller.h" #include "Loadout.h" @@ -36,538 +29,277 @@ namespace RTE { class MovableObject; class ACraft; - ////////////////////////////////////////////////////////////////////////////////////////// - // Class: BuyMenuGUI - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: A full menu system that represents a purchasing GUI for Cortex Command - // Parent(s): None. - // Class history: 8/22/2006 BuyMenuGUI Created. - + /// A full menu system that represents a purchasing GUI for Cortex Command class BuyMenuGUI { - ////////////////////////////////////////////////////////////////////////////////////////// - // Public member variable, method and friend function declarations - + /// Public member variable, method and friend function declarations public: - ////////////////////////////////////////////////////////////////////////////////////////// - // Constructor: BuyMenuGUI - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Constructor method used to instantiate a BuyMenuGUI object in system - // memory. Create() should be called before using the object. - // Arguments: None. - + /// Constructor method used to instantiate a BuyMenuGUI object in system + /// memory. Create() should be called before using the object. BuyMenuGUI() { Clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Destructor: ~BuyMenuGUI - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destructor method used to clean up a BuyMenuGUI object before deletion - // from system memory. - // Arguments: None. - + /// Destructor method used to clean up a BuyMenuGUI object before deletion + /// from system memory. ~BuyMenuGUI() { Destroy(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes the BuyMenuGUI object ready for use. - // Arguments: A poitner to a Controller which will control this Menu. Ownership is - // NOT TRANSFERRED! - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Makes the BuyMenuGUI object ready for use. + /// @param pController A poitner to a Controller which will control this Menu. Ownership is + /// NOT TRANSFERRED! + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Create(Controller* pController); - ////////////////////////////////////////////////////////////////////////////////////////// - // method: Reset - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Resets the entire BuyMenuGUI, including its inherited members, to - // their default settings or values. - // Arguments: None. - // Return value: None. - + /// Resets the entire BuyMenuGUI, including its inherited members, to + /// their default settings or values. void Reset() { Clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destroys and resets (through Clear()) the BuyMenuGUI object. - // Arguments: None. - // Return value: None. - + /// Destroys and resets (through Clear()) the BuyMenuGUI object. void Destroy(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: LoadAllLoadoutsFromFile - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Loads or re-loads all the loadout presets from the appropriate files - // on disk. This will first clear out all current loadout presets! - // Arguments: None. - // Return value: Success or not. - + /// Loads or re-loads all the loadout presets from the appropriate files + /// on disk. This will first clear out all current loadout presets! + /// @return Success or not. bool LoadAllLoadoutsFromFile(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SaveAllLoadoutsToFile - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Saves all the loadouts to appropriate file on disk. Does NOT save - // any named presets which will be loaded from the standard preset - // loadouts first anyway. - // Arguments: None. - // Return value: Success or not. - + /// Saves all the loadouts to appropriate file on disk. Does NOT save + /// any named presets which will be loaded from the standard preset + /// loadouts first anyway. + /// @return Success or not. bool SaveAllLoadoutsToFile(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetController - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the controller used by this. The ownership of the controller is - // NOT transferred! - // Arguments: The new controller for this menu. Ownership is NOT transferred - // Return value: None. - + /// Sets the controller used by this. The ownership of the controller is + /// NOT transferred! + /// @param pController The new controller for this menu. Ownership is NOT transferred void SetController(Controller* pController) { m_pController = pController; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetEnabled - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Enables or disables the menu. This will animate it in and out of view. - // Arguments: Whether to enable or disable the menu. - // Return value: None. - + /// Enables or disables the menu. This will animate it in and out of view. + /// @param enable Whether to enable or disable the menu. (default: true) void SetEnabled(bool enable = true); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: IsEnabled - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Reports whether the menu is enabled or not. - // Arguments: None. - // Return value: None. - + /// Reports whether the menu is enabled or not. bool IsEnabled() const { return m_MenuEnabled == ENABLED || m_MenuEnabled == ENABLING; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: IsVisible - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Reports whether the menu is at all visible or not. - // Arguments: None. - // Return value: None. - + /// Reports whether the menu is at all visible or not. bool IsVisible() const { return m_MenuEnabled == ENABLED || m_MenuEnabled == ENABLING || m_MenuEnabled == DISABLING; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetPosOnScreen - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets where on the screen that this GUI is being drawn to. If upper - // left corner, then 0, 0. This will affect the way the mouse is positioned - // etc. - // Arguments: The new screen position of this entire GUI. - + /// Sets where on the screen that this GUI is being drawn to. If upper + /// left corner, then 0, 0. This will affect the way the mouse is positioned + /// etc. + /// @param newPosX The new screen position of this entire GUI. void SetPosOnScreen(int newPosX, int newPosY); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetMetaPlayer - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets which MetaPlayer uses this menu, if any. - // Arguments: The index of the MetaPlayer that uses this menu. - // Return value: None. - + /// Sets which MetaPlayer uses this menu, if any. + /// @param metaPlayer The index of the MetaPlayer that uses this menu. void SetMetaPlayer(int metaPlayer); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetMetaPlayer - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets which MetaPlayer uses this menu, if any. - // Arguments: None. - // Return value: Metaplayer who owns this buy menu - + /// Gets which MetaPlayer uses this menu, if any. + /// @return Metaplayer who owns this buy menu int GetMetaPlayer() const { return m_MetaPlayer; } - /// /// Sets which DataModule ID should be treated as the native tech of the user of this menu. /// This will also apply the DataModule's faction BuyMenu theme, if applicable. - /// - /// The module ID to set as the native one. 0 means everything is native. + /// @param whichModule The module ID to set as the native one. 0 means everything is native. void SetNativeTechModule(int whichModule); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetForeignCostMultiplier - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the multiplier of the cost of any foreign Tech items. - // Arguments: The scalar multiplier of the costs of foreign Tech items. - // Return value: None. - + /// Sets the multiplier of the cost of any foreign Tech items. + /// @param newMultiplier The scalar multiplier of the costs of foreign Tech items. void SetForeignCostMultiplier(float newMultiplier) { m_ForeignCostMult = newMultiplier; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetModuleExpanded - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets whether a data module shown in the item menu should be expanded - // or not. - // Arguments: The module ID to set as expanded. - // Whether should be expanded or not. - // Return value: None. - + /// Sets whether a data module shown in the item menu should be expanded + /// or not. + /// @param whichModule The module ID to set as expanded. + /// @param expanded Whether should be expanded or not. (default: true) void SetModuleExpanded(int whichModule, bool expanded = true); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: PurchaseMade - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Reports whether a purchase was made during the last Update. - // Arguments: None. - // Return value: Wheter the BUY button was pressed or not during the last update. - + /// Reports whether a purchase was made during the last Update. + /// @return Wheter the BUY button was pressed or not during the last update. bool PurchaseMade() const { return m_PurchaseMade; } - /// /// Gets the width of the current delivery craft. - /// - /// The width of the delivery craft, in pixels. + /// @return The width of the delivery craft, in pixels. int GetDeliveryWidth() const { return m_DeliveryWidth; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetOrderList - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Return the list of things currently in the purchase order list box. - // Arguments: A reference to a an empty list to fill with the Object:s ordered. - // Ownership of the Object:s is NOT TRANSFERRED! - // Return value: Whetehr any items were put in the list at all. false if there are no - // items in the order listbox. - + /// Return the list of things currently in the purchase order list box. + /// @param listToFill A reference to a an empty list to fill with the Object:s ordered. + /// Ownership of the Object:s is NOT TRANSFERRED! + /// @return Whetehr any items were put in the list at all. false if there are no + /// items in the order listbox. bool GetOrderList(std::list& listToFill) const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetLoadoutPresets - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Return the list of loadouts currently saved as presets. - // Arguments: None. - // Return value: A reference to the list of loadout presets. - + /// Return the list of loadouts currently saved as presets. + /// @return A reference to the list of loadout presets. std::vector& GetLoadoutPresets() { return m_Loadouts; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SaveCurrentLoadout - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Saves the current loadout into a Set. - // Arguments: None. - // Return value: None. - + /// Saves the current loadout into a Set. void SaveCurrentLoadout(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetDeliveryCraftPreset - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Return the intended delivery vehicle instance from the order. - // Arguments: None. - // Return value: The poiner to the specified delivery craft instance. Note that this is - // just PresetMan's const pointer, so ownership is NOT transferred! - + /// Return the intended delivery vehicle instance from the order. + /// @return The poiner to the specified delivery craft instance. Note that this is + /// just PresetMan's const pointer, so ownership is NOT transferred! const SceneObject* GetDeliveryCraftPreset() { return m_pSelectedCraft; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetTotalCost - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Return the total cost of everything listed in the order box. - // Arguments: Whether or not to include delivery cost. - // Return value: The total cost in ounces of gold. - + /// Return the total cost of everything listed in the order box. + /// @param includeDelivery Whether or not to include delivery cost. (default: true) + /// @return The total cost in ounces of gold. float GetTotalCost(bool includeDelivery = true) const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetTotalOrderCost - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Return the total cost of everything listed in the order box, including delivery costs. - // Arguments: None. - // Return value: The total cost in ounces of gold. - + /// Return the total cost of everything listed in the order box, including delivery costs. + /// @return The total cost in ounces of gold. float GetTotalOrderCost() const { return GetTotalCost(true); }; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetTotalCartCost - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Return the total cost of everything listed in the order box, excluding delivery costs. - // Arguments: None. - // Return value: The total cost in ounces of gold. - + /// Return the total cost of everything listed in the order box, excluding delivery costs. + /// @return The total cost in ounces of gold. float GetTotalCartCost() const { return GetTotalCost(false); } - /// /// Return the total mass of all items listed in the order box. - /// - /// The total mass (in kg) of the BuyMenu's cart. + /// @return The total mass (in kg) of the BuyMenu's cart. float GetTotalOrderMass() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetCraftMass - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Return mass of craft used in the order box. - // Arguments: None. - // Return value: The total mass in kg. - + /// Return mass of craft used in the order box. + /// @return The total mass in kg. float GetCraftMass(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetTotalOrderPassengers - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Return teh total number of passengers in the order box. - // Arguments: None. - // Return value: The total number of passengers. - + /// Return teh total number of passengers in the order box. + /// @return The total number of passengers. int GetTotalOrderPassengers() const; - /// /// Enable or disable the equipment selection mode for this BuyMenuGUI. - /// - /// Whether or not equipment selection mode should be enabled. + /// @param enabled Whether or not equipment selection mode should be enabled. void EnableEquipmentSelection(bool enabled); - /// /// Updates the nesting level for every item in the cart. - /// void UpdateItemNestingLevels(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Update - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the state of this Menu each frame - // Arguments: None. - // Return value: None. - + /// Updates the state of this Menu each frame void Update(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Draw - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws the menu - // Arguments: The bitmap to draw on. - // Return value: None. - + /// Draws the menu + /// @param drawBitmap The bitmap to draw on. void Draw(BITMAP* drawBitmap) const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: EnforceMaxPassengersConstraint - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Tells whether passenger count constraints are enforced by this buy menu. - // Arguments: None. - // Return value: True if passenger constraints are enforced by this menu, false otherwise - + /// Method: EnforceMaxPassengersConstraint + /// Tells whether passenger count constraints are enforced by this buy menu. + /// @return True if passenger constraints are enforced by this menu, false otherwise bool EnforceMaxPassengersConstraint() const { return m_EnforceMaxPassengersConstraint; }; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetEnforceMaxPassengersConstraint - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets whether passenger count constraints are enforced by this buy menu. - // Arguments: True to enforce passenger constraints by this menu, false otherwise - // Return value: None. - + /// Method: SetEnforceMaxPassengersConstraint + /// Sets whether passenger count constraints are enforced by this buy menu. + /// @param enforce True to enforce passenger constraints by this menu, false otherwise void SetEnforceMaxPassengersConstraint(bool enforce) { m_EnforceMaxPassengersConstraint = enforce; }; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: EnforceMaxMassConstraint - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets whether mass constraints are enforced by this buy menu. - // Arguments: True if mass constraints are enforced by this menu, false otherwise - // Return value: None. - + /// Method: EnforceMaxMassConstraint + /// Sets whether mass constraints are enforced by this buy menu. + /// @param True if mass constraints are enforced by this menu, false otherwise bool EnforceMaxMassConstraint() const { return m_EnforceMaxMassConstraint; }; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetEnforceMaxMassConstraint - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets whether mass constraints are enforced by this buy menu. - // Arguments: True to enforce mass constraints by this menu, false otherwise - // Return value: None. - + /// Method: SetEnforceMaxMassConstraint + /// Sets whether mass constraints are enforced by this buy menu. + /// @param enforce True to enforce mass constraints by this menu, false otherwise void SetEnforceMaxMassConstraint(bool enforce) { m_EnforceMaxMassConstraint = enforce; }; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: AddAllowedItem - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Adds an item to the list of allowed items. - // If the list is not empty then everything not in the list is removed from the buy menu - // Items will be removed from the buy menu when it's called, category changed or after a ForceRefresh(). - // Arguments: Full preset name to add. - // Return value: None. - + /// Method: AddAllowedItem + /// Adds an item to the list of allowed items. + /// If the list is not empty then everything not in the list is removed from the buy menu + /// Items will be removed from the buy menu when it's called, category changed or after a ForceRefresh(). + /// @param presetName Full preset name to add. void AddAllowedItem(std::string presetName) { m_AllowedItems[presetName] = true; }; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: RemoveAllowedItem - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Removes an item from the list of allowed items. - // Arguments: Full preset name to remove. - // Return value: None. - + /// Method: RemoveAllowedItem + /// Removes an item from the list of allowed items. + /// @param m_AllowedItems.erase(presetName Full preset name to remove. void RemoveAllowedItem(std::string presetName) { m_AllowedItems.erase(presetName); }; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ClearAllowedItems - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears the list of allowed items - // Arguments: None. - // Return value: None. - + /// Method: ClearAllowedItems + /// Clears the list of allowed items void ClearAllowedItems() { m_AllowedItems.clear(); }; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: IsAllowedItem - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns true if the item is in allowed list - // Arguments: Full preset name. - // Return value: None. - + /// Method: IsAllowedItem + /// Returns true if the item is in allowed list + /// @param ! Full preset name. (default: m_AllowedItems.end() bool IsAllowedItem(std::string presetName) { return m_AllowedItems.find(presetName) != m_AllowedItems.end(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: AddAlwaysAllowedItem - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Adds an item to the list of always allowed items. This list overrides all previous constraints. - // Arguments: Full preset name to add. - // Return value: None. - + /// Method: AddAlwaysAllowedItem + /// Adds an item to the list of always allowed items. This list overrides all previous constraints. + /// @param presetName Full preset name to add. void AddAlwaysAllowedItem(std::string presetName) { m_AlwaysAllowedItems[presetName] = true; }; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: RemoveAlwaysAllowedItem - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Removes an item from the list of always allowed items. - // Arguments: Full preset name to remove. - // Return value: None. - + /// Method: RemoveAlwaysAllowedItem + /// Removes an item from the list of always allowed items. + /// @param m_AlwaysAllowedItems.erase(presetName Full preset name to remove. void RemoveAlwaysAllowedItem(std::string presetName) { m_AlwaysAllowedItems.erase(presetName); }; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ClearAlwaysAllowedItems - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears the list of allowed items - // Arguments: None. - // Return value: None. - + /// Method: ClearAlwaysAllowedItems + /// Clears the list of allowed items void ClearAlwaysAllowedItems() { m_AlwaysAllowedItems.clear(); }; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: IsAlwaysAllowedItem - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns true if the item is in always allowed list - // Arguments: Full preset name. - // Return value: None. - + /// Method: IsAlwaysAllowedItem + /// Returns true if the item is in always allowed list + /// @param ! Full preset name. (default: m_AlwaysAllowedItems.end() bool IsAlwaysAllowedItem(std::string presetName) { return m_AlwaysAllowedItems.find(presetName) != m_AlwaysAllowedItems.end(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: AddProhibitedItem - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Adds an item prohibited to buy from the buy menu. - // The item will be removed from the buy menu when it's called, category changed or after a ForceRefresh(). - // Arguments: Full preset name to add. - // Return value: None. - + /// Method: AddProhibitedItem + /// Adds an item prohibited to buy from the buy menu. + /// The item will be removed from the buy menu when it's called, category changed or after a ForceRefresh(). + /// @param presetName Full preset name to add. void AddProhibitedItem(std::string presetName) { m_ProhibitedItems[presetName] = true; }; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: RemoveProhibitedItem - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Removes item from the list of prohibited items - // Arguments: Full preset name to remove. - // Return value: None. - + /// Method: RemoveProhibitedItem + /// Removes item from the list of prohibited items + /// @param m_ProhibitedItems.erase(presetName Full preset name to remove. void RemoveProhibitedItem(std::string presetName) { m_ProhibitedItems.erase(presetName); }; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ClearProhibitedItems - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears the list of prohibited items - // Arguments: None. - // Return value: None. - + /// Method: ClearProhibitedItems + /// Clears the list of prohibited items void ClearProhibitedItems() { m_ProhibitedItems.clear(); }; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: IsProhibitedItem - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns true if the item is in prohibited list - // Arguments: Full preset name. - // Return value: None. - + /// Method: IsProhibitedItem + /// Returns true if the item is in prohibited list + /// @param ! Full preset name. (default: m_ProhibitedItems.end() bool IsProhibitedItem(std::string presetName) { return m_ProhibitedItems.find(presetName) != m_ProhibitedItems.end(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ForceRefresh - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Forces a refresh update of the list of buy menu items - // Arguments: None. - // Return value: None. - + /// Method: ForceRefresh + /// Forces a refresh update of the list of buy menu items void ForceRefresh() { CategoryChange(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ClearCartList - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clear the cart out of items selected for purchase - // Arguments: None. - // Return value: None. - + /// Method: ClearCartList + /// Clear the cart out of items selected for purchase void ClearCartList(); - /// /// Adds an item to the cart. - /// - /// The name shown for the item. - /// The text that is shown right-aligned on the item (typically the cost of the item). - /// The sprite image rendered for the item. This takes ownership! - /// The entity that this item refers to and will create when bought. - /// Extra index for special indexing or reference that the item is associated with. Menu-specific. + /// @param name The name shown for the item. + /// @param rightText The text that is shown right-aligned on the item (typically the cost of the item). + /// @param pBitmap The sprite image rendered for the item. This takes ownership! + /// @param pEntity The entity that this item refers to and will create when bought. + /// @param extraIndex Extra index for special indexing or reference that the item is associated with. Menu-specific. void AddCartItem(const std::string& name, const std::string& rightText = "", GUIBitmap* pBitmap = nullptr, const Entity* pEntity = 0, const int extraIndex = -1); - /// /// Duplicates an item in the cart. - /// - /// The index of the item to duplicate. + /// @param itemIndex The index of the item to duplicate. void DuplicateCartItem(const int itemIndex); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: LoadDefaultLoadoutToCart - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Loads the default loadout to the cart - // Arguments: None. - // Return value: None. - + /// Method: LoadDefaultLoadoutToCart + /// Loads the default loadout to the cart void LoadDefaultLoadoutToCart() { DeployLoadout(0); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetOnlyShowOwnedItems - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: If set to true only owned items will be shown in buy menu. Overriden by AlwaysAllowed list. - // Arguments: Value. - // Return value: None. - + /// Method: SetOnlyShowOwnedItems + /// If set to true only owned items will be shown in buy menu. Overriden by AlwaysAllowed list. + /// @param value Value. void SetOnlyShowOwnedItems(bool value) { m_OnlyShowOwnedItems = value; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetOnlyShowOwnedItems - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns whether only owned items will be shown in buy menu. Overriden by AlwaysAllowed list. - // Arguments: None. - // Return value: Whether only owned items will be shown in buy menu. - + /// Method: GetOnlyShowOwnedItems + /// Returns whether only owned items will be shown in buy menu. Overriden by AlwaysAllowed list. + /// @return Whether only owned items will be shown in buy menu. bool GetOnlyShowOwnedItems() const { return m_OnlyShowOwnedItems; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetOwnedItemsAmount - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the amount of specified items to be owned in this buy menu - // Arguments: Full preset name of item to own. Amount of owned items. - // Return value: None. - + /// Method: SetOwnedItemsAmount + /// Sets the amount of specified items to be owned in this buy menu + /// @param presetName Full preset name of item to own. Amount of owned items. void SetOwnedItemsAmount(std::string presetName, int amount) { m_OwnedItems[presetName] = amount; }; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetOwnedItemsAmount - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns the amount of specified items owned in this buy menu - // Arguments: Full preset name of item. - // Return value: Amount of owned items. - + /// Method: GetOwnedItemsAmount + /// Returns the amount of specified items owned in this buy menu + /// @param presetName Full preset name of item. + /// @return Amount of owned items. int GetOwnedItemsAmount(std::string presetName) { if (m_OwnedItems.find(presetName) != m_OwnedItems.end()) return m_OwnedItems[presetName]; @@ -575,106 +307,59 @@ namespace RTE { return 0; }; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: CommitPurchase - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Deducts 1 piece of owned item and return true if purchase can be made or false if the item is out of stock. - // Arguments: Full preset name of item. - // Return value: Whether the purchase can be conducted or the item is out of stock. - + /// Method: CommitPurchase + /// Deducts 1 piece of owned item and return true if purchase can be made or false if the item is out of stock. + /// @param presetName Full preset name of item. + /// @return Whether the purchase can be conducted or the item is out of stock. bool CommitPurchase(std::string presetName); #pragma region Faction Theme Handling - /// /// Changes the banner image to the one specified. If none is specified, resets it to the default banner image. - /// - /// Path to image to set as banner. + /// @param imagePath Path to image to set as banner. void SetBannerImage(const std::string& imagePath); - /// /// Changes the logo image to the one specified. If none is specified, resets it to the default logo image. - /// - /// Path to image to set as logo. + /// @param imagePath Path to image to set as logo. void SetLogoImage(const std::string& imagePath); #pragma endregion - ////////////////////////////////////////////////////////////////////////////////////////// - // Protected member variable and method declarations - + /// Protected member variable and method declarations protected: - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: CategoryChange - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes sure all things that to happen when category is changed, happens. - // Arguments: Wheter to change focus to the category tabs or not. - // Return value: None. - + /// Makes sure all things that to happen when category is changed, happens. + /// @param focusOnCategoryTabs Wheter to change focus to the category tabs or not. (default: true) void CategoryChange(bool focusOnCategoryTabs = true); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: DeployLoadout - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Loads the loadout set into the cart, replacing whatever's there now. - // Arguments: The index of the loadout to load. - // Return value: Whether it was loaded successfully or not. - + /// Loads the loadout set into the cart, replacing whatever's there now. + /// @param index The index of the loadout to load. + /// @return Whether it was loaded successfully or not. bool DeployLoadout(int index); - /// /// Adds all objects of a specific type already defined in PresetMan to the current shop/item list. They will be grouped into the different data modules they were read from. - /// - /// Reference to the data module vector of entity lists to add the items to. - /// The name of the class to add all objects of. "" or "All" looks for all. - /// The name of the groups to add all objects of. An empty vector or "All" looks for all. - /// Whether the specified groups should be excluded, meaning all objects NOT associated with the groups will be added. + /// @param moduleList Reference to the data module vector of entity lists to add the items to. + /// @param type The name of the class to add all objects of. "" or "All" looks for all. + /// @param groups The name of the groups to add all objects of. An empty vector or "All" looks for all. + /// @param excludeGroups Whether the specified groups should be excluded, meaning all objects NOT associated with the groups will be added. void AddObjectsToItemList(std::vector>& moduleList, const std::string& type = "", const std::vector& groups = {}, bool excludeGroups = false); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: AddPresetsToItemList - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Adds all loadout presets' representations to the item GUI list. - // Arguments: None. - // Return value: None. - + /// Adds all loadout presets' representations to the item GUI list. void AddPresetsToItemList(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: UpdateTotalCostLabel - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the text of the total cost label to reflect the total cost of - // all the items in teh order box. - // Arguments: The team to display the total funds of. - // Return value: None. - + /// Updates the text of the total cost label to reflect the total cost of + /// all the items in teh order box. + /// @param whichTeam The team to display the total funds of. (default: 0) void UpdateTotalCostLabel(int whichTeam = 0); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: UpdateTotalMassLabel - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the text of the specified label to reflect the total mass of - // all the items in the order box. - // Arguments: Craft to read MaxMass from. Label to update. - // Return value: None. - + /// Updates the text of the specified label to reflect the total mass of + /// all the items in the order box. + /// @param pCraft Craft to read MaxMass from. Label to update. void UpdateTotalMassLabel(const ACraft* pCraft, GUILabel* pLabel) const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: UpdateTotalPassengersLabel - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the text of the specified label to reflect the total passenger count of - // all the items in teh order box. - // Arguments: Craft to read MaxPassengers from. Label to update. - // Return value: None. - + /// Updates the text of the specified label to reflect the total passenger count of + /// all the items in teh order box. + /// @param pCraft Craft to read MaxPassengers from. Label to update. void UpdateTotalPassengersLabel(const ACraft* pCraft, GUILabel* pLabel) const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: TryPurchase - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Attempts to make a purchase with everything already set up. - // Arguments: None. - // Return value: None. - + /// Attempts to make a purchase with everything already set up. void TryPurchase(); enum MenuEnabled { @@ -845,26 +530,16 @@ namespace RTE { // A map of owned items, for which the gold will not be deducted when bought std::map m_OwnedItems; - ////////////////////////////////////////////////////////////////////////////////////////// - // Private member variable and method declarations - + /// Private member variable and method declarations private: static const std::string c_DefaultBannerImagePath; //!< Path to the default banner image. static const std::string c_DefaultLogoImagePath; //!< Path to the default logo image. - /// /// Refresh tab disabled states, so tabs get properly enabled/disabled based on whether or not equipment selection mode is enabled. - /// void RefreshTabDisabledStates(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Clear - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears all the member variables of this BuyMenuGUI, effectively - // resetting the members of this abstraction level only. - // Arguments: None. - // Return value: None. - + /// Clears all the member variables of this BuyMenuGUI, effectively + /// resetting the members of this abstraction level only. void Clear(); // Disallow the use of some implicit methods. diff --git a/Source/Menus/GibEditorGUI.cpp b/Source/Menus/GibEditorGUI.cpp index 89a9c464e1..d149b38b2d 100644 --- a/Source/Menus/GibEditorGUI.cpp +++ b/Source/Menus/GibEditorGUI.cpp @@ -1,15 +1,3 @@ -////////////////////////////////////////////////////////////////////////////////////////// -// File: GibEditorGUI.cpp -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Implementation file for the GibEditorGUI class -// Project: GUI Library -// Author(s): Daniel Tabar -// dtabar@datarealms.com -// http://www.datarealms.com - -////////////////////////////////////////////////////////////////////////////////////////// -// Inclusions of header files - #include "GibEditorGUI.h" #include "CameraMan.h" @@ -32,12 +20,6 @@ using namespace RTE; #define MAXZOOMFACTOR 5 #define MINZOOMFACTOR 1 -////////////////////////////////////////////////////////////////////////////////////////// -// Method: Clear -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Clears all the member variables of this GibEditorGUI, effectively -// resetting the members of this abstraction level only. - void GibEditorGUI::Clear() { m_pController = 0; m_EditMade = false; @@ -64,11 +46,6 @@ void GibEditorGUI::Clear() { m_pObjectToBlink = 0; } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: Create -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Makes the GibEditorGUI object ready for use. - int GibEditorGUI::Create(Controller* pController, int whichModuleSpace) { RTEAssert(pController, "No controller sent to GibEditorGUI on creation!"); m_pController = pController; @@ -104,11 +81,6 @@ int GibEditorGUI::Create(Controller* pController, int whichModuleSpace) { return 0; } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: Destroy -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Destroys and resets (through Clear()) the GibEditorGUI object. - void GibEditorGUI::Destroy() { delete m_pPicker; @@ -122,53 +94,24 @@ void GibEditorGUI::Destroy() { Clear(); } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: SetController -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Sets the controller used by this. The ownership of the controller is -// NOT transferred! - void GibEditorGUI::SetController(Controller* pController) { m_pController = pController; m_PieMenu->SetMenuController(pController); m_pPicker->SetController(pController); } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: SetPosOnScreen -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Sets where on the screen that this GUI is being drawn to. If upper -// left corner, then 0, 0. This will affect the way the mouse is positioned -// etc. - void GibEditorGUI::SetPosOnScreen(int newPosX, int newPosY) { m_pPicker->SetPosOnScreen(newPosX, newPosY); } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: GetActivatedPieSlice -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Gets any Pie menu slice command activated last update. - PieSlice::SliceType GibEditorGUI::GetActivatedPieSlice() const { return m_PieMenu->GetPieCommand(); } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: SetModuleSpace -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Sets which DataModule space to be picking objects from. If -1, then -// let the player pick from all loaded modules. - void GibEditorGUI::SetModuleSpace(int moduleSpaceID) { m_pPicker->SetModuleSpace(moduleSpaceID); } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: Update -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Updates the state of this Menu each frame - void GibEditorGUI::Update() { // Update the user controller // m_pController->Update(); @@ -632,11 +575,6 @@ void GibEditorGUI::Update() { } } -////////////////////////////////////////////////////////////////////////////////////////// -// Virtual Method: Draw -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Draws the menu - void GibEditorGUI::Draw(BITMAP* pTargetBitmap, const Vector& targetPos) const { // Done, so don't draw the UI if (m_EditorGUIMode == DONEEDITING) @@ -729,11 +667,6 @@ void GibEditorGUI::Draw(BITMAP* pTargetBitmap, const Vector& targetPos) const { m_PieMenu->Draw(pTargetBitmap, targetPos); } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: AddPlacedObject -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Adds a MovableObject to be placed in this scene. Ownership IS transferred! - void GibEditorGUI::AddPlacedObject(MovableObject* pObjectToAdd, int listOrder) { if (!pObjectToAdd) return; @@ -751,11 +684,6 @@ void GibEditorGUI::AddPlacedObject(MovableObject* pObjectToAdd, int listOrder) { } } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: RemovePlacedObject -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Removes a MovableObject placed in this scene. - void GibEditorGUI::RemovePlacedObject(int whichToRemove) { if (m_PlacedGibs.empty()) return; @@ -774,12 +702,6 @@ void GibEditorGUI::RemovePlacedObject(int whichToRemove) { } } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: PickPlacedObject -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Returns the last placed object that graphically overlaps an absolute -// point in the scene. - const MovableObject* GibEditorGUI::PickPlacedObject(Vector& scenePoint, int* pListOrderPlace) const { // REVERSE! int i = m_PlacedGibs.size() - 1; @@ -796,12 +718,6 @@ const MovableObject* GibEditorGUI::PickPlacedObject(Vector& scenePoint, int* pLi return 0; } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: UpdatePlacedObjects -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Updated the objects in the placed scene objects list of this. This is -// mostly for the editor to represent the items correctly. - void GibEditorGUI::UpdatePlacedObjects() { for (std::list::iterator itr = m_PlacedGibs.begin(); itr != m_PlacedGibs.end(); ++itr) { (*itr)->Update(); diff --git a/Source/Menus/GibEditorGUI.h b/Source/Menus/GibEditorGUI.h index 2727042c47..46478ed484 100644 --- a/Source/Menus/GibEditorGUI.h +++ b/Source/Menus/GibEditorGUI.h @@ -1,19 +1,12 @@ #ifndef _GIBEDITORGUI_ #define _GIBEDITORGUI_ -////////////////////////////////////////////////////////////////////////////////////////// -// File: GibEditorGUI.h -////////////////////////////////////////////////////////////////////////////////////////// -// Description: GibEditorGUI class -// Project: GUI Library -// Author(s): Daniel Tabar -// dtabar@datarealms.com -// http://www.datarealms.com - -////////////////////////////////////////////////////////////////////////////////////////// -// Inclusions of header files - -//#include "FrameMan.h" +/// GibEditorGUI class +/// @author Daniel Tabar +/// dtabar@datarealms.com +/// http://www.datarealms.com +/// Inclusions of header files +// #include "FrameMan.h" #include "Timer.h" #include "Vector.h" #include "Controller.h" @@ -28,18 +21,10 @@ namespace RTE { class ObjectPickerGUI; class PieMenu; - ////////////////////////////////////////////////////////////////////////////////////////// - // Class: GibEditorGUI - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: A placement part of the gib editor which manages the pie menu and picker. - // Parent(s): None. - // Class history: 9/16/2007 GibEditorGUI Created. - + /// A placement part of the gib editor which manages the pie menu and picker. class GibEditorGUI { - ////////////////////////////////////////////////////////////////////////////////////////// - // Public member variable, method and friend function declarations - + /// Public member variable, method and friend function declarations public: // Different modes of this editor enum EditorGUIMode { @@ -56,239 +41,121 @@ namespace RTE { EDITORGUIMODECOUNT }; - ////////////////////////////////////////////////////////////////////////////////////////// - // Constructor: GibEditorGUI - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Constructor method used to instantiate a GibEditorGUI object in system - // memory. Create() should be called before using the object. - // Arguments: None. - + /// Constructor method used to instantiate a GibEditorGUI object in system + /// memory. Create() should be called before using the object. GibEditorGUI() { Clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Destructor: ~GibEditorGUI - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destructor method used to clean up a GibEditorGUI object before deletion - // from system memory. - // Arguments: None. - + /// Destructor method used to clean up a GibEditorGUI object before deletion + /// from system memory. ~GibEditorGUI() { Destroy(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes the GibEditorGUI object ready for use. - // Arguments: A poitner to a Controller which will control this Menu. Ownership is - // NOT TRANSFERRED! - // Which module space that this eidtor will be able to pick objects from. - // -1 means all modules. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Makes the GibEditorGUI object ready for use. + /// @param pController A poitner to a Controller which will control this Menu. Ownership is + /// @param whichModuleSpace NOT TRANSFERRED! (default: -1) + /// Which module space that this eidtor will be able to pick objects from. + /// -1 means all modules. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Create(Controller* pController, int whichModuleSpace = -1); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Reset - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Resets the entire GibEditorGUI, including its inherited members, to - // their default settings or values. - // Arguments: None. - // Return value: None. - + /// Resets the entire GibEditorGUI, including its inherited members, to + /// their default settings or values. void Reset() { Clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destroys and resets (through Clear()) the GibEditorGUI object. - // Arguments: None. - // Return value: None. - + /// Destroys and resets (through Clear()) the GibEditorGUI object. void Destroy(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetController - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the controller used by this. The ownership of the controller is - // NOT transferred! - // Arguments: The new controller for this menu. Ownership is NOT transferred - // Return value: None. - + /// Sets the controller used by this. The ownership of the controller is + /// NOT transferred! + /// @param pController The new controller for this menu. Ownership is NOT transferred void SetController(Controller* pController); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetPosOnScreen - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets where on the screen that this GUI is being drawn to. If upper - // left corner, then 0, 0. This will affect the way the mouse is positioned - // etc. - // Arguments: The new screen position of this entire GUI. - + /// Sets where on the screen that this GUI is being drawn to. If upper + /// left corner, then 0, 0. This will affect the way the mouse is positioned + /// etc. + /// @param newPosX The new screen position of this entire GUI. void SetPosOnScreen(int newPosX, int newPosY); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetCursorPos - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the absolute scene coordinates of the cursor of this Editor. - // Arguments: The new cursor position in absolute scene units. - // Return value: None. - + /// Sets the absolute scene coordinates of the cursor of this Editor. + /// @param newCursorPos The new cursor position in absolute scene units. void SetCursorPos(const Vector& newCursorPos) { m_CursorPos = newCursorPos; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetCurrentGib - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the new Object to be held at the gib cursor of this Editor. Ownership - // IS transferred! - // Arguments: The new Object to be held by the cursor. Ownership IS transferred! - // Return value: None. - + /// Sets the new Object to be held at the gib cursor of this Editor. Ownership + /// IS transferred! + /// @param pNewGibObject The new Object to be held by the cursor. Ownership IS transferred! void SetCurrentGib(MovableObject* pNewGibObject) { m_pCurrentGib = pNewGibObject; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetActivatedPieSlice - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets any Pie menu slice command activated last update. - // Arguments: None. - // Return value: The enum'd int of any slice activated. See the PieSlice::SliceType enum. - + /// Gets any Pie menu slice command activated last update. + /// @return The enum'd int of any slice activated. See the PieSlice::SliceType enum. PieSlice::SliceType GetActivatedPieSlice() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetPlacedGibs - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the list of already placed gibs of the currently edited object. - // Ownership of neither list not objects IS NOT transferred! - // Arguments: None. - // Return value: The current list of placed gibs. OWNERSHIP IS NOT TRANSFERRED! - + /// Gets the list of already placed gibs of the currently edited object. + /// Ownership of neither list not objects IS NOT transferred! + /// @return The current list of placed gibs. OWNERSHIP IS NOT TRANSFERRED! std::list* GetPlacedGibs() { return &m_PlacedGibs; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetCurrentGib - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the currently held Object in the cursor of this Editor. Ownership - // IS NOT transferred! - // Arguments: None. - // Return value: The currently held object, if any. OWNERSHIP IS NOT TRANSFERRED! - + /// Gets the currently held Object in the cursor of this Editor. Ownership + /// IS NOT transferred! + /// @return The currently held object, if any. OWNERSHIP IS NOT TRANSFERRED! const MovableObject* GetCurrentGib() { return m_pCurrentGib; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetObjectToLoad - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns a refernece instance of an object if it has been picked to be - // loaded into the editor. Ownership is NOT transferred. - // Arguments: None. - // Return value: Reference instance of the picked object to be loaded. 0 if nothing. OWNERSHIP IS NOT TRANSFERRED! - // was picked since last update. - + /// Returns a refernece instance of an object if it has been picked to be + /// loaded into the editor. Ownership is NOT transferred. + /// @return Reference instance of the picked object to be loaded. 0 if nothing. OWNERSHIP IS NOT TRANSFERRED! + /// was picked since last update. const MOSRotating* GetObjectToLoad() { return m_pObjectToLoad; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetEditorMode - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the current mode of this editor. - // Arguments: The new mode to set to, see the EditorGUIMode enum. - // Return value: None. - + /// Sets the current mode of this editor. + /// @param newMode The new mode to set to, see the EditorGUIMode enum. void SetEditorGUIMode(EditorGUIMode newMode) { m_EditorGUIMode = newMode; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetEditorMode - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the current mode of this editor. - // Arguments: None. - // Return value: The current mode this is set to; see the EditorGUIMode enum. - + /// Gets the current mode of this editor. + /// @return The current mode this is set to; see the EditorGUIMode enum. EditorGUIMode GetEditorGUIMode() const { return m_EditorGUIMode; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetModuleSpace - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets which DataModule space to be picking objects from. If -1, then - // let the player pick from all loaded modules. - // Arguments: The ID of the module to let the player pick objects from. All official - // modules' objects will alwayws be presented, in addition to the one - // passed in here. - // Return value: None. - + /// Sets which DataModule space to be picking objects from. If -1, then + /// let the player pick from all loaded modules. + /// @param moduleSpaceID The ID of the module to let the player pick objects from. All official (default: -1) + /// modules' objects will alwayws be presented, in addition to the one + /// passed in here. void SetModuleSpace(int moduleSpaceID = -1); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: EditMade - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Shows whether an edit on the scene was made in the last Update. - // Arguments: None. - // Return value: Whether any edit was made. - + /// Shows whether an edit on the scene was made in the last Update. + /// @return Whether any edit was made. bool EditMade() const { return m_EditMade; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Update - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the state of this Menu each frame - // Arguments: None. - // Return value: None. - + /// Updates the state of this Menu each frame void Update(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Draw - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws the editor - // Arguments: The bitmap to draw on. - // The absolute position of the target bitmap's upper left corner in the scene. - // Return value: None. - + /// Draws the editor + /// @param pTargetBitmap The bitmap to draw on. + /// @param targetPos The absolute position of the target bitmap's upper left corner in the scene. (default: Vector()) void Draw(BITMAP* pTargetBitmap, const Vector& targetPos = Vector()) const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Protected member variable and method declarations - + /// Protected member variable and method declarations protected: - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: AddPlacedObject - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Adds a MovableObject to be placed in the editor. Ownership IS transferred! - // Arguments: The MovableOjbect instace to add, OIT! - // Where in the list the object should be inserted. -1 means at the end - // of the list. - // Return value: None. - + /// Adds a MovableObject to be placed in the editor. Ownership IS transferred! + /// @param pObjectToAdd The MovableOjbect instace to add, OIT! + /// @param listOrder Where in the list the object should be inserted. -1 means at the end (default: -1) + /// of the list. void AddPlacedObject(MovableObject* pObjectToAdd, int listOrder = -1); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: RemovePlacedObject - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Removes a MovableObject placed in this editor. - // Arguments: The list order number of the object to remove. If -1, the last one is removed. - // Return value: None. - + /// Removes a MovableObject placed in this editor. + /// @param whichToRemove The list order number of the object to remove. If -1, the last one is removed. (default: -1) void RemovePlacedObject(int whichToRemove = -1); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: PickPlacedObject - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Returns the last placed object that graphically overlaps an absolute - // point in the scene. Note that the placed object don't really exist in - // the scene, but in the editor. Their own Pos's are used. - // Arguments: The point in absolute scene coordinates that will be used to pick the - // last placed MovableObject which overlaps it. - // An int which will be filled out with the order place of any found object - // in the list. if nothing is found, it will get a value of -1. - // Return value: The last hit MovableObject, if any. Ownership is NOT transferred! - + /// Returns the last placed object that graphically overlaps an absolute + /// point in the scene. Note that the placed object don't really exist in + /// the scene, but in the editor. Their own Pos's are used. + /// @param scenePoint The point in absolute scene coordinates that will be used to pick the + /// last placed MovableObject which overlaps it. + /// @param pListOrderPlace An int which will be filled out with the order place of any found object (default: 0) + /// in the list. if nothing is found, it will get a value of -1. + /// @return The last hit MovableObject, if any. Ownership is NOT transferred! const MovableObject* PickPlacedObject(Vector& scenePoint, int* pListOrderPlace = 0) const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: UpdatePlacedObjects - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updated the objects in the placed scene objects list of this. This is - // mostly for the editor to represent the items correctly. - // Arguments: None. - // Return value: None. - + /// Updated the objects in the placed scene objects list of this. This is + /// mostly for the editor to represent the items correctly. void UpdatePlacedObjects(); enum BlinkMode { @@ -347,18 +214,10 @@ namespace RTE { // Currently placed scene object to make blink when drawing it. NOT OWNED. const MovableObject* m_pObjectToBlink; - ////////////////////////////////////////////////////////////////////////////////////////// - // Private member variable and method declarations - + /// Private member variable and method declarations private: - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Clear - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears all the member variables of this GibEditorGUI, effectively - // resetting the members of this abstraction level only. - // Arguments: None. - // Return value: None. - + /// Clears all the member variables of this GibEditorGUI, effectively + /// resetting the members of this abstraction level only. void Clear(); // Disallow the use of some implicit methods. diff --git a/Source/Menus/InventoryMenuGUI.cpp b/Source/Menus/InventoryMenuGUI.cpp index 1021e0ca54..59d16abdc6 100644 --- a/Source/Menus/InventoryMenuGUI.cpp +++ b/Source/Menus/InventoryMenuGUI.cpp @@ -30,8 +30,6 @@ namespace RTE { BITMAP* InventoryMenuGUI::s_CursorBitmap = nullptr; - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void InventoryMenuGUI::CarouselItemBox::GetIconsAndMass(std::vector& itemIcons, float& totalItemMass, const std::vector>* equippedItems) const { if (IsForEquippedItems) { itemIcons.reserve(equippedItems->size()); @@ -51,8 +49,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void InventoryMenuGUI::Clear() { m_SmallFont = nullptr; m_LargeFont = nullptr; @@ -123,8 +119,6 @@ namespace RTE { m_GUIInventoryItemsScrollbar = nullptr; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int InventoryMenuGUI::Create(Controller* activityPlayerController, Actor* inventoryActor, MenuMode menuMode) { RTEAssert(activityPlayerController, "No controller sent to InventoryMenuGUI on creation!"); RTEAssert(c_ItemsPerRow % 2 == 1, "Don't you dare use an even number of items per inventory row, you filthy animal!"); @@ -148,7 +142,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void InventoryMenuGUI::Destroy() { destroy_bitmap(m_CarouselBitmap.release()); @@ -157,8 +150,6 @@ namespace RTE { Clear(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int InventoryMenuGUI::SetupCarouselMode() { for (std::unique_ptr& carouselItemBox: m_CarouselItemBoxes) { carouselItemBox = std::make_unique(); @@ -192,8 +183,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int InventoryMenuGUI::SetupFullOrTransferMode() { if (!m_GUIControlManager) { m_GUIControlManager = std::make_unique(); @@ -275,8 +264,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void InventoryMenuGUI::SetInventoryActor(Actor* newInventoryActor) { m_InventoryActor = newInventoryActor; if (m_InventoryActor) { @@ -288,8 +275,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void InventoryMenuGUI::SetEnabled(bool enable) { if (!m_MenuController || !m_InventoryActor) { return; @@ -317,16 +302,12 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool InventoryMenuGUI::EnableIfNotEmpty() { bool shouldEnable = !m_InventoryActorEquippedItems.empty() || (m_InventoryActor && !m_InventoryActor->IsInventoryEmpty()); SetEnabled(shouldEnable); return shouldEnable; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void InventoryMenuGUI::ClearSelectedItem() { if (m_GUISelectedItem) { m_GUISelectedItem->Button->OnLoseFocus(); @@ -334,8 +315,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void InventoryMenuGUI::SetSelectedItem(GUIButton* selectedItemButton, MovableObject* selectedItemObject, int inventoryIndex, int equippedItemIndex, bool isBeingDragged) { if (!selectedItemButton || !selectedItemObject || (inventoryIndex < 0 && equippedItemIndex < 0)) { ClearSelectedItem(); @@ -352,8 +331,6 @@ namespace RTE { m_GUISelectedItem->DragHoldCount = 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void InventoryMenuGUI::Update() { if (IsEnabled() && (!m_MenuController || !m_InventoryActor || !g_MovableMan.ValidMO(m_InventoryActor))) { SetEnabled(false); @@ -402,8 +379,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void InventoryMenuGUI::Draw(BITMAP* targetBitmap, const Vector& targetPos) const { Vector drawPos = m_CenterPos - targetPos; @@ -429,8 +404,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void InventoryMenuGUI::UpdateCarouselMode() { if (!CarouselModeReadyForUse()) { SetupCarouselMode(); @@ -488,8 +461,6 @@ namespace RTE { UpdateCarouselItemBoxSizesAndPositions(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void InventoryMenuGUI::UpdateCarouselItemBoxSizesAndPositions() { float halfMassFontHeight = static_cast(m_SmallFont->GetFontHeight() / 2); int carouselIndex = 0; @@ -546,8 +517,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void InventoryMenuGUI::UpdateFullMode() { if (!FullOrTransferModeReadyForUse()) { SetupFullOrTransferMode(); @@ -619,8 +588,6 @@ namespace RTE { UpdateFullModeNonItemButtonIconsAndHighlightWidths(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void InventoryMenuGUI::UpdateFullModeEquippedItemButtons() { const MovableObject* equippedItem = m_GUIInventoryActorCurrentEquipmentSetIndex < m_InventoryActorEquippedItems.size() ? m_InventoryActorEquippedItems.at(m_GUIInventoryActorCurrentEquipmentSetIndex).first : nullptr; const MovableObject* offhandEquippedItem = m_GUIInventoryActorCurrentEquipmentSetIndex < m_InventoryActorEquippedItems.size() ? m_InventoryActorEquippedItems.at(m_GUIInventoryActorCurrentEquipmentSetIndex).second : nullptr; @@ -655,8 +622,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void InventoryMenuGUI::UpdateFullModeScrollbar(const std::deque* inventory) { if (inventory->size() > c_FullViewPageItemLimit) { m_GUIInventoryItemsScrollbar->SetMaximum(static_cast(std::ceil(static_cast(inventory->size() - c_FullViewPageItemLimit) / static_cast(c_ItemsPerRow))) + 1); @@ -684,8 +649,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void InventoryMenuGUI::UpdateFullModeInventoryItemButtons(const std::deque* inventory) { int startIndex = m_GUIInventoryItemsScrollbar->GetValue() * c_ItemsPerRow; int lastPopulatedIndex = static_cast(inventory->size() - 1); @@ -715,8 +678,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void InventoryMenuGUI::UpdateFullModeInformationText(const std::deque* inventory) { if (!m_GUIShowInformationText && m_GUIInformationText->GetVisible()) { m_GUIInformationText->SetVisible(false); @@ -750,8 +711,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void InventoryMenuGUI::UpdateFullModeNonItemButtonIconsAndHighlightWidths() { std::vector> buttonsToCheckIconsFor = { {m_GUIInformationToggleButton, m_GUIInformationToggleButtonIcon}, @@ -777,14 +736,10 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void InventoryMenuGUI::UpdateTransferMode() { // TODO Make Transfer mode } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void InventoryMenuGUI::HandleInput() { if (m_MenuController->IsState(ControlState::PRESS_SECONDARY)) { SetEnabled(false); @@ -842,8 +797,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool InventoryMenuGUI::HandleMouseInput() { int mouseX; int mouseY; @@ -968,8 +921,6 @@ namespace RTE { return false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void InventoryMenuGUI::HandleNonMouseInput() { if (!m_NonMouseHighlightedButton || !m_NonMouseHighlightedButton->GetVisible() || (!m_GUIShowEmptyRows && m_NonMouseHighlightedButton->GetParent() == m_GUIInventoryItemsBox && m_InventoryActor->IsInventoryEmpty())) { m_NonMouseHighlightedButton = m_GUIEquippedItemButton; @@ -1022,8 +973,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - Directions InventoryMenuGUI::GetNonMouseButtonControllerMovement() { bool pressUp = m_MenuController->IsState(ControlState::PRESS_UP) || m_MenuController->IsState(ControlState::SCROLL_UP); bool pressDown = m_MenuController->IsState(ControlState::PRESS_DOWN) || m_MenuController->IsState(ControlState::SCROLL_DOWN); @@ -1057,8 +1006,6 @@ namespace RTE { return Directions::None; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIButton* InventoryMenuGUI::HandleNonMouseUpInput() { GUIButton* nextButtonToHighlight = nullptr; @@ -1092,8 +1039,6 @@ namespace RTE { return nextButtonToHighlight; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIButton* InventoryMenuGUI::HandleNonMouseDownInput() { GUIButton* nextButtonToHighlight = nullptr; @@ -1131,8 +1076,6 @@ namespace RTE { return nextButtonToHighlight; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIButton* InventoryMenuGUI::HandleNonMouseLeftInput() { GUIButton* nextButtonToHighlight = nullptr; @@ -1164,8 +1107,6 @@ namespace RTE { return nextButtonToHighlight; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUIButton* InventoryMenuGUI::HandleNonMouseRightInput() { GUIButton* nextButtonToHighlight = nullptr; @@ -1204,8 +1145,6 @@ namespace RTE { return nextButtonToHighlight; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void InventoryMenuGUI::HandleItemButtonPressOrHold(GUIButton* pressedButton, MovableObject* buttonObject, int buttonEquippedItemIndex, bool buttonHeld) { if (buttonHeld && m_GUISelectedItem) { return; @@ -1274,8 +1213,6 @@ namespace RTE { pressedButton->OnLoseFocus(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool InventoryMenuGUI::SwapEquippedItemAndInventoryItem(int equippedItemIndex, int inventoryItemIndex) { if (!m_InventoryActorIsHuman) { g_GUISound.UserErrorSound()->Play(m_MenuController->GetPlayer()); @@ -1312,8 +1249,6 @@ namespace RTE { return true; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void InventoryMenuGUI::ReloadSelectedItem() { // for a in MovableMan.Actors do print(ToAHuman(a).EquippedBGItem:SetOneHanded(true)) end if (!m_InventoryActorIsHuman) { return; @@ -1337,8 +1272,6 @@ namespace RTE { m_GUIReloadButton->OnLoseFocus(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void InventoryMenuGUI::DropSelectedItem(const Vector* dropDirection) { auto LaunchInventoryItem = [this, &dropDirection](MovableObject* itemToLaunch) { Vector itemPosition = m_InventoryActor->GetPos(); @@ -1374,8 +1307,6 @@ namespace RTE { m_GUIDropButton->OnLoseFocus(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void InventoryMenuGUI::DrawCarouselMode(BITMAP* targetBitmap, const Vector& drawPos) const { clear_to_color(m_CarouselBitmap.get(), g_MaskColor); clear_to_color(m_CarouselBGBitmap.get(), g_MaskColor); @@ -1428,8 +1359,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void InventoryMenuGUI::DrawCarouselItemBoxBackground(const CarouselItemBox& itemBoxToDraw) const { auto DrawBox = [](BITMAP* targetBitmap, const Vector& boxTopLeftCorner, const Vector& boxBottomRightCorner, int color, bool roundedLeftSide, bool roundedRightSide) { if (roundedLeftSide) { @@ -1452,8 +1381,6 @@ namespace RTE { DrawBox(m_CarouselBGBitmap.get(), itemBoxToDraw.Pos + (itemBoxToDraw.RoundedAndBorderedSides.first ? m_CarouselBackgroundBoxBorderSize : Vector(0, m_CarouselBackgroundBoxBorderSize.GetY())), itemBoxToDraw.Pos + itemBoxToDraw.CurrentSize - spriteZeroIndexSizeOffset - (itemBoxToDraw.RoundedAndBorderedSides.second ? m_CarouselBackgroundBoxBorderSize : Vector(0, m_CarouselBackgroundBoxBorderSize.GetY())), m_CarouselBackgroundBoxColor, itemBoxToDraw.RoundedAndBorderedSides.first, itemBoxToDraw.RoundedAndBorderedSides.second); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void InventoryMenuGUI::DrawCarouselItemBoxForeground(const CarouselItemBox& itemBoxToDraw, AllegroBitmap* carouselAllegroBitmap) const { std::vector itemIcons; float totalItemMass = 0; @@ -1489,8 +1416,6 @@ namespace RTE { m_SmallFont->DrawAligned(carouselAllegroBitmap, itemBoxToDraw.IconCenterPosition.GetFloorIntX(), itemBoxToDraw.IconCenterPosition.GetFloorIntY() - ((itemBoxToDraw.CurrentSize.GetFloorIntY() + m_SmallFont->GetFontHeight()) / 2) + 1, massString.c_str(), GUIFont::Centre); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void InventoryMenuGUI::DrawFullMode(BITMAP* targetBitmap, const Vector& drawPos) const { m_GUITopLevelBox->SetPositionAbs(drawPos.GetFloorIntX(), drawPos.GetFloorIntY()); diff --git a/Source/Menus/InventoryMenuGUI.h b/Source/Menus/InventoryMenuGUI.h index 30c6783a81..1f7ce95143 100644 --- a/Source/Menus/InventoryMenuGUI.h +++ b/Source/Menus/InventoryMenuGUI.h @@ -22,15 +22,11 @@ namespace RTE { class GUIButton; class GUIScrollbar; - /// /// A GUI menu for managing inventories. - /// class InventoryMenuGUI { public: - /// /// Enumeration for the modes an InventoryMenuGUI can have. - /// enum class MenuMode { Carousel, Full, @@ -38,137 +34,97 @@ namespace RTE { }; #pragma region Creation - /// /// Constructor method used to instantiate an InventoryMenuGUI object in system memory. Create() should be called before using the object. - /// InventoryMenuGUI() { Clear(); } - /// /// Makes the InventoryMenuGUI object ready for use. - /// - /// A pointer to a Controller which will control this Menu. Ownership is NOT transferred! - /// The Actor whose inventory this GUI will display. Ownership is NOT transferred! - /// The mode this menu should use when it's enabled. Defaults to Carousel. - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @param activityPlayerController A pointer to a Controller which will control this Menu. Ownership is NOT transferred! + /// @param inventoryActor The Actor whose inventory this GUI will display. Ownership is NOT transferred! + /// @param menuMode The mode this menu should use when it's enabled. Defaults to Carousel. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create(Controller* activityPlayerController, Actor* inventoryActor = nullptr, MenuMode menuMode = MenuMode::Carousel); #pragma endregion #pragma region Destruction - /// /// Destructor method used to clean up an InventoryMenuGUI object before deletion from system memory. - /// ~InventoryMenuGUI() { Destroy(); } - /// /// Destroys and resets the InventoryMenuGUI object. - /// void Destroy(); #pragma endregion #pragma region Getters and Setters - /// /// Sets the controller used by this. The ownership of the controller is NOT transferred! - /// - /// The new controller for this menu. Ownership is NOT transferred! + /// @param controller The new controller for this menu. Ownership is NOT transferred! void SetController(Controller* controller) { m_MenuController = controller; } - /// /// Gets the Actor whose inventory this GUI will display. The ownership of the Actor is NOT transferred! - /// - /// The Actor whose inventory this GUI will display. Ownership is NOT transferred! + /// @return The Actor whose inventory this GUI will display. Ownership is NOT transferred! const Actor* GetInventoryActor() const { return m_InventoryActor; } - /// /// Sets the Actor whose inventory this GUI will display. The ownership of the Actor is NOT transferred! - /// - /// The new Actor whose inventory this GUI will display. Ownership is NOT transferred! + /// @param actor The new Actor whose inventory this GUI will display. Ownership is NOT transferred! void SetInventoryActor(Actor* newInventoryActor); - /// /// Gets the MenuMode this InventoryMenuGUI is currently in. - /// - /// The current MenuMode of this InventoryMenuGUI. + /// @return The current MenuMode of this InventoryMenuGUI. MenuMode GetMenuMode() const { return m_MenuMode; } - /// /// Sets the MenuMode for this InventoryMenuGUI to be in. - /// - /// The new MenuMode of this InventoryMenuGUI. + /// @param newMenuMode The new MenuMode of this InventoryMenuGUI. void SetMenuMode(MenuMode newMenuMode) { m_MenuMode = newMenuMode; } - /// /// Gets whether the menu is enabled or not. - /// - /// Whether the menu is enabled. + /// @return Whether the menu is enabled. bool IsEnabled() const { return m_EnabledState == EnabledState::Enabled || m_EnabledState == EnabledState::Enabling; } - /// /// Gets whether the menu is enabled and not in carousel mode or not. - /// - /// Whether the menu is enabled and not in carousel mode + /// @return Whether the menu is enabled and not in carousel mode bool IsEnabledAndNotCarousel() const { return IsEnabled() && m_MenuMode != MenuMode::Carousel; } - /// /// Gets whether the menu is in the process of enabling or disabling. - /// - /// + /// @return bool IsEnablingOrDisabling() const { return m_EnabledState == EnabledState::Enabling || m_EnabledState == EnabledState::Disabling; } - /// /// Gets whether the menu is at all visible or not. - /// - /// Whether the menu is visible. + /// @return Whether the menu is visible. bool IsVisible() const { return m_EnabledState != EnabledState::Disabled; } - /// /// Enables or disables the menu and animates it in and out of view. - /// - /// Whether to enable or disable the menu. + /// @param enable Whether to enable or disable the menu. void SetEnabled(bool enable); - /// /// Enables or disables the InventoryMenuGUI based on whether or not it's empty (i.e. its actor has equipped or inventory items). - /// - /// Whether it tried to enable InventoryMenuGUI (true) or disable it (false). + /// @return Whether it tried to enable InventoryMenuGUI (true) or disable it (false). bool EnableIfNotEmpty(); #pragma endregion #pragma region Full And Transfer Mode Getters and Setters - /// /// Clears the selected item for this InventoryMenuGUI. - /// void ClearSelectedItem(); - /// /// Sets the selected item for this InventoryMenuGUI. /// If the button pointer or object pointer are null, or both indices are null, the selected item will instead be cleared. - /// - /// A pointer to the GUIButton that is selected. - /// A pointer to the MovableObject that is selected. - /// The index of this selected item in the displayed inventory. -1 means the item is not in the inventory. - /// The index of this selected item in the vector of equipped items. -1 means the item is not in the inventory. - /// Whether or not the selected item is being dragged. + /// @param selectedItemButton A pointer to the GUIButton that is selected. + /// @param selectedItemObject A pointer to the MovableObject that is selected. + /// @param inventoryIndex The index of this selected item in the displayed inventory. -1 means the item is not in the inventory. + /// @param equippedItemIndex The index of this selected item in the vector of equipped items. -1 means the item is not in the inventory. + /// @param isBeingDragged Whether or not the selected item is being dragged. void SetSelectedItem(GUIButton* selectedItemButton, MovableObject* selectedItemObject, int inventoryIndex, int equippedItemIndex, bool isBeingDragged); #pragma endregion #pragma region Updating - /// /// Updates the state of this GUI each frame. - /// void Update(); - /// /// Draws the GUI. - /// - /// A pointer to a BITMAP to draw on. Generally a screen BITMAP. - /// The absolute position of the target bitmap's upper left corner in the scene. + /// @param targetBitmap A pointer to a BITMAP to draw on. Generally a screen BITMAP. + /// @param targetPos The absolute position of the target bitmap's upper left corner in the scene. void Draw(BITMAP* targetBitmap, const Vector& targetPos = Vector()) const; #pragma endregion private: - /// /// A struct containing all information required to drawn and animate a carousel item box in Carousel MenuMode. - /// struct CarouselItemBox { MovableObject* Item; //!< A pointer to the item being displayed in the CarouselItemBox. bool IsForEquippedItems; //!< Whether or not this CarouselItemBox is for displaying equipped items. @@ -178,19 +134,15 @@ namespace RTE { Vector IconCenterPosition; //!< The calculated position for the center of the icon this CarouselItemBox is displaying. std::pair RoundedAndBorderedSides; //!< Whether the left and right sides, respectively, of this CarouselItemBox should have rounded corners and a border. - /// /// Fills the passed in vector of Bitmaps and float with the appropriate graphical icons and mass for the Item of this CarouselItemBox. /// If this CarouselItemBox IsForEquippedItem, it will instead used the passed in pointer to the vector of equipped items. - /// - /// A vector of Bitmaps to be filled in with the icon(s) for this CarouselItemBox's item(s). - /// A float to be filled in with the total mass of this CarouselItemBox's item(s). - /// A pointer to the vector of sets of equipped items to be used if the CarouselItemBox IsForEquippedItem. + /// @param itemIcons A vector of Bitmaps to be filled in with the icon(s) for this CarouselItemBox's item(s). + /// @param totalItemMass A float to be filled in with the total mass of this CarouselItemBox's item(s). + /// @param equippedItems A pointer to the vector of sets of equipped items to be used if the CarouselItemBox IsForEquippedItem. void GetIconsAndMass(std::vector& itemIcons, float& totalItemMass, const std::vector>* equippedItems) const; }; - /// /// A struct containing all information required to describe a selected item in Full/Transfer MenuMode. - /// struct GUISelectedItem { GUIButton* Button; //!< A pointer to the button for this GUISelectedItem. MovableObject* Object; //!< A pointer to the MovableObject for this GUISelectedItem. Should always match up with what the Button is displaying. @@ -199,16 +151,12 @@ namespace RTE { bool IsBeingDragged; //!< Whether or not the GUISelectedItem is currently being dragged. int DragHoldCount; //!< How long dragging has been held for, used to determine if the GUISelectedItem was actually dragged or just clicked. - /// /// Whether this selected item was being dragged for long enough that it matters. This helps make dragging not cause problems during instant clicks and releases. - /// - /// Whether this selected item was being dragged for long enough that it matters. + /// @return Whether this selected item was being dragged for long enough that it matters. bool DragWasHeldForLongEnough() const { return IsBeingDragged && DragHoldCount > 10; } }; - /// /// Enumeration for enabled states when enabling/disabling the InventoryMenuGUI. - /// enum class EnabledState { Enabling, Enabled, @@ -216,9 +164,7 @@ namespace RTE { Disabled }; - /// /// Enumeration for which direction an inventory is being swapped in. - /// enum class CarouselAnimationDirection { Left = -1, None, @@ -289,9 +235,7 @@ namespace RTE { const Icon* m_GUIDropButtonIcon; //!< A pointer to the PresetMan pie icon for dropping items, used here for the drop button. Not Owned here. std::vector> m_GUIInventoryItemButtons; //!< A vector of pairs of MovableObject pointers and GUIButton pointers, connecting inventory GUIButtons to their corresponding MovableObjects. - /// /// GUI elements that make up the full mode InventoryMenuGUI. - /// std::unique_ptr m_GUIControlManager; std::unique_ptr m_GUIScreen; std::unique_ptr m_GUIInput; @@ -308,198 +252,136 @@ namespace RTE { GUIScrollbar* m_GUIInventoryItemsScrollbar; #pragma region Create Breakdown - /// /// Gets whether the InventoryMenuGUI is ready to be activated in Carousel MenuMode. If it's not, that mode should be setup. - /// - /// Whether or not the InventoryMenuGUI is ready to be activated in carousel MenuMode. + /// @return Whether or not the InventoryMenuGUI is ready to be activated in carousel MenuMode. bool CarouselModeReadyForUse() const { return m_CarouselBitmap && m_CarouselBGBitmap; } - /// /// Makes the InventoryMenuGUI object ready for Carousel MenuMode use. - /// - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int SetupCarouselMode(); - /// /// Gets whether the InventoryMenuGUI is ready to be activated in Full or Transfer MenuMode. If it's not, that mode should be setup. - /// - /// Whether or not the InventoryMenuGUI is ready to be activated in Full or Transfer MenuMode. + /// @return Whether or not the InventoryMenuGUI is ready to be activated in Full or Transfer MenuMode. bool FullOrTransferModeReadyForUse() const { return m_GUIControlManager && m_GUIScreen && m_GUIInput; } - /// /// Makes the InventoryMenuGUI object ready for Full or Transfer MenuMode use. - /// - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int SetupFullOrTransferMode(); #pragma endregion #pragma region Update Breakdown - /// /// Handles MenuMode specific updating for when the InventoryMenuGUI is in Carousel MenuMode. - /// void UpdateCarouselMode(); - /// /// Handles sorting out positions and sizes of CarouselItemBoxes when in Carousel MenuMode. - /// void UpdateCarouselItemBoxSizesAndPositions(); - /// /// Handles MenuMode specific updating for when the InventoryMenuGUI is in Full MenuMode. - /// void UpdateFullMode(); - /// /// Handles visibility and content for equipped item buttons in Full MenuMode. Does not deal with button input. - /// void UpdateFullModeEquippedItemButtons(); - /// /// Handles hiding and showing the scrollbar, and calculating everything related to it in Full MenuMode. - /// - /// A pointer to the inventory this InventoryMenuGUI is displaying. + /// @param inventory A pointer to the inventory this InventoryMenuGUI is displaying. void UpdateFullModeScrollbar(const std::deque* inventory); - /// /// Handles content and enabled status for inventory item buttons in Full MenuMode. Does not deal with button input. - /// - /// A pointer to the inventory this InventoryMenuGUI is displaying. + /// @param inventory A pointer to the inventory this InventoryMenuGUI is displaying. void UpdateFullModeInventoryItemButtons(const std::deque* inventory); - /// /// Handles everything for displaying information text in Full MenuMode. - /// - /// A pointer to the inventory this InventoryMenuGUI is displaying. + /// @param inventory A pointer to the inventory this InventoryMenuGUI is displaying. void UpdateFullModeInformationText(const std::deque* inventory); - /// /// Handles updating icons and widths to support higlighting, for non-item buttons in Full MenuMode. - /// void UpdateFullModeNonItemButtonIconsAndHighlightWidths(); - /// /// Handles MenuMode specific updating for when the InventoryMenuGUI is in Transfer MenuMode. - /// void UpdateTransferMode(); #pragma endregion #pragma region GUI Input Handling - /// /// Player input handling for all devices. - /// void HandleInput(); - /// /// Player mouse input event handling of the GUIControls of this InventoryMenuGUI. - /// - /// Whether the mouse was released this frame after being held long enough to count, useful to prevent duplicate button handling when releasing the left click. + /// @return Whether the mouse was released this frame after being held long enough to count, useful to prevent duplicate button handling when releasing the left click. bool HandleMouseInput(); - /// /// Player keyboard or gamepad input event handling of the GUIControls of this InventoryMenuGUI. - /// void HandleNonMouseInput(); - /// /// Gets any keyboard or gamepad directional input. - /// - /// The direction of found input. Priority matches ordering of the Directions enumeration. + /// @return The direction of found input. Priority matches ordering of the Directions enumeration. Directions GetNonMouseButtonControllerMovement(); - /// /// Breakdown of HandleNonMouseInput for handling pressing/holding up. - /// - /// The next button to highlight, based on input handling. + /// @return The next button to highlight, based on input handling. GUIButton* HandleNonMouseUpInput(); - /// /// Breakdown of HandleNonMouseInput for handling pressing/holding down. - /// - /// The next button to highlight, based on input handling. + /// @return The next button to highlight, based on input handling. GUIButton* HandleNonMouseDownInput(); - /// /// Breakdown of HandleNonMouseInput for handling pressing/holding left. - /// - /// The next button to highlight, based on input handling. + /// @return The next button to highlight, based on input handling. GUIButton* HandleNonMouseLeftInput(); - /// /// Breakdown of HandleNonMouseInput for handling pressing/holding right. - /// - /// The next button to highlight, based on input handling. + /// @return The next button to highlight, based on input handling. GUIButton* HandleNonMouseRightInput(); - /// /// Handles item button press command events from the GUIControls of this InventoryMenuGUI by selecting/de-selecting the corresponding item. - /// - /// A pointer to the GUIButton that was pressed. - /// A pointer to the MovableObject the GUIButton represents. - /// The index of this button in the vector of equipped items if applicable. The default value of -1 means it's not an equipped item. - /// Whether or not the button was held. + /// @param pressedButton A pointer to the GUIButton that was pressed. + /// @param buttonObject A pointer to the MovableObject the GUIButton represents. + /// @param buttonEquippedItemIndex The index of this button in the vector of equipped items if applicable. The default value of -1 means it's not an equipped item. + /// @param buttonHeld Whether or not the button was held. void HandleItemButtonPressOrHold(GUIButton* pressedButton, MovableObject* buttonObject, int buttonEquippedItemIndex = -1, bool buttonHeld = false); #pragma endregion #pragma region GUI Button Actions // TODO implement swap mode - /// /// Handles set swap button press command events from the GUIControls of this InventoryMenuGUI. - /// // void SwapEquippedItemSet() {} - /// /// Swaps the equipped item at the given equipped item index with one in the inventory Actor's inventory at the given inventory item index. /// Accounts for either index pointing to empty buttons and any other potential complications. - /// - /// The index of the equipped item being swapped out. - /// The index in the inventory of the item being swapped in. - /// Whether the inventory item at the given inventory item index was successfully equipped to the given equipped item index. + /// @param equippedItemIndex The index of the equipped item being swapped out. + /// @param inventoryItemIndex The index in the inventory of the item being swapped in. + /// @return Whether the inventory item at the given inventory item index was successfully equipped to the given equipped item index. bool SwapEquippedItemAndInventoryItem(int equippedItemIndex, int inventoryItemIndex); - /// /// Reloads the selected item if it is equipped, or swaps to it and then reloads it if it isn't. - /// void ReloadSelectedItem(); - /// /// Drops the selected item, rotating its drop velocity in the direction of the passed in dropDirection Vector. - /// - /// A pointer to a Vector containing the direction the selected item should be dropped in. Nullptr means standard dropping will be used. + /// @param dropDirection A pointer to a Vector containing the direction the selected item should be dropped in. Nullptr means standard dropping will be used. void DropSelectedItem(const Vector* dropDirection = nullptr); #pragma endregion #pragma region Draw Breakdown - /// /// Draws the InventoryMenuGUI when it's in Carousel MenuMode. - /// - /// A pointer to a BITMAP to draw on. Generally a screen BITMAP. - /// The position at which to draw the carousel. + /// @param targetBitmap A pointer to a BITMAP to draw on. Generally a screen BITMAP. + /// @param drawPos The position at which to draw the carousel. void DrawCarouselMode(BITMAP* targetBitmap, const Vector& drawPos) const; - /// /// Draws the InventoryMenuGUI when it's in Full MenuMode. - /// - /// A pointer to a BITMAP to draw on. Generally a screen BITMAP. - /// The position at which to draw the GUI. + /// @param targetBitmap A pointer to a BITMAP to draw on. Generally a screen BITMAP. + /// @param drawPos The position at which to draw the GUI. void DrawFullMode(BITMAP* targetBitmap, const Vector& drawPos) const; - /// /// Draws the specified CarouselItemBox's background to the carousel background Bitmap. - /// - /// The CarouselItemBox to draw. + /// @param itemBoxToDraw The CarouselItemBox to draw. void DrawCarouselItemBoxBackground(const CarouselItemBox& itemBoxToDraw) const; - /// /// Draws the specified CarouselItemBox's item(s) and mass text to the carousel Bitmap. - /// - /// The CarouselItemBox to draw. - /// An AllegroBitmap of the bitmap the CarouselItemBox should draw its foreground to. Used for drawing mass strings, and predefined to avoid needless creation. + /// @param itemBoxToDraw The CarouselItemBox to draw. + /// @param carouselAllegroBitmap An AllegroBitmap of the bitmap the CarouselItemBox should draw its foreground to. Used for drawing mass strings, and predefined to avoid needless creation. void DrawCarouselItemBoxForeground(const CarouselItemBox& itemBoxToDraw, AllegroBitmap* carouselAllegroBitmap) const; #pragma endregion - /// /// Clears all the member variables of this InventoryMenuGUI, effectively resetting the members of this abstraction level only. - /// void Clear(); // Disallow the use of some implicit methods. diff --git a/Source/Menus/LoadingScreen.cpp b/Source/Menus/LoadingScreen.cpp index 06a6efe3f9..e638e3639a 100644 --- a/Source/Menus/LoadingScreen.cpp +++ b/Source/Menus/LoadingScreen.cpp @@ -14,8 +14,6 @@ namespace RTE { - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void LoadingScreen::Clear() { m_LoadingLogWriter = nullptr; m_LoadingSplashBitmap = nullptr; @@ -24,8 +22,6 @@ namespace RTE { m_ProgressListboxPosY = 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void LoadingScreen::Create(AllegroScreen* guiScreen, GUIInputWrapper* guiInput, bool progressReportDisabled) { GUIControlManager loadingScreenManager; RTEAssert(loadingScreenManager.Create(guiScreen, guiInput, "Base.rte/GUIs/Skins/Menus", "LoadingScreenSkin.ini"), "Failed to create GUI Control Manager and load it from Base.rte/GUIs/Skins/Menus/LoadingScreenSkin.ini"); @@ -59,8 +55,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void LoadingScreen::CreateLoadingSplash(int xOffset) { if (m_LoadingSplashBitmap) { destroy_bitmap(m_LoadingSplashBitmap); @@ -79,8 +73,6 @@ namespace RTE { loadingSplash.Draw(m_LoadingSplashBitmap, loadingSplashTargetBox); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void LoadingScreen::CreateProgressReportListbox(GUIControlManager* parentControlManager) { dynamic_cast(parentControlManager->GetControl("root"))->SetSize(g_WindowMan.GetResX(), g_WindowMan.GetResY()); GUIListBox* listBox = dynamic_cast(parentControlManager->GetControl("ProgressBox")); @@ -104,8 +96,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void LoadingScreen::Destroy() { destroy_bitmap(m_LoadingSplashBitmap); if (m_ProgressListboxBitmap) { @@ -114,8 +104,6 @@ namespace RTE { Clear(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void LoadingScreen::LoadingSplashProgressReport(const std::string& reportString, bool newItem) { if (System::IsLoggingToCLI()) { System::PrintLoadingToCLI(reportString, newItem); @@ -149,8 +137,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void LoadingScreen::DrawLoadingSplash() { draw_sprite(g_FrameMan.GetBackBuffer32(), m_LoadingSplashBitmap, 0, 0); } diff --git a/Source/Menus/LoadingScreen.h b/Source/Menus/LoadingScreen.h index 68d15faf44..7c4df7eaed 100644 --- a/Source/Menus/LoadingScreen.h +++ b/Source/Menus/LoadingScreen.h @@ -12,58 +12,42 @@ namespace RTE { class GUIControlManager; class Writer; - /// /// Handling for the loading screen composition and loading progress box when starting the game. - /// class LoadingScreen : public Singleton { public: #pragma region Creation - /// /// Constructor method used to instantiate a LoadingScreen object in system memory. - /// LoadingScreen() { Clear(); } - /// /// Makes the LoadingScreen object ready for use. - /// - /// Pointer to a GUIScreen interface that will be used by this LoadingScreen's GUIControlManager. Ownership is NOT transferred! - /// Pointer to a GUIInput interface that will be used by this LoadingScreen's GUIControlManager. Ownership is NOT transferred! - /// Whether the loading screen progress report is disabled meaning GUI elements and adjustments relevant to it can be skipped. + /// @param guiScreen Pointer to a GUIScreen interface that will be used by this LoadingScreen's GUIControlManager. Ownership is NOT transferred! + /// @param guiInput Pointer to a GUIInput interface that will be used by this LoadingScreen's GUIControlManager. Ownership is NOT transferred! + /// @param progressReportDisabled Whether the loading screen progress report is disabled meaning GUI elements and adjustments relevant to it can be skipped. void Create(AllegroScreen* guiScreen, GUIInputWrapper* guiInput, bool progressReportDisabled); - /// /// Creates the loading splash screen and draws the composed frame to the LoadingSplashBitmap. - /// - /// Horizontal offset of the loading splash screen. + /// @param xOffset Horizontal offset of the loading splash screen. void CreateLoadingSplash(int xOffset = 0); - /// /// Creates the GUIListBox that the progress report will be drawn to, if not disabled through the settings file to speed up loading times. /// As it turned out, a massive amount of time is spent updating the GUI control and flipping the frame buffers. - /// - /// Pointer to the parent GUIControlManager which owns all the GUIControls of this LoadingScreen. Ownership is NOT transferred! + /// @param parentControlManager Pointer to the parent GUIControlManager which owns all the GUIControls of this LoadingScreen. Ownership is NOT transferred! void CreateProgressReportListbox(GUIControlManager* parentControlManager); #pragma endregion #pragma region Destruction - /// /// Destroys and resets (through Clear()) the LoadingScreen object. - /// void Destroy(); #pragma endregion #pragma region Concrete Methods - /// /// Updates the loading progress report and draws it to the screen if not disabled through the settings file. - /// - /// The string to print in the report and log. - /// Whether to start a new line in the log writer and to scroll the bitmap. + /// @param reportString The string to print in the report and log. + /// @param newItem Whether to start a new line in the log writer and to scroll the bitmap. static void LoadingSplashProgressReport(const std::string& reportString, bool newItem = false); - /// /// Draws the loading splash to the screen. - /// void DrawLoadingSplash(); #pragma endregion @@ -75,9 +59,7 @@ namespace RTE { int m_ProgressListboxPosX; //!< Position of the progress report box on X axis. int m_ProgressListboxPosY; //!< Position of the progress report box on Y axis. - /// /// Clears all the member variables of this LoadingScreen, effectively resetting the members of this abstraction level only. - /// void Clear(); // Disallow the use of some implicit methods. diff --git a/Source/Menus/MainMenuGUI.cpp b/Source/Menus/MainMenuGUI.cpp index 7582440fe8..93d8bfe0d1 100644 --- a/Source/Menus/MainMenuGUI.cpp +++ b/Source/Menus/MainMenuGUI.cpp @@ -20,8 +20,6 @@ namespace RTE { - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void MainMenuGUI::Clear() { m_RootBoxMaxWidth = 0; @@ -54,8 +52,6 @@ namespace RTE { m_MainScreenPrevHoveredButtonIndex = 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void MainMenuGUI::Create(AllegroScreen* guiScreen, GUIInputWrapper* guiInput) { m_MainMenuScreenGUIControlManager = std::make_unique(); RTEAssert(m_MainMenuScreenGUIControlManager->Create(guiScreen, guiInput, "Base.rte/GUIs/Skins/Menus", "MainMenuScreenSkin.ini"), "Failed to create GUI Control Manager and load it from Base.rte/GUIs/Skins/Menus/MainMenuScreenSkin.ini"); @@ -90,8 +86,6 @@ namespace RTE { SetActiveMenuScreen(g_WindowMan.ResolutionChanged() ? MenuScreen::SettingsScreen : MenuScreen::MainScreen, false); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void MainMenuGUI::CreateMainScreen() { m_MainMenuScreens[MenuScreen::MainScreen] = dynamic_cast(m_MainMenuScreenGUIControlManager->GetControl("MainScreen")); m_MainMenuScreens[MenuScreen::MainScreen]->CenterInParent(true, false); @@ -123,8 +117,6 @@ namespace RTE { m_VersionLabel->SetPositionAbs(10, g_WindowMan.GetResY() - m_VersionLabel->GetTextHeight() - 5); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void MainMenuGUI::CreateMetaGameNoticeScreen() { m_MainMenuScreens[MenuScreen::MetaGameNoticeScreen] = dynamic_cast(m_SubMenuScreenGUIControlManager->GetControl("MetaScreen")); m_MainMenuScreens[MenuScreen::MetaGameNoticeScreen]->CenterInParent(true, false); @@ -133,8 +125,6 @@ namespace RTE { m_MainMenuButtons[MenuButton::MetaGameContinueButton] = dynamic_cast(m_SubMenuScreenGUIControlManager->GetControl("ButtonContinue")); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void MainMenuGUI::CreateEditorsScreen() { m_MainMenuScreens[MenuScreen::EditorScreen] = dynamic_cast(m_SubMenuScreenGUIControlManager->GetControl("EditorScreen")); m_MainMenuScreens[MenuScreen::EditorScreen]->CenterInParent(true, false); @@ -146,8 +136,6 @@ namespace RTE { m_MainMenuButtons[MenuButton::ActorEditorButton] = dynamic_cast(m_SubMenuScreenGUIControlManager->GetControl("ButtonActorEditor")); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void MainMenuGUI::CreateCreditsScreen() { m_MainMenuScreens[MenuScreen::CreditsScreen] = dynamic_cast(m_SubMenuScreenGUIControlManager->GetControl("CreditsScreen")); m_MainMenuScreens[MenuScreen::CreditsScreen]->Resize(m_MainMenuScreens[MenuScreen::CreditsScreen]->GetWidth(), g_WindowMan.GetResY()); @@ -173,8 +161,6 @@ namespace RTE { m_CreditsTextLabel->ResizeHeightToFit(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void MainMenuGUI::CreateQuitScreen() { m_MainMenuScreens[MenuScreen::QuitScreen] = dynamic_cast(m_SubMenuScreenGUIControlManager->GetControl("QuitConfirmBox")); m_MainMenuScreens[MenuScreen::QuitScreen]->CenterInParent(true, false); @@ -183,8 +169,6 @@ namespace RTE { m_MainMenuButtons[MenuButton::QuitCancelButton] = dynamic_cast(m_SubMenuScreenGUIControlManager->GetControl("QuitCancelButton")); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void MainMenuGUI::HideAllScreens() { for (GUICollectionBox* menuScreen: m_MainMenuScreens) { if (menuScreen) { @@ -194,8 +178,6 @@ namespace RTE { m_MenuScreenChange = true; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void MainMenuGUI::SetActiveMenuScreen(MenuScreen screenToShow, bool playButtonPressSound) { if (screenToShow != m_ActiveMenuScreen) { HideAllScreens(); @@ -213,8 +195,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void MainMenuGUI::ShowMainScreen() { m_VersionLabel->SetVisible(true); @@ -227,8 +207,6 @@ namespace RTE { m_MenuScreenChange = false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void MainMenuGUI::ShowMetaGameNoticeScreen() { m_MainMenuScreens[MenuScreen::MetaGameNoticeScreen]->SetVisible(true); m_MainMenuScreens[MenuScreen::MetaGameNoticeScreen]->GUIPanel::AddChild(m_MainMenuButtons[MenuButton::BackToMainButton]); @@ -252,8 +230,6 @@ namespace RTE { m_MenuScreenChange = false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void MainMenuGUI::ShowEditorsScreen() { m_MainMenuScreens[MenuScreen::EditorScreen]->SetVisible(true); m_MainMenuScreens[MenuScreen::EditorScreen]->GUIPanel::AddChild(m_MainMenuButtons[MenuButton::BackToMainButton]); @@ -264,8 +240,6 @@ namespace RTE { m_MenuScreenChange = false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void MainMenuGUI::ShowCreditsScreen() { m_MainMenuScreens[MenuScreen::CreditsScreen]->SetVisible(true); m_MainMenuScreens[MenuScreen::CreditsScreen]->GUIPanel::AddChild(m_MainMenuButtons[MenuButton::BackToMainButton]); @@ -281,8 +255,6 @@ namespace RTE { m_MenuScreenChange = false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void MainMenuGUI::ShowQuitScreenOrQuit() { if (m_ActiveMenuScreen != MenuScreen::QuitScreen && g_ActivityMan.GetActivity() && (g_ActivityMan.GetActivity()->GetActivityState() == Activity::Running || g_ActivityMan.GetActivity()->GetActivityState() == Activity::Editing)) { SetActiveMenuScreen(MenuScreen::QuitScreen); @@ -293,8 +265,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void MainMenuGUI::ShowAndBlinkResumeButton() { if (!m_MainMenuButtons[MenuButton::ResumeButton]->GetVisible()) { m_ResumeButtonBlinkTimer.Reset(); @@ -311,8 +281,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool MainMenuGUI::RollCredits() { int scrollDuration = m_CreditsTextLabel->GetHeight() * 50; float scrollDist = static_cast(m_CreditsScrollPanel->GetHeight() + m_CreditsTextLabel->GetHeight()); @@ -325,8 +293,6 @@ namespace RTE { return false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - MainMenuGUI::MainMenuUpdateResult MainMenuGUI::Update() { m_UpdateResult = MainMenuUpdateResult::NoEvent; @@ -387,8 +353,6 @@ namespace RTE { return m_UpdateResult; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void MainMenuGUI::HandleBackNavigation(bool backButtonPressed) { if ((!m_ActiveDialogBox || m_ActiveDialogBox == m_MainMenuScreens[MenuScreen::QuitScreen]) && (backButtonPressed || g_UInputMan.KeyPressed(SDLK_ESCAPE))) { if (m_ActiveMenuScreen != MenuScreen::MainScreen) { @@ -411,8 +375,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool MainMenuGUI::HandleInputEvents() { if (m_ActiveMenuScreen == MenuScreen::MainScreen) { int mouseX = 0; @@ -451,8 +413,6 @@ namespace RTE { return false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void MainMenuGUI::HandleMainScreenInputEvents(const GUIControl* guiEventControl) { if (guiEventControl == m_MainMenuButtons[MenuButton::MetaGameButton]) { if (!m_MetaGameNoticeShown) { @@ -486,8 +446,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void MainMenuGUI::HandleMetaGameNoticeScreenInputEvents(const GUIControl* guiEventControl) { if (guiEventControl == m_MainMenuButtons[MenuButton::PlayTutorialButton]) { m_UpdateResult = MainMenuUpdateResult::ActivityStarted; @@ -498,8 +456,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void MainMenuGUI::HandleEditorsScreenInputEvents(const GUIControl* guiEventControl) { std::string editorToStart; if (guiEventControl == m_MainMenuButtons[MenuButton::SceneEditorButton]) { @@ -521,8 +477,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void MainMenuGUI::HandleQuitScreenInputEvents(const GUIControl* guiEventControl) { if (guiEventControl == m_MainMenuButtons[MenuButton::QuitConfirmButton]) { m_UpdateResult = MainMenuUpdateResult::Quit; @@ -532,8 +486,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void MainMenuGUI::UpdateMainScreenHoveredButton(const GUIButton* hoveredButton) { int hoveredButtonIndex = -1; if (hoveredButton) { @@ -554,8 +506,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void MainMenuGUI::Draw() { // Early return to avoid single frame flicker when title screen goes into transition from the meta notice screen to meta config screen. if (m_UpdateResult == MainMenuUpdateResult::MetaGameStarted) { diff --git a/Source/Menus/MainMenuGUI.h b/Source/Menus/MainMenuGUI.h index 43583e2156..5d34ff6967 100644 --- a/Source/Menus/MainMenuGUI.h +++ b/Source/Menus/MainMenuGUI.h @@ -17,15 +17,11 @@ namespace RTE { class GUILabel; class GUIControl; - /// /// Handling for the main menu screen composition and sub-menu interaction. - /// class MainMenuGUI { public: - /// /// Enumeration for the results of the MainMenuGUI input and event update. - /// enum class MainMenuUpdateResult { NoEvent, MetaGameStarted, @@ -38,41 +34,31 @@ namespace RTE { }; #pragma region Creation - /// /// Constructor method used to instantiate a MainMenuGUI object in system memory and makes it ready for use. - /// - /// Pointer to a GUIScreen interface that will be used by this MainMenuGUI's GUIControlManager. Ownership is NOT transferred! - /// Pointer to a GUIInput interface that will be used by this MainMenuGUI's GUIControlManager. Ownership is NOT transferred! + /// @param guiScreen Pointer to a GUIScreen interface that will be used by this MainMenuGUI's GUIControlManager. Ownership is NOT transferred! + /// @param guiInput Pointer to a GUIInput interface that will be used by this MainMenuGUI's GUIControlManager. Ownership is NOT transferred! MainMenuGUI(AllegroScreen* guiScreen, GUIInputWrapper* guiInput) { Clear(); Create(guiScreen, guiInput); } - /// /// Makes the MainMenuGUI object ready for use. - /// - /// Pointer to a GUIScreen interface that will be used by this MainMenuGUI's GUIControlManager. Ownership is NOT transferred! - /// Pointer to a GUIInput interface that will be used by this MainMenuGUI's GUIControlManager. Ownership is NOT transferred! + /// @param guiScreen Pointer to a GUIScreen interface that will be used by this MainMenuGUI's GUIControlManager. Ownership is NOT transferred! + /// @param guiInput Pointer to a GUIInput interface that will be used by this MainMenuGUI's GUIControlManager. Ownership is NOT transferred! void Create(AllegroScreen* guiScreen, GUIInputWrapper* guiInput); #pragma endregion #pragma region Concrete Methods - /// /// Updates the MainMenuGUI state. - /// - /// The result of the MainMenuGUI input and event update. See MainMenuUpdateResult enumeration. + /// @return The result of the MainMenuGUI input and event update. See MainMenuUpdateResult enumeration. MainMenuUpdateResult Update(); - /// /// Draws the MainMenuGUI to the screen. - /// void Draw(); #pragma endregion private: - /// /// Enumeration for the different sub-menu screens of the main menu. - /// enum MenuScreen { MainScreen, MetaGameNoticeScreen, @@ -85,9 +71,7 @@ namespace RTE { ScreenCount }; - /// /// Enumeration for all the different buttons of the main menu and sub-menus. - /// enum MenuButton { MetaGameButton, ScenarioButton, @@ -138,9 +122,7 @@ namespace RTE { GUIButton* m_MainScreenHoveredButton; //!< The currently hovered main screen button. int m_MainScreenPrevHoveredButtonIndex; //!< The index of the previously hovered main screen button in the main menu button array. - /// /// GUI elements that compose the main menu screen. - /// GUILabel* m_VersionLabel; GUILabel* m_CreditsTextLabel; GUICollectionBox* m_CreditsScrollPanel; @@ -148,129 +130,85 @@ namespace RTE { std::array m_MainMenuButtons; #pragma region Create Breakdown - /// /// Creates all the elements that compose the main menu screen. - /// void CreateMainScreen(); - /// /// Creates all the elements that compose the MetaGame notice menu screen. - /// void CreateMetaGameNoticeScreen(); - /// /// Creates all the elements that compose the editor selection menu screen. - /// void CreateEditorsScreen(); - /// /// Creates all the elements that compose the credits menu screen. - /// void CreateCreditsScreen(); - /// /// Creates all the elements that compose the quit confirmation menu screen. - /// void CreateQuitScreen(); #pragma endregion #pragma region Menu Screen Handling - /// /// Hides all main menu screens. - /// void HideAllScreens(); - /// /// Sets the MainMenuGUI to display a menu screen. - /// - /// Which menu screen to display. See MenuScreen enumeration. - /// Whether to play a sound if the menu screen change is triggered by a button press. + /// @param screenToShow Which menu screen to display. See MenuScreen enumeration. + /// @param playButtonPressSound Whether to play a sound if the menu screen change is triggered by a button press. void SetActiveMenuScreen(MenuScreen screenToShow, bool playButtonPressSound = true); - /// /// Makes the main menu screen visible to be interacted with by the player. - /// void ShowMainScreen(); - /// /// Makes the MetaGame notice menu screen visible to be interacted with by the player. - /// void ShowMetaGameNoticeScreen(); - /// /// Makes the editor selection menu screen visible to be interacted with by the player. - /// void ShowEditorsScreen(); - /// /// Makes the credits menu screen visible to be interacted with by the player and resets the scrolling timer for the credits. - /// void ShowCreditsScreen(); - /// /// Makes the quit confirmation menu screen visible to be interacted with by the player if a game is in progress, or immediately sets the UpdateResult to Quit if not. - /// void ShowQuitScreenOrQuit(); - /// /// Makes the resume game button visible to be interacted with by the player if a game is in progress and animates it (blinking). - /// void ShowAndBlinkResumeButton(); - /// /// Progresses the credits scrolling. - /// - /// Whether the credits finished scrolling. + /// @return Whether the credits finished scrolling. bool RollCredits(); #pragma endregion #pragma region Update Breakdown - /// /// Handles returning to the main menu from one of the sub-menus if the player requested to return via the back button or the esc key. Also handles closing active dialog boxes with the esc key. - /// - /// Whether the player requested to return to the main menu from one of the sub-menus via back button. + /// @param backButtonPressed Whether the player requested to return to the main menu from one of the sub-menus via back button. void HandleBackNavigation(bool backButtonPressed); - /// /// Handles the player interaction with the MainMenuGUI GUI elements. - /// - /// Whether the player requested to return to the main menu from one of the sub-menus. + /// @return Whether the player requested to return to the main menu from one of the sub-menus. bool HandleInputEvents(); - /// /// Handles the player interaction with the main screen GUI elements. - /// - /// Pointer to the GUI element that the player interacted with. + /// @param guiEventControl Pointer to the GUI element that the player interacted with. void HandleMainScreenInputEvents(const GUIControl* guiEventControl); - /// /// Handles the player interaction with the MetaGame notice screen GUI elements. - /// - /// Pointer to the GUI element that the player interacted with. + /// @param guiEventControl Pointer to the GUI element that the player interacted with. void HandleMetaGameNoticeScreenInputEvents(const GUIControl* guiEventControl); - /// /// Handles the player interaction with the editor selection screen GUI elements. - /// - /// Pointer to the GUI element that the player interacted with. + /// @param guiEventControl Pointer to the GUI element that the player interacted with. void HandleEditorsScreenInputEvents(const GUIControl* guiEventControl); - /// /// Handles the player interaction with the quit screen GUI elements. - /// - /// Pointer to the GUI element that the player interacted with. + /// @param guiEventControl Pointer to the GUI element that the player interacted with. void HandleQuitScreenInputEvents(const GUIControl* guiEventControl); - /// /// Updates the currently hovered main screen button text to give the hovered visual and updates the previously hovered button to remove the hovered visual. - /// - /// Pointer to the currently hovered main screen button, if any. Acquired by GUIControlManager::GetControlUnderPoint. + /// @param hoveredButton Pointer to the currently hovered main screen button, if any. Acquired by GUIControlManager::GetControlUnderPoint. void UpdateMainScreenHoveredButton(const GUIButton* hoveredButton); #pragma endregion - /// /// Clears all the member variables of this MainMenuGUI, effectively resetting the members of this object. - /// void Clear(); // Disallow the use of some implicit methods. diff --git a/Source/Menus/MetagameGUI.cpp b/Source/Menus/MetagameGUI.cpp index a62c667d28..66bee69527 100644 --- a/Source/Menus/MetagameGUI.cpp +++ b/Source/Menus/MetagameGUI.cpp @@ -1,15 +1,3 @@ -////////////////////////////////////////////////////////////////////////////////////////// -// File: MetagameGUI.cpp -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Implementation file for the MetagameGUI class -// Project: GUI Library -// Author(s): Daniel Tabar -// dtabar@datarealms.com -// http://www.datarealms.com - -////////////////////////////////////////////////////////////////////////////////////////// -// Inclusions of header files - #include "MetagameGUI.h" #include "WindowMan.h" @@ -66,11 +54,6 @@ using namespace RTE; const std::string MetagameGUI::c_ClassName = "MetagameGUI"; -////////////////////////////////////////////////////////////////////////////////////////// -// Method: Draw -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Draws a neat animation over a site to show it changing team ownership. - void MetagameGUI::SiteTarget::Draw(BITMAP* drawBitmap) const { if (!drawBitmap) return; @@ -132,12 +115,6 @@ void MetagameGUI::SiteTarget::Draw(BITMAP* drawBitmap) const { } } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: Clear -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Clears all the member variables of this MetagameGUI, effectively -// resetting the members of this abstraction level only. - void MetagameGUI::Clear() { m_RootBoxMaxWidth = 0; @@ -299,12 +276,6 @@ void MetagameGUI::Clear() { m_StationPosOnOrbit.Reset(); } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: SetToStartNewGame -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Resets internal state of GUI to show 'Start new campaign' screen -// Arguments: None. -// Return value: None. void MetagameGUI::SetToStartNewGame() { g_MetaMan.SetSuspend(true); HideAllScreens(); @@ -313,11 +284,6 @@ void MetagameGUI::SetToStartNewGame() { SwitchToScreen(MetagameGUI::NEWDIALOG); } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: Create -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Makes the MetagameGUI object ready for use. - int MetagameGUI::Create() { for (int metaPlayer = Players::PlayerOne; metaPlayer < Players::MaxPlayerCount; ++metaPlayer) { m_ActionSiteLines[metaPlayer].clear(); @@ -332,11 +298,6 @@ int MetagameGUI::Create() { return 0; } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: Create -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Makes the MetagameGUI object ready for use. - int MetagameGUI::Create(Controller* pController) { RTEAssert(pController, "No controller sent to MetagameGUI on creation!"); m_pController = pController; @@ -614,10 +575,6 @@ int MetagameGUI::Create(Controller* pController) { return 0; } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: MoveLocationsIntoTheScreen -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Moves any locations closer to the center of the planet if they were left out void MetagameGUI::MoveLocationsIntoTheScreen() { // Clear offsets for (std::vector::iterator pItr = g_MetaMan.m_Scenes.begin(); pItr != g_MetaMan.m_Scenes.end(); ++pItr) @@ -677,14 +634,6 @@ void MetagameGUI::MoveLocationsIntoTheScreen() { } } -////////////////////////////////////////////////////////////////////////////////////////// -// Virtual method: ReadProperty -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Reads a property value from a Reader stream. If the name isn't -// recognized by this class, then ReadProperty of the parent class -// is called. If the property isn't recognized by any of the base classes, -// false is returned, and the Reader's position is untouched. - int MetagameGUI::ReadProperty(const std::string_view& propName, Reader& reader) { Vector tempPos; @@ -719,12 +668,6 @@ int MetagameGUI::ReadProperty(const std::string_view& propName, Reader& reader) EndPropertyList; } -////////////////////////////////////////////////////////////////////////////////////////// -// Virtual method: Save -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Saves the complete state of this MetagameGUI to an output stream for -// later recreation with Create(Reader &reader); - int MetagameGUI::Save(Writer& writer) const { Serializable::Save(writer); @@ -738,11 +681,6 @@ int MetagameGUI::Save(Writer& writer) const { return 0; } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: Destroy -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Destroys and resets (through Clear()) the MetagameGUI object. - void MetagameGUI::Destroy() { delete m_pGUIController; delete m_pGUIInput; @@ -756,20 +694,10 @@ void MetagameGUI::Destroy() { Clear(); } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: GetGUIControlManager -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Gets the GUIControlManager owned and used by this. - GUIControlManager* MetagameGUI::GetGUIControlManager() { return m_pGUIController; } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: SetEnabled -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Enables or disables the menu. This will animate it in and out of view. - void MetagameGUI::SetEnabled(bool enable) { if (enable && m_MenuEnabled != ENABLED && m_MenuEnabled != ENABLING) { m_MenuEnabled = ENABLING; @@ -811,11 +739,6 @@ void MetagameGUI::SetEnabled(bool enable) { m_ScreenChange = true; } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: SelectScene -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Tries to select a specifically named scene on the metagame field. - void MetagameGUI::SelectScene(Scene* pScene) { m_pSelectedScene = pScene; @@ -851,11 +774,6 @@ void MetagameGUI::SelectScene(Scene* pScene) { } } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: SelectScene -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Tries to select a specifically named scene on the metagame field. - bool MetagameGUI::SelectScene(std::string sceneName) { for (std::vector::iterator sItr = g_MetaMan.m_Scenes.begin(); sItr != g_MetaMan.m_Scenes.end(); ++sItr) { // Only allow selection if the Scene is revealed yet! @@ -868,11 +786,6 @@ bool MetagameGUI::SelectScene(std::string sceneName) { return false; } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: SwitchToScreen -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Switches to showing a specific menu screen/mode. - void MetagameGUI::SwitchToScreen(int newScreen) { RTEAssert(newScreen >= ROOTBOX && newScreen < SCREENCOUNT, "Tried to switch to an out of bounds screen!"); @@ -889,11 +802,6 @@ void MetagameGUI::SwitchToScreen(int newScreen) { g_MetaMan.SetSuspend(m_MenuScreen != ROOTBOX && m_MenuScreen != STATSDIALOG && m_MenuScreen != SCENEINFOBOX); } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: GetRoundName -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Makes a round number into a nice friendly text string. "ONE" for 1 etc - std::string MetagameGUI::GetRoundName(int roundNumber) { if (roundNumber < 12) { if (roundNumber == 0) @@ -926,12 +834,6 @@ std::string MetagameGUI::GetRoundName(int roundNumber) { return std::string(numStr); } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: StartNewGame -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Attempts to start a new Metagame using the settings set in the -// New Game dialog box. - bool MetagameGUI::StartNewGame() { // Prepare the UI for the game intro/start UpdatePlayerSetup(); @@ -1118,12 +1020,6 @@ bool MetagameGUI::StartNewGame() { return true; } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: LoadGame -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Attempts to load a Metagame from disk using the settings set in the -// Load Game dialog box. - bool MetagameGUI::LoadGame() { // Get the MetaSave to load from the previously temporarily saved combobox selection if (m_pSelectedGameToLoad) { @@ -1168,12 +1064,6 @@ bool MetagameGUI::LoadGame() { return false; } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: SaveGame -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Attempts to save a Metagame to disk using the settings set in the -// Save Game dialog box. - bool MetagameGUI::SaveGame(std::string saveName, std::string savePath, bool resaveSceneData) { const std::string fullSavePath = g_PresetMan.GetFullModulePath(savePath); // If specified, first load all bitmap data of all Scenes in the current Metagame that have once saved em, so we can re-save them to the new files @@ -1226,12 +1116,6 @@ bool MetagameGUI::SaveGame(std::string saveName, std::string savePath, bool resa return true; } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: SaveGameFromDialog -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Attempts to save a Metagame to disk using the settings set in the -// Save Game dialog box. - bool MetagameGUI::SaveGameFromDialog() { std::string saveName; std::string savePath; @@ -1262,11 +1146,6 @@ bool MetagameGUI::SaveGameFromDialog() { return SaveGame(saveName, savePath, true); } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: Update -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Updates the state of this Menu each frame - void MetagameGUI::Update() { // Update the input controller m_pController->Update(); @@ -1766,11 +1645,6 @@ void MetagameGUI::Update() { m_PrevMousePos = mousePos; } -////////////////////////////////////////////////////////////////////////////////////////// -// Virtual Method: Draw -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Draws the menu - void MetagameGUI::Draw(BITMAP* drawBitmap) { // Don't draw site lines and dots if we're in the menus if (!g_MetaMan.IsSuspended()) { @@ -1903,13 +1777,6 @@ void MetagameGUI::Draw(BITMAP* drawBitmap) { } } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: UpdateInput -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Updates the user input processing. -// Arguments: None. -// Return value: None. - void MetagameGUI::UpdateInput() { // If esc pressed, show campaign dialog if applicable if (g_UInputMan.KeyPressed(SDLK_ESCAPE)) { @@ -2545,11 +2412,6 @@ void MetagameGUI::UpdateInput() { } } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: HideAllScreens -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Hides all menu screens, so one can easily be unhidden and shown only. - void MetagameGUI::HideAllScreens() { for (int iscreen = 0; iscreen < SCREENCOUNT; ++iscreen) { if (m_apScreenBox[iscreen] && iscreen != ROOTBOX) @@ -2584,11 +2446,6 @@ void MetagameGUI::HideAllScreens() { m_ScreenChange = true; } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: KeepBoxOnScreen -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Makes sure a specific box doesn't end up moved completely off-screen. - void MetagameGUI::KeepBoxOnScreen(GUICollectionBox* pBox, int margin) { if (margin < 0) { // Use the dimensions of the box itself to prevent it from at all going outside the screen @@ -2613,12 +2470,6 @@ void MetagameGUI::KeepBoxOnScreen(GUICollectionBox* pBox, int margin) { } } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: CompletedActivity -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Handles what happens after an Activity within the Metagame was -// run and completed fully. - void MetagameGUI::CompletedActivity() { Activity* pDoneActivity = dynamic_cast(g_ActivityMan.GetActivity()); GAScripted* pDoneScriptedActivity = dynamic_cast(g_ActivityMan.GetActivity()); @@ -2750,13 +2601,6 @@ void MetagameGUI::CompletedActivity() { } } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: AutoResolveOffensive -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Automatically resolves an offensive fight without actually launching -// and going through an Activity. Will randomly determine who won and -// what the consequences are. - bool MetagameGUI::AutoResolveOffensive(GAScripted* pOffensive, Scene* pScene, bool brainCheck) { bool changedOwnership = false; const Loadout* pLoadout = 0; @@ -2972,11 +2816,6 @@ bool MetagameGUI::AutoResolveOffensive(GAScripted* pOffensive, Scene* pScene, bo return changedOwnership; } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: UpdateSiteRevealing -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Updates the New Site Revealing animation - void MetagameGUI::UpdateSiteRevealing() { // First set up all the targets we'll be animating into view if (g_MetaMan.m_StateChanged) { @@ -3055,11 +2894,6 @@ void MetagameGUI::UpdateSiteRevealing() { } } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: UpdateSiteChangeAnim -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Updates team ownership change animations, if any. - void MetagameGUI::UpdateSiteChangeAnim() { // Continue animating the existing markers double animInterval = 600; @@ -3087,11 +2921,6 @@ void MetagameGUI::UpdateSiteChangeAnim() { } } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: UpdateIncomeCounting -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Updates the Count Income animation - void MetagameGUI::UpdateIncomeCounting(bool initOverride) { // First set up all the site lines we should be animating into view if (g_MetaMan.m_StateChanged || initOverride) { @@ -3516,11 +3345,6 @@ void MetagameGUI::UpdateIncomeCounting(bool initOverride) { } } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: UpdateHumanPlayerTurn -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Updates a human player's turn - void MetagameGUI::UpdateHumanPlayerTurn(int metaPlayer) { // In-game player - IMPORTANT to pass this to the Scenes, and not the metaplayer int player = g_MetaMan.m_Players[metaPlayer].GetInGamePlayer(); @@ -3554,11 +3378,6 @@ void MetagameGUI::UpdateHumanPlayerTurn(int metaPlayer) { } } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: UpdateBaseBuilding -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Updates the Base Building animation - void MetagameGUI::UpdateBaseBuilding() { m_pPhaseLabel->SetText("Building Bases"); @@ -3804,12 +3623,6 @@ void MetagameGUI::UpdateBaseBuilding() { } } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: SetupOffensives -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Sets up the Activities that represent all the offensive actions of -// the teams this round. - void MetagameGUI::SetupOffensives() { // Clear out the old ones, if any g_MetaMan.ClearActivities(); @@ -3897,11 +3710,6 @@ void MetagameGUI::SetupOffensives() { */ } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: UpdateOffensives -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Updates the offensive actions animation - void MetagameGUI::UpdateOffensives() { char str[256]; @@ -4562,11 +4370,6 @@ void MetagameGUI::UpdateOffensives() { } } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: FinalizeOffensive -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Finishes one battle in the UpdateOffensives and moves onto the next. - bool MetagameGUI::FinalizeOffensive() { // No Offensives this round? then skip all this business if (g_MetaMan.m_RoundOffensives.empty() || g_MetaMan.m_CurrentOffensive < 0 || g_MetaMan.m_CurrentOffensive >= g_MetaMan.m_RoundOffensives.size() || !m_pAnimScene) { @@ -4636,11 +4439,6 @@ bool MetagameGUI::FinalizeOffensive() { return true; } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: ResetBattleInfo -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Hides and resets all battle info labels and panels - void MetagameGUI::ResetBattleInfo() { int mp = 0; for (std::vector::iterator mpItr = g_MetaMan.m_Players.begin(); mpItr != g_MetaMan.m_Players.end(); ++mpItr) { @@ -4663,12 +4461,6 @@ void MetagameGUI::ResetBattleInfo() { m_PostBattleReview = false; } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: UpdateBattleQuads -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Updates which player get placed in which quad around a fought-over -// site. - void MetagameGUI::UpdateBattleQuads(Vector targetPos) { // Start with a clean slate for (int q = Players::PlayerOne; q < Players::MaxPlayerCount; ++q) @@ -4702,12 +4494,6 @@ void MetagameGUI::UpdateBattleQuads(Vector targetPos) { } } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: UpdatePreBattleAttackers -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Updates the animation and display of the info for the current -// offensive battle being next in line for this round. - void MetagameGUI::UpdatePreBattleAttackers(float progress) { // Sanity check that we have any offensive battle activity and scene to display around if (g_MetaMan.m_CurrentOffensive >= g_MetaMan.m_RoundOffensives.size() || @@ -4843,12 +4629,6 @@ void MetagameGUI::UpdatePreBattleAttackers(float progress) { } } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: UpdatePreBattleDefenders -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Updates the animation and display of the info for the current -// offensive battle's defenders being next in line for this round. - void MetagameGUI::UpdatePreBattleDefenders(float progress) { // Sanity check that we have any offensive battle activity and scene to display around if (g_MetaMan.m_CurrentOffensive >= g_MetaMan.m_RoundOffensives.size() || @@ -4972,12 +4752,6 @@ void MetagameGUI::UpdatePreBattleDefenders(float progress) { } } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: UpdatePostBattleRetreaters -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Updates the animation and display of the info for the current -// offensive battle's retreating brains going back to their pools - void MetagameGUI::UpdatePostBattleRetreaters(float progress) { // Sanity check that we have any offensive battle activity and scene to display around if (g_MetaMan.m_CurrentOffensive >= g_MetaMan.m_RoundOffensives.size() || @@ -5114,12 +4888,6 @@ void MetagameGUI::UpdatePostBattleRetreaters(float progress) { } } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: UpdatePostBattleResidents -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Updates the animation and display of the info for the current done -// offensive battle's winning brains going back into the site. - void MetagameGUI::UpdatePostBattleResidents(float progress) { // Sanity check that we have any offensive battle activity and scene to display around if (g_MetaMan.m_CurrentOffensive >= g_MetaMan.m_RoundOffensives.size() || @@ -5325,12 +5093,6 @@ void MetagameGUI::UpdatePostBattleResidents(float progress) { } } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: UpdatePlayerActionLines -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Updates the action lines as per what the player has chosen to do -// during the current turn so far. - float MetagameGUI::UpdatePlayerActionLines(int metaPlayer) //, bool addUnallocated) { // Make sure we're in a player turn phase @@ -5373,11 +5135,6 @@ float MetagameGUI::UpdatePlayerActionLines(int metaPlayer) //, bool addUnallocat return meterStart; } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: UpdateScenesBox -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Updates the contents of the scene selection box. - void MetagameGUI::UpdateScenesBox(bool sceneChanged) { // Always show the info box if something is selected if (m_pSelectedScene && !g_MetaMan.IsSuspended()) { @@ -5559,11 +5316,6 @@ void MetagameGUI::UpdateScenesBox(bool sceneChanged) { } } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: UpdateAISkillSliders -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Updates AI skill sliders and labels for all players. - void MetagameGUI::UpdateAISkillSliders(int player) { if (player >= Players::PlayerOne && player < Players::MaxPlayerCount) { m_apPlayerAISkillLabel[player]->SetText(Activity::GetAISkillString(m_apPlayerAISkillSlider[player]->GetValue())); @@ -5577,11 +5329,6 @@ void MetagameGUI::UpdateAISkillSliders(int player) { } } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: UpdateGameSizeLabels -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Updates the game size label of the new game dialog - void MetagameGUI::UpdateGameSizeLabels() { // How many players do we have set to go int playerCount = 0; @@ -5630,11 +5377,6 @@ void MetagameGUI::UpdateGameSizeLabels() { m_pDifficultyLabel->SetText("Difficulty: Nuts!"); } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: UpdatePlayerSetup -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Updates the player setup controls of the new game dialog - void MetagameGUI::UpdatePlayerSetup() { int humanPlayers = 0; int totalPlayers = 0; @@ -5705,11 +5447,6 @@ void MetagameGUI::UpdatePlayerSetup() { UpdateGameSizeLabels(); } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: UpdatePlayerBars -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Updates the floating player bars with current funds, flag, etc. - void MetagameGUI::UpdatePlayerBars() { if (g_MetaMan.m_GameState >= MetaMan::NOGAME && g_MetaMan.m_GameState <= MetaMan::ENDROUND && !g_MetaMan.IsSuspended()) { int metaPlayer = 0; @@ -5830,11 +5567,6 @@ void MetagameGUI::UpdatePlayerBars() { } } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: UpdateSiteHoverLabel -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Updates the floating label over a planet site. - void MetagameGUI::UpdateSiteNameLabel(bool visible, std::string text, const Vector& location, float height) { // Set up the hover label to appear over any hovered scene location m_pScenePlanetLabel->SetVisible(visible); @@ -5858,11 +5590,6 @@ void MetagameGUI::UpdateSiteNameLabel(bool visible, std::string text, const Vect } } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: PlayerTextIndication -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Starts an animation of a label showing a text string over a player bar - void MetagameGUI::PlayerTextIndication(int metaPlayer, std::string text, const Vector& screenPos, double animLengthMS) { m_apFundsChangeLabel[metaPlayer]->SetText(text); m_apFundsChangeLabel[metaPlayer]->SetHAlignment(GUIFont::Centre); @@ -5877,11 +5604,6 @@ void MetagameGUI::PlayerTextIndication(int metaPlayer, std::string text, const V m_apFundsChangeTimer[metaPlayer].SetRealTimeLimitMS(animLengthMS); } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: FundsChangeIndication -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Starts an animation of a label showing funds changing for a player - void MetagameGUI::FundsChangeIndication(int metaPlayer, float change, const Vector& screenPos, double animLengthMS) { char str[256]; std::snprintf(str, sizeof(str), change >= 1.0 ? "%c +%.0f oz" : (change <= -1.0 ? "%c %.0f oz" : "%c %.0f oz"), -58, change); @@ -5898,11 +5620,6 @@ void MetagameGUI::FundsChangeIndication(int metaPlayer, float change, const Vect m_apFundsChangeTimer[metaPlayer].SetRealTimeLimitMS(animLengthMS); } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: BrainsChangeIndication -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Starts an animation of a label showing brains changing for a metaPlayer - void MetagameGUI::BrainsChangeIndication(int metaPlayer, int change, const Vector& screenPos, int fontAlignment, double animLengthMS) { char str[256]; // [Brain Icon] [X] Number @@ -5922,11 +5639,6 @@ void MetagameGUI::BrainsChangeIndication(int metaPlayer, int change, const Vecto m_apBrainsChangeTimer[metaPlayer].SetRealTimeLimitMS(animLengthMS); } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: RemoveSiteLine -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Removes a specific index siteline out of a vector. - bool MetagameGUI::RemoveSiteLine(std::vector& lineList, int removeIndex) { if (lineList.empty()) return false; @@ -5942,11 +5654,6 @@ bool MetagameGUI::RemoveSiteLine(std::vector& lineList, int removeInde return removed; } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: GetPlayerLineFunds -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Gets the total funds of all visible lines of a specific player. - float MetagameGUI::GetPlayerLineFunds(std::vector& lineList, int metaPlayer, bool onlyVisible) { if (metaPlayer < Players::PlayerOne || metaPlayer >= g_MetaMan.m_Players.size()) return 0; @@ -5960,12 +5667,6 @@ float MetagameGUI::GetPlayerLineFunds(std::vector& lineList, int metaP return totalFunds; } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: UpdatePlayerLineRatios -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Updates the site line meter ratios of a player based on their fund -// amounts and visibilty. - void MetagameGUI::UpdatePlayerLineRatios(std::vector& lineList, int metaPlayer, bool onlyVisible, float total) { if (metaPlayer < Players::PlayerOne || metaPlayer >= g_MetaMan.m_Players.size()) return; @@ -5984,12 +5685,6 @@ void MetagameGUI::UpdatePlayerLineRatios(std::vector& lineList, int me } } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: DrawGlowLine -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Draws a fancy thick flickering line to point out scene points on the -// planet. - void MetagameGUI::DrawGlowLine(BITMAP* drawBitmap, const Vector& start, const Vector& end, int color) { int blendAmount = 210 + RandomNum(-15, 15); set_screen_blender(blendAmount, blendAmount, blendAmount, blendAmount); @@ -6015,12 +5710,6 @@ void MetagameGUI::DrawGlowLine(BITMAP* drawBitmap, const Vector& start, const Ve line(drawBitmap, start.m_X, start.m_Y - 1, end.m_X, end.m_Y - 1, color); } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: DrawScreenLineToSitePoint -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Draws a fancy thick flickering lines to point out scene points on the -// planet, FROM an arbitrary screen point. - bool MetagameGUI::DrawScreenLineToSitePoint(BITMAP* drawBitmap, const Vector& screenPoint, const Vector& planetPoint, @@ -6136,12 +5825,6 @@ bool MetagameGUI::DrawScreenLineToSitePoint(BITMAP* drawBitmap, return totalSegments <= onlyFirstSegments && totalSegments <= onlyLastSegments; } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: DrawPlayerLineToSitePoint -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Draws a fancy thick flickering lines to point out scene points on the -// planet, FROM a floating player bar, showing a certain ratio. - bool MetagameGUI::DrawPlayerLineToSitePoint(BITMAP* drawBitmap, int metaPlayer, float startMeterAt, diff --git a/Source/Menus/MetagameGUI.h b/Source/Menus/MetagameGUI.h index a994a39ec6..4b2c8e8f2e 100644 --- a/Source/Menus/MetagameGUI.h +++ b/Source/Menus/MetagameGUI.h @@ -1,18 +1,11 @@ #ifndef _METAGAMEGUI_ #define _METAGAMEGUI_ -////////////////////////////////////////////////////////////////////////////////////////// -// File: MetagameGUI.h -////////////////////////////////////////////////////////////////////////////////////////// -// Description: MetagameGUI class -// Project: Retro Terrain Engine -// Author(s): Daniel Tabar -// dtabar@datarealms.com -// http://www.datarealms.com - -////////////////////////////////////////////////////////////////////////////////////////// -// Inclusions of header files - +/// MetagameGUI class +/// @author Daniel Tabar +/// dtabar@datarealms.com +/// http://www.datarealms.com +/// Inclusions of header files #include "ActivityMan.h" #include "Timer.h" #include "GUIBanner.h" @@ -39,18 +32,10 @@ namespace RTE { class Activity; class GAScripted; - ////////////////////////////////////////////////////////////////////////////////////////// - // Class: MetagameGUI - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: A full menu system that represents the metagame GUI for Cortex Command - // Parent(s): Serializable. - // Class history: 8/22/2008 MetagameGUI Created. - + /// A full menu system that represents the metagame GUI for Cortex Command class MetagameGUI : public Serializable { - ////////////////////////////////////////////////////////////////////////////////////////// - // Public member variable, method and friend function declarations - + /// Public member variable, method and friend function declarations SerializableClassNameGetter SerializableOverrideMethods @@ -154,679 +139,348 @@ namespace RTE { m_AnimTimer.Reset(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Draw - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws this SiteTarget onto a bitmap of choice. - // Arguments: The bitmap to draw to. - // Return value: None. - + /// Draws this SiteTarget onto a bitmap of choice. + /// @param drawBitmap The bitmap to draw to. void Draw(BITMAP* drawBitmap) const; }; - ////////////////////////////////////////////////////////////////////////////////////////// - // Constructor: MetagameGUI - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Constructor method used to instantiate a MetagameGUI object in system - // memory. Create() should be called before using the object. - // Arguments: None. - + /// Constructor method used to instantiate a MetagameGUI object in system + /// memory. Create() should be called before using the object. MetagameGUI() { Clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Destructor: ~MetagameGUI - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destructor method used to clean up a MetagameGUI object before deletion - // from system memory. - // Arguments: None. - + /// Destructor method used to clean up a MetagameGUI object before deletion + /// from system memory. ~MetagameGUI() { Destroy(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes the MetagameGUI object ready for use. - // Arguments: A poitner to a Controller which will control this Menu. Ownership is - // NOT TRANSFERRED! - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Makes the MetagameGUI object ready for use. + /// @param pController A poitner to a Controller which will control this Menu. Ownership is + /// NOT TRANSFERRED! + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Create(Controller* pController); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Reset - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Resets the entire MetagameGUI, including its inherited members, to - // their default settings or values. - // Arguments: None. - // Return value: None. - + /// Resets the entire MetagameGUI, including its inherited members, to + /// their default settings or values. void Reset() override { Clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destroys and resets (through Clear()) the MetagameGUI object. - // Arguments: None. - // Return value: None. - + /// Destroys and resets (through Clear()) the MetagameGUI object. void Destroy(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetGUIControlManager - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the GUIControlManager owned and used by this. - // Arguments: None. - // Return value: The GUIControlManager. Ownership is not transferred! - + /// Gets the GUIControlManager owned and used by this. + /// @return The GUIControlManager. Ownership is not transferred! GUIControlManager* GetGUIControlManager(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetEnabled - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Enables or disables the menu. This will animate it in and out of view. - // Arguments: Whether to enable or disable the menu. - // Return value: None. - + /// Enables or disables the menu. This will animate it in and out of view. + /// @param enable Whether to enable or disable the menu. (default: true) void SetEnabled(bool enable = true); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: IsEnabled - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Reports whether the menu is enabled or not. - // Arguments: None. - // Return value: None. - + /// Reports whether the menu is enabled or not. bool IsEnabled() { return m_MenuEnabled == ENABLED || m_MenuEnabled == ENABLING; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SwitchToScreen - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Switches to showing a specific menu screen/mode. - // Arguments: The MenuScreen to switch to. - // Return value: None. - + /// Switches to showing a specific menu screen/mode. + /// @param newScreen The MenuScreen to switch to. void SwitchToScreen(int newScreen); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetRoundName - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes a round number into a nice friendly text string. "ONE" for 1 etc - // Arguments: The number of the round to convert to a string. - // Return value: The friendly text string for that round. - + /// Makes a round number into a nice friendly text string. "ONE" for 1 etc + /// @param roundNumber The number of the round to convert to a string. + /// @return The friendly text string for that round. std::string GetRoundName(int roundNumber); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetPlanetInfo - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets where the planet is on the scren and its other data so the menu - // can overlay properly on it. - // Arguments: The absolute screen coordinates of the planet's center. - // The radius, in screen pixel units, of the planet. - // Return value: None. - + /// Sets where the planet is on the scren and its other data so the menu + /// can overlay properly on it. + /// @param center The absolute screen coordinates of the planet's center. + /// @param radius The radius, in screen pixel units, of the planet. void SetPlanetInfo(const Vector& center, float radius) { m_PlanetCenter = center; m_PlanetRadius = radius; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SelectScene - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets a specific scene as the currently selected one. OWNERSHIP IS NOT TRANSFERRED! - // Arguments: The Scene to set as selected. Ownership is NOT transferred. - // Return value: None. - + /// Sets a specific scene as the currently selected one. OWNERSHIP IS NOT TRANSFERRED! + /// @param pScene The Scene to set as selected. Ownership is NOT transferred. void SelectScene(Scene* pScene); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SelectScene - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Tries to select a specifically named scene on the metagame field. - // Arguments: The name of the Scene to try to find and select. - // Return value: Whether mission was found and selected. - + /// Tries to select a specifically named scene on the metagame field. + /// @param sceneName The name of the Scene to try to find and select. + /// @return Whether mission was found and selected. bool SelectScene(std::string sceneName); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ContinuePhase - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Reports whether the player has decided to continue to next phase of the - // round of the current game. - // Arguments: None. - // Return value: Whether the player just decided to continue this frame - + /// Reports whether the player has decided to continue to next phase of the + /// round of the current game. + /// @return Whether the player just decided to continue this frame bool ContinuePhase() { return m_ContinuePhase; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ActivityRestarted - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Reports whether the player has decided to restart an activity this frame. - // All parameters for the new game has been fed into ActivityMan already. - // Arguments: None. - // Return value: Whether the activity should be restarted. - + /// Reports whether the player has decided to restart an activity this frame. + /// All parameters for the new game has been fed into ActivityMan already. + /// @return Whether the activity should be restarted. bool ActivityRestarted() { return m_ActivityRestarted; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ActivityResumed - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Reports whether the player has decided to resume the current activity. - // Arguments: None. - // Return value: Whether the activity should be resumed. - + /// Reports whether the player has decided to resume the current activity. + /// @return Whether the activity should be resumed. bool ActivityResumed() { return m_ActivityResumed; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: BackToMain - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Reports whether the player has decided to go back to the main menu. - // Arguments: None. - // Return value: Whether we should go back to main menu. - + /// Reports whether the player has decided to go back to the main menu. + /// @return Whether we should go back to main menu. bool BackToMain() { return m_BackToMain; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: QuitProgram - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Reports whether the player has decided to quit the program. - // Arguments: None. - // Return value: Whether the program has been commanded to shit down by the user. - + /// Reports whether the player has decided to quit the program. + /// @return Whether the program has been commanded to shit down by the user. bool QuitProgram() { return m_Quit; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: StartNewGame - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Attempts to start a new Metagame using the settings set in the - // New Game dialog box. - // Arguments: None. - // Return value: Whether the game was able to be set up with the current settings. - + /// Attempts to start a new Metagame using the settings set in the + /// New Game dialog box. + /// @return Whether the game was able to be set up with the current settings. bool StartNewGame(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: LoadGame - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Attempts to load a Metagame from disk using the settings set in the - // Load Game dialog box. - // Arguments: None. - // Return value: Whether the game was able to be loaded with the current settings. - + /// Attempts to load a Metagame from disk using the settings set in the + /// Load Game dialog box. + /// @return Whether the game was able to be loaded with the current settings. bool LoadGame(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SaveGame - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Just saves out the MetaGame and all its Scene data as-is to a specific - // location. - // Arguments: The name of the save game to create or overwrite here. - // The full path of the ini that we want to save the Metagame state to. - // Whether to load all the scene data that is on disk first so it will - // be re-saved to the new location here. - // Return value: Whether the game was able to be saved there. - + /// Just saves out the MetaGame and all its Scene data as-is to a specific + /// location. + /// @param saveName The name of the save game to create or overwrite here. + /// @param savePath The full path of the ini that we want to save the Metagame state to. + /// @param resaveSceneData Whether to load all the scene data that is on disk first so it will (default: false) + /// be re-saved to the new location here. + /// @return Whether the game was able to be saved there. bool SaveGame(std::string saveName, std::string savePath, bool resaveSceneData = false); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SaveGameFromDialog - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Attempts to save a Metagame to disk using the settings set in the - // Save Game dialog box. - // Arguments: None. - // Return value: Whether the game was able to be saved with the current settings. - + /// Attempts to save a Metagame to disk using the settings set in the + /// Save Game dialog box. + /// @return Whether the game was able to be saved with the current settings. bool SaveGameFromDialog(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Update - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the state of this Menu each frame - // Arguments: None. - // Return value: None. - + /// Updates the state of this Menu each frame void Update(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Draw - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws the menu - // Arguments: The bitmap to draw on. - // Return value: None. - + /// Draws the menu + /// @param drawBitmap The bitmap to draw on. void Draw(BITMAP* drawBitmap); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetToStartNewGame - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Resets internal state of GUI to show 'Start new campaign' screen - // Arguments: None. - // Return value: None. + /// Method: SetToStartNewGame + /// Resets internal state of GUI to show 'Start new campaign' screen void SetToStartNewGame(); - /// /// Sets where the station is located on the planet orbit. - /// - /// The position of the station on the planet orbit. + /// @param newStationPos The position of the station on the planet orbit. void SetStationOrbitPos(const Vector& newStationPos) { m_StationPosOnOrbit = newStationPos; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Protected member variable and method declarations - + /// Protected member variable and method declarations protected: - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes the MetaMan object ready for use -> this is acutally a light - // and not complete version of the one that takes a controller. - // It is only for init after reading stuff from file as a Serializable. - // Arguments: None. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Makes the MetaMan object ready for use -> this is acutally a light + /// and not complete version of the one that takes a controller. + /// It is only for init after reading stuff from file as a Serializable. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Create() override; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: UpdateInput - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the user input processing. - // Arguments: None. - // Return value: None. - + /// Updates the user input processing. void UpdateInput(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: HideAllScreens - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Hides all menu screens, so one can easily be unhidden and shown only. - // Arguments: None. - // Return value: None. - + /// Hides all menu screens, so one can easily be unhidden and shown only. void HideAllScreens(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: KeepBoxOnScreen - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes sure a specific box doesn't end up moved completely off-screen. - // Arguments: The GUICollectionBox to adjust, if necessary. - // The amount of margin to allow the box to stay within. If negative, - // the width/height of the box itself are used. - // Return value: None. - + /// Makes sure a specific box doesn't end up moved completely off-screen. + /// @param pBox The GUICollectionBox to adjust, if necessary. + /// @param margin The amount of margin to allow the box to stay within. If negative, (default: 10) + /// the width/height of the box itself are used. void KeepBoxOnScreen(GUICollectionBox* pBox, int margin = 10); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ChangeAnimMode - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Changes the animation mode - // Arguments: None. - // Return value: None. - + /// Changes the animation mode void ChangeAnimMode(int newMode) { m_AnimMode = newMode; m_AnimModeChange = true; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: NewAnimMode - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Checks for and switches off the new animation mode flag - // Arguments: None. - // Return value: None. - + /// Checks for and switches off the new animation mode flag bool NewAnimMode() { bool changed = m_AnimModeChange; m_AnimModeChange = false; return changed; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: CompletedActivity - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Handles what happens after an Activity within the Metagame was - // run and completed fully. - // Arguments: None. - // Return value: None. - + /// Handles what happens after an Activity within the Metagame was + /// run and completed fully. void CompletedActivity(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: AutoResolveOffensive - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Automatically resolves an offensive fight without actually launching - // and going through an Activity. Will randomly determine who won and - // what the consequences are. - // Arguments: The Offsenive Activity to resolve and manipulate accordingly. OWNERSHIP IS NOT TRANSFERRED! - // The Scene this Offensive is supposed to take place on. OWNERSHIP IS NOT TRANSFERRED! - // Whether to check the validity of all players based on whether they - // have brains remaining alive. If false, all active players will be - // instead be flagged as having had brains at some point. - // Return value: Whether the ownership of the relevant Scene changed due to this. - + /// Automatically resolves an offensive fight without actually launching + /// and going through an Activity. Will randomly determine who won and + /// what the consequences are. + /// @param pOffensive The Offsenive Activity to resolve and manipulate accordingly. OWNERSHIP IS NOT TRANSFERRED! + /// @param pScene The Scene this Offensive is supposed to take place on. OWNERSHIP IS NOT TRANSFERRED! + /// @param brainCheck Whether to check the validity of all players based on whether they (default: false) + /// have brains remaining alive. If false, all active players will be + /// instead be flagged as having had brains at some point. + /// @return Whether the ownership of the relevant Scene changed due to this. bool AutoResolveOffensive(GAScripted* pOffensive, Scene* pScene, bool brainCheck = false); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: UpdateSiteRevealing - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the New Site Revealing animation - // Arguments: None. - // Return value: None. - + /// Updates the New Site Revealing animation void UpdateSiteRevealing(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: UpdateSiteChangeAnim - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates team ownership change animations, if any. - // Arguments: None. - // Return value: None. - + /// Updates team ownership change animations, if any. void UpdateSiteChangeAnim(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: UpdateIncomeCounting - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the Count Income animation - // Arguments: Whether to just set up the lines and funds as if we had a new round. Also skips changing funds to avoid an income/cost duplication glitch when saving a game at the start of a round. - // Return value: None. - + /// Updates the Count Income animation + /// @param initOverride Whether to just set up the lines and funds as if we had a new round. Also skips changing funds to avoid an income/cost duplication glitch when saving a game at the start of a round. (default: false) void UpdateIncomeCounting(bool initOverride = false); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: UpdateHumanPlayerTurn - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates a human player's turn. - // Arguments: Which metaplayer' turn it is - // Return value: None. - + /// Updates a human player's turn. + /// @param metaPlayer Which metaplayer' turn it is void UpdateHumanPlayerTurn(int metaPlayer); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: UpdateBaseBuilding - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the Base Building animation - // Arguments: None. - // Return value: None. - + /// Updates the Base Building animation void UpdateBaseBuilding(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetupOffensives - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets up the Activities that represent all the offensive actions of - // the teams this round. - // Arguments: None. - // Return value: None. - + /// Sets up the Activities that represent all the offensive actions of + /// the teams this round. void SetupOffensives(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: UpdateOffensives - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the offensive actions animation - // Arguments: None. - // Return value: None. - + /// Updates the offensive actions animation void UpdateOffensives(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: FinalizeOffensive - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Finishes one battle in the UpdateOffensives and moves onto the next. - // Arguments: None. - // Return value: If there are any more battles after the one that was just finalized. - + /// Finishes one battle in the UpdateOffensives and moves onto the next. + /// @return If there are any more battles after the one that was just finalized. bool FinalizeOffensive(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: ResetBattleInfo - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Hides and resets all battle info labels and panels - // Arguments: None. - // Return value: None. - + /// Hides and resets all battle info labels and panels void ResetBattleInfo(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: UpdateBattleQuads - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates which player get placed in which quad around a fought-over - // site. - // Arguments: The absolutel screen position of the target site. - // Return value: None. - + /// Updates which player get placed in which quad around a fought-over + /// site. + /// @param targetPos The absolutel screen position of the target site. void UpdateBattleQuads(Vector targetPos); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: UpdatePreBattleAttackers - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the animation and display of the info for the current - // offensive battle's attackers being next in line for this round. - // Arguments: The normalized scalar which will set the desired progress of the - // total animation. 0 means nothing is shown, because it is at the start - // of the animation where brain icons start moving around. - // Return value: None. - + /// Updates the animation and display of the info for the current + /// offensive battle's attackers being next in line for this round. + /// @param progress The normalized scalar which will set the desired progress of the + /// total animation. 0 means nothing is shown, because it is at the start + /// of the animation where brain icons start moving around. void UpdatePreBattleAttackers(float progress); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: UpdatePreBattleDefenders - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the animation and display of the info for the current - // offensive battle's defenders being next in line for this round. - // Arguments: The normalized scalar which will set the desired progress of the - // total animation. 0 means nothing is shown, because it is at the start - // of the animation where brain icons start moving around. - // Return value: None. - + /// Updates the animation and display of the info for the current + /// offensive battle's defenders being next in line for this round. + /// @param progress The normalized scalar which will set the desired progress of the + /// total animation. 0 means nothing is shown, because it is at the start + /// of the animation where brain icons start moving around. void UpdatePreBattleDefenders(float progress); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: UpdatePostBattleRetreaters - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the animation and display of the info for the current - // offensive battle's retreating brains going back to their pools - // Arguments: The normalized scalar which will set the desired progress of the - // total animation. 0 means nothing has happened, because it is at the - // start of the animation where brain icons start moving around. - // Return value: None. - + /// Updates the animation and display of the info for the current + /// offensive battle's retreating brains going back to their pools + /// @param progress The normalized scalar which will set the desired progress of the + /// total animation. 0 means nothing has happened, because it is at the + /// start of the animation where brain icons start moving around. void UpdatePostBattleRetreaters(float progress); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: UpdatePostBattleResidents - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the animation and display of the info for the current done - // offensive battle's winning brains going back into the site. - // Arguments: The normalized scalar which will set the desired progress of the - // total animation. 0 means nothing has happened, because it is at the - // start of the animation where brain icons start moving around. - // Return value: None. - + /// Updates the animation and display of the info for the current done + /// offensive battle's winning brains going back into the site. + /// @param progress The normalized scalar which will set the desired progress of the + /// total animation. 0 means nothing has happened, because it is at the + /// start of the animation where brain icons start moving around. void UpdatePostBattleResidents(float progress); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: UpdatePlayerActionLines - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the action lines as per what the player has chosen to do - // during the current turn so far. - // Arguments: The metaplayer we want to update the lines for. - // Also add a line for the unallocated funds the player hasn't used for - // anyhting else yet. - NOPE, NOT IMPL YET - // Return value: The meter start that remains after all the lines are added. - + /// Updates the action lines as per what the player has chosen to do + /// during the current turn so far. + /// @param player The metaplayer we want to update the lines for. + /// Also add a line for the unallocated funds the player hasn't used for + /// anyhting else yet. - NOPE, NOT IMPL YET + /// @return The meter start that remains after all the lines are added. float UpdatePlayerActionLines(int player); //, bool addUnallocated = false); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: UpdateScenesBox - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the contents of the scene selection box. - // Arguments: Whether the selected has changed and should refresh the box completely. - // Return value: None. - + /// Updates the contents of the scene selection box. + /// @param sceneChanged Whether the selected has changed and should refresh the box completely. (default: false) void UpdateScenesBox(bool sceneChanged = false); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: UpdateGameSizeLabels - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the game size labels of the new game dialog - // Arguments: None. - // Return value: None. - + /// Updates the game size labels of the new game dialog void UpdateGameSizeLabels(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: UpdateAISkillSliders - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates AI skill sliders and labels for all players. - // Arguments: Which player's slider was changed. - // Return value: None. - + /// Updates AI skill sliders and labels for all players. + /// @param player Which player's slider was changed. void UpdateAISkillSliders(int player); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: UpdatePlayerSetup - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the player setup controls of the new game dialog - // Arguments: None. - // Return value: None. - + /// Updates the player setup controls of the new game dialog void UpdatePlayerSetup(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: UpdatePlayerBars - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the floating player bars with current funds, flag, etc. - // Arguments: None. - // Return value: None. - + /// Updates the floating player bars with current funds, flag, etc. void UpdatePlayerBars(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: UpdateSiteHoverLabel - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the floating label over a planet site. - // Arguments: Label is visible. - // Text to show above the location. - // The location in planetary coords. - // How high above the location to show the text, adjustment from a good default. - // Return value: None. - + /// Updates the floating label over a planet site. + /// @param visible Label is visible. + /// @param text Text to show above the location. (default: "") + /// @param location The location in planetary coords. (default: Vector()) + /// @param height How high above the location to show the text, adjustment from a good default. (default: 1.0) void UpdateSiteNameLabel(bool visible, std::string text = "", const Vector& location = Vector(), float height = 1.0); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: PlayerTextIndication - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Starts an animation of a label showing a text string over a player bar - // Arguments: Which player the indication is relevant to - // The string to display. - // Where, in screen coords the change should be indicated. The CENTER of - // the floating label will line up with this pos. - // How long, in MS, that the animation should linger - // Return value: None. - + /// Starts an animation of a label showing a text string over a player bar + /// @param player Which player the indication is relevant to + /// @param text The string to display. + /// @param screenPos Where, in screen coords the change should be indicated. The CENTER of + /// the floating label will line up with this pos. + /// @param animLengthMS How long, in MS, that the animation should linger void PlayerTextIndication(int player, std::string text, const Vector& screenPos, double animLengthMS); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: FundsChangeIndication - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Starts an animation of a label showing funds changing for a player - // Arguments: Which player the change is relevant to - // The change in funds to display. - // Where, in screen coords the change should be indicated. The RIGHTMOST - // UPPER CORNER of the floating label will line up with this pos. - // How long, in MS, that the animation should linger - // Return value: None. - + /// Starts an animation of a label showing funds changing for a player + /// @param player Which player the change is relevant to + /// @param change The change in funds to display. + /// @param screenPos Where, in screen coords the change should be indicated. The RIGHTMOST + /// @param animLengthMS UPPER CORNER of the floating label will line up with this pos. + /// How long, in MS, that the animation should linger void FundsChangeIndication(int player, float change, const Vector& screenPos, double animLengthMS); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: BrainsChangeIndication - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Starts an animation of a label showing brains changing for a player - // Arguments: Which player the change is relevant to - // The change in brains to display. - // Where, in screen coords the change should be indicated. The LEFTMOST - // UPPER CORNER of the floating label will line up with this pos. - // How long, in MS, that the animation should linger - // The horizontal font alignment of the change. - // Return value: None. - + /// Starts an animation of a label showing brains changing for a player + /// @param player Which player the change is relevant to + /// @param change The change in brains to display. + /// @param screenPos Where, in screen coords the change should be indicated. The LEFTMOST + /// @param fontAlignment UPPER CORNER of the floating label will line up with this pos. + /// @param animLengthMS How long, in MS, that the animation should linger + /// The horizontal font alignment of the change. void BrainsChangeIndication(int player, int change, const Vector& screenPos, int fontAlignment, double animLengthMS); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: IsSiteLineVisible - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Tells whether a SiteLine can be considered visible. - // Arguments: The SiteLine to check. - // Return value: Whether visible. - + /// Tells whether a SiteLine can be considered visible. + /// @param sl The SiteLine to check. + /// @return Whether visible. bool IsSiteLineVisible(SiteLine& sl) { return sl.m_OnlyFirstSegments != 0 && sl.m_OnlyLastSegments != 0; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: RemoveSiteLine - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Removes a specific index siteline out of a vector. - // Arguments: The vector of SiteLine:s to remove from. - // The index of the siteline to remove - // Return value: Whether the line was removed or not. - + /// Removes a specific index siteline out of a vector. + /// @param lineList The vector of SiteLine:s to remove from. + /// @param removeIndex The index of the siteline to remove + /// @return Whether the line was removed or not. bool RemoveSiteLine(std::vector& lineList, int removeIndex); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetPlayerLineFunds - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the total funds of all visible lines of a specific player. - // Arguments: A vector with SiteLine:s which may contain other players' lines too. - // Which player's lines to check for. - // Only count the funds of visible lines. - // Return value: The total funds, in oz. - + /// Gets the total funds of all visible lines of a specific player. + /// @param lineList A vector with SiteLine:s which may contain other players' lines too. + /// @param player Which player's lines to check for. + /// @param onlyVisible Only count the funds of visible lines. (default: true) + /// @return The total funds, in oz. float GetPlayerLineFunds(std::vector& lineList, int player, bool onlyVisible = true); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: UpdatePlayerLineRatios - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the site line meter ratios of a player based on their fund - // amounts and visibilty. - // Arguments: A vector with SiteLine:s which may contain other players' lines too. - // Which player's lines to update. - // Whetehr to only care about visible lines. - // The total funds to be calculating the ratios against. If negative, - // the total line amounts is what will be used. - // Return value: None. - + /// Updates the site line meter ratios of a player based on their fund + /// amounts and visibilty. + /// @param lineList A vector with SiteLine:s which may contain other players' lines too. + /// @param player Which player's lines to update. + /// @param onlyVisible Whetehr to only care about visible lines. (default: true) + /// @param total The total funds to be calculating the ratios against. If negative, (default: -1) + /// the total line amounts is what will be used. void UpdatePlayerLineRatios(std::vector& lineList, int player, bool onlyVisible = true, float total = -1); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: DrawGlowLine - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws a fancy thick flickering line to point out scene points on the - // planet. - // Arguments: The bitmap to draw to. - // The start and end Vector:s for the line, in absolute screen coordinates. - // The color to draw the line in. Use makecol(r, g, b) to create the color - // Return value: None. - + /// Draws a fancy thick flickering line to point out scene points on the + /// planet. + /// @param drawBitmap The bitmap to draw to. + /// @param start The start and end Vector:s for the line, in absolute screen coordinates. + /// @param end The color to draw the line in. Use makecol(r, g, b) to create the color static void DrawGlowLine(BITMAP* drawBitmap, const Vector& start, const Vector& end, int color); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: DrawScreenLineToSitePoint - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws a fancy thick flickering lines to point out scene points on the - // planet, FROM an arbitrary screen point. - // Arguments: The bitmap to draw to. - // The point on the screen to point from, in screen coordinates. - // The point on the planet to point at, in planet coordinates. - // The color of the line. - // How many of the segments from the start (the start of the line) to draw. - // How many of the segments from the end (site circle) to draw. -1 is all. - // The height of the 'channel' above and below that the lines will go around - // the player bar. - // What size factor from 'normal' should the circle's diameter be drawn. - // Return value: Whether all segments of the line were drawn with the segment params. - + /// Draws a fancy thick flickering lines to point out scene points on the + /// planet, FROM an arbitrary screen point. + /// @param drawBitmap The bitmap to draw to. + /// @param screenPoint The point on the screen to point from, in screen coordinates. + /// @param planetPoint The point on the planet to point at, in planet coordinates. + /// @param color The color of the line. + /// @param onlyFirstSegments How many of the segments from the start (the start of the line) to draw. (default: -1) + /// @param onlyLastSegments How many of the segments from the end (site circle) to draw. -1 is all. (default: -1) + /// @param channelHeight The height of the 'channel' above and below that the lines will go around (default: 80) + /// the player bar. + /// @param circleSize What size factor from 'normal' should the circle's diameter be drawn. (default: 1.0) + /// @return Whether all segments of the line were drawn with the segment params. bool DrawScreenLineToSitePoint(BITMAP* drawBitmap, const Vector& screenPoint, const Vector& planetPoint, @@ -837,26 +491,22 @@ namespace RTE { float circleSize = 1.0, bool squareSite = false) const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: DrawPlayerLineToSitePoint - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws a fancy thick flickering lines to point out scene points on the - // planet, FROM a floating player bar, showing a certain ratio. - // Arguments: The bitmap to draw to. - // The player whose floating bar we draw from. - // The start percentage of the meter to indicate, from 0 to 1.0 - // The actual percentage of the meter to indicate, from 0 to 1.0 - // The point on the planet to point at, in planet coordinates. - // The color of the line. - // How many of the segments from the start (the player floater) to draw. - // How many of the segments from the end (site circle) to draw. -1 is all. - // The height of the 'channel' above and below that the lines will go around - // the player bar. - // What size factor from 'normal' should the circle's diameter be drawn. - // Whether the circle should instead be a squareSite! - // Whether to draw the meter (FirstSegment == 1) no matter what - // Return value: Whether all segments of the line were drawn with the segment params. - + /// Draws a fancy thick flickering lines to point out scene points on the + /// planet, FROM a floating player bar, showing a certain ratio. + /// @param drawBitmap The bitmap to draw to. + /// @param player The player whose floating bar we draw from. + /// @param startMeterAt The start percentage of the meter to indicate, from 0 to 1.0 + /// @param meterAmount The actual percentage of the meter to indicate, from 0 to 1.0 + /// @param planetPoint The point on the planet to point at, in planet coordinates. + /// @param color The color of the line. + /// @param onlyFirstSegments How many of the segments from the start (the player floater) to draw. (default: -1) + /// @param onlyLastSegments How many of the segments from the end (site circle) to draw. -1 is all. (default: -1) + /// @param channelHeight The height of the 'channel' above and below that the lines will go around (default: 60) + /// the player bar. + /// @param circleSize What size factor from 'normal' should the circle's diameter be drawn. (default: 1.0) + /// @param squareSite Whether the circle should instead be a squareSite! (default: false) + /// @param drawMeterOverride Whether to draw the meter (FirstSegment == 1) no matter what (default: false) + /// @return Whether all segments of the line were drawn with the segment params. bool DrawPlayerLineToSitePoint(BITMAP* drawBitmap, int player, float startMeterAt, @@ -870,26 +520,18 @@ namespace RTE { bool squareSite = false, bool drawMeterOverride = false) const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: DrawPlayerLineToSitePoint - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws a fancy thick flickering lines to point out scene points on the - // planet, FROM a floating player bar, showing a certain ratio. - // Arguments: The bitmap to draw to. - // The SiteLine struct with all the parameters this needs. - // Whether to draw the meter (FirstSegment == 1) no matter what - // Return value: Whether all segments of the line were drawn with the segment params. - + /// Draws a fancy thick flickering lines to point out scene points on the + /// planet, FROM a floating player bar, showing a certain ratio. + /// @param drawBitmap The bitmap to draw to. + /// @param sl The SiteLine struct with all the parameters this needs. + /// @param drawMeterOverride Whether to draw the meter (FirstSegment == 1) no matter what (default: false) const { return DrawPlayerLineToSitePoint(drawBitmap) + /// @return Whether all segments of the line were drawn with the segment params. bool DrawPlayerLineToSitePoint(BITMAP* drawBitmap, const SiteLine& sl, bool drawMeterOverride = false) const { return DrawPlayerLineToSitePoint(drawBitmap, sl.m_Player, sl.m_StartMeterAt, sl.m_MeterAmount, sl.m_PlanetPoint.GetFloored(), sl.m_Color, sl.m_OnlyFirstSegments, sl.m_OnlyLastSegments, sl.m_ChannelHeight, sl.m_CircleSize, sl.m_Square, drawMeterOverride); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: MoveLocationsIntoTheScreen - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Moves any locations closer to the ceonter of the planet if they were left out - // of the screen due to low display resolution. - // Arguments: None. - // Return value: None. - + /// Moves any locations closer to the ceonter of the planet if they were left out + /// of the screen due to low display resolution. + /// Arguments: None. + /// Return value: None. void MoveLocationsIntoTheScreen(); enum MenuEnabled { @@ -1182,20 +824,12 @@ namespace RTE { Vector m_StationPosOnOrbit; //!< The position of the station on the planet orbit. - ////////////////////////////////////////////////////////////////////////////////////////// - // Private member variable and method declarations - + /// Private member variable and method declarations private: static const std::string c_ClassName; //!< A string with the friendly-formatted type name of this object. - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Clear - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears all the member variables of this MetagameGUI, effectively - // resetting the members of this abstraction level only. - // Arguments: None. - // Return value: None. - + /// Clears all the member variables of this MetagameGUI, effectively + /// resetting the members of this abstraction level only. void Clear(); // Disallow the use of some implicit methods. diff --git a/Source/Menus/ModManagerGUI.cpp b/Source/Menus/ModManagerGUI.cpp index e44fa18232..c0a750622b 100644 --- a/Source/Menus/ModManagerGUI.cpp +++ b/Source/Menus/ModManagerGUI.cpp @@ -16,8 +16,6 @@ namespace RTE { - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - ModManagerGUI::ModManagerGUI(AllegroScreen* guiScreen, GUIInputWrapper* guiInput, bool createForPauseMenu) { m_GUIControlManager = std::make_unique(); RTEAssert(m_GUIControlManager->Create(guiScreen, guiInput, "Base.rte/GUIs/Skins/Menus", "MainMenuSubMenuSkin.ini"), "Failed to create GUI Control Manager and load it from Base.rte/GUIs/Skins/Menus/MainMenuSubMenuSkin.ini"); @@ -58,8 +56,6 @@ namespace RTE { m_ScriptsListFetched = false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ModManagerGUI::PopulateKnownModsList() { for (int i = 0; i < g_PresetMan.GetTotalModuleCount(); ++i) { if (i >= g_PresetMan.GetOfficialModuleCount() && i < g_PresetMan.GetTotalModuleCount()) { @@ -92,8 +88,6 @@ namespace RTE { m_ModsListFetched = true; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ModManagerGUI::PopulateKnownScriptsList() { std::list globalScriptList; g_PresetMan.GetAllOfType(globalScriptList, "GlobalScript"); @@ -113,8 +107,6 @@ namespace RTE { m_ScriptsListFetched = true; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ModManagerGUI::ToggleMod() { int index = m_ModsListBox->GetSelectedIndex(); if (index > -1) { @@ -141,8 +133,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ModManagerGUI::ToggleScript() { int index = m_ScriptsListBox->GetSelectedIndex(); if (index > -1) { @@ -169,8 +159,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool ModManagerGUI::HandleInputEvents() { if (!ListsFetched()) { PopulateKnownModsList(); @@ -207,8 +195,6 @@ namespace RTE { return false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ModManagerGUI::Draw() const { m_GUIControlManager->Draw(); } diff --git a/Source/Menus/ModManagerGUI.h b/Source/Menus/ModManagerGUI.h index 9c3b5f58ab..d649c1242d 100644 --- a/Source/Menus/ModManagerGUI.h +++ b/Source/Menus/ModManagerGUI.h @@ -10,78 +10,58 @@ namespace RTE { class GUIButton; class GUIListBox; - /// /// Integrated mod and script manager user interface composition and handling. - /// class ModManagerGUI { public: #pragma region Creation - /// /// Constructor method used to instantiate a ModManagerGUI object in system memory and make it ready for use. - /// - /// Pointer to a GUIScreen interface that will be used by this ModManagerGUI's GUIControlManager. Ownership is NOT transferred! - /// Pointer to a GUIInput interface that will be used by this ModManagerGUI's GUIControlManager. Ownership is NOT transferred! - /// Whether this SettingsGUI is part of ModManagerGUI and should have a slightly different layout. + /// @param guiScreen Pointer to a GUIScreen interface that will be used by this ModManagerGUI's GUIControlManager. Ownership is NOT transferred! + /// @param guiInput Pointer to a GUIInput interface that will be used by this ModManagerGUI's GUIControlManager. Ownership is NOT transferred! + /// @param createForPauseMenu Whether this SettingsGUI is part of ModManagerGUI and should have a slightly different layout. ModManagerGUI(AllegroScreen* guiScreen, GUIInputWrapper* guiInput, bool createForPauseMenu = false); #pragma endregion #pragma region Concrete Methods - /// /// Handles the player interaction with the ModManagerGUI GUI elements. - /// - /// Whether the player requested to return to the main menu. + /// @return Whether the player requested to return to the main menu. bool HandleInputEvents(); - /// /// Draws the ModManagerGUI to the screen. - /// void Draw() const; #pragma endregion private: - /// /// Struct containing information about a valid mod DataModule. - /// struct ModRecord { std::string ModulePath; //!< Mod DataModule path. std::string ModuleName; //!< Mod ModuleName. std::string Description; //!< Mod description. bool Disabled; //!< Whether the mod is disabled through the settings file or not. - /// /// Makes GUI displayable string with mod info. - /// - /// String with mod info. + /// @return String with mod info. std::string GetDisplayString() const { return (Disabled ? "- " : "+ ") + ModulePath + " - " + ModuleName; } - /// /// Comparison operator for sorting the KnownMods list alphabetically by path with std::sort. - /// - /// ModRecord to compare with. - /// Bool with result of the alphabetical comparison. + /// @param rhs ModRecord to compare with. + /// @return Bool with result of the alphabetical comparison. bool operator<(const ModRecord& rhs) const { return ModulePath < rhs.ModulePath; } }; - /// /// Struct containing information about a valid GlobalScript. - /// struct ScriptRecord { std::string PresetName; //!< Script PresetName. std::string Description; //!< Script description. bool Enabled; //!< Whether the script is enabled through the settings file or not. - /// /// Makes GUI displayable string with script info. - /// - /// String with script info. + /// @return String with script info. std::string GetDisplayString() const { return (!Enabled ? "- " : "+ ") + PresetName; } - /// /// Comparison operator for sorting the KnownScripts list alphabetically by PresetName with std::sort. - /// - /// ScriptRecord to compare with. - /// Bool with result of the alphabetical comparison. + /// @param rhs ScriptRecord to compare with. + /// @return Bool with result of the alphabetical comparison. bool operator<(const ScriptRecord& rhs) const { return PresetName < rhs.PresetName; } }; @@ -93,9 +73,7 @@ namespace RTE { bool m_ModsListFetched; //!< Whether the known mods list was fetched, even if no valid mod DataModules were added to it. bool m_ScriptsListFetched; //!< Whether the known scripts list was fetched, even if no valid GlobalScripts were added to it. - /// /// GUI elements that compose the Mod Manager menu screen. - /// GUIButton* m_BackToMainButton; GUIButton* m_ToggleModButton; GUIButton* m_ToggleScriptButton; @@ -104,30 +82,20 @@ namespace RTE { GUILabel* m_ModOrScriptDescriptionLabel; #pragma region Mod and Script Handling - /// /// Gets whether both lists were fetched, even if nothing valid was added to them. - /// - /// Whether both lists were fetched, even if nothing valid was added to them. + /// @return Whether both lists were fetched, even if nothing valid was added to them. bool ListsFetched() const { return m_ModsListFetched && m_ScriptsListFetched; } - /// /// Fills the KnownMods list with all valid mod DataModules, then fills the ModsListBox using it. - /// void PopulateKnownModsList(); - /// /// Fills the KnownScripts list with all valid GlobalScripts, then fills the ScriptsListBox using it. - /// void PopulateKnownScriptsList(); - /// /// Turns currently selected mod on and off and changes GUI elements accordingly. - /// void ToggleMod(); - /// /// Turns currently selected script on and off and changes GUI elements accordingly. - /// void ToggleScript(); #pragma endregion diff --git a/Source/Menus/MultiplayerGameGUI.cpp b/Source/Menus/MultiplayerGameGUI.cpp index 733b237de5..a3ad6e7d66 100644 --- a/Source/Menus/MultiplayerGameGUI.cpp +++ b/Source/Menus/MultiplayerGameGUI.cpp @@ -1,15 +1,3 @@ -////////////////////////////////////////////////////////////////////////////////////////// -// File: MultiplayerGameGUI.cpp -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Implementation file for the MultiplayerGameGUI class -// Project: GUI Library -// Author(s): Daniel Tabar -// dtabar@datarealms.com -// http://www.datarealms.com - -////////////////////////////////////////////////////////////////////////////////////////// -// Inclusions of header files - #include "MultiplayerGameGUI.h" #include "FrameMan.h" @@ -17,21 +5,10 @@ using namespace std; using namespace RTE; -////////////////////////////////////////////////////////////////////////////////////////// -// Method: Clear -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Clears all the member variables of this MultiplayerGameGUI, effectively -// resetting the members of this abstraction level only. - void MultiplayerGameGUI::Clear() { m_pController = 0; } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: Create -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Makes the MultiplayerGameGUI object ready for use. - int MultiplayerGameGUI::Create(Controller* pController) { AAssert(pController, "No controller sent to MultiplayerGameGUI on creation!"); m_pController = pController; @@ -43,27 +20,12 @@ int MultiplayerGameGUI::Create(Controller* pController) { return 0; } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: Destroy -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Destroys and resets (through Clear()) the MultiplayerGameGUI object. - void MultiplayerGameGUI::Destroy() { Clear(); } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: Update -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Updates the state of this Menu each frame - void MultiplayerGameGUI::Update() { } -////////////////////////////////////////////////////////////////////////////////////////// -// Virtual Method: Draw -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Draws the menu - void MultiplayerGameGUI::Draw(BITMAP* pTargetBitmap, const Vector& targetPos) const { } diff --git a/Source/Menus/MultiplayerGameGUI.h b/Source/Menus/MultiplayerGameGUI.h index c79902c2c7..b88619448a 100644 --- a/Source/Menus/MultiplayerGameGUI.h +++ b/Source/Menus/MultiplayerGameGUI.h @@ -1,17 +1,10 @@ #ifndef _MULTIPLAYERGAMEGUI_ #define _MULTIPLAYERGAMEGUI_ -////////////////////////////////////////////////////////////////////////////////////////// -// File: MultiplayerGameGUI.h -////////////////////////////////////////////////////////////////////////////////////////// -// Description: -// Project: GUI Library -// Author(s): - -////////////////////////////////////////////////////////////////////////////////////////// -// Inclusions of header files - -//#include "FrameMan.h" +/// Description: +/// Author(s): +/// Inclusions of header files +// #include "FrameMan.h" #include "Timer.h" #include "Vector.h" #include "Controller.h" @@ -23,18 +16,11 @@ namespace RTE { class ObjectPickerGUI; class PieMenuGUI; - ////////////////////////////////////////////////////////////////////////////////////////// - // Class: MultiplayerGameGUI - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: - // Parent(s): None. - // Class history: - + /// Description: + /// Class history: class MultiplayerGameGUI { - ////////////////////////////////////////////////////////////////////////////////////////// - // Public member variable, method and friend function declarations - + /// Public member variable, method and friend function declarations public: // Different modes of this editor enum GUIMode { @@ -42,98 +28,51 @@ namespace RTE { ACTIVE = 1 }; - ////////////////////////////////////////////////////////////////////////////////////////// - // Constructor: MultiplayerGameGUI - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Constructor method used to instantiate a MultiplayerGameGUI object in system - // memory. Create() should be called before using the object. - // Arguments: None. - + /// Constructor method used to instantiate a MultiplayerGameGUI object in system + /// memory. Create() should be called before using the object. MultiplayerGameGUI() { Clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Destructor: ~MultiplayerGameGUI - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destructor method used to clean up a MultiplayerGameGUI object before deletion - // from system memory. - // Arguments: None. - + /// Destructor method used to clean up a MultiplayerGameGUI object before deletion + /// from system memory. ~MultiplayerGameGUI() { Destroy(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes the MultiplayerGameGUI object ready for use. - // Arguments: A poitner to a Controller which will control this Menu. Ownership is - // NOT TRANSFERRED! - // Whether the editor should have all the features enabled, like load/save - // and undo capabilities. - // Which module space that this eidtor will be able to pick objects from. - // -1 means all modules. - // Which Tech module that will be presented as the native one to the player. - // The multiplier of all foreign techs' costs. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Makes the MultiplayerGameGUI object ready for use. + /// @param pController A poitner to a Controller which will control this Menu. Ownership is + /// NOT TRANSFERRED! + /// Whether the editor should have all the features enabled, like load/save + /// and undo capabilities. + /// Which module space that this eidtor will be able to pick objects from. + /// -1 means all modules. + /// Which Tech module that will be presented as the native one to the player. + /// The multiplier of all foreign techs' costs. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Create(Controller* pController); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Reset - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Resets the entire MultiplayerGameGUI, including its inherited members, to - // their default settings or values. - // Arguments: None. - // Return value: None. - + /// Resets the entire MultiplayerGameGUI, including its inherited members, to + /// their default settings or values. void Reset() { Clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destroys and resets (through Clear()) the MultiplayerGameGUI object. - // Arguments: None. - // Return value: None. - + /// Destroys and resets (through Clear()) the MultiplayerGameGUI object. void Destroy(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Update - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the state of this Menu each frame - // Arguments: None. - // Return value: None. - + /// Updates the state of this Menu each frame void Update(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Draw - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws the editor - // Arguments: The bitmap to draw on. - // The absolute position of the target bitmap's upper left corner in the scene. - // Return value: None. - + /// Draws the editor + /// @param pTargetBitmap The bitmap to draw on. + /// @param targetPos The absolute position of the target bitmap's upper left corner in the scene. (default: Vector()) void Draw(BITMAP* pTargetBitmap, const Vector& targetPos = Vector()) const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Protected member variable and method declarations - + /// Protected member variable and method declarations protected: // Controller which conrols this menu. Not owned Controller* m_pController; - ////////////////////////////////////////////////////////////////////////////////////////// - // Private member variable and method declarations - + /// Private member variable and method declarations private: - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Clear - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears all the member variables of this MultiplayerGameGUI, effectively - // resetting the members of this abstraction level only. - // Arguments: None. - // Return value: None. - + /// Clears all the member variables of this MultiplayerGameGUI, effectively + /// resetting the members of this abstraction level only. void Clear(); // Disallow the use of some implicit methods. diff --git a/Source/Menus/ObjectPickerGUI.cpp b/Source/Menus/ObjectPickerGUI.cpp index 07d017db46..9e372d2f7a 100644 --- a/Source/Menus/ObjectPickerGUI.cpp +++ b/Source/Menus/ObjectPickerGUI.cpp @@ -27,8 +27,6 @@ namespace RTE { BITMAP* ObjectPickerGUI::s_Cursor = nullptr; - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ObjectPickerGUI::Clear() { m_GUIScreen = nullptr; m_GUIInput = nullptr; @@ -58,8 +56,6 @@ namespace RTE { m_ExpandedModules[0] = true; // Base.rte is always expanded } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int ObjectPickerGUI::Create(Controller* controller, int whichModuleSpace, const std::string_view& onlyOfType) { RTEAssert(controller, "No controller sent to ObjectPickerGUI on creation!"); m_Controller = controller; @@ -129,8 +125,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ObjectPickerGUI::SetEnabled(bool enable) { if (enable && m_PickerState != PickerState::Enabled && m_PickerState != PickerState::Enabling) { m_PickerState = PickerState::Enabling; @@ -151,8 +145,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ObjectPickerGUI::SetNativeTechModule(int whichModule) { if (whichModule >= 0 && whichModule < g_PresetMan.GetTotalModuleCount()) { m_NativeTechModuleID = whichModule; @@ -181,8 +173,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool ObjectPickerGUI::SetListFocus(PickerFocus listToFocusOn) { if (listToFocusOn == m_PickerFocus) { return false; @@ -201,8 +191,6 @@ namespace RTE { return true; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool ObjectPickerGUI::SelectGroupByName(const std::string_view& groupName) { for (const GUIListPanel::Item* groupListItem: *m_GroupsList->GetItemList()) { if (groupListItem->m_Name == groupName) { @@ -214,8 +202,6 @@ namespace RTE { return false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ObjectPickerGUI::SelectGroupByIndex(int groupIndex, bool updateObjectsList) { m_SelectedGroupIndex = (groupIndex < 0) ? m_ShownGroupIndex : groupIndex; m_GroupsList->SetSelectedIndex(m_SelectedGroupIndex); @@ -229,8 +215,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ObjectPickerGUI::SelectNextOrPrevGroup(bool selectPrev) { int groupIndex = m_SelectedGroupIndex; if (selectPrev) { @@ -247,8 +231,6 @@ namespace RTE { SelectGroupByIndex(groupIndex); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ObjectPickerGUI::UpdateGroupsList() { m_GroupsList->ClearList(); bool showAssemblySchemes = dynamic_cast(g_ActivityMan.GetActivity()); @@ -300,8 +282,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - const SceneObject* ObjectPickerGUI::GetSelectedObject() { if (const GUIListPanel::Item* selectedItem = m_ObjectsList->GetSelected()) { return dynamic_cast(selectedItem->m_pEntity); @@ -309,8 +289,6 @@ namespace RTE { return nullptr; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ObjectPickerGUI::SelectObjectByIndex(int objectIndex, bool playSelectionSound) { m_SelectedObjectIndex = objectIndex; m_ObjectsList->SetSelectedIndex(m_SelectedObjectIndex); @@ -319,8 +297,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ObjectPickerGUI::SelectNextOrPrevObject(bool getPrev) { int objectIndex = m_SelectedObjectIndex; if (getPrev) { @@ -337,8 +313,6 @@ namespace RTE { SelectObjectByIndex(objectIndex); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ObjectPickerGUI::AddObjectsListModuleGroup(int moduleID) { const DataModule* dataModule = g_PresetMan.GetDataModule(moduleID); std::string moduleName = dataModule->GetFriendlyName(); @@ -347,8 +321,6 @@ namespace RTE { m_ObjectsList->AddItem(moduleName, m_ExpandedModules.at(moduleID) ? "-" : "+", dataModuleIcon, nullptr, moduleID); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ObjectPickerGUI::SetObjectsListModuleGroupExpanded(int moduleID, bool expanded) { if (moduleID > 0 && moduleID < m_ExpandedModules.size()) { m_ExpandedModules.at(moduleID) = expanded; @@ -358,8 +330,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ObjectPickerGUI::ToggleObjectsListModuleGroupExpansion(int moduleID) { if (moduleID > 0 && moduleID < m_ExpandedModules.size()) { m_ExpandedModules.at(moduleID) = !m_ExpandedModules.at(moduleID); @@ -368,8 +338,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ObjectPickerGUI::ShowDescriptionPopupBox() { std::string description = ""; GUIListPanel::Item* objectListItem = m_ObjectsList->GetSelected(); @@ -395,8 +363,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ObjectPickerGUI::UpdateObjectsList(bool selectTop) { m_ObjectsList->ClearList(); std::vector> moduleList(g_PresetMan.GetTotalModuleCount(), std::list()); @@ -457,8 +423,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ObjectPickerGUI::Update() { m_PopupBox->SetVisible(false); @@ -488,8 +452,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool ObjectPickerGUI::HandleInput() { bool objectPickedOrPickerClosed = false; if (m_Controller->IsMouseControlled()) { @@ -556,8 +518,6 @@ namespace RTE { return false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool ObjectPickerGUI::HandleMouseEvents() { int mousePosX; int mousePosY; @@ -608,8 +568,6 @@ namespace RTE { return false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ObjectPickerGUI::AnimateOpenClose() { if (m_PickerState == PickerState::Enabling) { m_ParentBox->SetVisible(true); @@ -641,8 +599,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ObjectPickerGUI::Draw(BITMAP* drawBitmap) const { AllegroScreen drawScreen(drawBitmap); m_GUIControlManager->Draw(&drawScreen); diff --git a/Source/Menus/ObjectPickerGUI.h b/Source/Menus/ObjectPickerGUI.h index 39182e2e2c..08cac7451e 100644 --- a/Source/Menus/ObjectPickerGUI.h +++ b/Source/Menus/ObjectPickerGUI.h @@ -16,71 +16,51 @@ namespace RTE { class GUILabel; class SceneObject; - /// /// A GUI for picking object instances for placement to the Scene in various editors. - /// class ObjectPickerGUI { public: #pragma region Creation - /// /// Constructor method used to instantiate a ObjectPickerGUI object in system memory. Create() should be called before using the object. - /// ObjectPickerGUI() { Clear(); } - /// /// Makes the ObjectPickerGUI object ready for use. - /// - /// A pointer to a Controller which will control this Menu. Ownership is NOT transferred! - /// Which DataModule space to be picking from. -1 means pick from all objects loaded in all DataModules. - /// Which lowest common denominator type to be showing. - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @param controller A pointer to a Controller which will control this Menu. Ownership is NOT transferred! + /// @param whichModuleSpace Which DataModule space to be picking from. -1 means pick from all objects loaded in all DataModules. + /// @param onlyOfType Which lowest common denominator type to be showing. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create(Controller* controller, int whichModuleSpace = -1, const std::string_view& onlyOfType = "All"); #pragma endregion #pragma region Destruction - /// /// Resets the entire ObjectPickerGUI, including its inherited members, to their default settings or values. - /// void Reset() { Clear(); } #pragma endregion #pragma region Getters and Setters - /// /// Reports whether the menu is at all visible or not. - /// - /// + /// @return bool IsVisible() const { return m_PickerState != PickerState::Disabled; } - /// /// Reports whether the menu is enabled or not. - /// - /// + /// @return bool IsEnabled() const { return m_PickerState == PickerState::Enabled || m_PickerState == PickerState::Enabling; } - /// /// Enables or disables the menu. This will animate it in and out of view. - /// - /// Whether to enable or disable the menu. + /// @param enable Whether to enable or disable the menu. void SetEnabled(bool enable = true); - /// /// Sets the controller used by this. The ownership of the controller is NOT transferred! - /// - /// The new controller for this menu. Ownership is NOT transferred! + /// @param controller The new controller for this menu. Ownership is NOT transferred! void SetController(Controller* controller) { m_Controller = controller; } - /// /// Sets where on the screen that this GUI is being drawn to. If upper left corner, then 0, 0. This will affect the way the mouse is positioned etc. - /// - /// The new X position of this entire GUI on the screen. - /// The new Y position of this entire GUI on the screen. + /// @param newPosX The new X position of this entire GUI on the screen. + /// @param newPosY The new Y position of this entire GUI on the screen. void SetPosOnScreen(int newPosX, int newPosY) const { m_GUIControlManager->SetPosOnScreen(newPosX, newPosY); } - /// /// Sets which DataModule space to be picking objects from. If -1, then let the player pick from all loaded modules. - /// - /// The ID of the module to let the player pick objects from. All official module objects will always be presented, in addition to the one passed in here. + /// @param newModuleSpaceID The ID of the module to let the player pick objects from. All official module objects will always be presented, in addition to the one passed in here. void SetModuleSpace(int newModuleSpaceID = -1) { if (newModuleSpaceID != m_ModuleSpaceID) { m_ModuleSpaceID = newModuleSpaceID; @@ -88,87 +68,65 @@ namespace RTE { } } - /// /// Sets which DataModule space to be picking objects from. If -1, then let the player pick from all loaded modules. - /// - /// The ID of the module to let the player pick objects from. All official module objects will always be presented, in addition to the one passed in here. + /// @param showType The ID of the module to let the player pick objects from. All official module objects will always be presented, in addition to the one passed in here. void ShowOnlyType(const std::string_view& showType = "All") { m_ShowType = showType; UpdateGroupsList(); } - /// /// Sets which DataModule ID should be treated as the native tech of the user of this menu. /// This will also apply the DataModule's faction BuyMenu theme skin and background color for visual consistency, if applicable. - /// - /// The module ID to set as the native one. 0 means everything is native. + /// @param whichModule The module ID to set as the native one. 0 means everything is native. void SetNativeTechModule(int whichModule); - /// /// Sets the multiplier of the cost of any foreign Tech items. - /// - /// The scalar multiplier of the costs of foreign Tech items. + /// @param newMultiplier The scalar multiplier of the costs of foreign Tech items. void SetForeignCostMultiplier(float newMultiplier) { m_ForeignCostMult = newMultiplier; } - /// /// Selects the specified group name in the groups list and updates the objects list to show the group's objects. - /// - /// The name of the group to select in the picker. - /// Whether the group was found and switched to successfully. + /// @param groupName The name of the group to select in the picker. + /// @return Whether the group was found and switched to successfully. bool SelectGroupByName(const std::string_view& groupName); #pragma endregion #pragma region Object Picking Handling - /// /// Gets the next object in the objects list, even if the picker is disabled. - /// - /// The next object in the picker list, looping around if necessary. If the next object is an invalid SceneObject (e.g. a module subgroup) then this will recurse until a valid object is found. + /// @return The next object in the picker list, looping around if necessary. If the next object is an invalid SceneObject (e.g. a module subgroup) then this will recurse until a valid object is found. const SceneObject* GetNextObject() { SelectNextOrPrevObject(false); const SceneObject* object = GetSelectedObject(); return object ? object : GetNextObject(); } - /// /// Gets the previous object in the objects list, even if the picker is disabled. - /// - /// The previous object in the picker list, looping around if necessary. If the previous object is an invalid SceneObject (e.g. a module subgroup) then this will recurse until a valid object is found. + /// @return The previous object in the picker list, looping around if necessary. If the previous object is an invalid SceneObject (e.g. a module subgroup) then this will recurse until a valid object is found. const SceneObject* GetPrevObject() { SelectNextOrPrevObject(true); const SceneObject* object = GetSelectedObject(); return object ? object : GetPrevObject(); } - /// /// Reports whether and which object has been picked by the player. There may be an object picked even when the player is not done with the picker, as scrolling through objects (but not mousing over them) picks them. - /// - /// A pointer to the object picked by the player, or nullptr if none was picked. Ownership is NOT transferred! + /// @return A pointer to the object picked by the player, or nullptr if none was picked. Ownership is NOT transferred! const SceneObject* ObjectPicked() const { return m_PickedObject; } - /// /// Reports whether the player has finished using the picker, and the final picked object is returned. - /// - /// The object the player picked before they closed the picker, or nullptr if none was picked. Ownership is NOT transferred!< / returns> + /// @return The object the player picked before they closed the picker, or nullptr if none was picked. Ownership is NOT transferred! const SceneObject* DonePicking() const { return (!IsEnabled() && m_PickedObject) ? m_PickedObject : nullptr; } #pragma endregion #pragma region Concrete Methods - /// /// Updates the state of this ObjectPickerGUI each frame. - /// void Update(); - /// /// Draws the ObjectPickerGUI to the specified BITMAP. - /// - /// The BITMAP to draw on. + /// @param drawBitmap The BITMAP to draw on. void Draw(BITMAP* drawBitmap) const; #pragma endregion private: - /// /// Enumeration for ObjectPicker states when enabling/disabling the ObjectPicker. - /// enum class PickerState { Enabling, Enabled, @@ -176,9 +134,7 @@ namespace RTE { Disabled }; - /// /// Enumeration for the ObjectPicker columns ListBox focus states. - /// enum class PickerFocus { GroupList, ObjectList @@ -217,107 +173,75 @@ namespace RTE { std::vector m_ExpandedModules; //!< The modules that have been expanded in the item list. #pragma region General List Handling - /// /// Sets the currently focused list in the picker. For list item highlighting and non-mouse input handling. - /// - /// The list to focus on. See PickerFocus enumeration. - /// Whether a focus change was made or not. + /// @param listToFocusOn The list to focus on. See PickerFocus enumeration. + /// @return Whether a focus change was made or not. bool SetListFocus(PickerFocus listToFocusOn); #pragma endregion #pragma region Group List Handling - /// /// Selects the specified group index in the groups list and updates the objects list to show the group's objects. - /// - /// The group index to select. Removing any selection (with index -1) will be overridden and the currently shown group will be selected instead. - /// Whether to update the objects list after making the selection or not. + /// @param groupIndex The group index to select. Removing any selection (with index -1) will be overridden and the currently shown group will be selected instead. + /// @param updateObjectsList Whether to update the objects list after making the selection or not. void SelectGroupByIndex(int groupIndex, bool updateObjectsList = true); - /// /// Selects the next or previous group from the one that is currently selected in the groups list. - /// - /// Whether to select the previous group. Next group will be selected by default. + /// @param selectPrev Whether to select the previous group. Next group will be selected by default. void SelectNextOrPrevGroup(bool selectPrev = false); - /// /// Adds all groups with a specific type already defined in PresetMan that are within the set ModuleSpaceID and aren't empty to the current groups list. - /// void UpdateGroupsList(); #pragma endregion #pragma region Object List Handling - /// /// Gets the SceneObject from the currently selected index in the objects list. Ownership is NOT transferred! - /// - /// The SceneObject of the currently selected index in the objects list. Nullptr if no valid object is selected (eg. a module subgroup). + /// @return The SceneObject of the currently selected index in the objects list. Nullptr if no valid object is selected (eg. a module subgroup). const SceneObject* GetSelectedObject(); - /// /// Selects the specified object index in the objects list. - /// - /// The object index to select. - /// Whether to play the selection change sound or not. + /// @param objectIndex The object index to select. + /// @param playSelectionSound Whether to play the selection change sound or not. void SelectObjectByIndex(int objectIndex, bool playSelectionSound = true); - /// /// Selects the next or previous object from the one that is currently selected in the objects list. - /// - /// Whether to select the previous object. Next object will be selected by default. + /// @param getPrev Whether to select the previous object. Next object will be selected by default. void SelectNextOrPrevObject(bool getPrev = false); - /// /// Add the expandable DataModule group separator in the objects list with appropriate name and icon. - /// - /// The DataModule ID to add group separator for. + /// @param moduleID The DataModule ID to add group separator for. void AddObjectsListModuleGroup(int moduleID); - /// /// Sets whether a DataModule group separator shown in the objects list should be expanded or collapsed. - /// - /// The module ID to set as expanded or collapsed. - /// Whether should be expanded or not. + /// @param moduleID The module ID to set as expanded or collapsed. + /// @param expanded Whether should be expanded or not. void SetObjectsListModuleGroupExpanded(int moduleID, bool expanded = true); - /// /// Toggles the expansion/collapse of a DataModule group separator in the objects list. - /// - /// The module ID to toggle for. + /// @param moduleID The module ID to toggle for. void ToggleObjectsListModuleGroupExpansion(int moduleID); - /// /// Displays the popup box with the description of the selected item in the objects list. - /// void ShowDescriptionPopupBox(); - /// /// Adds all objects of the currently selected group to the objects list. - /// - /// Whether to reset the selection to the top of the list when we're done updating this. + /// @param selectTop Whether to reset the selection to the top of the list when we're done updating this. void UpdateObjectsList(bool selectTop = true); #pragma endregion #pragma region Update Breakdown - /// /// Player input handling for all types of input devices. - /// - /// True if the picker was set to be closed or by making a selection from the objects list. + /// @return True if the picker was set to be closed or by making a selection from the objects list. bool HandleInput(); - /// /// Player mouse input event handling of the GUIControls of this ObjectPickerGUI. - /// - /// True if the picker was set to be closed by clicking off it or by making a selection from the objects list. + /// @return True if the picker was set to be closed by clicking off it or by making a selection from the objects list. bool HandleMouseEvents(); - /// /// Open/close animation handling and GUI element enabling/disabling. - /// void AnimateOpenClose(); #pragma endregion - /// /// Clears all the member variables of this ObjectPickerGUI, effectively resetting the members of this abstraction level only. - /// void Clear(); // Disallow the use of some implicit methods. diff --git a/Source/Menus/PauseMenuGUI.cpp b/Source/Menus/PauseMenuGUI.cpp index a748ea4f3d..b267e4be9f 100644 --- a/Source/Menus/PauseMenuGUI.cpp +++ b/Source/Menus/PauseMenuGUI.cpp @@ -21,8 +21,6 @@ namespace RTE { - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PauseMenuGUI::Clear() { m_GUIControlManager = nullptr; m_ActiveDialogBox = nullptr; @@ -49,8 +47,6 @@ namespace RTE { m_PauseMenuButtons.fill(nullptr); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PauseMenuGUI::Create(AllegroScreen* guiScreen, GUIInputWrapper* guiInput) { m_GUIControlManager = std::make_unique(); RTEAssert(m_GUIControlManager->Create(guiScreen, guiInput, "Base.rte/GUIs/Skins/Menus", "MainMenuScreenSkin.ini"), "Failed to create GUI Control Manager and load it from Base.rte/GUIs/Skins/Menus/MainMenuScreenSkin.ini"); @@ -94,8 +90,6 @@ namespace RTE { m_ModManagerMenu = std::make_unique(guiScreen, guiInput, true); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PauseMenuGUI::SetBackButtonTargetName(const std::string& menuName) { std::string newButtonText = "Back to " + menuName + " Menu"; @@ -111,8 +105,6 @@ namespace RTE { m_PauseMenuButtons[PauseMenuButton::BackToMainButton]->CenterInParent(true, false); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PauseMenuGUI::EnableOrDisablePauseMenuFeatures() { bool disableModManager = true; @@ -135,8 +127,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PauseMenuGUI::SetActiveMenuScreen(PauseMenuScreen screenToShow, bool playButtonPressSound) { if (screenToShow != m_ActiveMenuScreen) { m_ActiveMenuScreen = screenToShow; @@ -149,8 +139,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - PauseMenuGUI::PauseMenuUpdateResult PauseMenuGUI::Update() { m_UpdateResult = PauseMenuUpdateResult::NoEvent; @@ -183,8 +171,6 @@ namespace RTE { return m_UpdateResult; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PauseMenuGUI::HandleBackNavigation(bool backButtonPressed) { if (!m_ActiveDialogBox && (backButtonPressed || g_UInputMan.KeyPressed(SDLK_ESCAPE))) { if (m_ActiveMenuScreen != PauseMenuScreen::MainScreen) { @@ -205,8 +191,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool PauseMenuGUI::HandleInputEvents() { if (m_ActiveMenuScreen == PauseMenuScreen::MainScreen) { int mousePosX; @@ -239,8 +223,6 @@ namespace RTE { return false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PauseMenuGUI::UpdateHoveredButton(const GUIButton* hoveredButton) { int hoveredButtonIndex = -1; if (hoveredButton) { @@ -261,8 +243,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PauseMenuGUI::BlinkResumeButton() { if (m_HoveredButton && m_HoveredButton == m_PauseMenuButtons[PauseMenuButton::ResumeButton]) { m_PauseMenuButtons[PauseMenuButton::ResumeButton]->SetText(m_ResumeButtonBlinkTimer.AlternateReal(500) ? m_ButtonHoveredText[PauseMenuButton::ResumeButton] : "]" + m_ButtonHoveredText[PauseMenuButton::ResumeButton] + "["); @@ -271,8 +251,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PauseMenuGUI::Draw() { g_WindowMan.DrawPostProcessBuffer(); blit(m_BackdropBitmap, g_FrameMan.GetBackBuffer32(), 0, 0, 0, 0, m_BackdropBitmap->w, m_BackdropBitmap->h); diff --git a/Source/Menus/PauseMenuGUI.h b/Source/Menus/PauseMenuGUI.h index 98e1f0b29b..cddc060368 100644 --- a/Source/Menus/PauseMenuGUI.h +++ b/Source/Menus/PauseMenuGUI.h @@ -16,15 +16,11 @@ namespace RTE { class ModManagerGUI; class SaveLoadMenuGUI; - /// /// Handling for the pause menu screen composition and interaction. - /// class PauseMenuGUI { public: - /// /// Enumeration for the results of the PauseMenuGUI input and event update. - /// enum class PauseMenuUpdateResult { NoEvent, BackToMain, @@ -32,54 +28,40 @@ namespace RTE { }; #pragma region Creation - /// /// Constructor method used to instantiate a PauseMenuGUI object in system memory and make it ready for use. - /// - /// Pointer to a GUIScreen interface that will be used by this PauseMenuGUI's GUIControlManager. Ownership is NOT transferred! - /// Pointer to a GUIInput interface that will be used by this PauseMenuGUI's GUIControlManager. Ownership is NOT transferred! + /// @param guiScreen Pointer to a GUIScreen interface that will be used by this PauseMenuGUI's GUIControlManager. Ownership is NOT transferred! + /// @param guiInput Pointer to a GUIInput interface that will be used by this PauseMenuGUI's GUIControlManager. Ownership is NOT transferred! PauseMenuGUI(AllegroScreen* guiScreen, GUIInputWrapper* guiInput) { Clear(); Create(guiScreen, guiInput); } - /// /// Makes the PauseMenuGUI object ready for use. - /// - /// Pointer to a GUIScreen interface that will be used by this PauseMenuGUI's GUIControlManager. Ownership is NOT transferred! - /// Pointer to a GUIInput interface that will be used by this PauseMenuGUI's GUIControlManager. Ownership is NOT transferred! + /// @param guiScreen Pointer to a GUIScreen interface that will be used by this PauseMenuGUI's GUIControlManager. Ownership is NOT transferred! + /// @param guiInput Pointer to a GUIInput interface that will be used by this PauseMenuGUI's GUIControlManager. Ownership is NOT transferred! void Create(AllegroScreen* guiScreen, GUIInputWrapper* guiInput); #pragma endregion #pragma region Setters - /// /// Sets the "Back to Main Menu" button text to the menu we will be going back to. - /// - /// The target menu name, e.g. "Conquest" will result in "Back to Conquest Menu". + /// @param menuName The target menu name, e.g. "Conquest" will result in "Back to Conquest Menu". void SetBackButtonTargetName(const std::string& menuName); #pragma endregion #pragma region Concrete Methods - /// /// Enables or disables buttons depending on the current Activity. - /// void EnableOrDisablePauseMenuFeatures(); - /// /// Updates the PauseMenuGUI state. - /// - /// The result of the PauseMenuGUI input and event update. See PauseMenuUpdateResult enumeration. + /// @return The result of the PauseMenuGUI input and event update. See PauseMenuUpdateResult enumeration. PauseMenuUpdateResult Update(); - /// /// Draws the PauseMenuGUI to the screen. - /// void Draw(); #pragma endregion private: - /// /// Enumeration for the different sub-menu screens of the pause menu. - /// enum PauseMenuScreen { MainScreen, SaveOrLoadGameScreen, @@ -88,9 +70,7 @@ namespace RTE { ScreenCount }; - /// /// Enumeration for all the different buttons of the pause menu. - /// enum PauseMenuButton { BackToMainButton, SaveOrLoadGameButton, @@ -124,49 +104,35 @@ namespace RTE { bool m_SavingButtonsDisabled; //!< Whether the save and load buttons are disabled and hidden. bool m_ModManagerButtonDisabled; //!< Whether the mod manager button is disabled and hidden. - /// /// GUI elements that compose the pause menu screen. - /// GUICollectionBox* m_PauseMenuBox; std::array m_PauseMenuButtons; #pragma region Menu Screen Handling - /// /// Sets the PauseMenuGUI to display a menu screen. - /// - /// Which menu screen to display. See PauseMenuScreen enumeration. - /// Whether to play a sound if the menu screen change is triggered by a button press. + /// @param screenToShow Which menu screen to display. See PauseMenuScreen enumeration. + /// @param playButtonPressSound Whether to play a sound if the menu screen change is triggered by a button press. void SetActiveMenuScreen(PauseMenuScreen screenToShow, bool playButtonPressSound = true); #pragma endregion #pragma region Update Breakdown - /// /// Handles returning to the pause menu from one of the sub-menus if the player requested to return via the back button or the esc key. Also handles closing active dialog boxes with the esc key. - /// - /// Whether the player requested to return to the pause menu from one of the sub-menus via back button. + /// @param backButtonPressed Whether the player requested to return to the pause menu from one of the sub-menus via back button. void HandleBackNavigation(bool backButtonPressed); - /// /// Handles the player interaction with the PauseMenuGUI GUI elements. - /// - /// Whether the player requested to return to the main menu. + /// @return Whether the player requested to return to the main menu. bool HandleInputEvents(); - /// /// Updates the currently hovered button text to give the hovered visual and updates the previously hovered button to remove the hovered visual. - /// - /// Pointer to the currently hovered button, if any. Acquired by GUIControlManager::GetControlUnderPoint. + /// @param hoveredButton Pointer to the currently hovered button, if any. Acquired by GUIControlManager::GetControlUnderPoint. void UpdateHoveredButton(const GUIButton* hoveredButton); - /// /// Animates (blinking) the resume game button. - /// void BlinkResumeButton(); #pragma endregion - /// /// Clears all the member variables of this PauseMenuGUI, effectively resetting the members of this object. - /// void Clear(); // Disallow the use of some implicit methods. diff --git a/Source/Menus/SaveLoadMenuGUI.cpp b/Source/Menus/SaveLoadMenuGUI.cpp index 1a39491e5a..b96f19ae34 100644 --- a/Source/Menus/SaveLoadMenuGUI.cpp +++ b/Source/Menus/SaveLoadMenuGUI.cpp @@ -21,8 +21,6 @@ namespace RTE { - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - SaveLoadMenuGUI::SaveLoadMenuGUI(AllegroScreen* guiScreen, GUIInputWrapper* guiInput, bool createForPauseMenu) { m_GUIControlManager = std::make_unique(); RTEAssert(m_GUIControlManager->Create(guiScreen, guiInput, "Base.rte/GUIs/Skins/Menus", "MainMenuSubMenuSkin.ini"), "Failed to create GUI Control Manager and load it from Base.rte/GUIs/Skins/Menus/MainMenuSubMenuSkin.ini"); @@ -74,8 +72,6 @@ namespace RTE { SwitchToConfirmDialogMode(ConfirmDialogMode::None); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SaveLoadMenuGUI::PopulateSaveGamesList() { m_SaveGames.clear(); m_SaveGameName->SetText(""); @@ -125,8 +121,6 @@ namespace RTE { UpdateSaveGamesGUIList(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SaveLoadMenuGUI::UpdateSaveGamesGUIList() { const std::string& currentOrder = m_OrderByComboBox->GetSelectedItem()->m_Name; if (currentOrder == "Name") { @@ -171,8 +165,6 @@ namespace RTE { m_SaveGamesListBox->ScrollToTop(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool SaveLoadMenuGUI::LoadSave() { bool success = g_ActivityMan.LoadAndLaunchGame(m_SaveGameName->GetText()); @@ -185,8 +177,6 @@ namespace RTE { return success; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SaveLoadMenuGUI::CreateSave() { bool success = g_ActivityMan.SaveCurrentGame(m_SaveGameName->GetText()); if (success) { @@ -198,8 +188,6 @@ namespace RTE { PopulateSaveGamesList(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SaveLoadMenuGUI::DeleteSave() { std::string saveFilePath = g_PresetMan.GetFullModulePath(c_UserScriptedSavesModuleName) + "/" + m_SaveGameName->GetText(); @@ -209,8 +197,6 @@ namespace RTE { PopulateSaveGamesList(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SaveLoadMenuGUI::UpdateButtonEnabledStates() { bool allowSave = g_ActivityMan.GetActivity() && g_ActivityMan.GetActivity()->GetAllowsUserSaving() && m_SaveGameName->GetText() != ""; @@ -242,8 +228,6 @@ namespace RTE { m_ActivityCannotBeSavedLabel->SetVisible(g_ActivityMan.GetActivity() && !g_ActivityMan.GetActivity()->GetAllowsUserSaving()); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SaveLoadMenuGUI::SwitchToConfirmDialogMode(ConfirmDialogMode mode) { m_ConfirmDialogMode = mode; @@ -262,8 +246,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool SaveLoadMenuGUI::HandleInputEvents(PauseMenuGUI* pauseMenu) { m_GUIControlManager->Update(); @@ -317,15 +299,11 @@ namespace RTE { return false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SaveLoadMenuGUI::Refresh() { PopulateSaveGamesList(); UpdateButtonEnabledStates(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SaveLoadMenuGUI::Draw() const { m_GUIControlManager->Draw(); } diff --git a/Source/Menus/SaveLoadMenuGUI.h b/Source/Menus/SaveLoadMenuGUI.h index 448e7ca3c3..451bb99cfa 100644 --- a/Source/Menus/SaveLoadMenuGUI.h +++ b/Source/Menus/SaveLoadMenuGUI.h @@ -17,38 +17,28 @@ namespace RTE { class GUIComboBox; class GUICollectionBox; - /// /// Integrated savegame user interface composition and handling. - /// class SaveLoadMenuGUI { public: #pragma region Creation - /// /// Constructor method used to instantiate a SaveLoadMenuGUI object in system memory and make it ready for use. - /// - /// Pointer to a GUIScreen interface that will be used by this SaveLoadMenuGUI's GUIControlManager. Ownership is NOT transferred! - /// Pointer to a GUIInput interface that will be used by this SaveLoadMenuGUI's GUIControlManager. Ownership is NOT transferred! - /// Whether this SettingsGUI is part of SaveLoadMenuGUI and should have a slightly different layout. + /// @param guiScreen Pointer to a GUIScreen interface that will be used by this SaveLoadMenuGUI's GUIControlManager. Ownership is NOT transferred! + /// @param guiInput Pointer to a GUIInput interface that will be used by this SaveLoadMenuGUI's GUIControlManager. Ownership is NOT transferred! + /// @param createForPauseMenu Whether this SettingsGUI is part of SaveLoadMenuGUI and should have a slightly different layout. SaveLoadMenuGUI(AllegroScreen* guiScreen, GUIInputWrapper* guiInput, bool createForPauseMenu = false); #pragma endregion #pragma region Concrete Methods - /// /// Handles the player interaction with the SaveLoadMenuGUI GUI elements. - /// - /// Pointer to the pause menu, if we're being called from the pause menu. Ownership is NOT transferred! - /// Whether the player requested to return to the main menu. + /// @param pauseMenu Pointer to the pause menu, if we're being called from the pause menu. Ownership is NOT transferred! + /// @return Whether the player requested to return to the main menu. bool HandleInputEvents(PauseMenuGUI* pauseMenu = nullptr); - /// /// Causes a refresh of the save files. - /// void Refresh(); - /// /// Draws the SaveLoadMenuGUI to the screen. - /// void Draw() const; #pragma endregion @@ -59,9 +49,7 @@ namespace RTE { ConfirmDelete }; - /// /// Struct containing information about a valid Savegame. - /// struct SaveRecord { std::filesystem::path SavePath; //!< Savegame filepath. std::filesystem::file_time_type SaveDate; //!< Last modified date. @@ -75,9 +63,7 @@ namespace RTE { bool m_SaveGamesFetched; //!< Whether the savegames list has been fetched. - /// /// GUI elements that compose the Mod Manager menu screen. - /// GUICollectionBox* m_SaveGameMenuBox; GUIButton* m_BackToMainButton; GUITextBox* m_SaveGameName; @@ -97,47 +83,31 @@ namespace RTE { GUIButton* m_CancelButton; #pragma region Savegame Handling - /// /// Gets whether both lists were fetched, even if nothing valid was added to them. - /// - /// Whether save games were fetched, even if nothing valid was added to them. + /// @return Whether save games were fetched, even if nothing valid was added to them. bool ListsFetched() const { return m_SaveGamesFetched; } - /// /// Fills the SaveGames list with all valid savegames. - /// void PopulateSaveGamesList(); - /// /// Updates the SaveGamesListBox GUI. - /// void UpdateSaveGamesGUIList(); - /// /// Loads the currently selected savefile. - /// - /// Whether a same was succesfully loaded. + /// @return Whether a same was succesfully loaded. bool LoadSave(); - /// /// Creates a new savefile (or overwrites the existing one) with the name from the textbox. - /// void CreateSave(); - /// /// Deletes the savefile with the name from the textbox. - /// void DeleteSave(); #pragma endregion - /// /// Updates buttons and sets whether or not they should be enabled. - /// void UpdateButtonEnabledStates(); - /// /// Shows confirmation box for overwrite or delete. - /// void SwitchToConfirmDialogMode(ConfirmDialogMode mode); // Disallow the use of some implicit methods. diff --git a/Source/Menus/ScenarioActivityConfigGUI.cpp b/Source/Menus/ScenarioActivityConfigGUI.cpp index 272fda0dd8..18069d1990 100644 --- a/Source/Menus/ScenarioActivityConfigGUI.cpp +++ b/Source/Menus/ScenarioActivityConfigGUI.cpp @@ -19,8 +19,6 @@ namespace RTE { - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - ScenarioActivityConfigGUI::ScenarioActivityConfigGUI(GUIControlManager* parentControlManager) : m_GUIControlManager(parentControlManager) { m_ActivityConfigBox = dynamic_cast(m_GUIControlManager->GetControl("CollectionBoxActivityConfig")); @@ -69,8 +67,6 @@ namespace RTE { m_TechListFetched = false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ScenarioActivityConfigGUI::PopulateTechComboBoxes() { for (int team = Activity::Teams::TeamOne; team < Activity::Teams::MaxTeamCount; ++team) { m_TeamTechComboBoxes[team]->GetListPanel()->AddItem("-All-", "", nullptr, nullptr, -2); @@ -90,14 +86,10 @@ namespace RTE { m_TechListFetched = true; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool ScenarioActivityConfigGUI::IsEnabled() const { return m_ActivityConfigBox->GetEnabled() && m_ActivityConfigBox->GetVisible(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ScenarioActivityConfigGUI::SetEnabled(bool enable, const Activity* selectedActivity, Scene* selectedScene) { m_ActivityConfigBox->SetEnabled(enable); m_ActivityConfigBox->SetVisible(enable); @@ -132,8 +124,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ScenarioActivityConfigGUI::ResetActivityConfigBox() { m_ActivityDifficultyLabel->SetText(" " + Activity::GetDifficultyString(m_ActivityDifficultySlider->GetValue())); @@ -205,8 +195,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ScenarioActivityConfigGUI::StartGame() { GameActivity* gameActivity = dynamic_cast(m_SelectedActivity->Clone()); @@ -247,8 +235,6 @@ namespace RTE { g_ActivityMan.SetStartActivity(gameActivity); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool ScenarioActivityConfigGUI::Update(int mouseX, int mouseY) { UpdatePlayerTeamSetupCell(mouseX, mouseY); @@ -295,8 +281,6 @@ namespace RTE { return HandleInputEvents(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ScenarioActivityConfigGUI::UpdateStartingGoldSliderAndLabel() { if (!m_StartingGoldAdjustedManually) { if (m_ActivityDifficultySlider->GetValue() <= Activity::DifficultySetting::CakeDifficulty && m_SelectedActivity->GetDefaultGoldCakeDifficulty() > -1) { @@ -327,8 +311,6 @@ namespace RTE { m_StartingGoldLabel->SetText(goldString); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ScenarioActivityConfigGUI::UpdatePlayerTeamSetupCell(int mouseX, int mouseY) { if (const GUICollectionBox* hoveredCell = dynamic_cast(m_GUIControlManager->GetControlUnderPoint(mouseX, mouseY, m_PlayersAndTeamsConfigBox, 1))) { int hoveredPlayer = PlayerColumns::PlayerColumnCount; @@ -354,8 +336,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ScenarioActivityConfigGUI::HandleClickOnPlayerTeamSetupCell(int clickedPlayer, int clickedTeam) { m_PlayerBoxes.at(clickedPlayer).at(clickedTeam)->SetDrawType(GUICollectionBox::Image); const Icon* playerIcon = (clickedPlayer != PlayerColumns::PlayerCPU) ? g_UInputMan.GetSchemeIcon(clickedPlayer) : dynamic_cast(g_PresetMan.GetEntityPreset("Icon", "Device CPU")); @@ -416,8 +396,6 @@ namespace RTE { g_GUISound.FocusChangeSound()->Play(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool ScenarioActivityConfigGUI::HandleInputEvents() { GUIEvent guiEvent; while (m_GUIControlManager->GetEvent(&guiEvent)) { @@ -454,8 +432,6 @@ namespace RTE { return false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ScenarioActivityConfigGUI::Draw() { m_GUIControlManager->Draw(); diff --git a/Source/Menus/ScenarioActivityConfigGUI.h b/Source/Menus/ScenarioActivityConfigGUI.h index a175bd2c88..f5a1b85b93 100644 --- a/Source/Menus/ScenarioActivityConfigGUI.h +++ b/Source/Menus/ScenarioActivityConfigGUI.h @@ -16,63 +16,47 @@ namespace RTE { class GUISlider; class GUIEvent; - /// /// Handling for the scenario Activity configuration screen composition and interaction. - /// class ScenarioActivityConfigGUI { public: #pragma region Creation - /// /// Constructor method used to instantiate a ScenarioActivityConfigGUI object in system memory and make it ready for use. - /// - /// Pointer to the parent GUIControlManager which owns all the GUIControls of this ScenarioActivityConfigGUI. Ownership is NOT transferred! + /// @param parentControlManager Pointer to the parent GUIControlManager which owns all the GUIControls of this ScenarioActivityConfigGUI. Ownership is NOT transferred! explicit ScenarioActivityConfigGUI(GUIControlManager* parentControlManager); #pragma endregion #pragma region Getters and Setters - /// /// Gets whether this ScenarioActivityConfigGUI is currently visible and enabled. - /// - /// Whether this ScenarioActivityConfigGUI is currently visible and enabled. + /// @return Whether this ScenarioActivityConfigGUI is currently visible and enabled. bool IsEnabled() const; - /// /// Enables or disables the ScenarioActivityConfigGUI. - /// - /// Show and enable or hide and disable the ScenarioActivityConfigGUI. - /// Pointer to the Activity this ScenarioActivityConfigGUI will be configuring for. - /// Pointer to the Scene the passed in Activity will be using. + /// @param enable Show and enable or hide and disable the ScenarioActivityConfigGUI. + /// @param selectedActivity Pointer to the Activity this ScenarioActivityConfigGUI will be configuring for. + /// @param selectedScene Pointer to the Scene the passed in Activity will be using. void SetEnabled(bool enable, const Activity* selectedActivity = nullptr, Scene* selectedScene = nullptr); #pragma endregion #pragma region Concrete Methods - /// /// Updates the ScenarioActivityConfigGUI state. - /// - /// Mouse X position. - /// Mouse Y position. - /// Whether the player started a new game through the ScenarioActivityConfigGUI. + /// @param mouseX Mouse X position. + /// @param mouseY Mouse Y position. + /// @return Whether the player started a new game through the ScenarioActivityConfigGUI. bool Update(int mouseX, int mouseY); - /// /// Draws the ScenarioActivityConfigGUI to the screen. - /// void Draw(); #pragma endregion private: - /// /// Enumeration for all the player columns in the player setup box. "Extends" the Players enumeration by adding an entry for the CPU player. - /// enum PlayerColumns { PlayerCPU = Players::MaxPlayerCount, PlayerColumnCount }; - /// /// Enumeration for all the team rows in the player setup box. "Extends" the Teams enumeration by adding an entry for unused (disabled) Team. - /// enum TeamRows { DisabledTeam = Activity::Teams::MaxTeamCount, TeamRowCount @@ -91,9 +75,7 @@ namespace RTE { bool m_TechListFetched; //!< Whether the tech list was fetched and each team's ComboBox was populated with it, even if no valid tech modules were added. - /// /// GUI elements that compose the Activity setup box. - /// GUICollectionBox* m_ActivityConfigBox; GUILabel* m_StartErrorLabel; GUIButton* m_StartGameButton; @@ -115,45 +97,31 @@ namespace RTE { std::array m_TeamAISkillSliders; #pragma region Activity Configuration Screen Handling - /// /// Fills each team's Tech ComboBox with all valid Tech DataModules. - /// void PopulateTechComboBoxes(); - /// /// Resets the configuration screen to the selected Activity's default settings and enables/disables attribute settings accordingly, making the configuration screen ready for interaction. - /// void ResetActivityConfigBox(); - /// /// Sets up and starts the currently selected Activity with the configured settings. - /// void StartGame(); - /// /// Updates the starting gold slider to the Activity difficulty setting (when applicable) and updates the value in the label according to the value in the slider. - /// - /// + /// @return void UpdateStartingGoldSliderAndLabel(); - /// /// Updates the currently hovered cell in the players and teams config box to apply the hovered visual and removes the hovered visual from any other cells. Also handles clicking on cells. - /// - /// Mouse X position. - /// Mouse Y position. + /// @param mouseX Mouse X position. + /// @param mouseY Mouse Y position. void UpdatePlayerTeamSetupCell(int mouseX, int mouseY); - /// /// Handles the player interaction with a cell in the players and teams config box. - /// - /// The player box that was clicked. - /// The team box that was clicked. + /// @param clickedPlayer The player box that was clicked. + /// @param clickedTeam The team box that was clicked. void HandleClickOnPlayerTeamSetupCell(int clickedPlayer, int clickedTeam); - /// /// Handles the player interaction with the ScenarioActivityConfigGUI GUI elements. - /// - /// Whether the player started a new game through the ScenarioActivityConfigGUI. + /// @return Whether the player started a new game through the ScenarioActivityConfigGUI. bool HandleInputEvents(); #pragma endregion diff --git a/Source/Menus/ScenarioGUI.cpp b/Source/Menus/ScenarioGUI.cpp index f86bce4526..610eae823a 100644 --- a/Source/Menus/ScenarioGUI.cpp +++ b/Source/Menus/ScenarioGUI.cpp @@ -23,8 +23,6 @@ namespace RTE { - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ScenarioGUI::Clear() { m_RootBoxMaxWidth = 0; @@ -51,8 +49,6 @@ namespace RTE { m_DrawDefaultScenePreview = true; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ScenarioGUI::Create(AllegroScreen* guiScreen, GUIInputWrapper* guiInput) { m_GUIControlManager = std::make_unique(); RTEAssert(m_GUIControlManager->Create(guiScreen, guiInput, "Base.rte/GUIs/Skins/Menus", "MainMenuSubMenuSkin.ini"), "Failed to create GUI Control Manager and load it from Base.rte/GUIs/Skins/Menus/MainMenuSubMenuSkin.ini"); @@ -77,8 +73,6 @@ namespace RTE { m_ActivityConfigBox = std::make_unique(m_GUIControlManager.get()); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ScenarioGUI::CreateActivityInfoBox() { m_ActivityInfoBox = dynamic_cast(m_GUIControlManager->GetControl("CollectionBoxActivityInfo")); m_ActivityInfoBox->SetPositionRel(16, 16); @@ -88,8 +82,6 @@ namespace RTE { m_ActivityDescriptionLabel->SetFont(m_GUIControlManager->GetSkin()->GetFont("FontSmall.png")); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ScenarioGUI::CreateSceneInfoBox() { m_SceneInfoBox = dynamic_cast(m_GUIControlManager->GetControl("CollectionBoxSceneInfo")); m_SceneInfoBox->SetPositionRel(m_RootBox->GetWidth() - m_SceneInfoBox->GetWidth() - 16, 16); @@ -109,8 +101,6 @@ namespace RTE { m_ScenePreviewBitmap->Create(c_ScenePreviewWidth, c_ScenePreviewHeight, 32); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ScenarioGUI::SetEnabled(const Vector& center, float radius) { bool centerChanged = (center != m_PlanetCenter); m_PlanetCenter = center; @@ -130,8 +120,6 @@ namespace RTE { m_ScenePreviewAnimTimer.Reset(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ScenarioGUI::SetDraggedBox(int mouseX, int mouseY) { GUICollectionBox* hoveredBox = dynamic_cast(m_GUIControlManager->GetControlUnderPoint(mouseX, mouseY, m_RootBox, 1)); const GUIControl* hoveredControl = m_GUIControlManager->GetControlUnderPoint(mouseX, mouseY, hoveredBox, 1); @@ -141,8 +129,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ScenarioGUI::SetSelectedActivity(const Activity* newSelectedActivity) { m_SelectedActivity = newSelectedActivity; m_ActivityScenes = nullptr; @@ -168,8 +154,6 @@ namespace RTE { m_ActivityInfoBox->Resize(m_ActivityInfoBox->GetWidth(), m_ActivityDescriptionLabel->ResizeHeightToFit() + 60); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ScenarioGUI::SetSelectedScene(Scene* newSelectedScene) { m_SelectedScene = newSelectedScene; if (m_SelectedScene) { @@ -202,8 +186,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ScenarioGUI::DragBox(int mouseX, int mouseY) { if (m_DraggedBox) { m_DraggedBox->MoveRelative(mouseX - m_PrevMousePos.GetFloorIntX(), mouseY - m_PrevMousePos.GetFloorIntY()); @@ -219,8 +201,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ScenarioGUI::FetchActivitiesAndScenesLists() { int prevSelectedActivityIndex = m_ActivitySelectComboBox->GetSelectedIndex(); Scene* prevSelectedScene = m_SelectedScene; @@ -271,8 +251,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ScenarioGUI::AdjustSitePointOffsetsOnPlanet(const std::vector& sceneList) const { for (Scene* sceneListEntry: sceneList) { int sceneYPos = (m_PlanetCenter + sceneListEntry->GetLocation() + sceneListEntry->GetLocationOffset()).GetFloorIntY(); @@ -327,8 +305,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ScenarioGUI::CalculateLinesToSitePoint() { m_LineToSitePoints.clear(); if (!m_SelectedScene) { @@ -400,8 +376,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - ScenarioGUI::ScenarioMenuUpdateResult ScenarioGUI::Update() { m_UpdateResult = ScenarioMenuUpdateResult::NoEvent; @@ -455,8 +429,6 @@ namespace RTE { return m_UpdateResult; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ScenarioGUI::UpdateHoveredSitePointLabel(int mouseX, int mouseY) { bool foundAnyHover = false; if (m_ActivityScenes && !m_DraggedBox && !m_ActivityInfoBox->PointInside(mouseX, mouseY) && !m_SceneInfoBox->PointInside(mouseX, mouseY)) { @@ -489,8 +461,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ScenarioGUI::HandleInputEvents(int mouseX, int mouseY) { GUIEvent guiEvent; while (m_GUIControlManager->GetEvent(&guiEvent)) { @@ -535,8 +505,6 @@ namespace RTE { m_PrevMousePos.SetXY(static_cast(mouseX), static_cast(mouseY)); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ScenarioGUI::Draw() const { // Early return to avoid single frame flicker before title screen goes into fadeout. if (m_UpdateResult == ScenarioMenuUpdateResult::ActivityStarted) { @@ -561,8 +529,6 @@ namespace RTE { m_GUIControlManager->DrawMouse(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ScenarioGUI::DrawSitePoints(BITMAP* drawBitmap) const { int blendAmount = 0; for (const Scene* scenePointer: *m_ActivityScenes) { @@ -589,8 +555,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ScenarioGUI::DrawLinesToSitePoint(BITMAP* drawBitmap) const { int blendAmount = 0; int drawColor = c_GUIColorWhite; diff --git a/Source/Menus/ScenarioGUI.h b/Source/Menus/ScenarioGUI.h index 62ba79d98d..6b4fe7447a 100644 --- a/Source/Menus/ScenarioGUI.h +++ b/Source/Menus/ScenarioGUI.h @@ -17,15 +17,11 @@ namespace RTE { class GUIButton; class GUILabel; - /// /// Handling for the scenario menu screen composition and sub-menu interaction. - /// class ScenarioGUI { public: - /// /// Enumeration for the results of the ScenarioGUI input and event update. - /// enum class ScenarioMenuUpdateResult { NoEvent, BackToMain, @@ -34,43 +30,33 @@ namespace RTE { }; #pragma region Creation - /// /// Constructor method used to instantiate this ScenarioGUI object in system memory. - /// - /// Pointer to a GUIScreen interface that will be used by this ScenarioGUI's GUIControlManager. Ownership is NOT transferred! - /// Pointer to a GUIInput interface that will be used by this ScenarioGUI's GUIControlManager. Ownership is NOT transferred! + /// @param guiScreen Pointer to a GUIScreen interface that will be used by this ScenarioGUI's GUIControlManager. Ownership is NOT transferred! + /// @param guiInput Pointer to a GUIInput interface that will be used by this ScenarioGUI's GUIControlManager. Ownership is NOT transferred! ScenarioGUI(AllegroScreen* guiScreen, GUIInputWrapper* guiInput) { Clear(); Create(guiScreen, guiInput); } - /// /// Makes the ScenarioGUI object ready for use. - /// - /// Pointer to a GUIScreen interface that will be used by this ScenarioGUI's GUIControlManager. Ownership is NOT transferred! - /// Pointer to a GUIInput interface that will be used by this ScenarioGUI's GUIControlManager. Ownership is NOT transferred! + /// @param guiScreen Pointer to a GUIScreen interface that will be used by this ScenarioGUI's GUIControlManager. Ownership is NOT transferred! + /// @param guiInput Pointer to a GUIInput interface that will be used by this ScenarioGUI's GUIControlManager. Ownership is NOT transferred! void Create(AllegroScreen* guiScreen, GUIInputWrapper* guiInput); #pragma endregion #pragma region Setters - /// /// Enables the GUI elements for the menu, sets the planet coordinates on the screen so the menu can properly overlay it, and fetches the Scenes and Activities lists. - /// - /// The absolute screen coordinates of the planet's center. - /// The radius, in screen pixel units, of the planet. + /// @param center The absolute screen coordinates of the planet's center. + /// @param radius The radius, in screen pixel units, of the planet. void SetEnabled(const Vector& center, float radius); #pragma endregion #pragma region Concrete Methods - /// /// Updates the ScenarioGUI state. - /// - /// The result of the ScenarioGUI input and event update. See ScenarioMenuUpdateResult enumeration. + /// @return The result of the ScenarioGUI input and event update. See ScenarioMenuUpdateResult enumeration. ScenarioMenuUpdateResult Update(); - /// /// Draws the ScenarioGUI to the screen. - /// void Draw() const; #pragma endregion @@ -102,9 +88,7 @@ namespace RTE { std::unique_ptr m_ActivityConfigBox; //!< The Activity configuration box. - /// /// GUI elements that compose the scenario menu screen. - /// GUICollectionBox* m_RootBox; GUICollectionBox* m_ActivityConfigBoxRootBox; GUIButton* m_BackToMainButton; @@ -122,94 +106,66 @@ namespace RTE { GUILabel* m_SitePointNameLabel; #pragma region Create Breakdown - /// /// Creates all the elements that compose the Activity info box. - /// void CreateActivityInfoBox(); - /// /// Creates all the elements that compose the Scene info box. - /// void CreateSceneInfoBox(); #pragma endregion #pragma region Scenario Menu Handling - /// /// Sets the CollectionBox that is currently being dragged, if applicable. - /// - /// Mouse X position. - /// Mouse Y position. + /// @param mouseX Mouse X position. + /// @param mouseY Mouse Y position. void SetDraggedBox(int mouseX, int mouseY); - /// /// Sets the selected Activity, refreshes the compatible Scenes on the planet and updates the Activity info box appropriately. - /// - /// The new selected Activity. + /// @param newSelectedActivity The new selected Activity. void SetSelectedActivity(const Activity* newSelectedActivity); - /// /// Sets the currently selected Scene and updates the Scene info box appropriately. - /// - /// The new selected Scene. + /// @param newSelectedScene The new selected Scene. void SetSelectedScene(Scene* newSelectedScene); - /// /// Moves the CollectionBox that is selected as being dragged, if any. - /// - /// Mouse X position to calculate box position. - /// Mouse Y position to calculate box position. + /// @param mouseX Mouse X position to calculate box position. + /// @param mouseY Mouse Y position to calculate box position. void DragBox(int mouseX, int mouseY); - /// /// Fetches all the available Scenes and Activity presets from PresetMan. - /// void FetchActivitiesAndScenesLists(); - /// /// Adjusts the positions of the site points on the planet if they don't fit the screen or overlap. - /// - /// Vector of Scenes to adjust positions for. + /// @param sceneList Vector of Scenes to adjust positions for. void AdjustSitePointOffsetsOnPlanet(const std::vector& sceneList) const; - /// /// Calculates how to draw lines from the Scene info box to the selected site point on the planet. - /// void CalculateLinesToSitePoint(); #pragma endregion #pragma region Update Breakdown - /// /// Displays the site name label if the mouse is over a site point. - /// - /// Mouse X position. - /// Mouse Y position. + /// @param mouseX Mouse X position. + /// @param mouseY Mouse Y position. void UpdateHoveredSitePointLabel(int mouseX, int mouseY); - /// /// Handles the player interaction with the ScenarioGUI GUI elements. - /// - /// Mouse X position. - /// Mouse Y position. + /// @param mouseX Mouse X position. + /// @param mouseY Mouse Y position. void HandleInputEvents(int mouseX, int mouseY); #pragma endregion #pragma region Draw Breakdown - /// /// Draws the site points on top of the planet. - /// - /// The bitmap to draw on. + /// @param drawBitmap The bitmap to draw on. void DrawSitePoints(BITMAP* drawBitmap) const; - /// /// Draws fancy thick flickering lines from the Scene info box to the selected scene point on the planet. - /// - /// The bitmap to draw to. + /// @param drawBitmap The bitmap to draw to. void DrawLinesToSitePoint(BITMAP* drawBitmap) const; #pragma endregion - /// /// Clears all the member variables of this ScenarioGUI, effectively resetting the members of this object. - /// void Clear(); // Disallow the use of some implicit methods. diff --git a/Source/Menus/SceneEditorGUI.cpp b/Source/Menus/SceneEditorGUI.cpp index c67438e800..3adc942441 100644 --- a/Source/Menus/SceneEditorGUI.cpp +++ b/Source/Menus/SceneEditorGUI.cpp @@ -1,15 +1,3 @@ -////////////////////////////////////////////////////////////////////////////////////////// -// File: SceneEditorGUI.cpp -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Implementation file for the SceneEditorGUI class -// Project: GUI Library -// Author(s): Daniel Tabar -// dtabar@datarealms.com -// http://www.datarealms.com - -////////////////////////////////////////////////////////////////////////////////////////// -// Inclusions of header files - #include "SceneEditorGUI.h" #include "CameraMan.h" @@ -45,12 +33,6 @@ using namespace RTE; BITMAP* SceneEditorGUI::s_pValidPathDot = 0; BITMAP* SceneEditorGUI::s_pInvalidPathDot = 0; -////////////////////////////////////////////////////////////////////////////////////////// -// Method: Clear -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Clears all the member variables of this SceneEditorGUI, effectively -// resetting the members of this abstraction level only. - void SceneEditorGUI::Clear() { m_pController = 0; m_FeatureSet = INGAMEEDIT; @@ -84,11 +66,6 @@ void SceneEditorGUI::Clear() { m_PathRequest.reset(); } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: Create -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Makes the SceneEditorGUI object ready for use. - int SceneEditorGUI::Create(Controller* pController, FeatureSets featureSet, int whichModuleSpace, int nativeTechModule, float foreignCostMult) { RTEAssert(pController, "No controller sent to SceneEditorGUI on creation!"); m_pController = pController; @@ -149,11 +126,6 @@ int SceneEditorGUI::Create(Controller* pController, FeatureSets featureSet, int return 0; } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: Destroy -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Destroys and resets (through Clear()) the SceneEditorGUI object. - void SceneEditorGUI::Destroy() { delete m_pPicker; @@ -162,20 +134,12 @@ void SceneEditorGUI::Destroy() { Clear(); } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: SetController -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Sets the controller used by this. The ownership of the controller is -// NOT transferred! - void SceneEditorGUI::SetController(Controller* pController) { m_pController = pController; m_PieMenu->SetMenuController(pController); m_pPicker->SetController(pController); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SceneEditorGUI::SetFeatureSet(SceneEditorGUI::FeatureSets newFeatureSet) { m_FeatureSet = newFeatureSet; if (m_PieMenu) { @@ -203,25 +167,10 @@ void SceneEditorGUI::SetFeatureSet(SceneEditorGUI::FeatureSets newFeatureSet) { m_PieMenu->SetMenuController(m_pController); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -////////////////////////////////////////////////////////////////////////////////////////// -// Method: SetPosOnScreen -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Sets where on the screen that this GUI is being drawn to. If upper -// left corner, then 0, 0. This will affect the way the mouse is positioned -// etc. - void SceneEditorGUI::SetPosOnScreen(int newPosX, int newPosY) { m_pPicker->SetPosOnScreen(newPosX, newPosY); } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: SetCurrentObject -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Sets the new Object to be held at the cursor of this Editor. Ownership -// IS transferred! - bool SceneEditorGUI::SetCurrentObject(SceneObject* pNewObject) { if (m_pCurrentObject == pNewObject) return true; @@ -245,31 +194,14 @@ bool SceneEditorGUI::SetCurrentObject(SceneObject* pNewObject) { return true; } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: GetActivatedPieSlice -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Gets any Pie menu slice command activated last update. - PieSlice::SliceType SceneEditorGUI::GetActivatedPieSlice() const { return m_PieMenu->GetPieCommand(); } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: SetModuleSpace -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Sets which DataModule space to be picking objects from. If -1, then -// let the player pick from all loaded modules. - void SceneEditorGUI::SetModuleSpace(int moduleSpaceID) { m_pPicker->SetModuleSpace(moduleSpaceID); } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: SetNativeTechModule -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Sets which DataModule ID should be treated as the native tech of the -// user of this menu. - void SceneEditorGUI::SetNativeTechModule(int whichModule) { if (whichModule >= 0 && whichModule < g_PresetMan.GetTotalModuleCount()) { m_NativeTechModule = whichModule; @@ -277,25 +209,11 @@ void SceneEditorGUI::SetNativeTechModule(int whichModule) { } } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: SetForeignCostMultiplier -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Sets the multiplier of the cost of any foreign Tech items. - void SceneEditorGUI::SetForeignCostMultiplier(float newMultiplier) { m_ForeignCostMult = newMultiplier; m_pPicker->SetForeignCostMultiplier(m_ForeignCostMult); } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: TestBrainResidence -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Checks whether the resident brain is currently placed into a valid -// location in this scene, based on whether there is a clear path to the -// sky above it. This forces the editor into place brain mode with the -// current resident brain if the current placement is no bueno. It also -// removes the faulty brain from residence in the scene! - bool SceneEditorGUI::TestBrainResidence(bool noBrainIsOK) { // Do we have a resident at all? SceneObject* pBrain = g_SceneMan.GetScene()->GetResidentBrain(m_pController->GetPlayer()); @@ -349,11 +267,6 @@ bool SceneEditorGUI::TestBrainResidence(bool noBrainIsOK) { return true; } -////////////////////////////////////////////////////////////////////////////////////////// -// Method: Update -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Updates the state of this Menu each frame - void SceneEditorGUI::Update() { // Update the user controller // m_pController->Update(); @@ -1259,11 +1172,6 @@ void SceneEditorGUI::Update() { } } -////////////////////////////////////////////////////////////////////////////////////////// -// Virtual Method: Draw -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Draws the menu - void SceneEditorGUI::Draw(BITMAP* pTargetBitmap, const Vector& targetPos) const { // Done, so don't draw the UI if (m_EditorGUIMode == DONEEDITING) @@ -1412,8 +1320,6 @@ void SceneEditorGUI::Draw(BITMAP* pTargetBitmap, const Vector& targetPos) const m_PieMenu->Draw(pTargetBitmap, targetPos); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SceneEditorGUI::UpdateBrainSkyPathAndCost(Vector brainPos) { if (!m_RequireClearPathToOrbit) { m_PathRequest.reset(); @@ -1504,8 +1410,6 @@ void SceneEditorGUI::UpdateBrainSkyPathAndCost(Vector brainPos) { }); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool SceneEditorGUI::UpdateBrainPath() { if (m_pCurrentObject && m_pCurrentObject->IsInGroup("Brains")) { UpdateBrainSkyPathAndCost(m_CursorPos); diff --git a/Source/Menus/SceneEditorGUI.h b/Source/Menus/SceneEditorGUI.h index cffd30ba17..403090a0bf 100644 --- a/Source/Menus/SceneEditorGUI.h +++ b/Source/Menus/SceneEditorGUI.h @@ -1,19 +1,12 @@ #ifndef _SCENEEDITORGUI_ #define _SCENEEDITORGUI_ -////////////////////////////////////////////////////////////////////////////////////////// -// File: SceneEditorGUI.h -////////////////////////////////////////////////////////////////////////////////////////// -// Description: SceneEditorGUI class -// Project: GUI Library -// Author(s): Daniel Tabar -// dtabar@datarealms.com -// http://www.datarealms.com - -////////////////////////////////////////////////////////////////////////////////////////// -// Inclusions of header files - -//#include "FrameMan.h" +/// SceneEditorGUI class +/// @author Daniel Tabar +/// dtabar@datarealms.com +/// http://www.datarealms.com +/// Inclusions of header files +// #include "FrameMan.h" #include "Timer.h" #include "Vector.h" #include "Controller.h" @@ -28,18 +21,10 @@ namespace RTE { class ObjectPickerGUI; class PieMenu; - ////////////////////////////////////////////////////////////////////////////////////////// - // Class: SceneEditorGUI - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: A full menu system that represents the scene editing GUI for Cortex Command - // Parent(s): None. - // Class history: 7/08/2007 SceneEditorGUI Created. - + /// A full menu system that represents the scene editing GUI for Cortex Command class SceneEditorGUI { - ////////////////////////////////////////////////////////////////////////////////////////// - // Public member variable, method and friend function declarations - + /// Public member variable, method and friend function declarations public: enum FeatureSets { ONLOADEDIT = 0, @@ -63,229 +48,122 @@ namespace RTE { EDITORGUIMODECOUNT }; - ////////////////////////////////////////////////////////////////////////////////////////// - // Constructor: SceneEditorGUI - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Constructor method used to instantiate a SceneEditorGUI object in system - // memory. Create() should be called before using the object. - // Arguments: None. - + /// Constructor method used to instantiate a SceneEditorGUI object in system + /// memory. Create() should be called before using the object. SceneEditorGUI() { Clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Destructor: ~SceneEditorGUI - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destructor method used to clean up a SceneEditorGUI object before deletion - // from system memory. - // Arguments: None. - + /// Destructor method used to clean up a SceneEditorGUI object before deletion + /// from system memory. ~SceneEditorGUI() { Destroy(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Create - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Makes the SceneEditorGUI object ready for use. - // Arguments: A poitner to a Controller which will control this Menu. Ownership is - // NOT TRANSFERRED! - // Whether the editor should have all the features enabled, like load/save - // and undo capabilities. - // Which module space that this eidtor will be able to pick objects from. - // -1 means all modules. - // Which Tech module that will be presented as the native one to the player. - // The multiplier of all foreign techs' costs. - // Return value: An error return value signaling sucess or any particular failure. - // Anything below 0 is an error signal. - + /// Makes the SceneEditorGUI object ready for use. + /// @param pController A poitner to a Controller which will control this Menu. Ownership is + /// @param featureSet NOT TRANSFERRED! (default: INGAMEEDIT) + /// @param whichModuleSpace Whether the editor should have all the features enabled, like load/save (default: -1) + /// and undo capabilities. + /// @param nativeTechModule Which module space that this eidtor will be able to pick objects from. (default: 0) + /// -1 means all modules. + /// @param foreignCostMult Which Tech module that will be presented as the native one to the player. (default: 1.0) + /// The multiplier of all foreign techs' costs. + /// @return An error return value signaling sucess or any particular failure. + /// Anything below 0 is an error signal. int Create(Controller* pController, FeatureSets featureSet = INGAMEEDIT, int whichModuleSpace = -1, int nativeTechModule = 0, float foreignCostMult = 1.0); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Reset - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Resets the entire SceneEditorGUI, including its inherited members, to - // their default settings or values. - // Arguments: None. - // Return value: None. - + /// Resets the entire SceneEditorGUI, including its inherited members, to + /// their default settings or values. void Reset() { Clear(); } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Destroy - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Destroys and resets (through Clear()) the SceneEditorGUI object. - // Arguments: None. - // Return value: None. - + /// Destroys and resets (through Clear()) the SceneEditorGUI object. void Destroy(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetController - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the controller used by this. The ownership of the controller is - // NOT transferred! - // Arguments: The new controller for this menu. Ownership is NOT transferred - // Return value: None. - + /// Sets the controller used by this. The ownership of the controller is + /// NOT transferred! + /// @param pController The new controller for this menu. Ownership is NOT transferred void SetController(Controller* pController); - /// /// Sets the FeatureSet for this SceneEditorGUI, and sets up the PieMenu accordingly. - /// - /// The new FeatureSet for this SceneEditorGUI. + /// @param newFeatureSet The new FeatureSet for this SceneEditorGUI. void SetFeatureSet(SceneEditorGUI::FeatureSets newFeatureSet); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetPosOnScreen - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets where on the screen that this GUI is being drawn to. If upper - // left corner, then 0, 0. This will affect the way the mouse is positioned - // etc. - // Arguments: The new screen position of this entire GUI. - + /// Sets where on the screen that this GUI is being drawn to. If upper + /// left corner, then 0, 0. This will affect the way the mouse is positioned + /// etc. + /// @param newPosX The new screen position of this entire GUI. void SetPosOnScreen(int newPosX, int newPosY); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetCursorPos - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the absolute scene coordinates of the cursor of this Editor. - // Arguments: The new cursor position in absolute scene units. - // Return value: None. - + /// Sets the absolute scene coordinates of the cursor of this Editor. + /// @param newCursorPos The new cursor position in absolute scene units. void SetCursorPos(const Vector& newCursorPos) { m_CursorPos = newCursorPos; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetCurrentObject - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the new Object to be held at the cursor of this Editor. Ownership - // IS transferred! - // Arguments: The new Object to be held by the cursor. Ownership IS transferred! - // Return value: Whether the cursor holds a valid object after setting. - + /// Sets the new Object to be held at the cursor of this Editor. Ownership + /// IS transferred! + /// @param pNewObject The new Object to be held by the cursor. Ownership IS transferred! + /// @return Whether the cursor holds a valid object after setting. bool SetCurrentObject(SceneObject* pNewObject); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetActivatedPieSlice - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets any Pie menu slice command activated last update. - // Arguments: None. - // Return value: The enum'd int of any slice activated. See the PieSlice::SliceType enum. - + /// Gets any Pie menu slice command activated last update. + /// @return The enum'd int of any slice activated. See the PieSlice::SliceType enum. PieSlice::SliceType GetActivatedPieSlice() const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetCurrentObject - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the currently held Object in the cursor of this Editor. Ownership - // IS NOT transferred! - // Arguments: None. - // Return value: The currently held object, if any. OWNERSHIP IS NOT TRANSFERRED! - + /// Gets the currently held Object in the cursor of this Editor. Ownership + /// IS NOT transferred! + /// @return The currently held object, if any. OWNERSHIP IS NOT TRANSFERRED! const SceneObject* GetCurrentObject() const { return m_pCurrentObject; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetEditorMode - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the current mode of this editor. - // Arguments: The new mode to set to, see the EditorGUIMode enum. - // Return value: None. - + /// Sets the current mode of this editor. + /// @param newMode The new mode to set to, see the EditorGUIMode enum. void SetEditorGUIMode(EditorGUIMode newMode) { m_EditorGUIMode = newMode; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: GetEditorMode - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Gets the current mode of this editor. - // Arguments: None. - // Return value: The current mode this is set to; see the EditorGUIMode enum. - + /// Gets the current mode of this editor. + /// @return The current mode this is set to; see the EditorGUIMode enum. EditorGUIMode GetEditorGUIMode() const { return m_EditorGUIMode; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetModuleSpace - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets which DataModule space to be picking objects from. If -1, then - // let the player pick from all loaded modules. - // Arguments: The ID of the module to let the player pick objects from. All official - // modules' objects will alwayws be presented, in addition to the one - // passed in here. - // Return value: None. - + /// Sets which DataModule space to be picking objects from. If -1, then + /// let the player pick from all loaded modules. + /// @param moduleSpaceID The ID of the module to let the player pick objects from. All official (default: -1) + /// modules' objects will alwayws be presented, in addition to the one + /// passed in here. void SetModuleSpace(int moduleSpaceID = -1); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetNativeTechModule - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets which DataModule ID should be treated as the native tech of the - // user of this menu. - // Arguments: The module ID to set as the native one. 0 means everything is native. - // Return value: None. - + /// Sets which DataModule ID should be treated as the native tech of the + /// user of this menu. + /// @param whichModule The module ID to set as the native one. 0 means everything is native. void SetNativeTechModule(int whichModule); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: SetForeignCostMultiplier - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Sets the multiplier of the cost of any foreign Tech items. - // Arguments: The scalar multiplier of the costs of foreign Tech items. - // Return value: None. - + /// Sets the multiplier of the cost of any foreign Tech items. + /// @param newMultiplier The scalar multiplier of the costs of foreign Tech items. void SetForeignCostMultiplier(float newMultiplier); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: EditMade - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Shows whether an edit on the scene was made in the last Update. - // Arguments: None. - // Return value: Whether any edit was made. - + /// Shows whether an edit on the scene was made in the last Update. + /// @return Whether any edit was made. bool EditMade() const { return m_EditMade; } - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: TestBrainResidence - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Checks whether the resident brain is currently placed into a valid - // location in this scene, based on whether there is a clear path to the - // sky above it. This forces the editor into place brain mode with the - // current resident brain if the current placement is no bueno. It also - // removes the faulty brain from residence in the scene! - // Arguments: Whether it's OK if we dont' have a brain right now - ie don't force - // into isntallation mode if no brain was found. - // Return value: Whether a resident brain was found, AND found in a valid location! - + /// Checks whether the resident brain is currently placed into a valid + /// location in this scene, based on whether there is a clear path to the + /// sky above it. This forces the editor into place brain mode with the + /// current resident brain if the current placement is no bueno. It also + /// removes the faulty brain from residence in the scene! + /// @param noBrainIsOK Whether it's OK if we dont' have a brain right now - ie don't force (default: false) + /// into isntallation mode if no brain was found. + /// @return Whether a resident brain was found, AND found in a valid location! bool TestBrainResidence(bool noBrainIsOK = false); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Update - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Updates the state of this Menu each frame - // Arguments: None. - // Return value: None. - + /// Updates the state of this Menu each frame void Update(); - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Draw - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Draws the editor - // Arguments: The bitmap to draw on. - // The absolute position of the target bitmap's upper left corner in the scene. - // Return value: None. - + /// Draws the editor + /// @param pTargetBitmap The bitmap to draw on. + /// @param targetPos The absolute position of the target bitmap's upper left corner in the scene. (default: Vector()) void Draw(BITMAP* pTargetBitmap, const Vector& targetPos = Vector()) const; - ////////////////////////////////////////////////////////////////////////////////////////// - // Protected member variable and method declarations - + /// Protected member variable and method declarations protected: - /// /// Updates the path to the current brain in the cursor or resident in the scene, if any. If there's none, the path is cleared. - /// - /// Whether a brain was found in the cursor or the scene. + /// @return Whether a brain was found in the cursor or the scene. bool UpdateBrainPath(); - /// /// Updates the path from the designated position to orbit, and its cost. - /// - /// The designated position of the brain. + /// @param brainPos The designated position of the brain. void UpdateBrainSkyPathAndCost(Vector brainPos); enum BlinkMode { @@ -361,18 +239,10 @@ namespace RTE { // The current pathfinding request std::shared_ptr m_PathRequest; - ////////////////////////////////////////////////////////////////////////////////////////// - // Private member variable and method declarations - + /// Private member variable and method declarations private: - ////////////////////////////////////////////////////////////////////////////////////////// - // Method: Clear - ////////////////////////////////////////////////////////////////////////////////////////// - // Description: Clears all the member variables of this SceneEditorGUI, effectively - // resetting the members of this abstraction level only. - // Arguments: None. - // Return value: None. - + /// Clears all the member variables of this SceneEditorGUI, effectively + /// resetting the members of this abstraction level only. void Clear(); // Disallow the use of some implicit methods. diff --git a/Source/Menus/SettingsAudioGUI.cpp b/Source/Menus/SettingsAudioGUI.cpp index e0dbd816ac..4c1d060150 100644 --- a/Source/Menus/SettingsAudioGUI.cpp +++ b/Source/Menus/SettingsAudioGUI.cpp @@ -9,8 +9,6 @@ namespace RTE { - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - SettingsAudioGUI::SettingsAudioGUI(GUIControlManager* parentControlManager) : m_GUIControlManager(parentControlManager) { m_AudioSettingsBox = dynamic_cast(m_GUIControlManager->GetControl("CollectionBoxAudioSettings")); @@ -35,39 +33,29 @@ namespace RTE { UpdateSoundVolumeControls(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SettingsAudioGUI::SetEnabled(bool enable) const { m_AudioSettingsBox->SetVisible(enable); m_AudioSettingsBox->SetEnabled(enable); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SettingsAudioGUI::UpdateMasterVolumeControls() { int masterVolume = static_cast(std::round(g_AudioMan.GetMasterVolume() * 100)); m_MasterVolumeLabel->SetText("Volume: " + std::to_string(masterVolume)); m_MasterVolumeSlider->SetValue(masterVolume); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SettingsAudioGUI::UpdateMusicVolumeControls() { int musicVolume = static_cast(std::round(g_AudioMan.GetMusicVolume() * 100)); m_MusicVolumeLabel->SetText("Volume: " + std::to_string(musicVolume)); m_MusicVolumeSlider->SetValue(musicVolume); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SettingsAudioGUI::UpdateSoundVolumeControls() { int soundVolume = static_cast(std::round(g_AudioMan.GetSoundsVolume() * 100)); m_SoundVolumeLabel->SetText("Volume: " + std::to_string(soundVolume)); m_SoundVolumeSlider->SetValue(soundVolume); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SettingsAudioGUI::HandleInputEvents(GUIEvent& guiEvent) { if (guiEvent.GetType() == GUIEvent::Notification) { if (guiEvent.GetControl() == m_MasterVolumeSlider) { diff --git a/Source/Menus/SettingsAudioGUI.h b/Source/Menus/SettingsAudioGUI.h index 9e89a30925..b21018336e 100644 --- a/Source/Menus/SettingsAudioGUI.h +++ b/Source/Menus/SettingsAudioGUI.h @@ -10,40 +10,30 @@ namespace RTE { class GUICheckbox; class GUIEvent; - /// /// Handling for audio settings through the game settings user interface. - /// class SettingsAudioGUI { public: #pragma region Creation - /// /// Constructor method used to instantiate a SettingsAudioGUI object in system memory and make it ready for use. - /// - /// Pointer to the parent GUIControlManager which owns all the GUIControls of this SettingsAudioGUI. Ownership is NOT transferred! + /// @param parentControlManager Pointer to the parent GUIControlManager which owns all the GUIControls of this SettingsAudioGUI. Ownership is NOT transferred! explicit SettingsAudioGUI(GUIControlManager* parentControlManager); #pragma endregion #pragma region Concrete Methods - /// /// Enables or disables the SettingsAudioGUI. - /// - /// Show and enable or hide and disable the SettingsAudioGUI. + /// @param enable Show and enable or hide and disable the SettingsAudioGUI. void SetEnabled(bool enable = true) const; - /// /// Handles the player interaction with the AudioVideoGUI GUI elements. - /// - /// The GUIEvent containing information about the player interaction with an element. + /// @param guiEvent The GUIEvent containing information about the player interaction with an element. void HandleInputEvents(GUIEvent& guiEvent); #pragma endregion private: GUIControlManager* m_GUIControlManager; //!< The GUIControlManager which holds all the GUIControls of this menu. Not owned by this. - /// /// GUI elements that compose the audio settings menu screen. - /// GUICollectionBox* m_AudioSettingsBox; GUILabel* m_MasterVolumeLabel; GUISlider* m_MasterVolumeSlider; @@ -56,19 +46,13 @@ namespace RTE { GUICheckbox* m_SoundMuteCheckbox; #pragma region Audio Settings Handling - /// /// Updates the position of the master volume slider and volume value label, based on what the AudioMan is currently set to. - /// void UpdateMasterVolumeControls(); - /// /// Updates the position of the music volume slider and volume value label, based on what the AudioMan is currently set to. - /// void UpdateMusicVolumeControls(); - /// /// Updates the position of the sound volume slider and volume value label, based on what the AudioMan is currently set to. - /// void UpdateSoundVolumeControls(); #pragma endregion diff --git a/Source/Menus/SettingsGUI.cpp b/Source/Menus/SettingsGUI.cpp index 44e5c39cb7..7aed598ae7 100644 --- a/Source/Menus/SettingsGUI.cpp +++ b/Source/Menus/SettingsGUI.cpp @@ -10,8 +10,6 @@ namespace RTE { - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - SettingsGUI::SettingsGUI(AllegroScreen* guiScreen, GUIInputWrapper* guiInput, bool createForPauseMenu) { m_GUIControlManager = std::make_unique(); RTEAssert(m_GUIControlManager->Create(guiScreen, guiInput, "Base.rte/GUIs/Skins/Menus", "MainMenuSubMenuSkin.ini"), "Failed to create GUI Control Manager and load it from Base.rte/GUIs/Skins/Menus/MainMenuSubMenuSkin.ini"); @@ -54,8 +52,6 @@ namespace RTE { m_SettingsMenuTabs[m_ActiveSettingsMenuScreen]->SetCheck(true); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUICollectionBox* SettingsGUI::GetActiveDialogBox() const { GUICollectionBox* activeDialogBox = nullptr; switch (m_ActiveSettingsMenuScreen) { @@ -73,8 +69,6 @@ namespace RTE { return activeDialogBox; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SettingsGUI::CloseActiveDialogBox() const { switch (m_ActiveSettingsMenuScreen) { case SettingsMenuScreen::VideoSettingsMenu: @@ -90,8 +84,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SettingsGUI::DisableSettingsMenuNavigation(bool disable) const { m_BackToMainButton->SetEnabled(!disable); for (GUITab* settingsTabberTab: m_SettingsMenuTabs) { @@ -99,8 +91,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SettingsGUI::SetActiveSettingsMenuScreen(SettingsMenuScreen activeMenu, bool playButtonPressSound) { m_VideoSettingsMenu->SetEnabled(false); m_AudioSettingsMenu->SetEnabled(false); @@ -137,8 +127,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool SettingsGUI::HandleInputEvents() { m_GUIControlManager->Update(); @@ -200,8 +188,6 @@ namespace RTE { return false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SettingsGUI::Draw() const { m_GUIControlManager->Draw(); m_GUIControlManager->DrawMouse(); diff --git a/Source/Menus/SettingsGUI.h b/Source/Menus/SettingsGUI.h index dd65341956..e3a6d64573 100644 --- a/Source/Menus/SettingsGUI.h +++ b/Source/Menus/SettingsGUI.h @@ -15,57 +15,41 @@ namespace RTE { class GUIButton; class GUITab; - /// /// Handling for the settings menu screen composition and sub-menu interaction. - /// class SettingsGUI { public: #pragma region Creation - /// /// Constructor method used to instantiate a SettingsGUI object in system memory and make it ready for use. - /// - /// Pointer to a GUIScreen interface that will be used by this SettingsGUI's GUIControlManager. Ownership is NOT transferred! - /// Pointer to a GUIInput interface that will be used by this SettingsGUI's GUIControlManager. Ownership is NOT transferred! - /// Whether this SettingsGUI is part of PauseMenuGUI and should have a slightly different layout. + /// @param guiScreen Pointer to a GUIScreen interface that will be used by this SettingsGUI's GUIControlManager. Ownership is NOT transferred! + /// @param guiInput Pointer to a GUIInput interface that will be used by this SettingsGUI's GUIControlManager. Ownership is NOT transferred! + /// @param createForPauseMenu Whether this SettingsGUI is part of PauseMenuGUI and should have a slightly different layout. SettingsGUI(AllegroScreen* guiScreen, GUIInputWrapper* guiInput, bool createForPauseMenu = false); #pragma endregion #pragma region Getters - /// /// Gets the currently active GUICollectionBox of this SettingsGUI or any of its sub-menus that acts as a dialog box and requires disabling navigation and drawing an overlay. - /// - /// Pointer to the GUICollectionBox that is the currently active dialog box. Ownership is NOT transferred! + /// @return Pointer to the GUICollectionBox that is the currently active dialog box. Ownership is NOT transferred! GUICollectionBox* GetActiveDialogBox() const; #pragma endregion #pragma region Concrete Methods - /// /// Closes the currently active GUICollectionBox that acts as a dialog box by hiding it. If the active dialog box is a sub-menu, disables it. - /// void CloseActiveDialogBox() const; - /// /// Sets the currently active settings menu screen again to refresh it. This is used in case textboxes were left empty or focused on settings screen exit via back button or esc. - /// void RefreshActiveSettingsMenuScreen() { SetActiveSettingsMenuScreen(m_ActiveSettingsMenuScreen, false); } - /// /// Handles the player interaction with the SettingsGUI GUI elements. - /// - /// Whether the player requested to return to the main menu. + /// @return Whether the player requested to return to the main menu. bool HandleInputEvents(); - /// /// Draws the SettingsGUI to the screen. - /// void Draw() const; #pragma endregion private: - /// /// Enumeration for the different sub-menu screens of the settings menu. - /// enum SettingsMenuScreen { VideoSettingsMenu, AudioSettingsMenu, @@ -85,24 +69,18 @@ namespace RTE { std::unique_ptr m_GameplaySettingsMenu; //!< The gameplay settings sub-menu. std::unique_ptr m_MiscSettingsMenu; //!< The misc settings sub-menu. - /// /// GUI elements that compose the settings menu screen. - /// GUICollectionBox* m_SettingsTabberBox; GUIButton* m_BackToMainButton; std::array m_SettingsMenuTabs; #pragma region Settings Menu Handling - /// /// Disables the settings menu tabber and back buttons. This is used when a settings sub-menu dialog box is active. - /// void DisableSettingsMenuNavigation(bool disable) const; - /// /// Sets the SettingsGUI to display a settings menu screen. - /// - /// Which settings menu screen to display. See the SettingsMenuScreen enumeration. - /// Whether to play a sound if the menu screen change is triggered by a button/tab press. + /// @param activeMenu Which settings menu screen to display. See the SettingsMenuScreen enumeration. + /// @param playButtonPressSound Whether to play a sound if the menu screen change is triggered by a button/tab press. void SetActiveSettingsMenuScreen(SettingsMenuScreen activeMenu, bool playButtonPressSound = true); #pragma endregion diff --git a/Source/Menus/SettingsGameplayGUI.cpp b/Source/Menus/SettingsGameplayGUI.cpp index e000041f68..8936e04a5e 100644 --- a/Source/Menus/SettingsGameplayGUI.cpp +++ b/Source/Menus/SettingsGameplayGUI.cpp @@ -12,8 +12,6 @@ namespace RTE { - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - SettingsGameplayGUI::SettingsGameplayGUI(GUIControlManager* parentControlManager) : m_GUIControlManager(parentControlManager) { m_GameplaySettingsBox = dynamic_cast(m_GUIControlManager->GetControl("CollectionBoxGameplaySettings")); @@ -77,8 +75,6 @@ namespace RTE { UpdateScreenShakeStrength(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SettingsGameplayGUI::SetEnabled(bool enable) { m_GameplaySettingsBox->SetVisible(enable); m_GameplaySettingsBox->SetEnabled(enable); @@ -89,8 +85,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SettingsGameplayGUI::UpdateMaxUnheldItemsTextbox() { if (m_MaxUnheldItemsTextbox->GetText().empty()) { m_MaxUnheldItemsTextbox->SetText(std::to_string(g_MovableMan.GetMaxDroppedItems())); @@ -99,8 +93,6 @@ namespace RTE { m_GameplaySettingsBox->SetFocus(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SettingsGameplayGUI::UpdateCrabBombThresholdTextbox() { if (m_CrabBombThresholdTextbox->GetText().empty()) { m_CrabBombThresholdTextbox->SetText(std::to_string(g_SettingsMan.GetCrabBombThreshold())); @@ -112,8 +104,6 @@ namespace RTE { m_GameplaySettingsBox->SetFocus(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SettingsGameplayGUI::UpdateUnheldItemsHUDDisplayRange() { int newValue = m_UnheldItemsHUDDisplayRangeSlider->GetValue(); if (newValue < 3) { @@ -128,16 +118,12 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SettingsGameplayGUI::UpdateScreenShakeStrength() { int newValue = m_ScreenShakeStrengthSlider->GetValue(); m_ScreenShakeStrengthLabel->SetText(std::to_string(newValue) + "%"); g_CameraMan.SetScreenShakeStrength(static_cast(newValue) / 100.0F); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SettingsGameplayGUI::HandleInputEvents(GUIEvent& guiEvent) { if (guiEvent.GetType() == GUIEvent::Notification) { if (guiEvent.GetControl() == m_FlashOnBrainDamageCheckbox) { diff --git a/Source/Menus/SettingsGameplayGUI.h b/Source/Menus/SettingsGameplayGUI.h index f2f76e9ef0..f572e46f5c 100644 --- a/Source/Menus/SettingsGameplayGUI.h +++ b/Source/Menus/SettingsGameplayGUI.h @@ -11,40 +11,30 @@ namespace RTE { class GUILabel; class GUIEvent; - /// /// Handling for gameplay settings through the game settings user interface. - /// class SettingsGameplayGUI { public: #pragma region Creation - /// /// Constructor method used to instantiate a SettingsGameplayGUI object in system memory and make it ready for use. - /// - /// Pointer to the parent GUIControlManager which owns all the GUIControls of this SettingsGameplayGUI. Ownership is NOT transferred! + /// @param parentControlManager Pointer to the parent GUIControlManager which owns all the GUIControls of this SettingsGameplayGUI. Ownership is NOT transferred! explicit SettingsGameplayGUI(GUIControlManager* parentControlManager); #pragma endregion #pragma region Concrete Methods - /// /// Enables or disables the SettingsGameplayGUI. - /// - /// Show and enable or hide and disable the SettingsGameplayGUI. + /// @param enable Show and enable or hide and disable the SettingsGameplayGUI. void SetEnabled(bool enable = true); - /// /// Handles the player interaction with the SettingsInputGUI GUI elements. - /// - /// The GUIEvent containing information about the player interaction with an element. + /// @param guiEvent The GUIEvent containing information about the player interaction with an element. void HandleInputEvents(GUIEvent& guiEvent); #pragma endregion private: GUIControlManager* m_GUIControlManager; //!< The GUIControlManager which holds all the GUIControls of this menu. Not owned by this. - /// /// GUI elements that compose the gameplay settings menu screen. - /// GUICollectionBox* m_GameplaySettingsBox; GUICheckbox* m_FlashOnBrainDamageCheckbox; GUICheckbox* m_BlipOnRevealUnseenCheckbox; @@ -65,24 +55,16 @@ namespace RTE { GUILabel* m_ScreenShakeStrengthLabel; #pragma region Gameplay Settings Handling - /// /// Updates the MaxUnheldItems textbox to override any invalid input, applies the setting value and removes its focus. - /// void UpdateMaxUnheldItemsTextbox(); - /// /// Updates the CrabBombThreshold textbox to override any invalid input, applies the setting value and removes its focus. - /// void UpdateCrabBombThresholdTextbox(); - /// /// Updates the UnheldItemsHUDDisplayRange setting and label according to the slider value. - /// void UpdateUnheldItemsHUDDisplayRange(); - /// /// Updates the Screen Shake strength setting and label according to the slider value. - /// void UpdateScreenShakeStrength(); #pragma endregion diff --git a/Source/Menus/SettingsInputGUI.cpp b/Source/Menus/SettingsInputGUI.cpp index 1cb04c1efd..a85aa71b54 100644 --- a/Source/Menus/SettingsInputGUI.cpp +++ b/Source/Menus/SettingsInputGUI.cpp @@ -10,8 +10,6 @@ namespace RTE { - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - SettingsInputGUI::SettingsInputGUI(GUIControlManager* parentControlManager) : m_GUIControlManager(parentControlManager) { m_InputSettingsBox = dynamic_cast(m_GUIControlManager->GetControl("CollectionBoxInputSettings")); @@ -40,15 +38,11 @@ namespace RTE { m_InputMappingConfigMenu = std::make_unique(parentControlManager); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SettingsInputGUI::SetEnabled(bool enable) const { m_InputSettingsBox->SetVisible(enable); m_InputSettingsBox->SetEnabled(enable); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SettingsInputGUI::ResetPlayerInputSettings(int player) { if (m_PlayerInputSettingsBoxes.at(player).ResetControlsButton->GetText() == "Reset") { // Only one player's reset button can be pending confirmation at a time, so cancel any other pending confirmations. @@ -74,8 +68,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SettingsInputGUI::SetPlayerNextOrPrevInputDevice(int player, bool nextDevice) { int currentDevice = static_cast(g_UInputMan.GetControlScheme(player)->GetDevice()); @@ -95,8 +87,6 @@ namespace RTE { ShowOrHidePlayerInputDeviceSensitivityControls(player); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SettingsInputGUI::UpdatePlayerSelectedDeviceLabel(int player) { std::string deviceLabel; @@ -125,8 +115,6 @@ namespace RTE { m_PlayerInputSettingsBoxes.at(player).SelectedDeviceLabel->SetText(deviceLabel); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SettingsInputGUI::ShowOrHidePlayerInputDeviceSensitivityControls(int player) { m_PlayerInputSettingsBoxes.at(player).SensitivityLabel->SetVisible(false); m_PlayerInputSettingsBoxes.at(player).SensitivitySlider->SetVisible(false); @@ -158,8 +146,6 @@ namespace RTE { UpdatePlayerInputSensitivityControlValues(player); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SettingsInputGUI::UpdatePlayerInputSensitivityControlValues(int player) { switch (g_UInputMan.GetControlScheme(player)->GetDevice()) { case InputDevice::DEVICE_KEYB_ONLY: @@ -192,8 +178,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SettingsInputGUI::HandleInputEvents(GUIEvent& guiEvent) { if (m_InputMappingConfigMenu->IsEnabled()) { m_InputMappingConfigMenu->HandleInputEvents(guiEvent); diff --git a/Source/Menus/SettingsInputGUI.h b/Source/Menus/SettingsInputGUI.h index 23a6bb5d8f..3ca9e2781c 100644 --- a/Source/Menus/SettingsInputGUI.h +++ b/Source/Menus/SettingsInputGUI.h @@ -16,75 +16,53 @@ namespace RTE { class GUIRadioButton; class GUIEvent; - /// /// Handling for player input settings through the game settings user interface. - /// class SettingsInputGUI { public: #pragma region Creation - /// /// Constructor method used to instantiate a SettingsInputGUI object in system memory and make it ready for use. - /// - /// Pointer to the parent GUIControlManager which owns all the GUIControls of this SettingsInputGUI. Ownership is NOT transferred! + /// @param parentControlManager Pointer to the parent GUIControlManager which owns all the GUIControls of this SettingsInputGUI. Ownership is NOT transferred! explicit SettingsInputGUI(GUIControlManager* parentControlManager); #pragma endregion #pragma region Getters and Setters - /// /// Enables or disables the SettingsInputGUI. - /// - /// Show and enable or hide and disable the SettingsInputGUI. + /// @param enable Show and enable or hide and disable the SettingsInputGUI. void SetEnabled(bool enable = true) const; - /// /// Gets the currently active GUICollectionBox that acts as a dialog box and requires disabling navigation and drawing an overlay. - /// - /// Pointer to the GUICollectionBox that is the currently active dialog box, if any. Ownership is NOT transferred! + /// @return Pointer to the GUICollectionBox that is the currently active dialog box, if any. Ownership is NOT transferred! GUICollectionBox* GetActiveDialogBox() const { return m_InputMappingConfigMenu->GetActiveDialogBox(); } - /// /// Closes the currently active GUICollectionBox that acts as a dialog box by hiding it. If the active dialog box is a sub-menu, disables it. - /// void CloseActiveDialogBox() const { m_InputMappingConfigMenu->CloseActiveDialogBox(); } #pragma endregion #pragma region Input Config Wizard Handling - /// /// Gets whether the player is currently manually configuring an InputMapping through the input mapping menu screen. - /// - /// Whether the player is currently manually configuring an InputMapping through the input mapping menu screen. + /// @return Whether the player is currently manually configuring an InputMapping through the input mapping menu screen. bool InputMappingConfigIsConfiguringManually() const { return m_InputMappingConfigMenu->IsConfiguringManually(); } - /// /// Handles input capture logic of the input mapping menu screen manual configuration sequence. - /// void HandleMappingConfigManualConfiguration() const { m_InputMappingConfigMenu->HandleManualConfigSequence(); } - /// /// Gets whether the player is currently manually configuring the InputScheme through the input mapping wizard. - /// - /// Whether the player is currently manually configuring the InputScheme through the input mapping wizard. + /// @return Whether the player is currently manually configuring the InputScheme through the input mapping wizard. bool InputConfigWizardIsConfiguringManually() const { return m_InputMappingConfigMenu->GetInputConfigWizardMenu()->IsConfiguringManually(); } - /// /// Handles input capture logic of the input mapping wizard manual configuration sequence. - /// void HandleConfigWizardManualConfiguration() const { m_InputMappingConfigMenu->GetInputConfigWizardMenu()->HandleManualConfigSequence(); } #pragma endregion #pragma region Concrete Methods - /// /// Handles the player interaction with the SettingsInputGUI GUI elements. - /// - /// The GUIEvent containing information about the player interaction with an element. + /// @param guiEvent The GUIEvent containing information about the player interaction with an element. void HandleInputEvents(GUIEvent& guiEvent); #pragma endregion private: - /// /// Struct containing GUI elements that compose the input settings box of a player. - /// struct PlayerInputSettingsBox { GUILabel* SelectedDeviceLabel; GUIButton* NextDeviceButton; @@ -102,42 +80,30 @@ namespace RTE { std::unique_ptr m_InputMappingConfigMenu; //!< The input mapping configuration sub-menu. - /// /// GUI elements that compose the input settings menu screen. - /// GUICollectionBox* m_InputSettingsBox; std::array m_PlayerInputSettingsBoxes; #pragma region Input Settings Handling - /// /// Resets the player input settings to the defaults. - /// - /// The player to reset input settings for. + /// @param player The player to reset input settings for. void ResetPlayerInputSettings(int player); - /// /// Changes the player's input device in the InputScheme and proceeds to update the device labels accordingly. - /// - /// The player to change input device for. - /// Whether to change to the next or previous input device. + /// @param player The player to change input device for. + /// @param nextDevice Whether to change to the next or previous input device. void SetPlayerNextOrPrevInputDevice(int player, bool nextDevice); - /// /// Updates the currently selected input device label of a player according to the InputScheme. - /// - /// The player to update selected input device label for. + /// @param player The player to update selected input device label for. void UpdatePlayerSelectedDeviceLabel(int player); - /// /// Enables the input sensitivity controls for a player if applicable to the selected input device. - /// - /// The player to enable input sensitivity controls for. + /// @param player The player to enable input sensitivity controls for. void ShowOrHidePlayerInputDeviceSensitivityControls(int player); - /// /// Updates the input sensitivity controls of a player according to the InputScheme. - /// - /// The player to update input sensitivity control values for. + /// @param player The player to update input sensitivity control values for. void UpdatePlayerInputSensitivityControlValues(int player); #pragma endregion diff --git a/Source/Menus/SettingsInputMappingGUI.cpp b/Source/Menus/SettingsInputMappingGUI.cpp index c345a3f38a..954ae40371 100644 --- a/Source/Menus/SettingsInputMappingGUI.cpp +++ b/Source/Menus/SettingsInputMappingGUI.cpp @@ -12,8 +12,6 @@ namespace RTE { std::array SettingsInputMappingGUI::m_InputElementsUsedByMouse = {InputElements::INPUT_FIRE, InputElements::INPUT_PIEMENU_ANALOG, InputElements::INPUT_AIM, InputElements::INPUT_AIM_UP, InputElements::INPUT_AIM_DOWN, InputElements::INPUT_AIM_LEFT, InputElements::INPUT_AIM_RIGHT}; - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - SettingsInputMappingGUI::SettingsInputMappingGUI(GUIControlManager* parentControlManager) : m_GUIControlManager(parentControlManager) { m_InputMappingSettingsBox = dynamic_cast(m_GUIControlManager->GetControl("CollectionBoxPlayerInputMapping")); @@ -50,14 +48,10 @@ namespace RTE { m_InputElementCapturingInput = InputElements::INPUT_COUNT; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool SettingsInputMappingGUI::IsEnabled() const { return m_InputMappingSettingsBox->GetVisible() && m_InputMappingSettingsBox->GetEnabled(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SettingsInputMappingGUI::SetEnabled(bool enable, int player) { m_InputMappingSettingsBox->SetVisible(enable); m_InputMappingSettingsBox->SetEnabled(enable); @@ -76,8 +70,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUICollectionBox* SettingsInputMappingGUI::GetActiveDialogBox() const { if (m_InputConfigWizardMenu->IsEnabled()) { return m_InputConfigWizardMenu->GetActiveDialogBox(); @@ -87,8 +79,6 @@ namespace RTE { return (m_InputMappingSettingsBox->GetEnabled() && m_InputMappingSettingsBox->GetVisible()) ? m_InputMappingSettingsBox : nullptr; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SettingsInputMappingGUI::CloseActiveDialogBox() { if (m_InputConfigWizardMenu->IsEnabled()) { m_InputConfigWizardMenu->SetEnabled(false); @@ -99,14 +89,10 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool SettingsInputMappingGUI::IsConfiguringManually() const { return m_ConfiguringManually && m_InputMappingCaptureBox->GetVisible() && m_InputMappingCaptureBox->GetEnabled(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SettingsInputMappingGUI::ShowInputMappingCaptureBox(InputElements inputElement) { m_InputMappingSettingsBox->SetEnabled(false); m_InputMappingCaptureBox->SetVisible(true); @@ -118,8 +104,6 @@ namespace RTE { g_UInputMan.SetSkipHandlingSpecialInput(true); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SettingsInputMappingGUI::HideInputMappingCaptureBox() { m_InputMappingSettingsBox->SetEnabled(true); m_InputMappingCaptureBox->SetVisible(false); @@ -129,8 +113,6 @@ namespace RTE { g_UInputMan.SetSkipHandlingSpecialInput(false); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SettingsInputMappingGUI::UpdateMappingButtonLabels() { const std::array* inputMappings = m_ConfiguringPlayerInputScheme->GetInputMappings(); for (int i = 0; i < InputElements::INPUT_COUNT; ++i) { @@ -145,16 +127,12 @@ namespace RTE { m_InputMapScrollingBoxScrollbar->SetPageSize(m_InputMapScrollingBoxScrollbar->GetMaximum() / 2); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SettingsInputMappingGUI::UpdateScrollingInputBoxScrollPosition() { int scrollbarValue = m_InputMapScrollingBoxScrollbar->GetValue(); m_InputMapScrollingBox->SetPositionRel(m_InputMapScrollingBox->GetRelXPos(), m_InputMapScrollingBox->GetRelYPos() + (m_LastInputMapScrollingBoxScrollbarValue - scrollbarValue)); m_LastInputMapScrollingBoxScrollbarValue = scrollbarValue; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SettingsInputMappingGUI::HandleInputEvents(GUIEvent& guiEvent) { if (m_InputConfigWizardMenu->IsEnabled()) { if (m_InputConfigWizardMenu->HandleInputEvents(guiEvent)) { @@ -191,8 +169,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SettingsInputMappingGUI::HandleManualConfigSequence() { bool inputCaptured = false; if (g_UInputMan.KeyReleased(SDLK_DELETE)) { diff --git a/Source/Menus/SettingsInputMappingGUI.h b/Source/Menus/SettingsInputMappingGUI.h index 4fe312157c..1e5a5769c0 100644 --- a/Source/Menus/SettingsInputMappingGUI.h +++ b/Source/Menus/SettingsInputMappingGUI.h @@ -13,68 +13,48 @@ namespace RTE { class GUIScrollbar; class GUIEvent; - /// /// Handling for player input mapping settings through the game settings user interface. - /// class SettingsInputMappingGUI { public: #pragma region Creation - /// /// Constructor method used to instantiate a SettingsInputMappingGUI object in system memory and make it ready for use. - /// - /// Pointer to the parent GUIControlManager which owns all the GUIControls of this SettingsInputMappingGUI. Ownership is NOT transferred! + /// @param parentControlManager Pointer to the parent GUIControlManager which owns all the GUIControls of this SettingsInputMappingGUI. Ownership is NOT transferred! explicit SettingsInputMappingGUI(GUIControlManager* parentControlManager); #pragma endregion #pragma region Getters and Setters - /// /// Gets whether this SettingsInputMappingGUI is currently visible and enabled. - /// - /// Whether this SettingsInputMappingGUI is currently visible and enabled. + /// @return Whether this SettingsInputMappingGUI is currently visible and enabled. bool IsEnabled() const; - /// /// Enables or disables the SettingsInputMappingGUI. - /// - /// Show and enable or hide and disable the SettingsInputMappingGUI. - /// The player this SettingsInputMappingGUI is configuring input mapping for. + /// @param enable Show and enable or hide and disable the SettingsInputMappingGUI. + /// @param player The player this SettingsInputMappingGUI is configuring input mapping for. void SetEnabled(bool enable = true, int player = 0); - /// /// Gets the currently active GUICollectionBox that acts as a dialog box and requires disabling navigation and drawing an overlay. - /// - /// Pointer to the GUICollectionBox that is the currently active dialog box, if any. Ownership is NOT transferred! + /// @return Pointer to the GUICollectionBox that is the currently active dialog box, if any. Ownership is NOT transferred! GUICollectionBox* GetActiveDialogBox() const; - /// /// Closes the currently active GUICollectionBox that acts as a dialog box by hiding it. If the active dialog box is a sub-menu, disables it. - /// void CloseActiveDialogBox(); - /// /// Gets whether this SettingsInputMappingGUI needs to capture input for manual configuration. - /// - /// Whether this SettingsInputMappingGUI needs to capture input for manual configuration. + /// @return Whether this SettingsInputMappingGUI needs to capture input for manual configuration. bool IsConfiguringManually() const; - /// /// Gets the SettingsInputMappingWizardGUI of this SettingsInputMappingGUI. - /// - /// Pointer to the SettingsInputMappingWizardGUI of this SettingsInputMappingGUI. Ownership is NOT transferred! + /// @return Pointer to the SettingsInputMappingWizardGUI of this SettingsInputMappingGUI. Ownership is NOT transferred! SettingsInputMappingWizardGUI* GetInputConfigWizardMenu() { return m_InputConfigWizardMenu.get(); } #pragma endregion #pragma region Concrete Methods - /// /// Handles the player interaction with the SettingsInputMappingGUI GUI elements. - /// - /// The GUIEvent containing information about the player interaction with an element. + /// @param guiEvent The GUIEvent containing information about the player interaction with an element. void HandleInputEvents(GUIEvent& guiEvent); - /// /// Handles capturing input and updating the manual input configuration sequence. - /// void HandleManualConfigSequence(); #pragma endregion @@ -93,9 +73,7 @@ namespace RTE { std::unique_ptr m_InputConfigWizardMenu; //!< The input mapping config wizard. - /// /// GUI elements that compose the input mapping settings menu screen. - /// GUICollectionBox* m_InputMappingSettingsBox; GUILabel* m_InputMappingSettingsLabel; GUIButton* m_CloseMappingBoxButton; @@ -108,25 +86,17 @@ namespace RTE { std::array m_InputMapButton; #pragma region Input Mapping Settings Handling - /// /// Shows and enables the input mapping capture box, starting the input capture sequence. - /// - /// + /// @param inputElement void ShowInputMappingCaptureBox(InputElements inputElement); - /// /// Hides and disables the input mapping capture box, ending the input capture sequence. - /// void HideInputMappingCaptureBox(); - /// /// Updates the mapping button key labels with the configuring player's InputScheme mappings. - /// void UpdateMappingButtonLabels(); - /// /// Updates the input mapping scrolling box scroll position. - /// void UpdateScrollingInputBoxScrollPosition(); #pragma endregion diff --git a/Source/Menus/SettingsInputMappingWizardGUI.cpp b/Source/Menus/SettingsInputMappingWizardGUI.cpp index c7d1762d1b..f81593012b 100644 --- a/Source/Menus/SettingsInputMappingWizardGUI.cpp +++ b/Source/Menus/SettingsInputMappingWizardGUI.cpp @@ -9,8 +9,6 @@ namespace RTE { - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SettingsInputMappingWizardGUI::Clear() { m_ConfiguringPlayer = Players::NoPlayer; m_ConfiguringPlayerScheme = nullptr; @@ -35,8 +33,6 @@ namespace RTE { m_DualAnalogXBDiagramBitmaps.clear(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - SettingsInputMappingWizardGUI::SettingsInputMappingWizardGUI(GUIControlManager* parentControlManager) : m_GUIControlManager(parentControlManager) { Clear(); @@ -55,8 +51,6 @@ namespace RTE { CreatePresetSelectionScreen(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SettingsInputMappingWizardGUI::CreateManualConfigScreen() { m_WizardManualConfigScreen.ManualConfigBox = dynamic_cast(m_GUIControlManager->GetControl("CollectionBoxWizardManualConfig")); @@ -74,8 +68,6 @@ namespace RTE { m_WizardManualConfigScreen.DiscardOrApplyConfigButton = dynamic_cast(m_GUIControlManager->GetControl("ButtonDiscardOrApply")); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SettingsInputMappingWizardGUI::CreatePresetSelectionScreen() { m_WizardPresetSelectScreen.PresetSelectBox = dynamic_cast(m_GUIControlManager->GetControl("CollectionBoxWizardPresets")); m_WizardPresetSelectScreen.CloseWizardButton = dynamic_cast(m_GUIControlManager->GetControl("ButtonCloseWizardBox")); @@ -96,14 +88,10 @@ namespace RTE { dynamic_cast(m_GUIControlManager->GetControl("CollectionBoxPresetAnalogXB360Diagram"))->SetDrawImage(new AllegroBitmap(m_DualAnalogXBDiagramBitmaps[0])); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool SettingsInputMappingWizardGUI::IsEnabled() const { return m_InputWizardScreenBox->GetVisible() && m_InputWizardScreenBox->GetEnabled(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SettingsInputMappingWizardGUI::SetEnabled(bool enable, int player, InputScheme* playerScheme) { m_InputWizardScreenBox->SetVisible(enable); m_InputWizardScreenBox->SetEnabled(enable); @@ -134,20 +122,14 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUICollectionBox* SettingsInputMappingWizardGUI::GetActiveDialogBox() const { return (m_InputWizardScreenBox->GetEnabled() && m_InputWizardScreenBox->GetVisible()) ? m_InputWizardScreenBox : nullptr; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool SettingsInputMappingWizardGUI::IsConfiguringManually() const { return m_ConfiguringManually && m_WizardManualConfigScreen.ManualConfigBox->GetVisible() && m_WizardManualConfigScreen.ManualConfigBox->GetEnabled(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SettingsInputMappingWizardGUI::ShowManualConfigScreen() { m_WizardPresetSelectScreen.PresetSelectBox->SetVisible(false); m_WizardPresetSelectScreen.PresetSelectBox->SetEnabled(false); @@ -192,8 +174,6 @@ namespace RTE { m_ConfiguringManually = true; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SettingsInputMappingWizardGUI::ShowPresetSelectionScreen() { m_WizardManualConfigScreen.ManualConfigBox->SetVisible(false); m_WizardManualConfigScreen.ManualConfigBox->SetEnabled(false); @@ -202,8 +182,6 @@ namespace RTE { m_WizardPresetSelectScreen.PresetSelectBox->SetEnabled(true); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SettingsInputMappingWizardGUI::ResetManualConfigSequence() { m_ConfigFinished = false; m_ConfigStep = 0; @@ -212,8 +190,6 @@ namespace RTE { m_NewInputScheme.SetDevice(m_ConfiguringDevice); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SettingsInputMappingWizardGUI::ApplyGamepadInputPreset(GamepadType gamepadType) { switch (gamepadType) { case GamepadType::DPad: @@ -233,8 +209,6 @@ namespace RTE { m_NewInputSchemeApplied = true; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SettingsInputMappingWizardGUI::ApplyManuallyConfiguredScheme() { m_ConfiguringPlayerScheme->SetDevice(m_NewInputScheme.GetDevice()); m_ConfiguringPlayerScheme->SetPreset(InputScheme::InputPreset::NoPreset); @@ -255,8 +229,6 @@ namespace RTE { m_ConfiguringManually = false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool SettingsInputMappingWizardGUI::HandleInputEvents(GUIEvent& guiEvent) { if (m_WizardManualConfigScreen.ManualConfigBox->GetVisible()) { HandleManualConfigScreenInputEvents(guiEvent); @@ -270,8 +242,6 @@ namespace RTE { return false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SettingsInputMappingWizardGUI::HandleManualConfigScreenInputEvents(GUIEvent& guiEvent) { if (guiEvent.GetType() == GUIEvent::Command) { if (guiEvent.GetControl() == m_WizardManualConfigScreen.PrevConfigStepButton) { @@ -304,8 +274,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SettingsInputMappingWizardGUI::HandlePresetSelectScreenInputEvents(GUIEvent& guiEvent) { if (guiEvent.GetType() == GUIEvent::Command) { if (guiEvent.GetControl() == m_WizardPresetSelectScreen.CloseWizardButton) { @@ -333,8 +301,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SettingsInputMappingWizardGUI::HandleManualConfigSequence() { if (m_ConfigStepChange) { HandleManualConfigStepChange(); @@ -376,8 +342,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SettingsInputMappingWizardGUI::HandleManualConfigStepChange() { int configuringDeviceSteps = 0; @@ -421,8 +385,6 @@ namespace RTE { m_WizardManualConfigScreen.NextConfigStepButton->SetVisible(m_ConfigStep < configuringDeviceSteps - 1); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool SettingsInputMappingWizardGUI::UpdateKeyboardConfigSequence() { switch (m_ConfigStep) { case 0: @@ -593,8 +555,6 @@ namespace RTE { return false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool SettingsInputMappingWizardGUI::UpdateMouseAndKeyboardConfigSequence() { switch (m_ConfigStep) { case 0: @@ -717,8 +677,6 @@ namespace RTE { return false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool SettingsInputMappingWizardGUI::UpdateGamepadDPadConfigSequence() { switch (m_ConfigStep) { case 0: @@ -851,8 +809,6 @@ namespace RTE { return false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool SettingsInputMappingWizardGUI::UpdateGamepadAnalogConfigSequence() { switch (m_ConfigStep) { case 0: diff --git a/Source/Menus/SettingsInputMappingWizardGUI.h b/Source/Menus/SettingsInputMappingWizardGUI.h index e56295cda0..3fbcb02477 100644 --- a/Source/Menus/SettingsInputMappingWizardGUI.h +++ b/Source/Menus/SettingsInputMappingWizardGUI.h @@ -15,74 +15,54 @@ namespace RTE { class GUIButton; class GUIEvent; - /// /// Handling for the user input mapping wizard through the game settings user interface. - /// class SettingsInputMappingWizardGUI { public: #pragma region Creation - /// /// Constructor method used to instantiate a SettingsInputMappingWizardGUI object in system memory and make it ready for use. - /// - /// Pointer to the parent GUIControlManager which owns all the GUIControls of this SettingsInputMappingWizardGUI. Ownership is NOT transferred! + /// @param parentControlManager Pointer to the parent GUIControlManager which owns all the GUIControls of this SettingsInputMappingWizardGUI. Ownership is NOT transferred! explicit SettingsInputMappingWizardGUI(GUIControlManager* parentControlManager); #pragma endregion #pragma region Getters and Setters - /// /// Gets whether this SettingsInputMappingWizardGUI is currently visible and enabled. - /// - /// Whether this SettingsInputMappingWizardGUI is currently visible and enabled. + /// @return Whether this SettingsInputMappingWizardGUI is currently visible and enabled. bool IsEnabled() const; - /// /// Enables or disables the SettingsInputMappingWizardGUI. - /// - /// Show and enable or hide and disable the SettingsInputMappingWizardGUI. - /// The player this SettingsInputMappingWizardGUI is mapping inputs for. + /// @param enable Show and enable or hide and disable the SettingsInputMappingWizardGUI. + /// @param player The player this SettingsInputMappingWizardGUI is mapping inputs for. void SetEnabled(bool enable = true, int player = 0, InputScheme* playerScheme = nullptr); - /// /// Gets the currently active GUICollectionBox that acts as a dialog box and requires disabling navigation and drawing an overlay. - /// - /// Pointer to the GUICollectionBox that is the currently active dialog box, if any. Ownership is NOT transferred! + /// @return Pointer to the GUICollectionBox that is the currently active dialog box, if any. Ownership is NOT transferred! GUICollectionBox* GetActiveDialogBox() const; - /// /// Gets whether this SettingsInputMappingWizardGUI needs to capture input for manual configuration. - /// - /// Whether this SettingsInputMappingWizardGUI needs to capture input for manual configuration. + /// @return Whether this SettingsInputMappingWizardGUI needs to capture input for manual configuration. bool IsConfiguringManually() const; #pragma endregion #pragma region Concrete Methods - /// /// Handles the player interaction with the SettingsInputMappingWizardGUI GUI elements. - /// - /// The GUIEvent containing information about the player interaction with an element. - /// Whether this SettingsInputMappingGUI changed the input scheme of the configuring player. + /// @param guiEvent The GUIEvent containing information about the player interaction with an element. + /// @return Whether this SettingsInputMappingGUI changed the input scheme of the configuring player. bool HandleInputEvents(GUIEvent& guiEvent); - /// /// Handles updating and progressing the manual input configuration sequence. - /// void HandleManualConfigSequence(); #pragma endregion private: - /// /// Enumeration for the different types of gamepads that can be configured. - /// enum GamepadType { DPad, AnalogDualShock, AnalogXbox }; - /// /// Struct containing GUI elements that compose the input mapping wizard manual configuration menu screen. - /// struct WizardManualConfigScreen { GUICollectionBox* ManualConfigBox; GUILabel* ConfigDeviceTypeLabel; @@ -98,9 +78,7 @@ namespace RTE { GUIButton* DiscardOrApplyConfigButton; }; - /// /// Struct containing GUI elements that compose the input mapping wizard preset selection menu screen. - /// struct WizardPresetSelectScreen { GUICollectionBox* PresetSelectBox; GUIButton* CloseWizardButton; @@ -144,99 +122,67 @@ namespace RTE { WizardManualConfigScreen m_WizardManualConfigScreen; //!< The manual input configuration menu screen. WizardPresetSelectScreen m_WizardPresetSelectScreen; //!< The preset selection menu screen. - /// /// GUI elements that compose the input mapping wizard menu screen. - /// GUICollectionBox* m_InputWizardScreenBox; GUILabel* m_InputWizardTitleLabel; #pragma region Create Breakdown - /// /// Creates all the elements that compose the manual input configuration box. - /// void CreateManualConfigScreen(); - /// /// Creates all the elements that compose the gamepad input preset selection box. - /// void CreatePresetSelectionScreen(); #pragma endregion #pragma region Input Mapping Wizard Handling - /// /// Makes the manual input configuration menu screen visible to be interacted with by the player. - /// void ShowManualConfigScreen(); - /// /// Makes the gamepad input preset selection menu screen visible to be interacted with by the player. - /// void ShowPresetSelectionScreen(); - /// /// Clears the InputScheme that was configured during manual configuration and resets the sequence to the first step. - /// void ResetManualConfigSequence(); - /// /// Applies the manually configured InputScheme as the active InputScheme of the configuring player. - /// void ApplyManuallyConfiguredScheme(); - /// /// Applies a gamepad InputScheme preset as the active InputScheme of the configuring player. - /// void ApplyGamepadInputPreset(GamepadType gamepadType); #pragma endregion #pragma region Input Event Handling Breakdown - /// /// Handles the player interaction with the SettingsInputMappingWizardGUI's WizardManualConfigScreen GUI elements. - /// - /// The GUIEvent containing information about the player interaction with an element. + /// @param guiEvent The GUIEvent containing information about the player interaction with an element. void HandleManualConfigScreenInputEvents(GUIEvent& guiEvent); - /// /// Handles the player interaction with the SettingsInputMappingWizardGUI's WizardPresetSelectScreen GUI elements. - /// - /// The GUIEvent containing information about the player interaction with an element. + /// @param guiEvent The GUIEvent containing information about the player interaction with an element. void HandlePresetSelectScreenInputEvents(GUIEvent& guiEvent); #pragma endregion #pragma region Input Configuration Sequence Handling Breakdown - /// /// Handles step changes in the manual input configuration sequence. - /// void HandleManualConfigStepChange(); - /// /// Handles capturing input and progressing the keyboard only configuration sequence. - /// - /// Whether input was captured and the sequence needs to progress. + /// @return Whether input was captured and the sequence needs to progress. bool UpdateKeyboardConfigSequence(); - /// /// Handles capturing input and progressing the mouse and keyboard configuration sequence. - /// - /// Whether input was captured and the sequence needs to progress. + /// @return Whether input was captured and the sequence needs to progress. bool UpdateMouseAndKeyboardConfigSequence(); - /// /// Handles capturing input and progressing the D-Pad type gamepad configuration sequence. - /// - /// Whether input was captured and the sequence needs to progress. + /// @return Whether input was captured and the sequence needs to progress. bool UpdateGamepadDPadConfigSequence(); - /// /// Handles capturing input and progressing the dual-analog type gamepad (DualShock/Xbox) configuration sequence. - /// - /// Whether input was captured and the sequence needs to progress. + /// @return Whether input was captured and the sequence needs to progress. bool UpdateGamepadAnalogConfigSequence(); #pragma endregion - /// /// Clears all the member variables of this SettingsInputMappingWizardGUI, effectively resetting the members of this object. - /// void Clear(); // Disallow the use of some implicit methods. diff --git a/Source/Menus/SettingsMiscGUI.cpp b/Source/Menus/SettingsMiscGUI.cpp index 74185b656c..199e8f32c0 100644 --- a/Source/Menus/SettingsMiscGUI.cpp +++ b/Source/Menus/SettingsMiscGUI.cpp @@ -11,8 +11,6 @@ namespace RTE { - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - SettingsMiscGUI::SettingsMiscGUI(GUIControlManager* parentControlManager) : m_GUIControlManager(parentControlManager) { m_MiscSettingsBox = dynamic_cast(m_GUIControlManager->GetControl("CollectionBoxMiscSettings")); @@ -48,15 +46,11 @@ namespace RTE { m_SceneBackgroundAutoScaleSlider->SetValue(g_SettingsMan.GetSceneBackgroundAutoScaleMode()); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SettingsMiscGUI::SetEnabled(bool enable) const { m_MiscSettingsBox->SetVisible(enable); m_MiscSettingsBox->SetEnabled(enable); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SettingsMiscGUI::UpdateSceneBackgroundAutoScaleLabel() { switch (g_SettingsMan.GetSceneBackgroundAutoScaleMode()) { case 1: @@ -71,8 +65,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SettingsMiscGUI::HandleInputEvents(GUIEvent& guiEvent) { if (guiEvent.GetType() == GUIEvent::Notification) { if (guiEvent.GetControl() == m_SkipIntroCheckbox) { diff --git a/Source/Menus/SettingsMiscGUI.h b/Source/Menus/SettingsMiscGUI.h index 804c646e50..c74da1f397 100644 --- a/Source/Menus/SettingsMiscGUI.h +++ b/Source/Menus/SettingsMiscGUI.h @@ -10,40 +10,30 @@ namespace RTE { class GUISlider; class GUIEvent; - /// /// Handling for misc settings through the game settings user interface. - /// class SettingsMiscGUI { public: #pragma region Creation - /// /// Constructor method used to instantiate a SettingsMiscGUI object in system memory and make it ready for use. - /// - /// Pointer to the parent GUIControlManager which owns all the GUIControls of this SettingsMiscGUI. Ownership is NOT transferred! + /// @param parentControlManager Pointer to the parent GUIControlManager which owns all the GUIControls of this SettingsMiscGUI. Ownership is NOT transferred! explicit SettingsMiscGUI(GUIControlManager* parentControlManager); #pragma endregion #pragma region Concrete Methods - /// /// Enables or disables the SettingsMiscGUI. - /// - /// Show and enable or hide and disable the SettingsMiscGUI. + /// @param enable Show and enable or hide and disable the SettingsMiscGUI. void SetEnabled(bool enable = true) const; - /// /// Handles the player interaction with the SettingsMiscGUI GUI elements. - /// - /// The GUIEvent containing information about the player interaction with an element. + /// @param guiEvent The GUIEvent containing information about the player interaction with an element. void HandleInputEvents(GUIEvent& guiEvent); #pragma endregion private: GUIControlManager* m_GUIControlManager; //!< The GUIControlManager which holds all the GUIControls of this menu. Not owned by this. - /// /// GUI elements that compose the misc settings menu screen. - /// GUICollectionBox* m_MiscSettingsBox; GUICheckbox* m_SkipIntroCheckbox; GUICheckbox* m_ShowToolTipsCheckbox; @@ -57,9 +47,7 @@ namespace RTE { GUISlider* m_SceneBackgroundAutoScaleSlider; #pragma region Misc Settings Handling - /// /// Updates the Scene background auto-scale label according to the setting. - /// void UpdateSceneBackgroundAutoScaleLabel(); #pragma endregion diff --git a/Source/Menus/SettingsVideoGUI.cpp b/Source/Menus/SettingsVideoGUI.cpp index 902a5ef8aa..cfe38fe7aa 100644 --- a/Source/Menus/SettingsVideoGUI.cpp +++ b/Source/Menus/SettingsVideoGUI.cpp @@ -30,8 +30,6 @@ namespace RTE { #endif } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - SettingsVideoGUI::SettingsVideoGUI(GUIControlManager* parentControlManager) : m_GUIControlManager(parentControlManager) { m_NewResX = g_WindowMan.GetResX(); @@ -83,8 +81,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SettingsVideoGUI::CreatePresetResolutionBox() { m_PresetResolutionBox = dynamic_cast(m_GUIControlManager->GetControl("CollectionPresetResolution")); m_PresetResolutionComboBox = dynamic_cast(m_GUIControlManager->GetControl("ComboPresetResolution")); @@ -95,8 +91,6 @@ namespace RTE { PopulateResolutionsComboBox(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SettingsVideoGUI::CreateCustomResolutionBox() { m_CustomResolutionBox = dynamic_cast(m_GUIControlManager->GetControl("CollectionCustomResolution")); m_CustomResolutionBox->SetVisible(false); @@ -126,8 +120,6 @@ namespace RTE { m_CustomResolutionMessageLabel->SetVisible(false); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SettingsVideoGUI::SetEnabled(bool enable) const { m_VideoSettingsBox->SetVisible(enable); m_VideoSettingsBox->SetEnabled(enable); @@ -147,14 +139,10 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - GUICollectionBox* SettingsVideoGUI::GetActiveDialogBox() const { return (m_ResolutionChangeDialogBox->GetEnabled() && m_ResolutionChangeDialogBox->GetVisible()) ? m_ResolutionChangeDialogBox : nullptr; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SettingsVideoGUI::CloseActiveDialogBox() const { if (m_ResolutionChangeDialogBox->GetEnabled() && m_ResolutionChangeDialogBox->GetVisible()) { m_ResolutionChangeDialogBox->SetVisible(false); @@ -162,8 +150,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool SettingsVideoGUI::IsSupportedResolution(int width, int height) const { if ((width >= c_MinResX && height >= c_MinResY) && (width <= g_WindowMan.GetMaxResX() && height <= g_WindowMan.GetMaxResY())) { return true; @@ -171,8 +157,6 @@ namespace RTE { return false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SettingsVideoGUI::PopulateResolutionsComboBox() { m_PresetResolutions.clear(); m_PresetResolutionComboBox->ClearList(); @@ -221,8 +205,6 @@ namespace RTE { m_CustomResolutionMultiplierComboBox->SetSelectedIndex(0); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SettingsVideoGUI::UpdateCustomResolutionLimits() { g_WindowMan.MapDisplays(); @@ -239,7 +221,6 @@ namespace RTE { m_CustomResolutionHeightTextBox->SetText(std::to_string(newMaxResY)); } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void SettingsVideoGUI::ApplyNewResolution(bool displaysWereMapped) { bool needWarning = (g_WindowMan.GetResX() != m_NewResX) && (g_WindowMan.GetResY() != m_NewResY); @@ -258,8 +239,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SettingsVideoGUI::ApplyQuickChangeResolution(ResolutionQuickChangeType resolutionChangeType) { g_WindowMan.MapDisplays(); @@ -298,8 +277,6 @@ namespace RTE { ApplyNewResolution(true); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SettingsVideoGUI::ApplyPresetResolution() { int presetResListEntryID = m_PresetResolutionComboBox->GetSelectedIndex(); if (presetResListEntryID >= 0) { @@ -318,8 +295,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SettingsVideoGUI::ApplyCustomResolution() { m_CustomResolutionMessageLabel->SetVisible(false); m_NewFullscreen = m_FullscreenCheckbox->GetCheck(); @@ -366,8 +341,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SettingsVideoGUI::HandleInputEvents(GUIEvent& guiEvent) { if (guiEvent.GetType() == GUIEvent::Command) { if (guiEvent.GetMsg() == GUIButton::Pushed) { diff --git a/Source/Menus/SettingsVideoGUI.h b/Source/Menus/SettingsVideoGUI.h index 599ebd55d8..4c486a2f1e 100644 --- a/Source/Menus/SettingsVideoGUI.h +++ b/Source/Menus/SettingsVideoGUI.h @@ -13,51 +13,37 @@ namespace RTE { class GUITextBox; class GUIEvent; - /// /// Handling for video settings through the game settings user interface. - /// class SettingsVideoGUI { public: #pragma region Creation - /// /// Constructor method used to instantiate a SettingsVideoGUI object in system memory and make it ready for use. - /// - /// Pointer to the parent GUIControlManager which owns all the GUIControls of this SettingsVideoGUI. Ownership is NOT transferred! + /// @param parentControlManager Pointer to the parent GUIControlManager which owns all the GUIControls of this SettingsVideoGUI. Ownership is NOT transferred! explicit SettingsVideoGUI(GUIControlManager* parentControlManager); #pragma endregion #pragma region Getters and Setters - /// /// Enables or disables the SettingsVideoGUI. - /// - /// Show and enable or hide and disable the SettingsVideoGUI. + /// @param enable Show and enable or hide and disable the SettingsVideoGUI. void SetEnabled(bool enable = true) const; - /// /// Gets the currently active GUICollectionBox that acts as a dialog box and requires disabling navigation and drawing an overlay. - /// - /// Pointer to the GUICollectionBox that is the currently active dialog box, if any. Ownership is NOT transferred! + /// @return Pointer to the GUICollectionBox that is the currently active dialog box, if any. Ownership is NOT transferred! GUICollectionBox* GetActiveDialogBox() const; - /// /// Closes the currently active GUICollectionBox that acts as a dialog box by hiding it. If the active dialog box is a sub-menu, disables it. - /// void CloseActiveDialogBox() const; #pragma endregion #pragma region Concrete Methods - /// /// Handles the player interaction with the SettingsVideoGUI GUI elements. - /// - /// The GUIEvent containing information about the player interaction with an element. + /// @param guiEvent The GUIEvent containing information about the player interaction with an element. void HandleInputEvents(GUIEvent& guiEvent); #pragma endregion private: - /// /// Enumeration for the different types of quick resolution change options. - /// enum ResolutionQuickChangeType { Windowed, Fullscreen, @@ -65,34 +51,26 @@ namespace RTE { QuickChangeTypeCount }; - /// /// Struct containing information about a supported resolution preset. - /// struct PresetResolutionRecord { int Width; //!< Resolution width. int Height; //!< Resolution height. float Scale; //!< Whether resolution is upscaled. - /// /// Constructor method to instantiate a PresetResolutionRecord object in system memory and make it ready for use. - /// - /// Resolution width. - /// Resolution height. - /// Whether resolution is upscaled. + /// @param width Resolution width. + /// @param height Resolution height. + /// @param upscaled Whether resolution is upscaled. PresetResolutionRecord(int width, int height, float scale) : Width(width), Height(height), Scale(scale) {} - /// /// Makes UI displayable string with resolution info. - /// - /// String with resolution info. + /// @return String with resolution info. std::string GetDisplayString() const; - /// /// Comparison operator for eliminating duplicates and sorting in the temporary PresetResolutionRecord std::sets during PopulateResolutionsComboBox. - /// - /// The PresetResolutionRecord to compare with. - /// Bool with the result of the comparison. + /// @param rhs The PresetResolutionRecord to compare with. + /// @return Bool with the result of the comparison. bool operator<(const PresetResolutionRecord& rhs) const { if (Width == rhs.Width && Height == rhs.Height) { return Scale > rhs.Scale; @@ -112,9 +90,7 @@ namespace RTE { float m_NewResMultiplier; //!< How much the new resolution should be upscaled when changing resolution. bool m_NewFullscreen; //!< Whether the game will be windowed or fullscreen. - /// /// GUI elements that compose the video settings menu screen. - /// GUICollectionBox* m_VideoSettingsBox; GUIRadioButton* m_TwoPlayerSplitscreenHSplitRadioButton; GUIRadioButton* m_TwoPlayerSplitscreenVSplitRadioButton; @@ -139,61 +115,41 @@ namespace RTE { std::array m_ResolutionQuickToggleButtons; #pragma region Create Breakdown - /// /// Creates all the elements that compose the preset resolution selection box. - /// void CreatePresetResolutionBox(); - /// /// Creates all the elements that compose the custom resolution controls box. - /// void CreateCustomResolutionBox(); #pragma endregion #pragma region Video Settings Handling - /// /// Checks whether the passed in width and height values can be used as a valid resolution setting. - /// - /// Resolution width. - /// Resolution height. - /// Whether the resolution is supported or not. + /// @param width Resolution width. + /// @param height Resolution height. + /// @return Whether the resolution is supported or not. bool IsSupportedResolution(int width, int height) const; - /// /// Fills the preset resolutions set and combo box with scaled resolutions down to c_MinRes. Defaults the combobox to the closest resolution to c_DefaultRes. - /// void PopulateResolutionsComboBox(); - /// /// Creates Resolution multipliers down to c_DefaultRes. - /// void PopulateResMultplierComboBox(); - /// /// Remaps the displays to get the new maximum resolution values to update the numeric limits on the custom resolution textboxes. - /// void UpdateCustomResolutionLimits(); - /// /// Attempts to change the resolution using the new values set by this SettingsVideoGUI, or if an Activity is running, first prompts to end it. - /// - /// Whether displays were mapped during interaction with this SettingsVideoGUI. + /// @param displaysWereMapped Whether displays were mapped during interaction with this SettingsVideoGUI. void ApplyNewResolution(bool displaysWereMapped = false); - /// /// Attempts to change the resolution using the new values set by the appropriate quick change type. - /// - /// The type of quick resolution change to apply. See ResolutionQuickChangeType enumeration. + /// @param resolutionChangeType The type of quick resolution change to apply. See ResolutionQuickChangeType enumeration. void ApplyQuickChangeResolution(ResolutionQuickChangeType resolutionChangeType); - /// /// Attempts to change the resolution using the new values set from the selected preset resolution. - /// void ApplyPresetResolution(); - /// /// Attempts to change the resolution using the new values set from the custom resolution controls. - /// void ApplyCustomResolution(); #pragma endregion diff --git a/Source/Menus/TitleScreen.cpp b/Source/Menus/TitleScreen.cpp index aabb0042ae..0f6e453a1f 100644 --- a/Source/Menus/TitleScreen.cpp +++ b/Source/Menus/TitleScreen.cpp @@ -12,8 +12,6 @@ namespace RTE { - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void TitleScreen::Clear() { m_FadeAmount = 0; @@ -68,8 +66,6 @@ namespace RTE { m_IntroSlides.fill(nullptr); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void TitleScreen::Create(AllegroScreen* guiScreen) { m_TitleScreenMaxWidth = g_WindowMan.FullyCoversAllDisplays() ? g_WindowMan.GetPrimaryWindowDisplayWidth() / g_WindowMan.GetResMultiplier() : g_WindowMan.GetResX(); @@ -94,8 +90,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void TitleScreen::CreateTitleElements() { m_DataRealmsLogo = ContentFile("Base.rte/GUIs/Title/Intro/DRLogo5x.png").GetAsBitmap(); m_FmodLogo = ContentFile("Base.rte/GUIs/Title/Intro/FMODLogo.png").GetAsBitmap(); @@ -145,8 +139,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void TitleScreen::CreateIntroSequenceSlides() { std::string highRes = (g_WindowMan.GetResY() >= 680) ? "HD" : ""; for (int slideNum = 0; slideNum < m_IntroSlides.size(); ++slideNum) { @@ -154,8 +146,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void TitleScreen::Update() { if (m_SectionSwitch) { m_SectionTimer.Reset(); @@ -200,8 +190,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void TitleScreen::UpdateIntroLogoSequence(bool skipSection) { if (skipSection && m_IntroSequenceState != IntroSequence::FmodLogoFadeOut) { m_SectionSwitch = true; @@ -256,8 +244,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void TitleScreen::UpdateIntroSlideshowSequence(bool skipSlideshow) { if (skipSlideshow && (m_IntroSequenceState > IntroSequence::SlideshowFadeIn && m_IntroSequenceState != IntroSequence::MainMenuAppear)) { m_SectionSwitch = true; @@ -376,8 +362,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void TitleScreen::UpdateIntroPreMainMenuSequence() { switch (m_IntroSequenceState) { case IntroSequence::GameLogoAppear: @@ -423,8 +407,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void TitleScreen::UpdateTitleTransitions() { static const float endDelay = 0.2F * g_SettingsMan.GetMenuTransitionDurationMultiplier(); @@ -547,8 +529,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void TitleScreen::Draw() { if (!m_FinishedPlayingIntro) { if (m_IntroSequenceState >= IntroSequence::SlideshowFadeIn) { @@ -594,8 +574,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void TitleScreen::DrawTitleScreenScene() { // This only needs to be done once, but bitmaps can be reloaded which effectively undoes this, so just do it all the time to not deal with flags and checks. set_write_alpha_blender(); @@ -626,8 +604,6 @@ namespace RTE { m_Station.Draw(g_FrameMan.GetBackBuffer32()); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void TitleScreen::DrawGameLogo() { m_GameLogo.Draw(g_FrameMan.GetBackBuffer32()); m_GameLogoGlow.SetPos(m_GameLogo.GetPos()); @@ -636,8 +612,6 @@ namespace RTE { m_GameLogoGlow.Draw(g_FrameMan.GetBackBuffer32(), Vector(), DrawMode::g_DrawTrans); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void TitleScreen::DrawSlideshowSlide() { int slide = static_cast(m_IntroSequenceState) - static_cast(IntroSequence::ShowSlide1); Vector slidePos(static_cast((m_TitleScreenMaxWidth - m_IntroSlides.at(slide)->w) / 2), static_cast((g_WindowMan.GetResY() / 2) - (m_IntroSlides.at(slide)->h / 2))); @@ -668,8 +642,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void TitleScreen::DrawOverlayEffectBitmap() const { set_trans_blender(m_FadeAmount, m_FadeAmount, m_FadeAmount, m_FadeAmount); draw_trans_sprite(g_FrameMan.GetBackBuffer32(), g_FrameMan.GetOverlayBitmap32(), 0, 0); diff --git a/Source/Menus/TitleScreen.h b/Source/Menus/TitleScreen.h index a565018056..1e50e5b2b4 100644 --- a/Source/Menus/TitleScreen.h +++ b/Source/Menus/TitleScreen.h @@ -12,15 +12,11 @@ namespace RTE { class AllegroScreen; class GUIFont; - /// /// Handling for the title screen scene composition, intro sequence and transitions between menu screens. - /// class TitleScreen { public: - /// /// Enumeration for the different transition (scrolling) states of the title screen. - /// enum class TitleTransition { MainMenu, MainMenuToScenario, @@ -43,33 +39,25 @@ namespace RTE { }; #pragma region Creation - /// /// Constructor method used to instantiate a TitleScreen object in system memory and make it ready for use. - /// - /// Pointer to a GUIScreen interface that will be used to create this TitleScreen's GUIFont. Ownership is NOT transferred! + /// @param guiScreen Pointer to a GUIScreen interface that will be used to create this TitleScreen's GUIFont. Ownership is NOT transferred! explicit TitleScreen(AllegroScreen* guiScreen) { Clear(); Create(guiScreen); } - /// /// Makes the TitleScreen object ready for use. - /// - /// Pointer to a GUIScreen interface that will be used to create this TitleScreen's GUIFont. Ownership is NOT transferred! + /// @param guiScreen Pointer to a GUIScreen interface that will be used to create this TitleScreen's GUIFont. Ownership is NOT transferred! void Create(AllegroScreen* guiScreen); #pragma endregion #pragma region Getters and Setters - /// /// Gets the current title transition state. - /// - /// The current title transition state. See TitleTransition enumeration for values. + /// @return The current title transition state. See TitleTransition enumeration for values. TitleTransition GetTitleTransitionState() const { return m_TitleTransitionState; } - /// /// Sets the target title transition state and, if different from the current, sets the section switch to trigger the transition. - /// - /// The target title transition state. + /// @param newTransitionState The target title transition state. void SetTitleTransitionState(TitleTransition newTransitionState) { if (newTransitionState != m_TitleTransitionState) { m_TitleTransitionState = newTransitionState; @@ -77,51 +65,37 @@ namespace RTE { } } - /// /// Sets the title transition to a pending state, stores the orbit timer elapsed time and resets the fade screen blend value. /// This is used to correctly restart transition states after breaking out of the game loop back to the menu loop. - /// void SetTitlePendingTransition() { m_TitleTransitionState = TitleTransition::TransitionPending; m_StationOrbitTimerElapsedTime = static_cast(m_StationOrbitTimer.GetElapsedRealTimeS()); m_FadeAmount = 0; } - /// /// Gets the position of the planet on the title screen scene. - /// - /// Vector with the position of the planet on the title screen scene. + /// @return Vector with the position of the planet on the title screen scene. Vector GetPlanetPos() const { return m_PlanetPos; } - /// /// Gets the radius of the planet. - /// - /// The radius of the planet. + /// @return The radius of the planet. float GetPlanetRadius() const { return m_PlanetRadius; } - /// /// Gets the position of the station on the planet orbit. - /// - /// Vector with the position of the station on the planet orbit. + /// @return Vector with the position of the station on the planet orbit. Vector GetStationPos() const { return m_StationOffset; } #pragma endregion #pragma region Concrete Methods - /// /// Updates the TitleScreen state. - /// void Update(); - /// /// Draws the TitleScreen to the screen. - /// void Draw(); #pragma endregion private: - /// /// Enumeration for the different states of the intro sequence. - /// enum class IntroSequence { DataRealmsLogoFadeIn, DataRealmsLogoDisplay, @@ -146,13 +120,9 @@ namespace RTE { MainMenuAppear }; - /// /// Struct that holds information for a title screen scene backdrop star. - /// struct Star { - /// /// Enumeration for the different Star sizes. - /// enum class StarSize { StarSmall, StarLarge, @@ -217,75 +187,51 @@ namespace RTE { std::array m_IntroSlides; //!< Array that contains all the slideshow slide bitmaps. Not Owned. #pragma region Create Breakdown - /// /// Creates all the elements that compose the title screen scene. - /// void CreateTitleElements(); - /// /// Creates the intro sequence slideshow slides. - /// void CreateIntroSequenceSlides(); #pragma endregion #pragma region Title Scene Handling - /// /// Sets the duration of a new section and resets the switch. - /// - /// The duration of the new section, in seconds. + /// @param newDuration The duration of the new section, in seconds. void SetSectionDurationAndResetSwitch(float newDuration) { m_SectionDuration = newDuration; m_SectionSwitch = false; } - /// /// Updates the title screen transition states and scrolls the title screen scene accordingly. - /// void UpdateTitleTransitions(); - /// /// Draws the whole title screen scene to the screen. - /// void DrawTitleScreenScene(); - /// /// Draws the game logo and effects to the screen. - /// void DrawGameLogo(); - /// /// Draws the overlay bitmap for fade in/out or darkening effects to the screen. - /// void DrawOverlayEffectBitmap() const; #pragma endregion #pragma region Intro Sequence Handling - /// /// Updates the state of the intro sequence logo splash. - /// - /// Whether the current section of the logo splash sequence should be skipped. + /// @param skipSection Whether the current section of the logo splash sequence should be skipped. void UpdateIntroLogoSequence(bool skipSection = false); - /// /// Updates the state of the intro sequence slideshow. - /// - /// Whether the whole slideshow should be skipped. + /// @param skipSlideshow Whether the whole slideshow should be skipped. void UpdateIntroSlideshowSequence(bool skipSlideshow = false); - /// /// Updates the state of the intro pre-main menu sequence. - /// void UpdateIntroPreMainMenuSequence(); - /// /// Draws the current slideshow sequence slide to the screen. - /// void DrawSlideshowSlide(); #pragma endregion - /// /// Clears all the member variables of this TitleScreen, effectively resetting the members of this object. - /// void Clear(); // Disallow the use of some implicit methods. diff --git a/Source/System/AllegroTools.h b/Source/System/AllegroTools.h index b41b7a5713..2e7ce14996 100644 --- a/Source/System/AllegroTools.h +++ b/Source/System/AllegroTools.h @@ -1,21 +1,15 @@ #ifndef _RTEALLEGROTOOLS_H_ #define _RTEALLEGROTOOLS_H_ -/// /// Contains hacks and workarounds for missing or wrong allegro functionality. /// Note: Prefer fixing in allegro itself over adding hacks here. -/// namespace RTE { #pragma region True Alpha Blending - /// /// Workaround for allegro's missing true alpha blender, use instead of set_alpha_blender when alpha values are desired or necessary after draw: /// ``` set_blender_mode_ex(_blender_black, _blender_black, _blender_black, TrueAlphaBlender, _blender_black, _blender_black, _blender_black, 0, 0, 0, 0);``` - /// unsigned long TrueAlphaBlender(unsigned long x, unsigned long y, unsigned long n); - /// /// Sets the 32bit allegro blender mode to TrueAlphaBlender - /// void SetTrueAlphaBlender(); #pragma endregion } // namespace RTE diff --git a/Source/System/Atom.cpp b/Source/System/Atom.cpp index e5266f898f..662421f67e 100644 --- a/Source/System/Atom.cpp +++ b/Source/System/Atom.cpp @@ -21,8 +21,6 @@ namespace RTE { // This forms a circle around the Atom's offset center, to check for mask color pixels in order to determine the normal at the Atom's position. const int Atom::s_NormalChecks[c_NormalCheckCount][2] = {{0, -3}, {1, -3}, {2, -2}, {3, -1}, {3, 0}, {3, 1}, {2, 2}, {1, 3}, {0, 3}, {-1, 3}, {-2, 2}, {-3, 1}, {-3, 0}, {-3, -1}, {-2, -2}, {-1, -3}}; - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void Atom::Clear() { m_Offset.Reset(); m_OriginalOffset.Reset(); @@ -62,8 +60,6 @@ namespace RTE { // m_Delta[m_Dom] = 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int Atom::Create(const Vector& offset, Material const* material, MovableObject* owner, Color trailColor, int trailLength) { m_Offset = m_OriginalOffset = offset; // Use the offset as normal for now @@ -77,8 +73,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int Atom::Create(const Atom& reference) { m_Offset = reference.m_Offset; m_OriginalOffset = reference.m_OriginalOffset; @@ -96,8 +90,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int Atom::ReadProperty(const std::string_view& propName, Reader& reader) { StartPropertyList(return Serializable::ReadProperty(propName, reader)); @@ -119,8 +111,6 @@ namespace RTE { EndPropertyList; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int Atom::Save(Writer& writer) const { Serializable::Save(writer); @@ -134,8 +124,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void* Atom::GetPoolMemory() { std::lock_guard guard(s_MemoryPoolMutex); @@ -156,8 +144,6 @@ namespace RTE { return foundMemory; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void Atom::FillPool(int fillAmount) { // Default to the set block allocation size if fillAmount is 0 if (fillAmount <= 0) { @@ -173,8 +159,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int Atom::ReturnPoolMemory(void* returnedMemory) { if (!returnedMemory) { return false; @@ -189,8 +173,6 @@ namespace RTE { return s_InstancesInUse; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool Atom::CalculateNormal(BITMAP* sprite, Vector spriteCenter) { RTEAssert(sprite, "Trying to set up Atom normal without passing in bitmap"); @@ -231,8 +213,6 @@ namespace RTE { return true; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool Atom::IsIgnoringMOID(MOID whichMOID) { if (whichMOID == m_IgnoreMOID) { return true; @@ -272,8 +252,6 @@ namespace RTE { return ignored; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool Atom::MOHitResponse() { RTEAssert(m_OwnerMO, "Stepping an Atom without a parent MO!"); @@ -346,8 +324,6 @@ namespace RTE { return false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - HitData& Atom::TerrHitResponse() { RTEAssert(m_OwnerMO, "Stepping an Atom without a parent MO!"); @@ -422,8 +398,6 @@ namespace RTE { return m_LastHit; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool Atom::SetupPos(Vector startPos) { RTEAssert(m_OwnerMO, "Stepping an Atom without a parent MO!"); @@ -450,8 +424,6 @@ namespace RTE { return m_MOIDHit != g_NoMOID || m_TerrainMatHit != g_MaterialAir; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int Atom::SetupSeg(Vector startPos, Vector trajectory, float stepRatio) { RTEAssert(m_OwnerMO, "Stepping an Atom without a parent MO!"); m_TerrainMatHit = g_MaterialAir; @@ -505,8 +477,6 @@ namespace RTE { return m_Delta[m_Dom] - m_DomSteps; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool Atom::StepForward(int numSteps) { RTEAssert(m_OwnerMO, "Stepping an Atom without a parent MO!"); @@ -593,8 +563,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void Atom::StepBack() { RTEAssert(m_OwnerMO, "Stepping an Atom without a parent MO!"); @@ -618,8 +586,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int Atom::Travel(float travelTime, bool autoTravel, bool scenePreLocked) { ZoneScoped; @@ -1074,8 +1040,6 @@ namespace RTE { return hitCount; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void HitData::Clear() { HitPoint.Reset(); VelDiff.Reset(); @@ -1098,8 +1062,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - HitData& HitData::operator=(const HitData& rhs) { if (this == &rhs) { return *this; diff --git a/Source/System/Atom.h b/Source/System/Atom.h index d9d25e7ea5..c5b00bb485 100644 --- a/Source/System/Atom.h +++ b/Source/System/Atom.h @@ -16,9 +16,7 @@ namespace RTE { }; #pragma region HitData - /// /// A struct to keep all data about a rigid body collision in one package. - /// struct HitData { MovableObject* Body[2]; //!< Pointers to the two hitting bodies. If hitee is 0, that means collision with terrain. The HitData struct doesn't own these. @@ -44,33 +42,23 @@ namespace RTE { float ImpulseFactor[2]; //!< The factor by which the final impulse vector should be scaled to account for multiple hits in the same step. bool Terminate[2]; //!< Whether either of the bodies should be stopped and deleted as a result of the collision. - /// /// Constructor method used to instantiate a HitData object in system memory. - /// HitData() { Clear(); } - /// /// Resets the entire HitData object to the default settings or values. - /// void Reset() { Clear(); } - /// /// An assignment operator for setting one HitData equal to another. - /// - /// A HitData reference. - /// A reference to the changed HitData. + /// @param rhs A HitData reference. + /// @return A reference to the changed HitData. HitData& operator=(const HitData& rhs); - /// /// Clears all the member variables of this HitData, effectively resetting the members of this abstraction level only. - /// void Clear(); }; #pragma endregion - /// /// A point (pixel) that tests for collisions with a BITMAP's drawn pixels, ie not the mask color. Owned and operated by other objects. - /// class Atom : public Serializable { public: @@ -78,15 +66,11 @@ namespace RTE { SerializableOverrideMethods; #pragma region Creation - /// /// Constructor method used to instantiate an Atom object in system memory. Create() should be called before using the object. - /// Atom() { Clear(); } - /// /// Copy constructor method used to instantiate an Atom object identical to an already existing one. - /// - /// An Atom object which is passed in by reference. + /// @param reference An Atom object which is passed in by reference. Atom(const Atom& reference) { if (this != &reference) { Clear(); @@ -94,385 +78,276 @@ namespace RTE { } } - /// /// Convenience constructor to both instantiate an Atom in memory and Create it at the same time. - /// - /// An offset Vector that will be used to offset collision calculations. - /// A Material that defines what material this Atom is made of. - /// The owner MovableObject of this Atom. Ownership is NOT transferred! - /// The trail color. - /// The trail length. If 0, no trail will be drawn. + /// @param offset An offset Vector that will be used to offset collision calculations. + /// @param material A Material that defines what material this Atom is made of. + /// @param owner The owner MovableObject of this Atom. Ownership is NOT transferred! + /// @param trailColor The trail color. + /// @param trailLength The trail length. If 0, no trail will be drawn. Atom(const Vector& offset, Material const* material, MovableObject* owner, Color trailColor = Color(), int trailLength = 0) { Clear(); Create(offset, material, owner, trailColor, trailLength); } - /// /// Convenience constructor to both instantiate an Atom in memory and Create it at the same time. - /// - /// An offset Vector that will be used to offset collision calculations. - /// The material ID of the Material that defines what this Atom is made of. - /// The owner MovableObject of this Atom. Ownership is NOT transferred! - /// The trail color. - /// The trail length. If 0, no trail will be drawn. + /// @param offset An offset Vector that will be used to offset collision calculations. + /// @param materialID The material ID of the Material that defines what this Atom is made of. + /// @param owner The owner MovableObject of this Atom. Ownership is NOT transferred! + /// @param trailColor The trail color. + /// @param trailLength The trail length. If 0, no trail will be drawn. Atom(const Vector& offset, unsigned char materialID, MovableObject* owner, Color trailColor = Color(), int trailLength = 0) { Clear(); Create(offset, g_SceneMan.GetMaterialFromID(materialID), owner, trailColor, trailLength); } - /// /// Creates an Atom to be identical to another, by deep copy. - /// - /// A reference to the Atom to deep copy. - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @param reference A reference to the Atom to deep copy. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create(const Atom& reference); - /// /// Makes the Atom object ready for use. - /// - /// An offset Vector that will be used to offset collision calculations. - /// A Material that defines what material this Atom is made of. - /// The owner MovableObject of this Atom. Ownership is NOT transferred! - /// The trail color. - /// The trail length. If 0, no trail will be drawn. - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @param offset An offset Vector that will be used to offset collision calculations. + /// @param material A Material that defines what material this Atom is made of. + /// @param owner The owner MovableObject of this Atom. Ownership is NOT transferred! + /// @param trailColor The trail color. + /// @param trailLength The trail length. If 0, no trail will be drawn. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create(const Vector& offset, Material const* material, MovableObject* owner, Color trailColor = Color(), int trailLength = 0); #pragma endregion #pragma region Destruction - /// /// Destructor method used to clean up an Atom object before deletion from system memory. - /// ~Atom() { Destroy(); } - /// /// Destroys and resets (through Clear()) the Atom object. - /// void Destroy() { Clear(); } #pragma endregion #pragma region Memory Management - /// /// Grabs from the pre-allocated pool, an available chunk of memory the exact size of an Atom. OWNERSHIP IS TRANSFERRED! - /// - /// A pointer to the pre-allocated pool memory. OWNERSHIP IS TRANSFERRED! + /// @return A pointer to the pre-allocated pool memory. OWNERSHIP IS TRANSFERRED! static void* GetPoolMemory(); - /// /// Adds a certain number of newly allocated instances to this' pool. - /// - /// The number of instances to fill with. If 0 is specified, the set refill amount will be used. + /// @param fillAmount The number of instances to fill with. If 0 is specified, the set refill amount will be used. static void FillPool(int fillAmount = 0); - /// /// Returns a raw chunk of memory back to the pre-allocated available pool. - /// - /// The raw chunk of memory that is being returned. Needs to be the same size as an Atom. OWNERSHIP IS TRANSFERRED! - /// The count of outstanding memory chunks after this was returned. + /// @param returnedMemory The raw chunk of memory that is being returned. Needs to be the same size as an Atom. OWNERSHIP IS TRANSFERRED! + /// @return The count of outstanding memory chunks after this was returned. static int ReturnPoolMemory(void* returnedMemory); #pragma endregion #pragma region Getters and Setters - /// /// Gets the current owner MovableObject of this AtomGroup. - /// - /// A const pointer to the owner. + /// @return A const pointer to the owner. const MovableObject* GetOwner() const { return m_OwnerMO; } - /// /// Sets the current owner MovableObject of this AtomGroup. - /// - /// A pointer to the new owner. Ownership is NOT transferred! + /// @param newOwner A pointer to the new owner. Ownership is NOT transferred! void SetOwner(MovableObject* newOwner) { m_OwnerMO = newOwner; } - /// /// Gets the group ID of this Atom. - /// - /// The group ID of this Atom. + /// @return The group ID of this Atom. long GetSubID() const { return m_SubgroupID; } - /// /// Sets the subgroup ID of this Atom. - /// - /// The new subgroup ID of this Atom. + /// @param newID The new subgroup ID of this Atom. void SetSubID(long newID = 0) { m_SubgroupID = newID; } - /// /// Gets the material of this Atom. - /// - /// The material of this Atom. + /// @return The material of this Atom. Material const* GetMaterial() const { return m_Material ? m_Material : g_SceneMan.GetMaterialFromID(g_MaterialAir); } - /// /// Sets the material of this Atom. - /// - /// The new material of this Atom. + /// @param newMat The new material of this Atom. void SetMaterial(const Material* newMat) { m_Material = newMat; } - /// /// Gets the Color of this Atom's trail. - /// - /// A Color object describing the trail color. + /// @return A Color object describing the trail color. Color GetTrailColor() const { return m_TrailColor; } - /// /// Sets the color value of this Atom's trail. - /// - /// A Color object specifying the new trail color. + /// @param newTrailColor A Color object specifying the new trail color. void SetTrailColor(Color newTrailColor) { m_TrailColor = newTrailColor; } - /// /// Gets the longest a trail can be drawn, in pixels. - /// - /// The new max length, in pixels. If 0, no trail is drawn. + /// @return The new max length, in pixels. If 0, no trail is drawn. int GetTrailLength() const { return m_TrailLength; } - /// /// Sets the longest a trail can be drawn, in pixels. - /// - /// The new max length, in pixels. If 0, no trail is drawn. + /// @param trailLength The new max length, in pixels. If 0, no trail is drawn. void SetTrailLength(const int trailLength) { m_TrailLength = trailLength; } - /// /// Gets the length variation of this Atom's trail. - /// - /// The length variation of this Atom's trail. + /// @return The length variation of this Atom's trail. float GetTrailLengthVariation() const { return m_TrailLengthVariation; } - /// /// Sets the length variation scalar of a trail. - /// - /// The new length variation scalar, 0 meaning no variation and 1 meaning full variation. + /// @param trailLengthVariation The new length variation scalar, 0 meaning no variation and 1 meaning full variation. void SetTrailLengthVariation(float trailLengthVariation) { m_TrailLengthVariation = trailLengthVariation; } - /// /// Gets the offset vector that was first set for this Atom. The GetOffset may have additional offsets baked into it if this is part of an group. - /// - /// The original offset Vector. + /// @return The original offset Vector. const Vector& GetOriginalOffset() const { return m_OriginalOffset; } - /// /// Gets the offset vector. - /// - /// The current offset Vector. + /// @return The current offset Vector. const Vector& GetOffset() const { return m_Offset; } - /// /// Sets a new offset vector for the collision calculations. - /// - /// A const reference to a Vector that will be used as offset. + /// @param newOffset A const reference to a Vector that will be used as offset. void SetOffset(const Vector& newOffset) { m_Offset = newOffset; } - /// /// Gets the surface normal of this vector, if it has been successfully calculated. If not, it'll be a 0 vector. - /// - /// The current normalized surface normal Vector of this. + /// @return The current normalized surface normal Vector of this. const Vector& GetNormal() const { return m_Normal; } #pragma endregion #pragma region Concrete Methods - /// /// Sets up the normal of this atom, based on its position on a sprite's bitmap. /// It will check pixels around it and see if they are inside the object or not, and infer a collision normal based on that. THIS ONLY WORKS IF THE ATOM IS ON THE SURFACE OF THE SPRITE! - /// - /// The bitmap to check against. Ownership IS NOT transferred! - /// Where on the bitmap the center of the object is. This atom's offset will be applied automatically before checking for its normal. - /// Whether normal was successfully derived from the bitmap. If not, then a provisional one is derived from the offset. + /// @param sprite The bitmap to check against. Ownership IS NOT transferred! + /// @param spriteCenter Where on the bitmap the center of the object is. This atom's offset will be applied automatically before checking for its normal. + /// @return Whether normal was successfully derived from the bitmap. If not, then a provisional one is derived from the offset. bool CalculateNormal(BITMAP* sprite, Vector spriteCenter); #pragma endregion #pragma region Collision - /// /// Gets the stored data struct on the last collision experienced by this Atom. - /// - /// The Vector describing the velocity of this Atom at the last time it hit something. + /// @return The Vector describing the velocity of this Atom at the last time it hit something. HitData& GetHitData() { return m_LastHit; } - /// /// Sets the HitData struct this Atom uses to represent the last hit it experienced. - /// - /// A reference to a HitData struct that will be copied to the Atom's. + /// @param newHitData A reference to a HitData struct that will be copied to the Atom's. void SetHitData(const HitData& newHitData) { m_LastHit = newHitData; } - /// /// Checks whether this Atom is set to ignore collisions with the terrain. - /// - /// Whether or not this is ignoring hits the with terrain. + /// @return Whether or not this is ignoring hits the with terrain. bool IsIgnoringTerrain() const { return m_TerrainHitsDisabled; } - /// /// Checks whether this Atom is temporarily ignoring all MO hits. - /// - /// Whether or not this is ignoring all MO hits. + /// @return Whether or not this is ignoring all MO hits. bool IsIgnoringAllMOs() const { return m_MOHitsDisabled; } - /// /// Checks whether this Atom is set to ignore collisions with a MO of a specific MOID. - /// - /// The MOID to check if it is ignored. - /// Whether or not this MOID is being ignored. + /// @param whichMOID The MOID to check if it is ignored. + /// @return Whether or not this MOID is being ignored. bool IsIgnoringMOID(MOID whichMOID); - /// /// Adds a MOID that this Atom should ignore collisions with during its next travel sequence. - /// - /// The MOID to add to the ignore list. + /// @param ignore The MOID to add to the ignore list. void AddMOIDToIgnore(MOID ignore) { m_IgnoreMOIDs.push_back(ignore); } - /// /// AtomGroup may set this shared list of ignored MOIDs to avoid setting and removing ignored MOIDs for every atom one by one. The list is maintained only by AtomGroup, Atom never owns it. - /// - /// New MOIDs list to ignore. + /// @param ignoreMOIDsByGroup New MOIDs list to ignore. void SetIgnoreMOIDsByGroup(std::vector const* ignoreMOIDsByGroup) { m_IgnoreMOIDsByGroup = ignoreMOIDsByGroup; }; - /// /// Clear the list of MOIDs that this Atom is set to ignore collisions with during its next travel sequence. /// This should be done each frame so that fresh MOIDs can be re-added. (MOIDs are only valid during a frame). - /// void ClearMOIDIgnoreList() { m_IgnoreMOIDs.clear(); } - /// /// Gets the number of consecutive penetrations of Terrain that this Atom has successfully made, ending with wherever it is now. - /// - /// The number of consecutive penetrations. Resets to 0 as soon as penetration streak ends. + /// @return The number of consecutive penetrations. Resets to 0 as soon as penetration streak ends. int GetNumPenetrations() const { return m_NumPenetrations; } - /// /// Returns the ID of the MO hit at the previously taken step by TakeStep. This will potentially return g_NoMOID if this Atom is not set to hit MO's or the MO hit is marked to be ignored. - /// - /// The ID of the non-ignored MO, if any, that this Atom is now intersecting because of the last step taken. + /// @return The ID of the non-ignored MO, if any, that this Atom is now intersecting because of the last step taken. MOID HitWhatMOID() const { return m_MOIDHit; } - /// /// Calculates the collision response with another MO, if the last step taken forward resulted in an intersection with a non-ignored MO. /// Note that one step backward should be taken after the intersecting step so that the Atom is not intersecting the hit MO anymore. /// The hit response is calculated and appropriate forces are applied to the hit MO and the impulse force imposed on the owner MO are returned, and also stored in this Atom to be later retrieved with GetHitImpulse(). - /// - /// Collision data should already be set by SetHitData(). - /// Whether this collision is valid and should be considered further. + /// @remark Collision data should already be set by SetHitData(). + /// @return Whether this collision is valid and should be considered further. bool MOHitResponse(); - /// /// Returns the terrain material the previously taken step by TakeStep hit, if any. - /// - /// The ID of the material, if any, that this MO hit during the last step. + /// @return The ID of the material, if any, that this MO hit during the last step. unsigned char HitWhatTerrMaterial() { return m_TerrainMatHit; } - /// /// Calculates the collision response with the Terrain, if the last step taken forward resulted in an intersection with the Terrain. /// Note that one step backward should be taken after the intersecting step so that the Atom is not intersecting the Terrain anymore, and the hit response calculations can be made accurately. /// The resulting impulse vector is also stored in this Atom to be later retrieved with GetHitImpulse(). - /// - /// Collision data should already be set by SetHitData(). - /// The resulting HitData of this Atom with all the information about the collision filled out. + /// @remark Collision data should already be set by SetHitData(). + /// @return The resulting HitData of this Atom with all the information about the collision filled out. HitData& TerrHitResponse(); #pragma endregion #pragma region Travel - /// /// Sets this Atom's initial position up for a straight segment of a trajectory to step through. This is to be done before SetupSeg. /// It will report whether the atom's position is inside the terrain or another MO. It also disables this' terrain and/or MO collisions when traveling, until the travel encounters an air/noMO pixel again. - /// - /// A Vector with the position to start from, in scene coordinates. - /// If the start pos is already intersecting the terrain or an MO, then this will return true. Do collision response as needed. + /// @param startPos A Vector with the position to start from, in scene coordinates. + /// @return If the start pos is already intersecting the terrain or an MO, then this will return true. Do collision response as needed. bool SetupPos(Vector startPos); - /// /// Gets the absolute current position of this Atom, in scene coordinates. This includes the rotated offset, and any steps that may have been taken on a segment. - /// - /// The current position of the Atom, with the offset baked in. + /// @return The current position of the Atom, with the offset baked in. Vector GetCurrentPos() const { return Vector(m_IntPos[X], m_IntPos[Y]); } - /// /// Sets this Atom up for a straight segment of a trajectory to step through. If this Atom find the startPos to be on an MO, it will ignore any collisions with that MO for the entire segment. /// The Scene MUST BE LOCKED before calling this! - /// - /// A Vector with the position to start from, in scene coordinates. - /// A Vector with the trajectory to travel during this next segment. - /// The ratio between the actual steps to be taken and the future calls to TakeStep(). - /// The total number of steps this will take in the newly set-up segment. + /// @param startPos A Vector with the position to start from, in scene coordinates. + /// @param trajectory A Vector with the trajectory to travel during this next segment. + /// @param stepRatio The ratio between the actual steps to be taken and the future calls to TakeStep(). + /// @return The total number of steps this will take in the newly set-up segment. int SetupSeg(Vector startPos, Vector trajectory, float stepRatio = 1.0); - /// /// Gets the segment trajectory currently set by SetupSeg. - /// - /// The currently traversed segment trajectory. + /// @return The currently traversed segment trajectory. Vector GetSegTraj() const { return m_SegTraj; } - /// /// Indicates the total original length of the current segment set by SetupSeg. - /// - /// The length of the currently traversed segment. + /// @return The length of the currently traversed segment. float GetSegLength() const { return m_SegTraj.GetMagnitude(); } - /// /// Takes one step along the trajectory segment set up by SetupSeg(). The Scene MUST BE LOCKED before calling this! - /// - /// The number of steps to take. - /// + /// @param numSteps The number of steps to take. + /// @return /// Whether anything was hit during the steps or not. MO hits will only be reported if this Atom is set to hit them, and the MO hit is not ignored by this Atom (if the segment started on that MO). /// Also if terrain hits are temporarily disabled, they will not be reported. - /// bool StepForward(int numSteps = 1); - /// /// Takes one step back, or undos the step, if any, previously taken along the trajectory segment set up by SetupSeg(). - /// - /// CAUTION: The previous HitWhat vars are not reset to what they previously were! + /// @remark CAUTION: The previous HitWhat vars are not reset to what they previously were! void StepBack(); - /// /// Gets the normalized ratio of how many steps are actually taken to how many calls to TakeStep are made. - /// - /// A normalized float describing the step ratio. + /// @return A normalized float describing the step ratio. float GetStepRatio() const { return m_StepRatio; } - /// /// Sets the ratio of how many steps are actually taken to how many calls to TakeStep are made. - /// - /// A float specifying the new step ratio. + /// @param newStepRatio A float specifying the new step ratio. void SetStepRatio(float newStepRatio) { m_StepRatio = newStepRatio; } - /// /// Indicates how many more steps remain to be taken to traverse the entire trajectory segment. - /// - /// The number of steps that remain to be taken on the set trajectory segment. + /// @return The number of steps that remain to be taken on the set trajectory segment. int GetStepsLeft() const { return m_Delta[m_Dom] - m_DomSteps; } - /// /// Tells this Atom that the previous travel move's fractional error isn't valid for consecutive travel moves. - /// void ChangedDir() { m_ChangedDir = true; } - /// /// Uses the current state of the owning MovableObject to determine if there are any collisions in the path of its travel during this frame, and if so, apply all collision responses to the MO. - /// - /// The amount of time in s that this Atom is allowed to travel. - /// A bool specifying if the end position result should be moved along the trajectory if no terrain is hit. - /// Whether the Scene has been pre-locked or not. - /// The number of hits against terrain that were made during the travel. + /// @param travelTime The amount of time in s that this Atom is allowed to travel. + /// @param autoTravel A bool specifying if the end position result should be moved along the trajectory if no terrain is hit. + /// @param scenePreLocked Whether the Scene has been pre-locked or not. + /// @return The number of hits against terrain that were made during the travel. int Travel(float travelTime, bool autoTravel = true, bool scenePreLocked = false); #pragma endregion #pragma region Operator Overloads - /// /// New operator overload for the pool allocation of Atoms. - /// - /// - /// + /// @param size + /// @return static void* operator new(size_t size) { return Atom::GetPoolMemory(); } - /// /// Delete operator overload for the pool deallocation of Atoms. - /// - /// + /// @param instance static void operator delete(void* instance) { Atom::ReturnPoolMemory(instance); } - /// /// An assignment operator for setting one Atom equal to another. - /// - /// An Atom reference. - /// A reference to the changed Atom. + /// @param rhs An Atom reference. + /// @return A reference to the changed Atom. Atom& operator=(const Atom& rhs) { if (this != &rhs) { Destroy(); @@ -548,9 +423,7 @@ namespace RTE { private: static const std::string c_ClassName; //!< A string with the friendly-formatted type name of this. - /// /// Clears all the member variables of this Atom, effectively resetting the members of this abstraction level only. - /// void Clear(); }; } // namespace RTE diff --git a/Source/System/Box.cpp b/Source/System/Box.cpp index ce06304ede..2d920ba5a7 100644 --- a/Source/System/Box.cpp +++ b/Source/System/Box.cpp @@ -4,8 +4,6 @@ namespace RTE { const std::string Box::c_ClassName = "Box"; - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool IntRect::IntersectionCut(const IntRect& rhs) { if (Intersects(rhs)) { m_Left = std::max(m_Left, rhs.m_Left); @@ -17,8 +15,6 @@ namespace RTE { return false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int Box::Create(const Vector& corner1, const Vector& corner2) { m_Corner = corner1; m_Width = corner2.m_X - corner1.m_X; @@ -27,8 +23,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int Box::Create(float x1, float y1, float x2, float y2) { m_Corner.SetXY(x1, y1); m_Width = x2 - x1; @@ -37,8 +31,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int Box::Create(const Vector& corner, float width, float height) { m_Corner = corner; m_Width = width; @@ -47,8 +39,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int Box::Create(const Box& reference) { m_Corner = reference.m_Corner; m_Width = reference.m_Width; @@ -57,8 +47,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int Box::ReadProperty(const std::string_view& propName, Reader& reader) { StartPropertyList(return Serializable::ReadProperty(propName, reader)); @@ -69,8 +57,6 @@ namespace RTE { EndPropertyList; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int Box::Save(Writer& writer) const { Serializable::Save(writer); @@ -81,8 +67,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void Box::Unflip() { if (m_Width < 0) { m_Width = -m_Width; @@ -94,8 +78,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool Box::IsWithinBox(const Vector& point) const { return !IsEmpty() && (((m_Width > 0 && point.m_X >= m_Corner.m_X && point.m_X < (m_Corner.m_X + m_Width)) || (m_Width < 0 && point.m_X < m_Corner.m_X && point.m_X >= (m_Corner.m_X + m_Width))) && @@ -103,22 +85,16 @@ namespace RTE { (m_Height < 0 && point.m_Y < m_Corner.m_Y && point.m_Y <= (m_Corner.m_Y + m_Height))); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool Box::IsWithinBoxX(float pointX) const { return !IsEmpty() && ((m_Width > 0 && pointX >= m_Corner.m_X && pointX < (m_Corner.m_X + m_Width)) || (m_Width < 0 && pointX < m_Corner.m_X && pointX >= (m_Corner.m_X + m_Width))); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool Box::IsWithinBoxY(float pointY) const { return !IsEmpty() && ((m_Height > 0 && pointY >= m_Corner.m_Y && pointY < (m_Corner.m_Y + m_Height)) || (m_Height < 0 && pointY < m_Corner.m_Y && pointY <= (m_Corner.m_Y + m_Height))); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - float Box::GetWithinBoxX(float pointX) const { if (m_Width > 0) { return Limit(pointX, m_Corner.m_X + m_Width - 1, m_Corner.m_X); @@ -128,8 +104,6 @@ namespace RTE { return m_Corner.m_X; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - float Box::GetWithinBoxY(float pointY) const { if (m_Height > 0) { return Limit(pointY, m_Corner.m_Y + m_Height - 1, m_Corner.m_Y); @@ -139,8 +113,6 @@ namespace RTE { return m_Corner.m_Y; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool Box::IntersectsBox(const Box& rhs) { if (IsEmpty() || rhs.IsEmpty()) { return false; diff --git a/Source/System/Box.h b/Source/System/Box.h index 56d0e82e11..8a79f1b8bb 100644 --- a/Source/System/Box.h +++ b/Source/System/Box.h @@ -6,9 +6,7 @@ namespace RTE { - /// /// A simple rectangle with integer coordinates. - /// struct IntRect { int m_Left = 0; //!< X position of the IntRect top left corner. @@ -16,35 +14,27 @@ namespace RTE { int m_Right = 0; //!< X position of the IntRect bottom right corner. int m_Bottom = 0; //!< Y position of the IntRect bottom right corner. - /// /// Constructor method used to instantiate an IntRect object from four int values defining the initial corners of this IntRect. - /// - /// X position of the IntRect top left corner. - /// Y position of the IntRect top left corner. - /// X position of the IntRect bottom right corner. - /// Y position of the IntRect bottom right corner. + /// @param left X position of the IntRect top left corner. + /// @param top Y position of the IntRect top left corner. + /// @param right X position of the IntRect bottom right corner. + /// @param bottom Y position of the IntRect bottom right corner. IntRect(int left, int top, int right, int bottom) : m_Left(left), m_Top(top), m_Right(right), m_Bottom(bottom) {} - /// /// Checks whether this IntRect is intersecting another one. - /// - /// The other IntRect to check for intersection with. - /// Whether this IntRect is intersecting another one. + /// @param rhs The other IntRect to check for intersection with. + /// @return Whether this IntRect is intersecting another one. bool Intersects(const IntRect& rhs) const { return m_Left < rhs.m_Right && m_Right > rhs.m_Left && m_Top < rhs.m_Bottom && m_Bottom > rhs.m_Top; } - /// /// If this and the passed in IntRect intersect, this will be modified to represent the boolean AND of the two. /// If they don't intersect, nothing happens and false is returned. - /// - /// THe other IntRect to cut against. - /// Whether an intersection was detected and this was cut down to the AND of the two IntRects. + /// @param rhs THe other IntRect to cut against. + /// @return Whether an intersection was detected and this was cut down to the AND of the two IntRects. bool IntersectionCut(const IntRect& rhs); }; - /// /// A useful 2D axis-aligned rectangle class. - /// class Box : public Serializable { public: @@ -56,216 +46,156 @@ namespace RTE { float m_Height; //!< Height of this box. #pragma region Creation - /// /// Constructor method used to instantiate a Box object. - /// Box() { Clear(); } - /// /// Constructor method used to instantiate a Box object from two points. - /// - /// Vector position of the upper left corner of this box. - /// Vector position of the lower right corner of this box. + /// @param corner1 Vector position of the upper left corner of this box. + /// @param corner2 Vector position of the lower right corner of this box. Box(const Vector& corner1, const Vector& corner2) { Create(corner1, corner2); } - /// /// Constructor method used to instantiate a Box object from four float values defining the initial corners of this Box. - /// - /// X position of box upper left corner. - /// Y position of box upper left corner. - /// X position of box lower right corner. - /// Y position of box lower right corner. + /// @param x1 X position of box upper left corner. + /// @param y1 Y position of box upper left corner. + /// @param x2 X position of box lower right corner. + /// @param y2 Y position of box lower right corner. Box(float x1, float y1, float x2, float y2) { Create(x1, y1, x2, y2); } - /// /// Constructor method used to instantiate a Box object from one point and two dimensions. /// They can be negative but it will affect the interpretation of which corner is defined. The Box will always return positive values for width and height. - /// - /// Vector position of the upper left corner of this box. - /// Width of this box. - /// Height of this box. + /// @param corner Vector position of the upper left corner of this box. + /// @param width Width of this box. + /// @param height Height of this box. Box(const Vector& corner, float width, float height) { Create(corner, width, height); } - /// /// Copy constructor method used to instantiate a Box object identical to an already existing one. - /// - /// A Box object which is passed in by reference. + /// @param reference A Box object which is passed in by reference. Box(const Box& reference) { Create(reference); } - /// /// Makes the Box object ready for use. - /// - /// Vector position of the upper left corner of this box. - /// Vector position of the lower right corner of this box. - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @param corner1 Vector position of the upper left corner of this box. + /// @param corner2 Vector position of the lower right corner of this box. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create(const Vector& corner1, const Vector& corner2); - /// /// Makes the Box object ready for use. - /// - /// X position of box upper left corner. - /// Y position of box upper left corner. - /// X position of box lower right corner. - /// Y position of box lower right corner. - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @param x1 X position of box upper left corner. + /// @param y1 Y position of box upper left corner. + /// @param x2 X position of box lower right corner. + /// @param y2 Y position of box lower right corner. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create(float x1, float y1, float x2, float y2); - /// /// Makes the Box object ready for use. - /// - /// Vector position of the upper left corner of this box. - /// Width of this box. - /// Height of this box. - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @param corner Vector position of the upper left corner of this box. + /// @param width Width of this box. + /// @param height Height of this box. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create(const Vector& corner, float width, float height); - /// /// Creates a Box to be identical to another, by deep copy. - /// - /// A reference to the Box to deep copy. - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @param reference A reference to the Box to deep copy. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create(const Box& reference); #pragma endregion #pragma region Destruction - /// /// Resets the entire Box object to the default settings or values. - /// void Reset() override { Clear(); } #pragma endregion #pragma region Concrete Methods - /// /// Makes the corner of this box represent the upper left corner, and both width and height will end up positive. - /// void Unflip(); #pragma endregion #pragma region Getters and Setters - /// /// Shows if this box has 0 width OR 0 height, ie can't contain anything. - /// - /// Whether either width OR height are 0. + /// @return Whether either width OR height are 0. bool IsEmpty() const { return (m_Width == 0 || m_Height == 0); }; - /// /// Gets the primary corner of this box. - /// - /// A Vector with the primary corner of this box. + /// @return A Vector with the primary corner of this box. Vector GetCorner() const { return m_Corner; } - /// /// Sets the primary corner of this box. - /// - /// A Vector with the new primary corner. + /// @param newCorner A Vector with the new primary corner. void SetCorner(const Vector& newCorner) { m_Corner = newCorner; } - /// /// Gets the center point of this Box' area, in absolute Scene coordinates. - /// - /// The center point. + /// @return The center point. Vector GetCenter() const { return Vector(m_Corner.m_X + (m_Width / 2), m_Corner.m_Y + (m_Height / 2)); } - /// /// Sets the primary corner of this box, by specifying where the center ought to be. - /// - /// A Vector with the new center point. + /// @param newCenter A Vector with the new center point. void SetCenter(const Vector& newCenter) { m_Corner.SetXY(newCenter.m_X - (m_Width / 2), newCenter.m_Y - (m_Height / 2)); } - /// /// Gets the width of this box. Note that this can be negative if the box hasn't been righted with Unflip(). - /// - /// A float value that represents the width value of this Box. + /// @return A float value that represents the width value of this Box. float GetWidth() const { return m_Width; } - /// /// Sets the width of this box. Note that this can be negative if the box hasn't been righted with Unflip(). - /// - /// A float value that represents the width value of this Box. + /// @param width A float value that represents the width value of this Box. void SetWidth(float width) { m_Width = width; } - /// /// Gets the height of this box. Note that this can be negative if the box hasn't been righted with Unflip(). - /// - /// A float value that represents the height value of this Box. + /// @return A float value that represents the height value of this Box. float GetHeight() const { return m_Height; } - /// /// Sets the height of this box. Note that this can be negative if the box hasn't been righted with Unflip(). - /// - /// A float value that represents the height value of this Box. + /// @param height A float value that represents the height value of this Box. void SetHeight(float height) { m_Height = height; } - /// /// Gets the width times the height. - /// - /// The width times the height. + /// @return The width times the height. float GetArea() const { return m_Width * m_Height; } - /// /// Gets a random point within this box. - /// - /// The random point within the box. + /// @return The random point within the box. Vector GetRandomPoint() const { return Vector(m_Corner.m_X + RandomNum(0.0F, m_Width), m_Corner.m_Y + RandomNum(0.0F, m_Height)); } #pragma endregion #pragma region Detection - /// /// Tells whether another box intersects this one. - /// - /// The other Box to check for intersection with. - /// Intersecting the other box or not. + /// @param rhs The other Box to check for intersection with. + /// @return Intersecting the other box or not. bool IntersectsBox(const Box& rhs); - /// /// Tells whether a point is within the Box or not, taking potential flipping into account. - /// - /// The Vector describing the point to test for within box bounds. - /// Inside the box or not. False if the box IsEmpty() + /// @param point The Vector describing the point to test for within box bounds. + /// @return Inside the box or not. False if the box IsEmpty() bool IsWithinBox(const Vector& point) const; - /// /// Tells whether an X coordinate is within the Box's X-range or not, taking potential flipping into account. - /// - /// The coordinate describing the X value to test for within box bounds. - /// Inside the box or not in the X axis. False if the box IsEmpty() + /// @param pointX The coordinate describing the X value to test for within box bounds. + /// @return Inside the box or not in the X axis. False if the box IsEmpty() bool IsWithinBoxX(float pointX) const; - /// /// Tells whether an Y coordinate is within the Box's Y-range or not, taking potential flipping into account. - /// - /// The coordinate describing the Y value to test for within box bounds. - /// Inside the box or not in the Y axis. False if the box IsEmpty() + /// @param pointY The coordinate describing the Y value to test for within box bounds. + /// @return Inside the box or not in the Y axis. False if the box IsEmpty() bool IsWithinBoxY(float pointY) const; - /// /// Returns a copy of a point constrained inside this box. - /// - /// The Vector describing the point to constrain inside the box. - /// The resulting point inside the box. + /// @param point The Vector describing the point to constrain inside the box. + /// @return The resulting point inside the box. Vector GetWithinBox(const Vector& point) const { return Vector(GetWithinBoxX(point.m_X), GetWithinBoxY(point.m_Y)); } - /// /// Returns an X value constrained inside the Box and returns it. - /// - /// The X value to constrain inside the Box. - /// The constrained value. + /// @param pointX The X value to constrain inside the Box. + /// @return The constrained value. float GetWithinBoxX(float pointX) const; - /// /// Returns an Y value constrained inside the Box and returns it. - /// - /// The Y value to constrain inside the Box. - /// The constrained value. + /// @param pointY The Y value to constrain inside the Box. + /// @return The constrained value. float GetWithinBoxY(float pointY) const; #pragma endregion #pragma region Operator Overloads - /// /// An assignment operator for setting one Box equal to another. - /// - /// A Box reference. - /// A reference to the changed Box. + /// @param rhs A Box reference. + /// @return A reference to the changed Box. Box& operator=(const Box& rhs) { if (*this != rhs) { Create(rhs); @@ -273,29 +203,23 @@ namespace RTE { return *this; } - /// /// An equality operator for testing if any two Boxes are equal. - /// - /// A Box reference as the left hand side operand. - /// A Box reference as the right hand side operand. - /// A boolean indicating whether the two operands are equal or not. + /// @param lhs A Box reference as the left hand side operand. + /// @param rhs A Box reference as the right hand side operand. + /// @return A boolean indicating whether the two operands are equal or not. friend bool operator==(const Box& lhs, const Box& rhs) { return lhs.m_Corner == rhs.m_Corner && lhs.m_Width == rhs.m_Width && lhs.m_Height == rhs.m_Height; } - /// /// An inequality operator for testing if any two Boxes are unequal. - /// - /// A Box reference as the left hand side operand. - /// A Box reference as the right hand side operand. - /// A boolean indicating whether the two operands are unequal or not. + /// @param lhs A Box reference as the left hand side operand. + /// @param rhs A Box reference as the right hand side operand. + /// @return A boolean indicating whether the two operands are unequal or not. friend bool operator!=(const Box& lhs, const Box& rhs) { return lhs.m_Corner != rhs.m_Corner || lhs.m_Width != rhs.m_Width || lhs.m_Height != rhs.m_Height; } #pragma endregion private: static const std::string c_ClassName; //!< A string with the friendly-formatted type name of this. - /// /// Clears all the member variables of this Box, effectively resetting the members of this abstraction level only. - /// void Clear() { m_Corner.Reset(); m_Width = m_Height = 0; diff --git a/Source/System/Color.cpp b/Source/System/Color.cpp index bbc334b52a..86a08c73ee 100644 --- a/Source/System/Color.cpp +++ b/Source/System/Color.cpp @@ -5,8 +5,6 @@ namespace RTE { const std::string Color::c_ClassName = "Color"; - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int Color::Create() { if (Serializable::Create()) { return -1; @@ -15,8 +13,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int Color::Create(int inputR, int inputG, int inputB) { SetR(inputR); SetG(inputG); @@ -25,8 +21,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int Color::ReadProperty(const std::string_view& propName, Reader& reader) { StartPropertyList(return Serializable::ReadProperty(propName, reader)); @@ -38,8 +32,6 @@ namespace RTE { EndPropertyList; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int Color::Save(Writer& writer) const { Serializable::Save(writer); @@ -50,8 +42,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void Color::SetRGBWithIndex(int index) { m_Index = std::clamp(index, 0, 255); @@ -64,8 +54,6 @@ namespace RTE { m_B = rgbColor.b * 4; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int Color::RecalculateIndex() { return m_Index = makecol8(m_R, m_G, m_B); } diff --git a/Source/System/Color.h b/Source/System/Color.h index c1e8bd7e45..02c06365f7 100644 --- a/Source/System/Color.h +++ b/Source/System/Color.h @@ -5,9 +5,7 @@ namespace RTE { - /// /// A class representing a RGB color value. - /// class Color : public Serializable { public: @@ -15,127 +13,95 @@ namespace RTE { SerializableOverrideMethods; #pragma region Creation - /// /// Constructor method used to instantiate a Color object. - /// Color() { Clear(); } - /// /// Constructor method used to instantiate a Color object from RGB values. - /// - /// Initial Red value of this color. - /// Initial Green value of this color. - /// Initial Blue value of this color. + /// @param R Initial Red value of this color. + /// @param G Initial Green value of this color. + /// @param B Initial Blue value of this color. Color(int R, int G, int B) { Clear(); Create(R, G, B); } - /// /// Constructor method used to instantiate a Color object from an entry in the current color palette. - /// - /// Palette index entry to create this color from. + /// @param index Palette index entry to create this color from. Color(int index) { Clear(); SetRGBWithIndex(index); } - /// /// Copy constructor method used to instantiate a Color object identical to an already existing one. - /// - /// A Color object which is passed in by reference. + /// @param reference A Color object which is passed in by reference. Color(const Color& reference) { Clear(); Create(reference.m_R, reference.m_G, reference.m_B); } - /// /// Makes the Color object ready for use. - /// - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create() override; - /// /// Makes the Color object ready for use. - /// - /// Initial Red value of this color. - /// Initial Green value of this color. - /// Initial Blue value of this color. - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @param R Initial Red value of this color. + /// @param G Initial Green value of this color. + /// @param B Initial Blue value of this color. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create(int inputR, int inputG, int inputB); #pragma endregion #pragma region Destruction - /// /// Sets RGB of this Color to zero. - /// void Reset() override { Clear(); } #pragma endregion #pragma region Getters and Setters - /// /// Gets the entry in the current color palette that most closely matches this Color's RGB values. - /// - /// The color entry index number. + /// @return The color entry index number. int GetIndex() const { return m_Index; } - /// /// Sets all three RGB values of this Color, using an index from the current color palette. - /// - /// The index of the palette entry that this Color object's RGB values should be set to. + /// @param index The index of the palette entry that this Color object's RGB values should be set to. void SetRGBWithIndex(int index); - /// /// Gets the red value of this Color. - /// - /// An integer value that represents the R value of this Color. 0 - 255. + /// @return An integer value that represents the R value of this Color. 0 - 255. int GetR() const { return m_R; } - /// /// Sets the red value of this Color. - /// - /// An integer value that the R value will be set to, between 0 and 255. + /// @param newR An integer value that the R value will be set to, between 0 and 255. void SetR(int newR) { m_R = std::clamp(newR, 0, 255); m_Index = 0; } - /// /// Gets the green value of this Color. - /// - /// An integer value that represents the green value of this Color. 0 - 255. + /// @return An integer value that represents the green value of this Color. 0 - 255. int GetG() const { return m_G; } - /// /// Sets the green value of this Color. - /// - /// An integer value that the green value will be set to, between 0 and 255. + /// @param newG An integer value that the green value will be set to, between 0 and 255. void SetG(int newG) { m_G = std::clamp(newG, 0, 255); m_Index = 0; } - /// /// Gets the blue value of this Color. - /// - /// An integer value that represents the blue value of this Color. 0 - 255. + /// @return An integer value that represents the blue value of this Color. 0 - 255. int GetB() const { return m_B; } - /// /// Sets the blue value of this Color. - /// - /// An integer value that the blue value will be set to, between 0 and 255. + /// @param newB An integer value that the blue value will be set to, between 0 and 255. void SetB(int newB) { m_B = std::clamp(newB, 0, 255); m_Index = 0; } - /// /// Sets all three RGB values of this Color. - /// - /// Integer value that the Red value will be set to, between 0 and 255. - /// Integer value that the Green value will be set to, between 0 and 255. - /// Integer value that the Blue value will be set to, between 0 and 255. + /// @param newR Integer value that the Red value will be set to, between 0 and 255. + /// @param newG Integer value that the Green value will be set to, between 0 and 255. + /// @param newB Integer value that the Blue value will be set to, between 0 and 255. void SetRGB(int newR, int newG, int newB) { SetR(newR); SetG(newG); @@ -145,10 +111,8 @@ namespace RTE { #pragma endregion #pragma region Concrete Methods - /// /// Causes recalculation of the nearest index even though there might be one cached or not. - /// - /// The new color entry index number. + /// @return The new color entry index number. int RecalculateIndex(); #pragma endregion @@ -161,9 +125,7 @@ namespace RTE { private: static const std::string c_ClassName; //!< A string with the friendly-formatted type name of this. - /// /// Clears all the member variables of this Color, effectively resetting the members of this abstraction level only. - /// void Clear() { m_R = m_G = m_B = m_Index = 0; } }; } // namespace RTE diff --git a/Source/System/Constants.h b/Source/System/Constants.h index 0df67bb3a2..5d61d6e9b8 100644 --- a/Source/System/Constants.h +++ b/Source/System/Constants.h @@ -181,9 +181,7 @@ namespace RTE { #pragma endregion #pragma region Input Constants - /// /// Enumeration for different types of input devices. - /// enum InputDevice { DEVICE_KEYB_ONLY = 0, DEVICE_MOUSE_KEYB, @@ -194,9 +192,7 @@ namespace RTE { DEVICE_COUNT }; - /// /// Enumeration for different elements the input scheme is composed of. - /// enum InputElements { INPUT_L_UP = 0, INPUT_L_DOWN, @@ -258,9 +254,7 @@ namespace RTE { "Analog Aim Right" // INPUT_R_RIGHT }; - /// /// Enumeration for mouse button types. - /// enum MouseButtons { MOUSE_NONE = -1, MOUSE_LEFT = 1, @@ -269,9 +263,7 @@ namespace RTE { MAX_MOUSE_BUTTONS }; - /// /// Enumeration for joystick button types. - /// enum JoyButtons { JOY_NONE = -1, JOY_1 = 0, @@ -298,19 +290,15 @@ namespace RTE { MAX_JOY_BUTTONS }; - /// /// Enumeration for joystick direction types. - /// enum JoyDirections { JOYDIR_ONE = 0, JOYDIR_TWO }; - /// /// Enumeration for joystick dead zone types. /// Square deadzone cuts-off any input from every axis separately. For example if x-axis has less than 20% input and y-axis has more, x-axis input is ignored. /// Circle uses a round zone to capture stick position on both axis then cut-off if this position is inside the round dead zone. - /// enum DeadZoneType { CIRCLE = 0, SQUARE = 1 @@ -318,9 +306,7 @@ namespace RTE { #pragma endregion #pragma region Global Enumerations - /// /// Enumeration all available players. - /// enum Players { NoPlayer = -1, PlayerOne = 0, @@ -330,9 +316,7 @@ namespace RTE { MaxPlayerCount }; - /// /// Enumeration and supporting maps for cardinal directions, as well as None and Any. - /// enum Directions { None = -1, Up, diff --git a/Source/System/ContentFile.cpp b/Source/System/ContentFile.cpp index 24de53ba50..c75ce31552 100644 --- a/Source/System/ContentFile.cpp +++ b/Source/System/ContentFile.cpp @@ -17,8 +17,6 @@ namespace RTE { std::unordered_map ContentFile::s_LoadedSamples; std::unordered_map ContentFile::s_PathHashes; - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ContentFile::Clear() { m_DataPath.clear(); m_DataPathExtension.clear(); @@ -31,16 +29,12 @@ namespace RTE { m_ImageFileInfo.fill(-1); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int ContentFile::Create(const char* filePath) { SetDataPath(filePath); return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int ContentFile::Create(const ContentFile& reference) { m_DataPath = reference.m_DataPath; m_DataPathExtension = reference.m_DataPathExtension; @@ -50,8 +44,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ContentFile::FreeAllLoaded() { for (int depth = BitDepths::Eight; depth < BitDepths::BitDepthCount; ++depth) { for (const auto& [bitmapPath, bitmapPtr]: s_LoadedBitmaps[depth]) { @@ -60,8 +52,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int ContentFile::ReadProperty(const std::string_view& propName, Reader& reader) { StartPropertyList(return Serializable::ReadProperty(propName, reader)); @@ -70,8 +60,6 @@ namespace RTE { EndPropertyList; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int ContentFile::Save(Writer& writer) const { Serializable::Save(writer); @@ -82,14 +70,10 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int ContentFile::GetDataModuleID() const { return (m_DataModuleID < 0) ? g_PresetMan.GetModuleIDFromPath(m_DataPath) : m_DataModuleID; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ContentFile::SetDataPath(const std::string& newDataPath) { m_DataPath = g_PresetMan.GetFullModulePath(newDataPath); m_DataPathExtension = std::filesystem::path(m_DataPath).extension().string(); @@ -103,21 +87,15 @@ namespace RTE { m_DataModuleID = g_PresetMan.GetModuleIDFromPath(m_DataPath); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - size_t ContentFile::GetHash() const { return Hash(m_DataPath); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ContentFile::SetFormattedReaderPosition(const std::string& newPosition) { m_FormattedReaderPosition = newPosition; m_DataPathAndReaderPosition = m_DataPath + "\n" + newPosition; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int ContentFile::GetImageFileInfo(ImageFileInfoType infoTypeToGet) { bool fetchFileInfo = false; for (const int& fileInfoEntry: m_ImageFileInfo) { @@ -142,8 +120,6 @@ namespace RTE { return m_ImageFileInfo[infoTypeToGet]; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ContentFile::ReadAndStorePNGFileInfo(FILE* imageFile) { std::array fileSignature = {}; @@ -168,8 +144,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ContentFile::ReadAndStoreBMPFileInfo(FILE* imageFile) { std::array bmpSignature = {0x42, 0x4D}; // { 'B', 'M' }. std::array fileSignature = {}; @@ -203,8 +177,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ContentFile::ReloadAllBitmaps() { for (const std::unordered_map& bitmapCache: s_LoadedBitmaps) { for (const auto& [filePath, oldBitmap]: bitmapCache) { @@ -214,8 +186,6 @@ namespace RTE { g_ConsoleMan.PrintString("SYSTEM: Sprites reloaded"); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - BITMAP* ContentFile::GetAsBitmap(int conversionMode, bool storeBitmap, const std::string& dataPathToSpecificFrame) { if (m_DataPath.empty()) { return nullptr; @@ -255,8 +225,6 @@ namespace RTE { return returnBitmap; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ContentFile::GetAsAnimation(std::vector& vectorToFill, int frameCount, int conversionMode) { if (m_DataPath.empty() || frameCount < 1) { return; @@ -285,8 +253,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - BITMAP* ContentFile::LoadAndReleaseBitmap(int conversionMode, const std::string& dataPathToSpecificFrame) { if (m_DataPath.empty()) { return nullptr; @@ -306,8 +272,6 @@ namespace RTE { return returnBitmap; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - FMOD::Sound* ContentFile::GetAsSound(bool abortGameForInvalidSound, bool asyncLoading) { if (m_DataPath.empty() || !g_AudioMan.IsAudioEnabled()) { return nullptr; @@ -326,8 +290,6 @@ namespace RTE { return returnSample; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - FMOD::Sound* ContentFile::LoadAndReleaseSound(bool abortGameForInvalidSound, bool asyncLoading) { if (m_DataPath.empty() || !g_AudioMan.IsAudioEnabled()) { return nullptr; @@ -370,8 +332,6 @@ namespace RTE { return returnSample; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ContentFile::ReloadBitmap(const std::string& filePath, int conversionMode) { const int bitDepth = (conversionMode == COLORCONV_8_TO_32) ? BitDepths::ThirtyTwo : BitDepths::Eight; @@ -396,8 +356,6 @@ namespace RTE { destroy_bitmap(newBitmap); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ContentFile::AddAlphaChannel(BITMAP* bitmap) { if (!bitmap) { return; diff --git a/Source/System/ContentFile.h b/Source/System/ContentFile.h index 89331690de..4b28c38a64 100644 --- a/Source/System/ContentFile.h +++ b/Source/System/ContentFile.h @@ -10,9 +10,7 @@ struct BITMAP; namespace RTE { - /// /// A representation of a content file that is stored directly on disk. - /// class ContentFile : public Serializable { public: @@ -20,193 +18,141 @@ namespace RTE { SerializableOverrideMethods; #pragma region Creation - /// /// Constructor method used to instantiate a ContentFile object in system memory. Create() should be called before using the object. - /// ContentFile() { Clear(); } - /// /// Constructor method used to instantiate a ContentFile object in system memory, and also do a Create() in the same line. - /// - /// A string defining the path to where the content file itself is located. + /// @param filePath A string defining the path to where the content file itself is located. explicit ContentFile(const char* filePath) { Clear(); Create(filePath); } - /// /// Constructor method used to instantiate a ContentFile object in system memory from a hash value of the file path, and also do a Create() in the same line. - /// - /// A hash value containing the path to where the content file itself is located. + /// @param hash A hash value containing the path to where the content file itself is located. explicit ContentFile(size_t hash) { Clear(); Create(GetPathFromHash(hash).c_str()); } - /// /// Makes the ContentFile object ready for use. - /// - /// A string defining the path to where the content file itself is located. - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @param filePath A string defining the path to where the content file itself is located. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create(const char* filePath); - /// /// Creates a ContentFile to be identical to another, by deep copy. - /// - /// A reference to the ContentFile to deep copy. - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @param reference A reference to the ContentFile to deep copy. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create(const ContentFile& reference); #pragma endregion #pragma region Destruction - /// /// Destructor method used to clean up a ContentFile object before deletion from system memory. - /// ~ContentFile() override = default; - /// /// Resets the entire ContentFile, including its inherited members, to their default settings or values. - /// void Reset() override { Clear(); } - /// /// Frees all loaded data used by all ContentFile instances. This should ONLY be done when quitting the app, or after everything else is completely destroyed. - /// static void FreeAllLoaded(); #pragma endregion #pragma region Getters and Setters - /// /// Gets the ID of the Data Module this file is inside. - /// - /// The ID of the DataModule containing this' file. + /// @return The ID of the DataModule containing this' file. int GetDataModuleID() const; - /// /// Gets the file path of the content file represented by this ContentFile object. - /// - /// A string with the file name path. + /// @return A string with the file name path. const std::string& GetDataPath() const { return m_DataPath; } - /// /// Sets the file path of the content file represented by this ContentFile object. - /// - /// A string with the new file name path. + /// @param newDataPath A string with the new file name path. void SetDataPath(const std::string& newDataPath); - /// /// Creates a hash value out of a path to a ContentFile. - /// - /// Hash value of a path to a ContentFile. + /// @return Hash value of a path to a ContentFile. size_t GetHash() const; - /// /// Converts hash values into file paths to ContentFiles. - /// - /// Hash value to get file path from. - /// Path to ContentFile. + /// @param hash Hash value to get file path from. + /// @return Path to ContentFile. static std::string GetPathFromHash(size_t hash) { return (s_PathHashes.find(hash) == s_PathHashes.end()) ? "" : s_PathHashes[hash]; } #pragma endregion #pragma region Logging - /// /// Gets the file and line that are currently being read. Formatted to be used for logging warnings and errors. - /// - /// A string containing the currently read file path and the line being read. + /// @return A string containing the currently read file path and the line being read. const std::string& GetFormattedReaderPosition() const { return m_FormattedReaderPosition; } - /// /// Sets the file and line that are currently being read. Formatted to be used for logging warnings and errors. - /// - /// A string containing the currently read file path and the line being read. + /// @param newPosition A string containing the currently read file path and the line being read. void SetFormattedReaderPosition(const std::string& newPosition) override; #pragma endregion #pragma region Image Info Getters - /// /// Gets whether the data file at this ContentFile's path is a supported image format. - /// - /// Whether the data file at this ContentFile's path is a supported image format. + /// @return Whether the data file at this ContentFile's path is a supported image format. bool DataPathIsImageFile() const { return m_DataPathIsImageFile; } - /// /// Gets the bit depth of the image file at this ContentFile's path. - /// - /// The bit depth of the image file at this ContentFile's path, or -1 if the file is not an image format. + /// @return The bit depth of the image file at this ContentFile's path, or -1 if the file is not an image format. int GetImageBitDepth() { return m_DataPathIsImageFile ? GetImageFileInfo(ImageFileInfoType::ImageBitDepth) : -1; } - /// /// Gets the width of the image file at this ContentFile's path. - /// - /// The width of the image file at this ContentFile's path, in pixels, or -1 if the file is not an image format. + /// @return The width of the image file at this ContentFile's path, in pixels, or -1 if the file is not an image format. int GetImageWidth() { return m_DataPathIsImageFile ? GetImageFileInfo(ImageFileInfoType::ImageWidth) : -1; } - /// /// Gets the height of the image file at this ContentFile's path. - /// - /// The height of the image file at this ContentFile's path, in pixels, or -1 if the file is not an image format. + /// @return The height of the image file at this ContentFile's path, in pixels, or -1 if the file is not an image format. int GetImageHeight() { return m_DataPathIsImageFile ? GetImageFileInfo(ImageFileInfoType::ImageHeight) : -1; } #pragma endregion #pragma region Data Handling - /// /// Reloads all BITMAPs in the cache from disk, allowing any changes to be reflected at runtime. - /// static void ReloadAllBitmaps(); - /// /// Gets the data represented by this ContentFile object as an Allegro BITMAP, loading it into the static maps if it's not already loaded. Note that ownership of the BITMAP is NOT transferred! - /// - /// The Allegro color conversion mode to use when loading this bitmap. - /// Whether to store the BITMAP in the relevant static map after loading it or not. If this is false, ownership of the BITMAP IS transferred! - /// Path to a specific frame when loading an animation to avoid overwriting the original preset DataPath when loading each frame. - /// Pointer to the BITMAP loaded from disk. + /// @param conversionMode The Allegro color conversion mode to use when loading this bitmap. + /// @param storeBitmap Whether to store the BITMAP in the relevant static map after loading it or not. If this is false, ownership of the BITMAP IS transferred! + /// @param dataPathToSpecificFrame Path to a specific frame when loading an animation to avoid overwriting the original preset DataPath when loading each frame. + /// @return Pointer to the BITMAP loaded from disk. BITMAP* GetAsBitmap(int conversionMode = 0, bool storeBitmap = true, const std::string& dataPathToSpecificFrame = ""); - /// /// Fills an existing vector of Allegro BITMAPs representing each frame in the animation with the data represented by this ContentFile object. /// It loads the BITMAPs into the static maps if they're not already loaded. Ownership of the BITMAPs is NOT transferred! - /// - /// The existing vector of Allegro BITMAPs to fill. - /// The number of frames to attempt to load, more than 1 frame will mean 00# is appended to DataPath to handle naming conventions. - /// The Allegro color conversion mode to use when loading this bitmap. + /// @param vectorToFill The existing vector of Allegro BITMAPs to fill. + /// @param frameCount The number of frames to attempt to load, more than 1 frame will mean 00# is appended to DataPath to handle naming conventions. + /// @param conversionMode The Allegro color conversion mode to use when loading this bitmap. void GetAsAnimation(std::vector& vectorToFill, int frameCount = 1, int conversionMode = 0); - /// /// Gets the data represented by this ContentFile object as a vector of Allegro BITMAPs, each representing a frame in the animation. /// It loads the BITMAPs into the static maps if they're not already loaded. Ownership of the BITMAPs is NOT transferred! - /// - /// The number of frames to attempt to load, more than 1 frame will mean 00# is appended to DataPath to handle naming conventions. - /// The Allegro color conversion mode to use when loading this bitmap. - /// A vector of BITMAP pointers loaded from the disk. + /// @param frameCount The number of frames to attempt to load, more than 1 frame will mean 00# is appended to DataPath to handle naming conventions. + /// @param conversionMode The Allegro color conversion mode to use when loading this bitmap. + /// @return A vector of BITMAP pointers loaded from the disk. std::vector GetAsAnimation(int frameCount = 1, int conversionMode = 0) { std::vector returnBitmaps; GetAsAnimation(returnBitmaps, frameCount, conversionMode); return returnBitmaps; } - /// /// Gets the data represented by this ContentFile object as an FMOD FSOUND_SAMPLE, loading it into the static maps if it's not already loaded. Ownership of the FSOUND_SAMPLE is NOT transferred! - /// - /// Whether to abort the game if the sound couldn't be added, or just show a console error. Default true. - /// Whether to enable FMOD asynchronous loading or not. Should be disabled for loading audio files with Lua AddSound. - /// Pointer to the FSOUND_SAMPLE loaded from disk. + /// @param abortGameForInvalidSound Whether to abort the game if the sound couldn't be added, or just show a console error. Default true. + /// @param asyncLoading Whether to enable FMOD asynchronous loading or not. Should be disabled for loading audio files with Lua AddSound. + /// @return Pointer to the FSOUND_SAMPLE loaded from disk. FMOD::Sound* GetAsSound(bool abortGameForInvalidSound = true, bool asyncLoading = true); #pragma endregion private: - /// /// Enumeration for loading BITMAPs by bit depth. NOTE: This can't be lower down because s_LoadedBitmaps relies on this definition. - /// enum BitDepths { Eight = 0, ThirtyTwo, BitDepthCount }; - /// /// Enumeration for the image file information types that can be stored. - /// enum ImageFileInfoType { ImageBitDepth, ImageWidth, @@ -233,60 +179,44 @@ namespace RTE { int m_DataModuleID; //!< Data Module ID of where this was loaded from. #pragma region Image Info Getters - /// /// Gets the specified image info from this ContentFile's data file on disk. - /// - /// The image info type to get. See ImageFileInfoType enumeration. - /// An integer value with the requested image info. + /// @param infoTypeToGet The image info type to get. See ImageFileInfoType enumeration. + /// @return An integer value with the requested image info. int GetImageFileInfo(ImageFileInfoType infoTypeToGet); - /// /// Reads a PNG file from disk and stores the relevant information without actually loading the whole file into memory. - /// - /// Pointer to the file stream to read. + /// @param imageFile Pointer to the file stream to read. void ReadAndStorePNGFileInfo(FILE* imageFile); - /// /// Reads a BMP file from disk and stores the relevant information without actually loading the whole file into memory. - /// - /// Pointer to the file stream to read. + /// @param imageFile Pointer to the file stream to read. void ReadAndStoreBMPFileInfo(FILE* imageFile); #pragma endregion #pragma region Data Handling - /// /// Loads and transfers the data represented by this ContentFile object as an Allegro BITMAP. Ownership of the BITMAP IS transferred! /// Note that this is relatively slow since it reads the data from disk each time. - /// - /// The Allegro color conversion mode to use when loading this bitmap. Only applies the first time a bitmap is loaded from the disk. - /// Path to a specific frame when loading an animation to avoid overwriting the original preset DataPath when loading each frame. - /// Pointer to the BITMAP loaded from disk. + /// @param conversionMode The Allegro color conversion mode to use when loading this bitmap. Only applies the first time a bitmap is loaded from the disk. + /// @param dataPathToSpecificFrame Path to a specific frame when loading an animation to avoid overwriting the original preset DataPath when loading each frame. + /// @return Pointer to the BITMAP loaded from disk. BITMAP* LoadAndReleaseBitmap(int conversionMode = 0, const std::string& dataPathToSpecificFrame = ""); - /// /// Loads and transfers the data represented by this ContentFile object as an FMOD FSOUND_SAMPLE. Ownership of the FSOUND_SAMPLE is NOT transferred! - /// - /// Whether to abort the game if the sound couldn't be added, or just show a console error. Default true. - /// Whether to enable FMOD asynchronous loading or not. Should be disabled for loading audio files with Lua AddSound. - /// Pointer to the FSOUND_SAMPLE loaded from disk. + /// @param abortGameForInvalidSound Whether to abort the game if the sound couldn't be added, or just show a console error. Default true. + /// @param asyncLoading Whether to enable FMOD asynchronous loading or not. Should be disabled for loading audio files with Lua AddSound. + /// @return Pointer to the FSOUND_SAMPLE loaded from disk. FMOD::Sound* LoadAndReleaseSound(bool abortGameForInvalidSound = true, bool asyncLoading = true); - /// /// Reloads a specific BITMAP in the cache from disk, allowing any changes to be reflected at runtime. - /// - /// The filepath to the bitmap we want to reload. - /// The Allegro color conversion mode to use when reloading this bitmap. + /// @param filePath The filepath to the bitmap we want to reload. + /// @param conversionMode The Allegro color conversion mode to use when reloading this bitmap. static void ReloadBitmap(const std::string& filePath, int conversionMode = 0); - /// /// Set alpha value of non mask color pixels to 255 for 32-bit bitmaps. (WARN: would override existing alpha values!) - /// static void AddAlphaChannel(BITMAP* bitmap); #pragma endregion - /// /// Clears all the member variables of this ContentFile, effectively resetting the members of this abstraction level only. - /// void Clear(); }; } // namespace RTE diff --git a/Source/System/Controller.cpp b/Source/System/Controller.cpp index fad67c4503..22b02c0d2a 100644 --- a/Source/System/Controller.cpp +++ b/Source/System/Controller.cpp @@ -7,8 +7,6 @@ namespace RTE { - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void Controller::Clear() { m_ControlStates.fill(false); m_AnalogMove.Reset(); @@ -34,8 +32,6 @@ namespace RTE { m_KeyAccelTimer.Reset(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int Controller::Create(InputMode mode, Actor* controlledActor) { m_InputMode = mode; m_ControlledActor = controlledActor; @@ -46,8 +42,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int Controller::Create(const Controller& reference) { for (int i = 0; i < ControlState::CONTROLSTATECOUNT; ++i) { m_ControlStates[i] = reference.m_ControlStates[i]; @@ -72,8 +66,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool Controller::RelativeCursorMovement(Vector& cursorPos, float moveScale) const { bool altered = false; @@ -114,26 +106,18 @@ namespace RTE { return altered; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - float Controller::GetDigitalAimSpeed() const { return m_Player != Players::NoPlayer ? g_UInputMan.GetControlScheme(m_Player)->GetDigitalAimSpeed() : 1.0F; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool Controller::IsMouseControlled() const { return m_Player != Players::NoPlayer && g_UInputMan.GetControlScheme(m_Player)->GetDevice() == InputDevice::DEVICE_MOUSE_KEYB; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool Controller::IsKeyboardOnlyControlled() const { return m_Player != Players::NoPlayer && g_UInputMan.GetControlScheme(m_Player)->GetDevice() == InputDevice::DEVICE_KEYB_ONLY; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool Controller::IsGamepadControlled() const { bool isGamepadControlled = false; if (m_Player != Players::NoPlayer) { @@ -145,14 +129,10 @@ namespace RTE { return isGamepadControlled; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int Controller::GetTeam() const { return m_ControlledActor ? m_ControlledActor->GetTeam() : m_Team; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void Controller::SetTeam(short team) { if (m_ControlledActor) { m_ControlledActor->SetTeam(team); @@ -160,8 +140,6 @@ namespace RTE { m_Team = team; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void Controller::Update() { if (IsDisabled()) { return; @@ -191,8 +169,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void Controller::ResetCommandState() { // Reset all command states. m_ControlStates.fill(false); @@ -202,8 +178,6 @@ namespace RTE { m_MouseMovement.Reset(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void Controller::GetInputFromPlayer() { ResetCommandState(); @@ -214,8 +188,6 @@ namespace RTE { UpdatePlayerInput(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool Controller::ShouldUpdateAIThisFrame() const { if (IsDisabled() || m_InputMode != InputMode::CIM_AI) { return false; @@ -231,8 +203,6 @@ namespace RTE { return true; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - Controller& Controller::operator=(const Controller& rhs) { if (this == &rhs) { return *this; @@ -242,15 +212,11 @@ namespace RTE { return *this; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void Controller::Override(const Controller& otherController) { RTEAssert(otherController.m_ControlledActor == m_ControlledActor, "Overriding a controller with a mismatched controlled actor!"); *this = otherController; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void Controller::UpdatePlayerInput() { UpdatePlayerPieMenuInput(); @@ -304,8 +270,6 @@ namespace RTE { UpdatePlayerAnalogInput(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void Controller::UpdatePlayerPieMenuInput() { // Holding of the switch buttons disables aiming later if (g_UInputMan.ElementHeld(m_Player, InputElements::INPUT_NEXT)) { @@ -403,8 +367,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void Controller::UpdatePlayerAnalogInput() { // ANALOG joystick values Vector move = g_UInputMan.AnalogMoveValues(m_Player); diff --git a/Source/System/Controller.h b/Source/System/Controller.h index 3de2fcab70..596f3892d4 100644 --- a/Source/System/Controller.h +++ b/Source/System/Controller.h @@ -65,9 +65,7 @@ namespace RTE { CONTROLSTATECOUNT }; - /// /// A class controlling MovableObjects through either player input, networking, scripting, AI, etc. - /// class Controller { public: @@ -85,94 +83,72 @@ namespace RTE { }; #pragma region Creation - /// /// Constructor method used to instantiate a Controller object in system memory. Create() should be called before using the object. - /// Controller() { Clear(); } - /// /// Constructor method used to instantiate a Controller object in system memory. Create() should be called before using the object. - /// - /// The controller input mode, like AI, player etc. - /// The Actor this is supposed to control. Ownership is NOT transferred! + /// @param mode The controller input mode, like AI, player etc. + /// @param controlledActor The Actor this is supposed to control. Ownership is NOT transferred! Controller(InputMode mode, Actor* controlledActor) { Clear(); Create(mode, controlledActor); } - /// /// Constructor method used to instantiate a Controller object in system memory. Create() should be called before using the object. - /// - /// The controller input mode, like AI, player etc. - /// Which human player is controlling this. + /// @param mode The controller input mode, like AI, player etc. + /// @param player Which human player is controlling this. Controller(InputMode mode, int player = Players::PlayerOne) { Clear(); Create(mode, player); } - /// /// Copy constructor method used to instantiate a Controller object identical to an already existing one. - /// - /// A Controller object which is passed in by reference. + /// @param reference A Controller object which is passed in by reference. Controller(const Controller& reference) { if (this != &reference) { Create(reference); } } - /// /// Makes the Controller object ready for use. - /// - /// The controller input mode, like AI, player etc. - /// The Actor this is supposed to control. Ownership is NOT transferred! - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @param mode The controller input mode, like AI, player etc. + /// @param controlledActor The Actor this is supposed to control. Ownership is NOT transferred! + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create(InputMode mode, Actor* controlledActor); - /// /// Makes the Controller object ready for use. - /// - /// The controller input mode, like AI, player etc. - /// Which player is controlling this. - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @param mode The controller input mode, like AI, player etc. + /// @param player Which player is controlling this. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create(InputMode mode, int player) { m_InputMode = mode; m_Player = player; return 0; } - /// /// Creates a Controller to be identical to another, by deep copy. - /// - /// A reference to the Controller to deep copy. - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @param reference A reference to the Controller to deep copy. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create(const Controller& reference); #pragma endregion #pragma region Destruction - /// /// Resets the entire Controller, including its inherited members, to their default settings or values. - /// void Reset() { Clear(); } #pragma endregion #pragma region Getters and Setters - /// /// Shortcut to indicate if in player input mode. - /// - /// If you want to check if it's controlled by a player, AND that player is someone else than a specific one, pass in that player number here. - /// Whether input mode is set to player input. + /// @param otherThanPlayer If you want to check if it's controlled by a player, AND that player is someone else than a specific one, pass in that player number here. + /// @return Whether input mode is set to player input. bool IsPlayerControlled(int otherThanPlayer = Players::NoPlayer) const { return (m_InputMode == InputMode::CIM_PLAYER && (otherThanPlayer < Players::PlayerOne || m_Player != otherThanPlayer)); } - /// /// Shows whether this controller is disabled. - /// - /// Whether disabled. + /// @return Whether disabled. bool IsDisabled() const { return m_InputMode == InputMode::CIM_DISABLED || m_Disabled; } - /// /// Sets whether this is a disabled controller that doesn't give any new output. - /// - /// Disabled or not. + /// @param disabled Disabled or not. void SetDisabled(bool disabled = true) { if (m_Disabled != disabled) { m_ReleaseTimer.Reset(); @@ -181,33 +157,25 @@ namespace RTE { m_Disabled = disabled; } - /// /// Shows whether the current controller is in a specific state. - /// - /// What control state to check for. - /// Whether the controller is in the specified state. + /// @param controlState What control state to check for. + /// @return Whether the controller is in the specified state. bool IsState(ControlState controlState) const { return m_ControlStates[controlState]; }; - /// /// Sets one of this controller's states. - /// - /// Value of the state being set. + /// @param controlStat Which state to set. + /// @param setting Value of the state being set. void SetState(ControlState controlState, bool setting = true) { RTEAssert(controlState >= 0 && controlState < ControlState::CONTROLSTATECOUNT, "Control state out of whack"); m_ControlStates[controlState] = setting; }; - /// /// Gets the current mode of input for this Controller. - /// - /// The InputMode that this controller is currently using. + /// @return The InputMode that this controller is currently using. InputMode GetInputMode() const { return m_InputMode; } - /// /// Sets the mode of input for this Controller. - /// - /// The new InputMode for this controller to use. + /// @param newMode The new InputMode for this controller to use. void SetInputMode(InputMode newMode) { if (m_InputMode != newMode) { m_ReleaseTimer.Reset(); @@ -215,108 +183,74 @@ namespace RTE { m_InputMode = newMode; } - /// /// Gets the analog movement input data. - /// - /// A vector with the analog movement data, both axes ranging form -1.0 to 1.0. + /// @return A vector with the analog movement data, both axes ranging form -1.0 to 1.0. Vector GetAnalogMove() const { return m_AnalogMove; } - /// /// Sets the analog movement vector state of this. - /// - /// The new analog movement vector. + /// @param newMove The new analog movement vector. void SetAnalogMove(const Vector& newMove) { m_AnalogMove = newMove; } - /// /// Gets the analog aiming input data. - /// - /// A vector with the analog aiming data, both axes ranging form -1.0 to 1.0. + /// @return A vector with the analog aiming data, both axes ranging form -1.0 to 1.0. Vector GetAnalogAim() const { return m_AnalogAim; } - /// /// Sets the analog aiming vector state of this. - /// - /// The new analog aiming vector. + /// @param newAim The new analog aiming vector. void SetAnalogAim(const Vector& newAim) { m_AnalogAim = newAim; } - /// /// Gets the analog menu input data. - /// - /// A vector with the analog menu data, both axes ranging form -1.0 to 1.0. + /// @return A vector with the analog menu data, both axes ranging form -1.0 to 1.0. Vector GetAnalogCursor() const { return m_AnalogCursor; } - /// /// Sets the analog cursor to the specified position. - /// - /// The position the analog cursor should be set to. + /// @param newAnalogCursor The position the analog cursor should be set to. void SetAnalogCursor(const Vector& newAnalogCursor) { m_AnalogCursor = newAnalogCursor; } - /// /// Sets the analog cursor angle limits for the given player (does nothing for player -1). The limit end is always CCW from the limit start. - /// - /// The starting angle limit for the analog cursor. - /// The ending angle limit for the analog cursor. + /// @param angleLimitStart The starting angle limit for the analog cursor. + /// @param angleLimitEnd The ending angle limit for the analog cursor. void SetAnalogCursorAngleLimits(float angleLimitStart, float angleLimitEnd) { m_AnalogCursorAngleLimits = {{angleLimitStart, angleLimitEnd}, true}; } - /// /// Clears the analog cursor aim limits for the given player (does nothing for player -1). - /// void ClearAnalogCursorAngleLimits() { m_AnalogCursorAngleLimits.second = false; } - /// /// Adds relative movement to a passed-in vector. Uses the appropriate input method currently of this. - /// - /// The vector to alter. - /// The scale of the input. 1.0 is 'normal'. - /// Whether the vector was altered or not. + /// @param cursorPos The vector to alter. + /// @param moveScale The scale of the input. 1.0 is 'normal'. + /// @return Whether the vector was altered or not. bool RelativeCursorMovement(Vector& cursorPos, float moveScale = 1.0F) const; - /// /// Indicates whether this is listening to mouse input at all. - /// - /// Whether this is using mouse input at all. + /// @return Whether this is using mouse input at all. bool IsMouseControlled() const; - /// /// Indicates whether this is only listening to keyboard input. - /// - /// Whether this is only using keyboard input. + /// @return Whether this is only using keyboard input. bool IsKeyboardOnlyControlled() const; - /// /// Indicates whether this is listening to gamepad at all. - /// - /// Whether this is using gamepad input at all. + /// @return Whether this is using gamepad input at all. bool IsGamepadControlled() const; - /// /// Gets the relative movement of the mouse since last update. - /// - /// The relative mouse movements, in both axes. + /// @return The relative mouse movements, in both axes. const Vector& GetMouseMovement() const { return m_MouseMovement; } - /// /// Get the digital aim speed multiplier of the scheme associated with this Controller. - /// - /// The digital aim speed set to the scheme of this Controller. + /// @return The digital aim speed set to the scheme of this Controller. float GetDigitalAimSpeed() const; - /// /// Gets the player this is listening. Unlike GetPlayer, this ignores the input mode. - /// - /// The player this is listening to, regardless of input mode. + /// @return The player this is listening to, regardless of input mode. int GetPlayerRaw() const { return m_Player; } - /// /// Gets which player's input this is listening to, if in player input mode. - /// - /// The player number, or -1 if not in player input mode. + /// @return The player number, or -1 if not in player input mode. int GetPlayer() const { return (m_InputMode == InputMode::CIM_PLAYER) ? m_Player : Players::NoPlayer; } - /// /// Sets which player's input this is listening to, and will enable player input mode. - /// - /// The player number. + /// @param player The player number. void SetPlayer(int player) { m_Player = player; if (m_Player >= Players::PlayerOne) { @@ -324,59 +258,43 @@ namespace RTE { } } - /// /// Gets the Team number using this controller. - /// - /// An int representing the team which this Controller belongs to. 0 is the first team. 0 if no team is using it. + /// @return An int representing the team which this Controller belongs to. 0 is the first team. 0 if no team is using it. int GetTeam() const; - /// /// Sets the team which is controlling this Controller's controlled Actor. - /// - /// The team number. 0 is the first team. + /// @param team The team number. 0 is the first team. void SetTeam(short team); - /// /// Gets which Actor is being controlled by this. 0 if none. - /// - /// A pointer to the Actor which is being controlled by this. Ownership is NOT transferred! + /// @return A pointer to the Actor which is being controlled by this. Ownership is NOT transferred! Actor* GetControlledActor() const { return m_ControlledActor; } - /// /// Sets which Actor is supposed to be controlled by this. - /// - /// A pointer to a an Actor which is being controlled by this. Ownership is NOT transferred! + /// @param controlledActor A pointer to a an Actor which is being controlled by this. Ownership is NOT transferred! void SetControlledActor(Actor* controlledActor = nullptr) { m_ControlledActor = controlledActor; } - /// /// Returns whether the AI should be updated this frame. - /// - /// Whether the AI should be updated this frame. + /// @return Whether the AI should be updated this frame. bool ShouldUpdateAIThisFrame() const; #pragma endregion #pragma region Virtual Override Methods - /// /// Updates this Controller. Supposed to be done every frame. - /// void Update(); #pragma endregion #pragma region Operator Overloads - /// /// An assignment operator for setting one Controller equal to another. - /// - /// A Controller reference. - /// A reference to the changed Controller. + /// @param rhs A Controller reference. + /// @return A reference to the changed Controller. Controller& operator=(const Controller& rhs); #pragma endregion #pragma region Misc - /// /// Overrides this controller, setting it to match another controller. This is useful for multithreading, where the Lua script can use a copied controller in a multi-threaded context, before overriding the controller in a single-threaded context. /// This is exposed to Lua API to be clear, whereas ownership relies on operator overloading is rather temperamental :) - /// - /// The other controller's state to copy. Ownership is not transferred + /// @param otherController The other controller's state to copy. Ownership is not transferred void Override(const Controller& otherController); #pragma endregion @@ -390,18 +308,14 @@ namespace RTE { Actor* m_ControlledActor; //!< The actor controlled by this. - /// /// The last player this controlled. This is necessary so we still have some control after controlled's death. /// If this is -1, no player is controlling/ed, even if in player control input mode. - /// int m_Player; int m_Team; //!< The last team this controlled. This is necessary so we still have some control after controlled's death. - /// /// These are hacks to make the switch to brain shortcut work without immediately switching away by /// detecting the release of the previous and next buttons after pressing them both down to get to the brain. - /// bool m_NextIgnore; bool m_PrevIgnore; @@ -422,36 +336,24 @@ namespace RTE { private: #pragma region Update Breakdown - /// /// Updates the player's inputs portion of this Controller. For breaking down Update into more comprehensible chunks. /// This method will call both UpdatePlayerPieMenuInput and UpdatePlayerAnalogInput. - /// void UpdatePlayerInput(); - /// /// Updates the player's PieMenu inputs portion of this Controller. For breaking down Update into more comprehensible chunks. - /// void UpdatePlayerPieMenuInput(); - /// /// Updates the player's analog inputs portion of this Controller. For breaking down Update into more comprehensible chunks. - /// void UpdatePlayerAnalogInput(); - /// /// Clears the command state, meaning no input is given and our actor will be idle. - /// void ResetCommandState(); - /// /// Requests and applies input from the player. - /// void GetInputFromPlayer(); #pragma endregion - /// /// Clears all the member variables of this Controller, effectively resetting the members of this abstraction level only. - /// void Clear(); }; } // namespace RTE diff --git a/Source/System/DataModule.cpp b/Source/System/DataModule.cpp index 3079cb9883..1582d8519c 100644 --- a/Source/System/DataModule.cpp +++ b/Source/System/DataModule.cpp @@ -10,8 +10,6 @@ namespace RTE { const std::string DataModule::c_ClassName = "DataModule"; - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void DataModule::Clear() { m_IsUserdata = false; m_FileName.clear(); @@ -35,8 +33,6 @@ namespace RTE { m_IsMerchant = false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int DataModule::Create(const std::string& moduleName, const ProgressCallback& progressCallback) { m_FileName = std::filesystem::path(moduleName).generic_string(); m_ModuleID = g_PresetMan.GetModuleID(moduleName); @@ -78,8 +74,6 @@ namespace RTE { return -1; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool DataModule::CreateOnDiskAsUserdata(const std::string& moduleName, const std::string_view& friendlyName, bool ignoreMissingItems, bool scanFolderContents) { std::string moduleNameWithPackageExtension = System::GetUserdataDirectory() + moduleName + (moduleName.ends_with(System::GetModulePackageExtension()) ? "" : System::GetModulePackageExtension()); if (Writer writer(moduleNameWithPackageExtension + "/Index.ini", false, true); writer.WriterOK()) { @@ -96,8 +90,6 @@ namespace RTE { return true; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void DataModule::Destroy() { for (const PresetEntry& preset: m_PresetList) { delete preset.m_EntityPreset; @@ -106,8 +98,6 @@ namespace RTE { Clear(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int DataModule::ReadModuleProperties(const std::string& moduleName, const ProgressCallback& progressCallback) { m_FileName = moduleName; m_ModuleID = g_PresetMan.GetModuleID(moduleName); @@ -128,8 +118,6 @@ namespace RTE { return -1; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int DataModule::ReadProperty(const std::string_view& propName, Reader& reader) { StartPropertyList(if (!g_PresetMan.GetEntityPreset(reader)) { reader.ReportError("Could not understand Preset type!"); }) @@ -216,8 +204,6 @@ namespace RTE { EndPropertyList; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int DataModule::Save(Writer& writer) const { Serializable::Save(writer); @@ -242,8 +228,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - std::string DataModule::GetEntityDataLocation(const std::string& exactType, const std::string& instance) { const Entity* foundEntity = GetEntityPreset(exactType, instance); if (foundEntity == nullptr) { @@ -261,8 +245,6 @@ namespace RTE { return ""; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - const Entity* DataModule::GetEntityPreset(const std::string& exactType, const std::string& instance) { if (exactType.empty() || instance == "None" || instance.empty()) { return nullptr; @@ -278,8 +260,6 @@ namespace RTE { return nullptr; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool DataModule::AddEntityPreset(Entity* entityToAdd, bool overwriteSame, const std::string& readFromFile) { // Fail if the entity is unnamed or it's not the original preset. // TODO If we're overwriting, we may not want to fail if it's not the original preset, this needs to be investigated @@ -330,8 +310,6 @@ namespace RTE { return entityAdded; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool DataModule::GetGroupsWithType(std::list& groupList, const std::string& withType) { bool foundAny = false; @@ -362,8 +340,6 @@ namespace RTE { return foundAny; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool DataModule::GetAllOfOrNotOfGroups(std::list& entityList, const std::string& type, const std::vector& groups, bool excludeGroups) { if (groups.empty()) { return false; @@ -401,8 +377,6 @@ namespace RTE { return foundAny; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool DataModule::GetAllOfType(std::list& entityList, const std::string& type) { if (type.empty()) { return false; @@ -419,8 +393,6 @@ namespace RTE { return false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool DataModule::AddMaterialMapping(unsigned char fromID, unsigned char toID) { RTEAssert(fromID > 0 && fromID < c_PaletteEntriesNumber && toID > 0 && toID < c_PaletteEntriesNumber, "Tried to make an out-of-bounds Material mapping"); @@ -430,8 +402,6 @@ namespace RTE { return clear; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int DataModule::LoadScripts() const { if (m_ScriptPath.empty()) { return 0; @@ -445,8 +415,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void DataModule::ReloadAllScripts() const { for (const PresetEntry& presetListEntry: m_PresetList) { presetListEntry.m_EntityPreset->ReloadScripts(); @@ -454,8 +422,6 @@ namespace RTE { LoadScripts(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int DataModule::FindAndRead(const ProgressCallback& progressCallback) { int result = 0; const std::string directoryToScan = g_PresetMan.GetFullModulePath(m_FileName); @@ -473,8 +439,6 @@ namespace RTE { return result; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // TODO: This method is almost identical to GetEntityPreset, except it doesn't return a const Entity *. // Investigate if the latter needs to return const (based on what's using it) and if not, get rid of this and replace its uses. At the very least, consider renaming this // See https://github.com/cortex-command-community/Cortex-Command-Community-Project-Source/issues/87 @@ -493,8 +457,6 @@ namespace RTE { return nullptr; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool DataModule::AddToTypeMap(Entity* entityToAdd) { if (!entityToAdd || entityToAdd->GetPresetName() == "None" || entityToAdd->GetPresetName().empty()) { return false; @@ -515,8 +477,6 @@ namespace RTE { return true; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void DataModule::CheckSupportedGameVersion() const { if (*m_SupportedGameVersion == c_GameVersion) { return; diff --git a/Source/System/DataModule.h b/Source/System/DataModule.h index 39bd884132..228704fee7 100644 --- a/Source/System/DataModule.h +++ b/Source/System/DataModule.h @@ -15,9 +15,7 @@ namespace RTE { class Entity; - /// /// A representation of a DataModule containing zero or many Material, Effect, Ammo, Device, Actor, or Scene definitions. - /// class DataModule : public Serializable { friend struct SystemLuaBindings; @@ -25,10 +23,8 @@ namespace RTE { SerializableClassNameGetter; SerializableOverrideMethods; - /// /// Struct that holds data about the custom BuyMenu/ObjectPicker theme of this DataModule. /// Themes are used when a DataModule is considered a faction and is selected to be played as in an Activity. - /// struct BuyMenuTheme { std::string SkinFilePath = ""; //!< Path to the custom BuyMenu skin file. std::string BannerImagePath = ""; //!< Path to the custom BuyMenu banner image. @@ -37,281 +33,204 @@ namespace RTE { }; #pragma region Creation - /// /// Constructor method used to instantiate a DataModule object in system memory. Create() should be called before using the object. - /// DataModule() { Clear(); } - /// /// Constructor method used to instantiate a DataModule object in system memory, and also do a Create() in the same line. /// Create() should therefore not be called after using this constructor. - /// - /// A string defining the path to where the content file itself is located, either within the package file, or directly on the disk. - /// A function pointer to a function that will be called and sent a string with information about the progress of this DataModule's creation. + /// @param moduleName A string defining the path to where the content file itself is located, either within the package file, or directly on the disk. + /// @param progressCallback A function pointer to a function that will be called and sent a string with information about the progress of this DataModule's creation. DataModule(const std::string& moduleName, const ProgressCallback& progressCallback = nullptr) { Clear(); Create(moduleName, progressCallback); } - /// /// Makes the DataModule object ready for use. This needs to be called after PresetMan is created. /// This looks for an "index.ini" within the specified .rte directory and loads all the defined objects in that index file. - /// - /// A string defining the name of this DataModule, e.g. "MyModule.rte". - /// A function pointer to a function that will be called and sent a string with information about the progress of this DataModule's creation. - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @param moduleName A string defining the name of this DataModule, e.g. "MyModule.rte". + /// @param progressCallback A function pointer to a function that will be called and sent a string with information about the progress of this DataModule's creation. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create(const std::string& moduleName, const ProgressCallback& progressCallback = nullptr); - /// /// Creates a new DataModule directory with "Index.ini" on disk to be used for userdata. Does NOT instantiate the newly created DataModule. - /// - /// File/folder name of the data module, e.g. "MyMod.rte". - /// Friendly name of the data module, e.g. "My Weapons Mod". - /// Whether module loader should scan for any .ini's inside module folder instead of loading files defined in IncludeFile only. - /// Whether module loader should ignore missing items in this module. - /// Whether the DataModule was successfully created on disk. + /// @param moduleName File/folder name of the data module, e.g. "MyMod.rte". + /// @param friendlyName Friendly name of the data module, e.g. "My Weapons Mod". + /// @param scanFolderContents Whether module loader should scan for any .ini's inside module folder instead of loading files defined in IncludeFile only. + /// @param ignoreMissingItems Whether module loader should ignore missing items in this module. + /// @return Whether the DataModule was successfully created on disk. static bool CreateOnDiskAsUserdata(const std::string& moduleName, const std::string_view& friendlyName, bool scanFolderContents = false, bool ignoreMissingItems = false); #pragma endregion #pragma region Destruction - /// /// Destructor method used to clean up a DataModule object before deletion from system memory. - /// ~DataModule() override { Destroy(); } - /// /// Destroys and resets (through Clear()) the DataModule object. - /// void Destroy(); - /// /// Resets the entire DataModule, including its inherited members, to their default settings or values. - /// void Reset() override { Clear(); } #pragma endregion #pragma region INI Handling - /// /// Read module specific properties from index.ini without processing IncludeFiles and loading the whole module. - /// - /// A string defining the name of this DataModule, e.g. "MyModule.rte". - /// A function pointer to a function that will be called and sent a string with information about the progress of this DataModule's creation. - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @param moduleName A string defining the name of this DataModule, e.g. "MyModule.rte". + /// @param progressCallback A function pointer to a function that will be called and sent a string with information about the progress of this DataModule's creation. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int ReadModuleProperties(const std::string& moduleName, const ProgressCallback& progressCallback = nullptr); - /// /// Returns true if loader should ignore missing items in this module. - /// - /// True if loader should ignore missing items in this module. + /// @return True if loader should ignore missing items in this module. bool GetIgnoreMissingItems() const { return m_IgnoreMissingItems; } #pragma endregion #pragma region Module Information Getters - /// /// Gets whether this DataModule is a userdata module. - /// - /// Whether this DataModule is used for userdata written by the game. + /// @return Whether this DataModule is used for userdata written by the game. bool IsUserdata() const { return m_IsUserdata; } - /// /// Sets this DataModule as a userdata module. - /// void SetAsUserdata() { m_IsUserdata = true; } - /// /// Gets the file name of this DataModule, e.g. "MyMod.rte". - /// - /// A string with the data module file name. + /// @return A string with the data module file name. const std::string& GetFileName() const { return m_FileName; } - /// /// Gets the friendly name of this DataModule, e.g. "My Great Mod". - /// - /// A string with the data module's friendly name. + /// @return A string with the data module's friendly name. const std::string& GetFriendlyName() const { return m_FriendlyName; } - /// /// Gets the author name of this DataModule, e.g. "Data Realms, LLC". - /// - /// A string with the author's name. + /// @return A string with the author's name. const std::string& GetAuthor() const { return m_Author; } - /// /// Gets the description of this DataModule's contents. - /// - /// A string with the description. + /// @return A string with the description. const std::string& GetDescription() const { return m_Description; } - /// /// Gets whether this DataModule is considered a faction. - /// - /// Whether this DataModule is considered a faction or not. + /// @return Whether this DataModule is considered a faction or not. bool IsFaction() const { return m_IsFaction; } - /// /// Gets whether this DataModule is considered a merchant. - /// - /// Whether this DataModule is considered a merchant or not. + /// @return Whether this DataModule is considered a merchant or not. bool IsMerchant() const { return m_IsMerchant; } - /// /// Gets the version number of this DataModule. - /// - /// An int with the version number, starting at 1. + /// @return An int with the version number, starting at 1. int GetVersionNumber() const { return m_Version; } - /// /// Gets the BITMAP that visually represents this DataModule, for use in menus. - /// - /// BITMAP pointer that might have the icon. 0 is very possible. + /// @return BITMAP pointer that might have the icon. 0 is very possible. BITMAP* GetIcon() const { return m_Icon; } - /// /// Returns crab-to-human spawn ration for this tech. - /// - /// Crab-to-human spawn ration value. + /// @return Crab-to-human spawn ration value. float GetCrabToHumanSpawnRatio() const { return m_CrabToHumanSpawnRatio; } - /// /// Gets the faction BuyMenu theme data of this DataModule. - /// - /// The faction BuyMenu theme information of this DataModule + /// @return The faction BuyMenu theme information of this DataModule const BuyMenuTheme& GetFactionBuyMenuTheme() const { return m_BuyMenuTheme; } #pragma endregion #pragma region Entity Mapping - /// /// Gets the data file path of a previously read in (defined) Entity. - /// - /// The type name of the derived Entity. Ownership is NOT transferred! - /// The instance name of the derived Entity instance. - /// The file path of the data file that the specified Entity was read from. If no Entity of that description was found, "" is returned. + /// @param exactType The type name of the derived Entity. Ownership is NOT transferred! + /// @param instance The instance name of the derived Entity instance. + /// @return The file path of the data file that the specified Entity was read from. If no Entity of that description was found, "" is returned. std::string GetEntityDataLocation(const std::string& exactType, const std::string& instance); - /// /// Gets a previously read in (defined) Entity, by exact type and instance name. Ownership is NOT transferred! - /// - /// The exact type name of the derived Entity instance to get. - /// The instance name of the derived Entity instance. - /// A pointer to the requested Entity instance. 0 if no Entity with that derived type or instance name was found. Ownership is NOT transferred! + /// @param exactType The exact type name of the derived Entity instance to get. + /// @param instance The instance name of the derived Entity instance. + /// @return A pointer to the requested Entity instance. 0 if no Entity with that derived type or instance name was found. Ownership is NOT transferred! const Entity* GetEntityPreset(const std::string& exactType, const std::string& instance); - /// /// Adds an Entity instance's pointer and name associations to the internal list of already read in Entities. Ownership is NOT transferred! /// If there already is an instance defined, nothing happens. If there is not, a clone is made of the passed-in Entity and added to the library. - /// - /// A pointer to the Entity derived instance to add. It should be created from a Reader. Ownership is NOT transferred! - /// + /// @param entityToAdd A pointer to the Entity derived instance to add. It should be created from a Reader. Ownership is NOT transferred! + /// @param overwriteSame /// Whether to overwrite if an instance of the EXACT same TYPE and name was found. /// If one of the same name but not the exact type, false is returned regardless and nothing will have been added. - /// - /// + /// @param readFromFile /// The file the instance was read from, or where it should be written. /// If "Same" is passed as the file path read from, an overwritten instance will keep the old one's file location entry. - /// - /// + /// @return /// Whether or not a copy of the passed-in instance was successfully inserted into the module. /// False will be returned if there already was an instance of that class and instance name inserted previously, unless overwritten. - /// bool AddEntityPreset(Entity* entityToAdd, bool overwriteSame = false, const std::string& readFromFile = "Same"); - /// /// Gets the list of all registered Entity groups of this. - /// - /// The list of all groups. Ownership is not transferred. + /// @return The list of all groups. Ownership is not transferred. const std::list* GetGroupRegister() const { return &m_GroupRegister; } - /// /// Registers the existence of an Entity group in this module. - /// - /// The group to register. + /// @param newGroup The group to register. void RegisterGroup(const std::string& newGroup) { m_GroupRegister.push_back(newGroup); m_GroupRegister.sort(); m_GroupRegister.unique(); } - /// /// Fills out a list with all groups registered with this that contain any objects of a specific type and it derivatives. - /// - /// The list that all found groups will be ADDED to. OWNERSHIP IS NOT TRANSFERRED! - /// The name of the type to only get groups of. - /// Whether any groups with the specified type were found. + /// @param groupList The list that all found groups will be ADDED to. OWNERSHIP IS NOT TRANSFERRED! + /// @param withType The name of the type to only get groups of. + /// @return Whether any groups with the specified type were found. bool GetGroupsWithType(std::list& groupList, const std::string& withType); - /// /// Adds to a list all previously read in (defined) Entities which are associated with several specific groups. - /// - /// Reference to a list which will get all matching Entities added to it. Ownership of the list or the Entities placed in it are NOT transferred! - /// A list of groups to look for. - /// The name of the least common denominator type of the Entities you want. "All" will look at all types. - /// Whether any Entities were found and added to the list. + /// @param entityList Reference to a list which will get all matching Entities added to it. Ownership of the list or the Entities placed in it are NOT transferred! + /// @param groups A list of groups to look for. + /// @param type The name of the least common denominator type of the Entities you want. "All" will look at all types. + /// @return Whether any Entities were found and added to the list. bool GetAllOfGroups(std::list& entityList, const std::vector& groups, const std::string& type) { return GetAllOfOrNotOfGroups(entityList, type, groups, false); } - /// /// Adds to a list all previously read in (defined) Entities which are not associated with several specific groups. - /// - /// Reference to a list which will get all matching Entities added to it. Ownership of the list or the Entities placed in it are NOT transferred! - /// A list of groups to exclude. - /// The name of the least common denominator type of the Entities you want. "All" will look at all types. - /// Whether any Entities were found and added to the list. + /// @param entityList Reference to a list which will get all matching Entities added to it. Ownership of the list or the Entities placed in it are NOT transferred! + /// @param group A list of groups to exclude. + /// @param type The name of the least common denominator type of the Entities you want. "All" will look at all types. + /// @return Whether any Entities were found and added to the list. bool GetAllNotOfGroups(std::list& entityList, const std::vector& groups, const std::string& type) { return GetAllOfOrNotOfGroups(entityList, type, groups, true); } - /// /// Adds to a list all previously read in (defined) Entities, by inexact type. - /// - /// Reference to a list which will get all matching Entities added to it. Ownership of the list or the Entities placed in it are NOT transferred! - /// The name of the least common denominator type of the Entities you want. "All" will look at all types. - /// Whether any Entities were found and added to the list. + /// @param objectList Reference to a list which will get all matching Entities added to it. Ownership of the list or the Entities placed in it are NOT transferred! + /// @param type The name of the least common denominator type of the Entities you want. "All" will look at all types. + /// @return Whether any Entities were found and added to the list. bool GetAllOfType(std::list& objectList, const std::string& type); #pragma endregion #pragma region Material Mapping - /// /// Gets a Material mapping local to this DataModule. /// This is used for when multiple DataModules are loading conflicting Materials, and need to resolve the conflicts by mapping their materials to ID's different than those specified in the data files. - /// - /// The material ID to get the mapping for. - /// The material ID that the passed in ID is mapped to, if any. 0 if no mapping present. + /// @param materialID The material ID to get the mapping for. + /// @return The material ID that the passed in ID is mapped to, if any. 0 if no mapping present. unsigned char GetMaterialMapping(unsigned char materialID) const { return m_MaterialMappings.at(materialID); } - /// /// Gets the entire Material mapping array local to this DataModule. - /// - /// A const reference to the entire local mapping array, 256 unsigned chars. Ownership is NOT transferred! + /// @return A const reference to the entire local mapping array, 256 unsigned chars. Ownership is NOT transferred! const std::array& GetAllMaterialMappings() const { return m_MaterialMappings; } - /// /// Adds a Material mapping local to a DataModule. /// This is used for when multiple DataModules are loading conflicting Materials, and need to resolve the conflicts by mapping their materials to ID's different than those specified in the data files. - /// - /// The material ID to map from. - /// The material ID to map to. - /// Whether this created a new mapping which didn't override a previous material mapping. + /// @param fromID The material ID to map from. + /// @param toID The material ID to map to. + /// @return Whether this created a new mapping which didn't override a previous material mapping. bool AddMaterialMapping(unsigned char fromID, unsigned char toID); #pragma endregion #pragma region Lua Script Handling - /// /// Loads the preset scripts of this object, from a specified path. - /// - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int LoadScripts() const; - /// /// Reloads all scripted Entity Presets with the latest version of their respective script files. - /// void ReloadAllScripts() const; #pragma endregion protected: - /// /// Holds and owns the actual object instance pointer, and the location of the data file it was read from, as well as where in that file. - /// struct PresetEntry { - /// /// Constructor method used to instantiate a PresetEntry object in system memory. - /// PresetEntry(Entity* preset, const std::string& file) : m_EntityPreset(preset), m_FileReadFrom(file) {} @@ -345,72 +264,56 @@ namespace RTE { std::list m_GroupRegister; //!< List of all Entity groups ever registered in this, all uniques. std::array m_MaterialMappings; //!< Material mappings local to this DataModule. - /// /// Ordered list of all owned Entity instances, ordered by the sequence of their reading - really now with overwriting?. /// This is used to be able to write back all of them in proper order into their respective files in the DataModule when writing this. /// The Entity instances ARE owned by this list. - /// std::list m_PresetList; - /// /// Map of class names and map of instance template names and actual Entity instances that were read for this DataModule. /// An Entity instance of a derived type will be placed in EACH of EVERY of its parent class' maps here. /// There can be multiple entries of the same instance name in any of the type sub-maps, but only ONE whose exact class is that of the type-list! /// The Entity instances are NOT owned by this map. - /// std::unordered_map>> m_TypeMap; private: static const std::string c_ClassName; //!< A string with the friendly-formatted type name of this object. #pragma region INI Handling - /// /// Checks the module's supported game version against the current game version to ensure compatibility. - /// void CheckSupportedGameVersion() const; - /// /// If ScanFolderContents is enabled in this DataModule's Index.ini, looks for any ini files in the top-level directory of the module and reads all of them in alphabetical order. - /// - /// A function pointer to a function that will be called and sent a string with information about the progress of this DataModule's creation. - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @param progressCallback A function pointer to a function that will be called and sent a string with information about the progress of this DataModule's creation. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int FindAndRead(const ProgressCallback& progressCallback = nullptr); #pragma endregion #pragma region Entity Mapping - /// /// Shared method for filling a list with all previously read in (defined) Entities which are or are not associated with a specific group or groups. - /// - /// Reference to a list which will get all matching Entities added to it. Ownership of the list or the Entities placed in it are NOT transferred! - /// The name of the least common denominator type of the Entities you want. "All" will look at all types. - /// The groups to look for. - /// Whether Entities belonging to the specified group or groups should be excluded. - /// Whether any Entities were found and added to the list. + /// @param entityList Reference to a list which will get all matching Entities added to it. Ownership of the list or the Entities placed in it are NOT transferred! + /// @param type The name of the least common denominator type of the Entities you want. "All" will look at all types. + /// @param groups The groups to look for. + /// @param excludeGroups Whether Entities belonging to the specified group or groups should be excluded. + /// @return Whether any Entities were found and added to the list. bool GetAllOfOrNotOfGroups(std::list& entityList, const std::string& type, const std::vector& groups, bool excludeGroups); - /// /// Checks if the type map has an instance added of a specific name and exact type. /// Does not check if any parent types with that name has been added. If found, that instance is returned, otherwise 0. - /// - /// The exact type name to look for. - /// The exact PresetName to look for. - /// The found Entity Preset of the exact type and name, if found. + /// @param exactType The exact type name to look for. + /// @param presetName The exact PresetName to look for. + /// @return The found Entity Preset of the exact type and name, if found. Entity* GetEntityIfExactType(const std::string& exactType, const std::string& presetName); - /// /// Adds a newly added preset instance to the type map, where it will end up in every type-list of every class it derived from as well. /// I.e the "Entity" map will contain every single instance added to this. /// This will NOT check if duplicates are added to any type-list, so please use GetEntityIfExactType to check this beforehand. /// Dupes are allowed if there are no more than one of the exact class and name. - /// - /// The new object instance to add. OWNERSHIP IS NOT TRANSFERRED! - /// Whether the Entity was added successfully or not. + /// @param entityToAdd The new object instance to add. OWNERSHIP IS NOT TRANSFERRED! + /// @return Whether the Entity was added successfully or not. bool AddToTypeMap(Entity* entityToAdd); #pragma endregion - /// /// Clears all the member variables of this DataModule, effectively resetting the members of this abstraction level only. - /// void Clear(); // Disallow the use of some implicit methods. diff --git a/Source/System/Entity.cpp b/Source/System/Entity.cpp index b9cb6fa700..571ffe651e 100644 --- a/Source/System/Entity.cpp +++ b/Source/System/Entity.cpp @@ -9,8 +9,6 @@ namespace RTE { Entity::ClassInfo Entity::m_sClass("Entity"); Entity::ClassInfo* Entity::ClassInfo::s_ClassHead = 0; - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void Entity::Clear() { m_PresetName = "None"; m_IsOriginalPreset = false; @@ -20,14 +18,10 @@ namespace RTE { m_RandomWeight = 100; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int Entity::Create() { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int Entity::Create(const Entity& reference) { m_PresetName = reference.m_PresetName; // Note how m_IsOriginalPreset is NOT assigned, automatically indicating that the copy is not an original Preset! @@ -41,8 +35,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int Entity::ReadProperty(const std::string_view& propName, Reader& reader) { StartPropertyList( // Search for a property name match failed! @@ -102,8 +94,6 @@ namespace RTE { EndPropertyList; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int Entity::Save(Writer& writer) const { Serializable::Save(writer); @@ -128,8 +118,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int Entity::SavePresetCopy(Writer& writer) const { // Can only save out copies with this if (m_IsOriginalPreset) { @@ -143,14 +131,10 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - const Entity* Entity::GetPreset() const { return g_PresetMan.GetEntityPreset(GetClassName(), GetPresetName(), m_DefinedInModule); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - std::string Entity::GetModuleAndPresetName() const { if (m_DefinedInModule < 0) { return GetPresetName(); @@ -163,8 +147,6 @@ namespace RTE { return dataModule->GetFileName() + "/" + GetPresetName(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - std::string Entity::GetModuleName() const { if (m_DefinedInModule >= 0) { if (const DataModule* dataModule = g_PresetMan.GetDataModule(m_DefinedInModule)) { @@ -174,8 +156,6 @@ namespace RTE { return ""; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool Entity::MigrateToModule(int whichModule) { if (m_DefinedInModule == whichModule) { return false; @@ -185,8 +165,6 @@ namespace RTE { return true; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - Reader& operator>>(Reader& reader, Entity& operand) { // Get this before reading Entity, since if it's the last one in its datafile, the stream will show the parent file instead std::string objectFilePath = reader.GetCurrentFilePath(); @@ -197,8 +175,6 @@ namespace RTE { return reader; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - Reader& operator>>(Reader& reader, Entity* operand) { if (operand) { // Get this before reading Entity, since if it's the last one in its datafile, the stream will show the parent file instead @@ -212,8 +188,6 @@ namespace RTE { return reader; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - Entity::ClassInfo::ClassInfo(const std::string& name, ClassInfo* parentInfo, MemoryAllocate allocFunc, MemoryDeallocate deallocFunc, Entity* (*newFunc)(), int allocBlockCount) : m_Name(name), m_ParentInfo(parentInfo), @@ -227,8 +201,6 @@ namespace RTE { m_PoolAllocBlockCount = (allocBlockCount > 0) ? allocBlockCount : 10; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - std::list Entity::ClassInfo::GetClassNames() { std::list retList; for (const ClassInfo* itr = s_ClassHead; itr != 0; itr = itr->m_NextClass) { @@ -237,8 +209,6 @@ namespace RTE { return retList; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - const Entity::ClassInfo* Entity::ClassInfo::GetClass(const std::string& name) { if (name.empty() || name == "None") { return 0; @@ -251,8 +221,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void Entity::ClassInfo::FillAllPools(int fillAmount) { for (ClassInfo* itr = s_ClassHead; itr != 0; itr = itr->m_NextClass) { if (itr->IsConcrete()) { @@ -261,8 +229,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void Entity::ClassInfo::FillPool(int fillAmount) { // Default to the set block allocation size if fillAmount is 0 if (fillAmount <= 0) { @@ -277,8 +243,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool Entity::ClassInfo::IsClassOrChildClassOf(const ClassInfo* classInfoToCheck) const { if (GetName() == classInfoToCheck->GetName()) { return true; @@ -288,8 +252,6 @@ namespace RTE { return false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void* Entity::ClassInfo::GetPoolMemory() { std::lock_guard guard(m_Mutex); @@ -312,8 +274,6 @@ namespace RTE { return foundMemory; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int Entity::ClassInfo::ReturnPoolMemory(void* returnedMemory) { if (!returnedMemory) { return 0; @@ -327,8 +287,6 @@ namespace RTE { return m_InstancesInUse; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void Entity::ClassInfo::DumpPoolMemoryInfo(const Writer& fileWriter) { for (const ClassInfo* itr = s_ClassHead; itr != nullptr; itr = itr->m_NextClass) { if (itr->IsConcrete()) { diff --git a/Source/System/Entity.h b/Source/System/Entity.h index e4ff20bfe9..2d82882d9c 100644 --- a/Source/System/Entity.h +++ b/Source/System/Entity.h @@ -19,18 +19,14 @@ namespace RTE { #define ConcreteSubClassInfo(TYPE, SUPER, PARENT, BLOCKCOUNT) \ Entity::ClassInfo SUPER::TYPE::m_sClass(#TYPE, &PARENT::m_sClass, SUPER::TYPE::Allocate, SUPER::TYPE::Deallocate, SUPER::TYPE::NewInstance, BLOCKCOUNT); -/// /// Convenience macro to cut down on duplicate ClassInfo methods in classes that extend Entity. -/// #define ClassInfoGetters \ const Entity::ClassInfo& GetClass() const override { return m_sClass; } \ const std::string& GetClassName() const override { return m_sClass.GetName(); } -/// /// Static method used in conjunction with ClassInfo to allocate an Entity. /// This function is passed into the constructor of this Entity's static ClassInfo's constructor, so that it can instantiate MovableObjects. -/// -/// A pointer to the newly dynamically allocated Entity. Ownership is transferred as well. +/// @return A pointer to the newly dynamically allocated Entity. Ownership is transferred as well. #define EntityAllocation(TYPE) \ static void* operator new(size_t size) { return TYPE::m_sClass.GetPoolMemory(); } \ static void operator delete(void* instance) { TYPE::m_sClass.ReturnPoolMemory(instance); } \ @@ -50,9 +46,7 @@ namespace RTE { } #pragma endregion - /// /// Whether to draw the colors, or own material property, or to clear the corresponding non-key-color pixels of the Entity being drawn with key-color pixels on the target. - /// enum DrawMode { g_DrawColor, g_DrawMaterial, @@ -64,9 +58,7 @@ namespace RTE { g_DrawAlpha }; - /// /// The base class that specifies certain common creation/destruction patterns and simple reflection support for virtually all RTE classes. - /// class Entity : public Serializable { friend class DataModule; @@ -74,125 +66,91 @@ namespace RTE { SerializableOverrideMethods; #pragma region ClassInfo - /// /// The class that describes each subclass of Entity. There should be one ClassInfo static instance for every Entity child. - /// class ClassInfo { friend class Entity; public: #pragma region Creation - /// /// Constructor method used to instantiate a ClassInfo Entity. - /// - /// A friendly-formatted name of the Entity that is going to be represented by this ClassInfo. - /// Pointer to the parent class' info. 0 if this describes a root class. - /// Function pointer to the raw allocation function of the derived's size. If the represented Entity subclass isn't concrete, pass in 0. - /// Function pointer to the raw deallocation function of memory. If the represented Entity subclass isn't concrete, pass in 0. - /// Function pointer to the new instance factory. If the represented Entity subclass isn't concrete, pass in 0. - /// The number of new instances to fill the pre-allocated pool with when it runs out. + /// @param name A friendly-formatted name of the Entity that is going to be represented by this ClassInfo. + /// @param parentInfo Pointer to the parent class' info. 0 if this describes a root class. + /// @param allocFunc Function pointer to the raw allocation function of the derived's size. If the represented Entity subclass isn't concrete, pass in 0. + /// @param deallocFunc Function pointer to the raw deallocation function of memory. If the represented Entity subclass isn't concrete, pass in 0. + /// @param newFunc Function pointer to the new instance factory. If the represented Entity subclass isn't concrete, pass in 0. + /// @param allocBlockCount The number of new instances to fill the pre-allocated pool with when it runs out. ClassInfo(const std::string& name, ClassInfo* parentInfo = 0, MemoryAllocate allocFunc = 0, MemoryDeallocate deallocFunc = 0, Entity* (*newFunc)() = 0, int allocBlockCount = 10); #pragma endregion #pragma region Getters - /// /// Gets the name of this ClassInfo. - /// - /// A string with the friendly-formatted name of this ClassInfo. + /// @return A string with the friendly-formatted name of this ClassInfo. const std::string& GetName() const { return m_Name; } - /// /// Gets the names of all ClassInfos in existence. - /// - /// A list of the names. + /// @return A list of the names. static std::list GetClassNames(); - /// /// Gets the ClassInfo of a particular RTE class corresponding to a friendly-formatted string name. - /// - /// The friendly name of the desired ClassInfo. - /// A pointer to the requested ClassInfo, or 0 if none that matched the name was found. Ownership is NOT transferred! + /// @param name The friendly name of the desired ClassInfo. + /// @return A pointer to the requested ClassInfo, or 0 if none that matched the name was found. Ownership is NOT transferred! static const ClassInfo* GetClass(const std::string& name); - /// /// Gets the ClassInfo which describes the parent of this. - /// - /// A pointer to the parent ClassInfo. 0 if this is a root class. + /// @return A pointer to the parent ClassInfo. 0 if this is a root class. const ClassInfo* GetParent() const { return m_ParentInfo; } - /// /// Gets whether or not this ClassInfo is the same as, or a parent of the ClassInfo corresponding to the given class name. - /// - /// The name of the class to check for. - /// Whether or not this ClassInfo is the same as, or a parent of corresponding ClassInfo for the given class. + /// @param classNameToCheck The name of the class to check for. + /// @return Whether or not this ClassInfo is the same as, or a parent of corresponding ClassInfo for the given class. bool IsClassOrParentClassOf(const std::string& classNameToCheck) const { return GetClass(classNameToCheck)->IsClassOrChildClassOf(this); } - /// /// Gets whether or not this ClassInfo is the same as, or a parent of the given ClassInfo. - /// - /// The name of the class to check for. - /// Whether or not this ClassInfo is the same as, or a parent of the given ClassInfo. + /// @param classNameToCheck The name of the class to check for. + /// @return Whether or not this ClassInfo is the same as, or a parent of the given ClassInfo. bool IsClassOrParentClassOf(const ClassInfo* classInfoToCheck) const { return classInfoToCheck->IsClassOrChildClassOf(this); } - /// /// Gets whether or not this ClassInfo is the same as, or a child of the ClassInfo corresponding to the given class name. - /// - /// The name of the class to check for. - /// Whether or not this ClassInfo is the same as, or a child of corresponding ClassInfo for the given class. + /// @param classNameToCheck The name of the class to check for. + /// @return Whether or not this ClassInfo is the same as, or a child of corresponding ClassInfo for the given class. bool IsClassOrChildClassOf(const std::string& classNameToCheck) const { return IsClassOrChildClassOf(GetClass(classNameToCheck)); } - /// /// Gets whether or not this ClassInfo is the same as, or a child of the given ClassInfo. - /// - /// The name of the class to check for. - /// Whether or not this ClassInfo is the same as, or a child of the given ClassInfo. + /// @param classNameToCheck The name of the class to check for. + /// @return Whether or not this ClassInfo is the same as, or a child of the given ClassInfo. bool IsClassOrChildClassOf(const ClassInfo* classInfoToCheck) const; #pragma endregion #pragma region Memory Management - /// /// Grabs from the pre-allocated pool, an available chunk of memory the exact size of the Entity this ClassInfo represents. OWNERSHIP IS TRANSFERRED! - /// - /// A pointer to the pre-allocated pool memory. OWNERSHIP IS TRANSFERRED! + /// @return A pointer to the pre-allocated pool memory. OWNERSHIP IS TRANSFERRED! void* GetPoolMemory(); - /// /// Returns a raw chunk of memory back to the pre-allocated available pool. - /// - /// The raw chunk of memory that is being returned. Needs to be the same size as the type this ClassInfo describes. OWNERSHIP IS TRANSFERRED! - /// The count of outstanding memory chunks after this was returned. + /// @param returnedMemory The raw chunk of memory that is being returned. Needs to be the same size as the type this ClassInfo describes. OWNERSHIP IS TRANSFERRED! + /// @return The count of outstanding memory chunks after this was returned. int ReturnPoolMemory(void* returnedMemory); - /// /// Writes a bunch of useful debug info about the memory pools to a file. - /// - /// The writer to write info to. + /// @param fileWriter The writer to write info to. static void DumpPoolMemoryInfo(const Writer& fileWriter); - /// /// Adds a certain number of newly allocated instances to this' pool. - /// - /// The number of instances to fill the pool with. If 0 is specified, the set refill amount will be used. + /// @param fillAmount The number of instances to fill the pool with. If 0 is specified, the set refill amount will be used. void FillPool(int fillAmount = 0); - /// /// Adds a certain number of newly allocated instances to all pools. - /// - /// The number of instances to fill the pool with. If 0 is specified, the set refill amount will be used. + /// @param fillAmount The number of instances to fill the pool with. If 0 is specified, the set refill amount will be used. static void FillAllPools(int fillAmount = 0); #pragma endregion #pragma region Entity Allocation - /// /// Returns whether the represented Entity subclass is concrete or not, that is if it can create new instances through NewInstance(). - /// - /// Whether the represented Entity subclass is concrete or not. + /// @return Whether the represented Entity subclass is concrete or not. bool IsConcrete() const { return (m_Allocate != 0) ? true : false; } - /// /// Dynamically allocates an instance of the Entity subclass that this ClassInfo represents. If the Entity isn't concrete, 0 will be returned. - /// - /// A pointer to the dynamically allocated Entity. Ownership is transferred. If the represented Entity subclass isn't concrete, 0 will be returned. + /// @return A pointer to the dynamically allocated Entity. Ownership is transferred. If the represented Entity subclass isn't concrete, 0 will be returned. virtual Entity* NewInstance() const { return IsConcrete() ? m_NewInstance() : 0; } #pragma endregion @@ -222,38 +180,28 @@ namespace RTE { #pragma endregion #pragma region Creation - /// /// Constructor method used to instantiate a Entity in system memory. Create() should be called before using the Entity. - /// Entity() { Clear(); } - /// /// Makes the Entity ready for use. - /// - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create() override; - /// /// Creates an Entity to be identical to another, by deep copy. - /// - /// A reference to the Entity to deep copy. - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @param reference A reference to the Entity to deep copy. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. virtual int Create(const Entity& reference); - /// /// Makes the Serializable ready for use. - /// - /// A Reader that the Serializable will create itself from. - /// Whether there is a class name in the stream to check against to make sure the correct type is being read from the stream. - /// Whether to do any additional initialization of the object after reading in all the properties from the Reader. This is done by calling Create(). - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @param reader A Reader that the Serializable will create itself from. + /// @param checkType Whether there is a class name in the stream to check against to make sure the correct type is being read from the stream. + /// @param doCreate Whether to do any additional initialization of the object after reading in all the properties from the Reader. This is done by calling Create(). + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create(Reader& reader, bool checkType = true, bool doCreate = true) override { return Serializable::Create(reader, checkType, doCreate); } - /// /// Uses a passed-in instance, or creates a new one, and makes it identical to this. - /// - /// A pointer to an instance to make identical to this. If 0 is passed in, a new instance is made inside here, and ownership of it IS returned! - /// An Entity pointer to the newly cloned-to instance. Ownership IS transferred! + /// @param cloneTo A pointer to an instance to make identical to this. If 0 is passed in, a new instance is made inside here, and ownership of it IS returned! + /// @return An Entity pointer to the newly cloned-to instance. Ownership IS transferred! virtual Entity* Clone(Entity* cloneTo = nullptr) const { RTEAbort("Attempt to clone an abstract or unclonable type!"); return nullptr; @@ -261,63 +209,45 @@ namespace RTE { #pragma endregion #pragma region Destruction - /// /// Destructor method used to clean up a Entity before deletion from system memory. - /// virtual ~Entity() { Destroy(true); } - /// /// Destroys and resets (through Clear()) the Entity. - /// - /// Whether to only destroy the members defined in this derived class, or to destroy all inherited members also. + /// @param notInherited Whether to only destroy the members defined in this derived class, or to destroy all inherited members also. virtual void Destroy(bool notInherited = false) { Clear(); } - /// /// Resets the entire Entity, including its inherited members, to their default settings or values. - /// void Reset() override { Clear(); } #pragma endregion #pragma region INI Handling - /// /// Only saves out a Preset reference of this to the stream. /// Is only applicable to objects that are not original presets and haven't been altered since they were copied from their original. - /// - /// A Writer that the Entity will save itself to. - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @param writer A Writer that the Entity will save itself to. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int SavePresetCopy(Writer& writer) const; #pragma endregion #pragma region Getters and Setters - /// /// Shows the ID of the DataModule this Entity has been defined in. - /// - /// The ID of the module, or -1 if it hasn't been defined in any. + /// @return The ID of the module, or -1 if it hasn't been defined in any. int GetModuleID() const { return m_DefinedInModule; } - /// /// Sets the module this Entity was supposed to be defined in. - /// - /// The ID of the module, or -1 if it hasn't been defined in any. + /// @param whichModule The ID of the module, or -1 if it hasn't been defined in any. void SetModuleID(int whichModule) { m_DefinedInModule = whichModule; } - /// /// Gets this Entity's data preset. - /// - /// This Entity's data preset. + /// @return This Entity's data preset. const Entity* GetPreset() const; - /// /// Gets the name of this Entity's data Preset. - /// - /// A string reference with the instance name of this Entity. + /// @return A string reference with the instance name of this Entity. const std::string& GetPresetName() const { return m_PresetName; } - /// /// Sets the name of this Entity's data Preset. - /// - /// A string reference with the instance name of this Entity. - /// Whether this method was called from Lua, in which case this change is cosmetic only and shouldn't affect scripts. + /// @param newName A string reference with the instance name of this Entity. + /// @param calledFromLua Whether this method was called from Lua, in which case this change is cosmetic only and shouldn't affect scripts. // TODO: Replace the calledFromLua flag with some DisplayName property // TODO: Figure out how to handle if same name was set, still make it wasgivenname = true? virtual void SetPresetName(const std::string& newName, bool calledFromLua = false) { /*if (m_PresetName != newName) { m_IsOriginalPreset = true; }*/ @@ -325,147 +255,107 @@ namespace RTE { m_PresetName = newName; } - /// /// Gets the plain text description of this Entity's data Preset. - /// - /// A string reference with the plain text description name of this Preset. + /// @return A string reference with the plain text description name of this Preset. const std::string& GetDescription() const { return m_PresetDescription; } - /// /// Sets the plain text description of this Entity's data Preset. Shouldn't be more than a couple of sentences. - /// - /// A string reference with the preset description. + /// @param newDesc A string reference with the preset description. void SetDescription(const std::string& newDesc) { m_PresetDescription = newDesc; } - /// /// Gets the name of this Entity's data Preset, preceded by the name of the Data Module it was defined in, separated with a '/'. - /// - /// A string with the module and instance name of this Entity. + /// @return A string with the module and instance name of this Entity. std::string GetModuleAndPresetName() const; - /// /// Gets the name of this Entity's Data Module it was defined in. - /// - /// A string with the module of this Entity. + /// @return A string with the module of this Entity. std::string GetModuleName() const; - /// /// Indicates whether this Entity was explicitly given a new instance name upon creation, or if it was just copied/inherited implicitly. - /// - /// Whether this Entity was given a new Preset Name upon creation. + /// @return Whether this Entity was given a new Preset Name upon creation. bool IsOriginalPreset() const { return m_IsOriginalPreset; } - /// /// Sets IsOriginalPreset flag to indicate that the object should be saved as CopyOf. - /// void ResetOriginalPresetFlag() { m_IsOriginalPreset = false; } #pragma endregion #pragma region Logging - /// /// Gets the file and line that are currently being read. Formatted to be used for logging warnings and errors. - /// - /// A string containing the currently read file path and the line being read. + /// @return A string containing the currently read file path and the line being read. const std::string& GetFormattedReaderPosition() const { return m_FormattedReaderPosition; } - /// /// Sets the file and line that are currently being read. Formatted to be used for logging warnings and errors. - /// - /// A string containing the currently read file path and the line being read. + /// @param newPosition A string containing the currently read file path and the line being read. void SetFormattedReaderPosition(const std::string& newPosition) override { m_FormattedReaderPosition = newPosition; } #pragma endregion #pragma region Virtual Override Methods - /// /// Makes this an original Preset in a different module than it was before. It severs ties deeply to the old module it was saved in. - /// - /// The ID of the new module. - /// Whether the migration was successful. If you tried to migrate to the same module it already was in, this would return false. + /// @param whichModule The ID of the new module. + /// @return Whether the migration was successful. If you tried to migrate to the same module it already was in, this would return false. virtual bool MigrateToModule(int whichModule); #pragma endregion #pragma region Groups - /// /// Gets the set of groups this is member of. - /// - /// A pointer to a list of strings which describes the groups this is added to. Ownership is NOT transferred! + /// @return A pointer to a list of strings which describes the groups this is added to. Ownership is NOT transferred! const std::unordered_set* GetGroups() const { return &m_Groups; } - /// /// Gets whether this is part of a specific group or not. - /// - /// A string which describes the group to check for. - /// Whether this Entity is in the specified group or not. + /// @param whichGroup A string which describes the group to check for. + /// @return Whether this Entity is in the specified group or not. bool IsInGroup(const std::string& whichGroup) const { return whichGroup == "None" ? false : (whichGroup == "All" || whichGroup == "Any" || m_Groups.contains(whichGroup)); } - /// /// Adds this Entity to a new grouping. - /// - /// A string which describes the group to add this to. Duplicates will be ignored. + /// @param newGroup A string which describes the group to add this to. Duplicates will be ignored. void AddToGroup(const std::string& newGroup) { m_Groups.emplace(newGroup); } - /// /// Removes this Entity from the specified grouping. - /// - /// A string which describes the group to remove this from. + /// @param groupToRemoveFrom A string which describes the group to remove this from. void RemoveFromGroup(const std::string& groupToRemoveFrom) { m_Groups.erase(groupToRemoveFrom); } - /// /// Returns random weight used in PresetMan::GetRandomBuyableOfGroupFromTech. - /// - /// This item's random weight from 0 to 100. + /// @return This item's random weight from 0 to 100. int GetRandomWeight() const { return m_RandomWeight; } #pragma endregion #pragma region Lua Script Handling - /// /// Reloads the Preset scripts of this Entity, from the same script file path as was originally defined. /// This will also update the original Preset in the PresetMan with the updated scripts so future objects spawned will use the new scripts. - /// - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. virtual int ReloadScripts() { return 0; } #pragma endregion #pragma region Operator Overloads - /// /// A stream insertion operator for sending a Entity to an output stream. - /// - /// An ostream reference as the left hand side operand. - /// A Entity reference as the right hand side operand. - /// An ostream reference for further use in an expression. + /// @param stream An ostream reference as the left hand side operand. + /// @param operand A Entity reference as the right hand side operand. + /// @return An ostream reference for further use in an expression. friend std::ostream& operator<<(std::ostream& stream, const Entity& operand) { stream << operand.GetPresetName() << ", " << operand.GetClassName(); return stream; } - /// /// A Reader extraction operator for filling an Entity from a Reader. - /// - /// A Reader reference as the left hand side operand. - /// An Entity reference as the right hand side operand. - /// A Reader reference for further use in an expression. + /// @param reader A Reader reference as the left hand side operand. + /// @param operand An Entity reference as the right hand side operand. + /// @return A Reader reference for further use in an expression. friend Reader& operator>>(Reader& reader, Entity& operand); - /// /// A Reader extraction operator for filling an Entity from a Reader. - /// - /// A Reader reference as the left hand side operand. - /// An Entity pointer as the right hand side operand. - /// A Reader reference for further use in an expression. + /// @param reader A Reader reference as the left hand side operand. + /// @param operand An Entity pointer as the right hand side operand. + /// @return A Reader reference for further use in an expression. friend Reader& operator>>(Reader& reader, Entity* operand); #pragma endregion #pragma region Class Info - /// /// Gets the ClassInfo instance of this Entity. - /// - /// A reference to the ClassInfo of this' class. + /// @return A reference to the ClassInfo of this' class. virtual const Entity::ClassInfo& GetClass() const { return m_sClass; } - /// /// Gets the class name of this Entity. - /// - /// A string with the friendly-formatted type name of this Entity. + /// @return A string with the friendly-formatted type name of this Entity. virtual const std::string& GetClassName() const { return m_sClass.GetName(); } #pragma endregion @@ -488,9 +378,7 @@ namespace RTE { Entity& operator=(const Entity& rhs) { return *this; } private: - /// /// Clears all the member variables of this Entity, effectively resetting the members of this abstraction level only. - /// void Clear(); }; } // namespace RTE diff --git a/Source/System/GLCheck.h b/Source/System/GLCheck.h index 4e2038c7d0..8107c4eaeb 100644 --- a/Source/System/GLCheck.h +++ b/Source/System/GLCheck.h @@ -1,15 +1,11 @@ #ifndef _RTEGLCHECK_H_ #define _RTEGLCHECK_H_ -///< summary> /// Debug function to print GL errors to the console from: /// https : // stackoverflow.com/questions/11256470/define-a-macro-to-facilitate-opengl-command-debugging -/// void CheckOpenGLError(const char* stmt, const char* fname, int line); -///< summary> /// Debug macro to be used for all GL calls. -/// #ifdef DEBUG #define GL_CHECK(stmt) \ do { \ diff --git a/Source/System/Gamepad.h b/Source/System/Gamepad.h index 2fdb249593..5ba2faaa25 100644 --- a/Source/System/Gamepad.h +++ b/Source/System/Gamepad.h @@ -6,9 +6,7 @@ namespace RTE { - /// /// Structure for storing SDL_GameController or SDL_Joystick states. - /// struct Gamepad { int m_DeviceIndex = -1; //!< The SDL device index, used when reopening devices as SDL will attempt to reassign joysticks to the same index. SDL_JoystickID m_JoystickID = -1; //!< The joystick ID for event handling. @@ -17,42 +15,32 @@ namespace RTE { std::vector m_Buttons; //!< Array of button states. #pragma region Creation - /// /// Constructor method used to instantiate a Gamepad object in system memory and make it ready for use. - /// Gamepad() = default; - /// /// Constructor method used to instantiate a Gamepad object in system memory and make it ready for use. - /// - /// The SDL device index. - /// The joystick ID for event handling. - /// Number of analog axis. - /// Number of buttons. + /// @param deviceIndex The SDL device index. + /// @param id The joystick ID for event handling. + /// @param numAxis Number of analog axis. + /// @param numButtons Number of buttons. Gamepad(int deviceIndex, SDL_JoystickID id, int numAxis, int numButtons) : m_DeviceIndex(deviceIndex), m_JoystickID(id), m_Axis(numAxis), m_DigitalAxis(numAxis), m_Buttons(numButtons) {} #pragma endregion #pragma region Operator Overloads - /// /// Equality operator for testing if any two Gamepads are equal by ID. - /// - /// The ID to check equality with. - /// A boolean indicating whether the two operands are equal or not. + /// @param joystickID The ID to check equality with. + /// @return A boolean indicating whether the two operands are equal or not. bool operator==(int joystickID) const { return m_JoystickID == joystickID; } - /// /// Equality operator for testing if any two Gamepads are equal. - /// - /// A Gamepad reference as the right hand side operand. - /// A boolean indicating whether the two operands are equal or not. + /// @param rhs A Gamepad reference as the right hand side operand. + /// @return A boolean indicating whether the two operands are equal or not. bool operator==(const Gamepad& rhs) const { return m_JoystickID == rhs.m_JoystickID; } - /// /// Comparison operator for sorting Gamepads by ID. - /// - /// A Gamepad reference as the right hand side operand. - /// A boolean indicating the comparison result. + /// @param rhs A Gamepad reference as the right hand side operand. + /// @return A boolean indicating the comparison result. bool operator<(const Gamepad& rhs) const { return m_JoystickID < rhs.m_JoystickID; } }; } // namespace RTE diff --git a/Source/System/GenericSavedData.cpp b/Source/System/GenericSavedData.cpp index 539b420626..c0c18bd86d 100644 --- a/Source/System/GenericSavedData.cpp +++ b/Source/System/GenericSavedData.cpp @@ -9,8 +9,6 @@ namespace RTE { const std::string GenericSavedData::GenericSavedStrings::c_ClassName = "GenericSavedStrings"; const std::string GenericSavedData::GenericSavedNumbers::c_ClassName = "GenericSavedNumbers"; - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int GenericSavedData::ReadProperty(const std::string_view& propName, Reader& reader) { StartPropertyList(return Serializable::ReadProperty(propName, reader)); @@ -21,8 +19,6 @@ namespace RTE { EndPropertyList; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int GenericSavedData::Save(Writer& writer) const { Serializable::Save(writer); @@ -33,8 +29,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GenericSavedData::SaveString(const std::string& key, const std::string& value) { if (value.length() == 0) { m_SavedEncodedStrings.m_Data[key] = value; @@ -69,8 +63,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - const std::string& GenericSavedData::LoadString(const std::string& key) { const std::string* loadString = &m_SavedStrings.m_Data[key]; if (*loadString == "") { @@ -79,16 +71,12 @@ namespace RTE { return *loadString; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int GenericSavedData::GenericSavedEncodedStrings::ReadProperty(const std::string_view& propName, Reader& reader) { std::string value = reader.ReadPropValue(); m_Data[std::string(propName)] = base64_decode(value); // until we get P0919R2. return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int GenericSavedData::GenericSavedEncodedStrings::Save(Writer& writer) const { Serializable::Save(writer); @@ -101,15 +89,11 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int GenericSavedData::GenericSavedStrings::ReadProperty(const std::string_view& propName, Reader& reader) { m_Data[std::string(propName)] = reader.ReadPropValue(); // until we get P0919R2. return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int GenericSavedData::GenericSavedStrings::Save(Writer& writer) const { Serializable::Save(writer); @@ -121,8 +105,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int GenericSavedData::GenericSavedNumbers::ReadProperty(const std::string_view& propName, Reader& reader) { float value; reader >> value; @@ -130,8 +112,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int GenericSavedData::GenericSavedNumbers::Save(Writer& writer) const { Serializable::Save(writer); diff --git a/Source/System/GenericSavedData.h b/Source/System/GenericSavedData.h index 29a6022d3b..fe5e3c8c30 100644 --- a/Source/System/GenericSavedData.h +++ b/Source/System/GenericSavedData.h @@ -5,29 +5,21 @@ namespace RTE { - /// /// Helper class to save generic data. - /// class GenericSavedData : public Serializable { - /// /// Helper class to save generic encoded string data, that can safely include newlines and = and other characters INI doesn't like. - /// class GenericSavedEncodedStrings : public Serializable { public: SerializableClassNameGetter; SerializableOverrideMethods; - /// /// Constructor method used to instantiate a GenericSavedStrings object in system memory and make it ready for use. - /// GenericSavedEncodedStrings() = default; - /// /// Constructor method used to instantiate a GenericSavedEncodedStrings object to be identical to another, by deep copy, and make it ready for use. - /// - /// A reference to the GenericSavedEncodedStrings to deep copy. + /// @param reference A reference to the GenericSavedEncodedStrings to deep copy. GenericSavedEncodedStrings(const GenericSavedEncodedStrings& reference) = default; std::unordered_map m_Data; //!< Stored string data. @@ -36,24 +28,18 @@ namespace RTE { static const std::string c_ClassName; //!< A string with the friendly formatted type name of this object. }; - /// /// Helper class to save generic string data. - /// class GenericSavedStrings : public Serializable { public: SerializableClassNameGetter; SerializableOverrideMethods; - /// /// Constructor method used to instantiate a GenericSavedStrings object in system memory and make it ready for use. - /// GenericSavedStrings() = default; - /// /// Constructor method used to instantiate a GenericSavedStrings object to be identical to another, by deep copy, and make it ready for use. - /// - /// A reference to the GenericSavedStrings to deep copy. + /// @param reference A reference to the GenericSavedStrings to deep copy. GenericSavedStrings(const GenericSavedStrings& reference) = default; std::unordered_map m_Data; //!< Stored string data. @@ -62,24 +48,18 @@ namespace RTE { static const std::string c_ClassName; //!< A string with the friendly formatted type name of this object. }; - /// /// Helper class to save generic number data. - /// class GenericSavedNumbers : public Serializable { public: SerializableClassNameGetter; SerializableOverrideMethods; - /// /// Constructor method used to instantiate a GenericSavedNumbers object in system memory and make it ready for use. - /// GenericSavedNumbers() = default; - /// /// Constructor method used to instantiate a GenericSavedNumbers object to be identical to another, by deep copy, and make it ready for use. - /// - /// A reference to the GenericSavedNumbers to deep copy. + /// @param reference A reference to the GenericSavedNumbers to deep copy. GenericSavedNumbers(const GenericSavedNumbers& reference) = default; std::unordered_map m_Data; //!< Stored number data. @@ -92,15 +72,11 @@ namespace RTE { SerializableClassNameGetter; SerializableOverrideMethods; - /// /// Constructor method used to instantiate a GenericSavedData object in system memory and make it ready for use. - /// GenericSavedData() = default; - /// /// Constructor method used to instantiate a GenericSavedData object to be identical to another, by deep copy, and make it ready for use. - /// - /// A reference to the GenericSavedData to deep copy. + /// @param reference A reference to the GenericSavedData to deep copy. GenericSavedData(const GenericSavedData& reference) = default; void SaveString(const std::string& key, const std::string& value); diff --git a/Source/System/GraphicalPrimitive.cpp b/Source/System/GraphicalPrimitive.cpp index f677d62c01..a17cdce22b 100644 --- a/Source/System/GraphicalPrimitive.cpp +++ b/Source/System/GraphicalPrimitive.cpp @@ -27,8 +27,6 @@ namespace RTE { const GraphicalPrimitive::PrimitiveType TextPrimitive::c_PrimitiveType = PrimitiveType::Text; const GraphicalPrimitive::PrimitiveType BitmapPrimitive::c_PrimitiveType = PrimitiveType::Bitmap; - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void GraphicalPrimitive::TranslateCoordinates(Vector targetPos, const Vector& scenePos, Vector& drawLeftPos, Vector& drawRightPos) const { drawLeftPos = scenePos; drawRightPos = scenePos; @@ -54,8 +52,6 @@ namespace RTE { drawRightPos.m_Y -= targetPos.m_Y; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void LinePrimitive::Draw(BITMAP* drawScreen, const Vector& targetPos) { if (!g_SceneMan.SceneWrapsX() && !g_SceneMan.SceneWrapsY()) { Vector drawStart = m_StartPos - targetPos; @@ -75,8 +71,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ArcPrimitive::Draw(BITMAP* drawScreen, const Vector& targetPos) { if (!g_SceneMan.SceneWrapsX() && !g_SceneMan.SceneWrapsY()) { Vector drawStart = m_StartPos - targetPos; @@ -105,8 +99,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SplinePrimitive::Draw(BITMAP* drawScreen, const Vector& targetPos) { if (!g_SceneMan.SceneWrapsX() && !g_SceneMan.SceneWrapsY()) { Vector drawStart = m_StartPos - targetPos; @@ -138,8 +130,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void BoxPrimitive::Draw(BITMAP* drawScreen, const Vector& targetPos) { if (!g_SceneMan.SceneWrapsX() && !g_SceneMan.SceneWrapsY()) { Vector drawStart = m_StartPos - targetPos; @@ -159,8 +149,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void BoxFillPrimitive::Draw(BITMAP* drawScreen, const Vector& targetPos) { if (!g_SceneMan.SceneWrapsX() && !g_SceneMan.SceneWrapsY()) { Vector drawStart = m_StartPos - targetPos; @@ -180,8 +168,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void RoundedBoxPrimitive::Draw(BITMAP* drawScreen, const Vector& targetPos) { if (m_StartPos.m_X > m_EndPos.m_X) { std::swap(m_StartPos.m_X, m_EndPos.m_X); @@ -232,8 +218,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void RoundedBoxFillPrimitive::Draw(BITMAP* drawScreen, const Vector& targetPos) { if (m_StartPos.m_X > m_EndPos.m_X) { std::swap(m_StartPos.m_X, m_EndPos.m_X); @@ -278,8 +262,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void CirclePrimitive::Draw(BITMAP* drawScreen, const Vector& targetPos) { if (!g_SceneMan.SceneWrapsX() && !g_SceneMan.SceneWrapsY()) { Vector drawStart = m_StartPos - targetPos; @@ -295,8 +277,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void CircleFillPrimitive::Draw(BITMAP* drawScreen, const Vector& targetPos) { if (!g_SceneMan.SceneWrapsX() && !g_SceneMan.SceneWrapsY()) { Vector drawStart = m_StartPos - targetPos; @@ -312,8 +292,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void EllipsePrimitive::Draw(BITMAP* drawScreen, const Vector& targetPos) { if (!g_SceneMan.SceneWrapsX() && !g_SceneMan.SceneWrapsY()) { Vector drawStart = m_StartPos - targetPos; @@ -329,8 +307,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void EllipseFillPrimitive::Draw(BITMAP* drawScreen, const Vector& targetPos) { if (!g_SceneMan.SceneWrapsX() && !g_SceneMan.SceneWrapsY()) { Vector drawStart = m_StartPos - targetPos; @@ -346,8 +322,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void TrianglePrimitive::Draw(BITMAP* drawScreen, const Vector& targetPos) { if (!g_SceneMan.SceneWrapsX() && !g_SceneMan.SceneWrapsY()) { Vector drawPointA = m_PointAPos - targetPos; @@ -377,8 +351,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void TriangleFillPrimitive::Draw(BITMAP* drawScreen, const Vector& targetPos) { if (!g_SceneMan.SceneWrapsX() && !g_SceneMan.SceneWrapsY()) { Vector drawPointA = m_PointAPos - targetPos; @@ -402,8 +374,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PolygonPrimitive::Draw(BITMAP* drawScreen, const Vector& targetPos) { if (!g_SceneMan.SceneWrapsX() && !g_SceneMan.SceneWrapsY()) { Vector drawStart; @@ -428,8 +398,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PolygonFillPrimitive::Draw(BITMAP* drawScreen, const Vector& targetPos) { size_t drawPointsSize = m_Vertices.size() * 2; @@ -463,8 +431,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void TextPrimitive::Draw(BITMAP* drawScreen, const Vector& targetPos) { if (m_Text.empty()) { return; @@ -533,8 +499,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void BitmapPrimitive::Draw(BITMAP* drawScreen, const Vector& targetPos) { if (!m_Bitmap) { return; diff --git a/Source/System/GraphicalPrimitive.h b/Source/System/GraphicalPrimitive.h index 0307abc5aa..00c91ccb98 100644 --- a/Source/System/GraphicalPrimitive.h +++ b/Source/System/GraphicalPrimitive.h @@ -6,23 +6,17 @@ namespace RTE { #pragma region Graphical Primitive - /// /// Class used to schedule drawing of graphical primitives created from Lua. /// All coordinates passed to GraphicalPrimitive objects are Scene coordinates. - /// class GraphicalPrimitive { public: -/// /// Convenience macro to cut down on duplicate methods in classes that extend GraphicalPrimitive. -/// #define GraphicalPrimitiveOverrideMethods \ const PrimitiveType GetPrimitiveType() const override { return c_PrimitiveType; } \ void Draw(BITMAP* drawScreen, const Vector& targetPos) override; - /// /// Enumeration of the different primitive types derived from GraphicalPrimitive. - /// enum class PrimitiveType { None, // Not derived (base GraphicalPrimitive). Line, @@ -51,39 +45,30 @@ namespace RTE { DrawBlendMode m_BlendMode = DrawBlendMode::NoBlend; //!< The blending mode that will be used when drawing this primitive. std::array m_ColorChannelBlendAmounts = {BlendAmountLimits::MinBlend, BlendAmountLimits::MinBlend, BlendAmountLimits::MinBlend, BlendAmountLimits::MinBlend}; //!< The blending amount for each color channel when drawing in blended mode. - /// /// Destructor method used to clean up a GraphicalPrimitive object before deletion from system memory. - /// virtual ~GraphicalPrimitive() = default; - /// /// Translates coordinates from scene to this bitmap offset producing two coordinates. - /// - /// Target position. - /// Position on scene. - /// 'Left' position of bitmap on scene with negative values as if scene seam is 0,0. - /// 'Right' position of bitmap on scene with positive values. - /// + /// @param targetPos Target position. + /// @param scenePos Position on scene. + /// @param drawLeftPos 'Left' position of bitmap on scene with negative values as if scene seam is 0,0. + /// @param drawRightPos 'Right' position of bitmap on scene with positive values. + /// @remark /// Unfortunately it's hard to explain how this works. It tries to represent scene bitmap as two parts with center in 0,0. /// Right part is just plain visible part with coordinates from [0, scenewidth] and left part is imaginary bitmap as if we traversed it across the seam right-to-left with coordinates [0, -scenewidth]. /// So in order to be drawn each screen coordinates calculated twice for left and right 'bitmaps' and then one of them either flies away off-screen or gets drawn on the screen. /// When we cross the seam either left or right part is actually drawn in the bitmap, and negative coordinates of right part are compensated by view point offset coordinates when we cross the seam right to left. /// I really don't know how to make it simpler, because it has so many special cases and simply wrapping all out-of-the scene coordinates don't work because this way nothing will be ever draw across the seam. /// You're welcome to rewrite this nightmare if you can, I wasted a whole week on this (I can admit that I'm just too dumb for this) ))) - /// void TranslateCoordinates(Vector targetPos, const Vector& scenePos, Vector& drawLeftPos, Vector& drawRightPos) const; - /// /// Draws this primitive on provided bitmap. - /// - /// Bitmap to draw on. - /// Position of graphical primitive. + /// @param drawScreen Bitmap to draw on. + /// @param targetPos Position of graphical primitive. virtual void Draw(BITMAP* drawScreen, const Vector& targetPos) = 0; - /// /// Gets the type identifier of this primitive. - /// - /// The type identifier of this primitive. + /// @return The type identifier of this primitive. virtual const PrimitiveType GetPrimitiveType() const = 0; private: @@ -92,21 +77,17 @@ namespace RTE { #pragma endregion #pragma region Line Primitive - /// /// Class used to schedule drawing of line primitives created from Lua. - /// class LinePrimitive : public GraphicalPrimitive { public: GraphicalPrimitiveOverrideMethods; - /// /// Constructor method for LinePrimitive object. - /// - /// Player screen to draw this primitive on. - /// Start position of the primitive. - /// End position of the primitive. - /// Color to draw this primitive with. + /// @param player Player screen to draw this primitive on. + /// @param startPos Start position of the primitive. + /// @param end End position of the primitive. + /// @param color Color to draw this primitive with. LinePrimitive(int player, const Vector& startPos, const Vector& endPos, unsigned char color) { m_StartPos = startPos; m_EndPos = endPos; @@ -120,9 +101,7 @@ namespace RTE { #pragma endregion #pragma region Arc Primitive - /// /// Class used to schedule drawing of arc line primitives created from Lua. - /// class ArcPrimitive : public GraphicalPrimitive { public: @@ -133,15 +112,13 @@ namespace RTE { int m_Radius = 0; //!< Radius of the arc primitive. int m_Thickness = 0; //!< Thickness of the arc primitive in pixels. - /// /// Constructor method for ArcPrimitive object. - /// - /// Player screen to draw this primitive on. - /// Position of this primitive's center. - /// The angle from which the arc drawing begins. - /// The angle at which the arc drawing ends. - /// Radius of the arc primitive. - /// Color to draw this primitive with. + /// @param player Player screen to draw this primitive on. + /// @param centerPos Position of this primitive's center. + /// @param startAngle The angle from which the arc drawing begins. + /// @param endAngle The angle at which the arc drawing ends. + /// @param radius Radius of the arc primitive. + /// @param color Color to draw this primitive with. ArcPrimitive(int player, const Vector& centerPos, float startAngle, float endAngle, int radius, int thickness, unsigned char color) : m_StartAngle(startAngle), m_EndAngle(endAngle), m_Radius(radius), m_Thickness(thickness) { @@ -156,9 +133,7 @@ namespace RTE { #pragma endregion #pragma region Spline Primitive - /// /// Class used to schedule drawing of spline primitives created from Lua. - /// class SplinePrimitive : public GraphicalPrimitive { public: @@ -167,15 +142,13 @@ namespace RTE { Vector m_GuidePointAPos; //!< A guide point that controls the curve of the spline. Vector m_GuidePointBPos; //!< A guide point that controls the curve of the spline. - /// /// Constructor method for SplinePrimitive object. - /// - /// Player screen to draw this primitive on. - /// Start position of the primitive. - /// The first guide point that controls the curve of the spline. The spline won't necessarily pass through this point, but it will affect it's shape. - /// The second guide point that controls the curve of the spline. The spline won't necessarily pass through this point, but it will affect it's shape. - /// End position of the primitive. - /// Color to draw this primitive with. + /// @param player Player screen to draw this primitive on. + /// @param startPos Start position of the primitive. + /// @param guideA The first guide point that controls the curve of the spline. The spline won't necessarily pass through this point, but it will affect it's shape. + /// @param guideB The second guide point that controls the curve of the spline. The spline won't necessarily pass through this point, but it will affect it's shape. + /// @param endPos End position of the primitive. + /// @param color Color to draw this primitive with. SplinePrimitive(int player, const Vector& startPos, const Vector& guideA, const Vector& guideB, const Vector& endPos, unsigned char color) : m_GuidePointAPos(guideA), m_GuidePointBPos(guideB) { @@ -191,21 +164,17 @@ namespace RTE { #pragma endregion #pragma region Box Primitive - /// /// Class used to schedule drawing of box primitives created from Lua. - /// class BoxPrimitive : public GraphicalPrimitive { public: GraphicalPrimitiveOverrideMethods; - /// /// Constructor method for BoxPrimitive object. - /// - /// Player screen to draw this primitive on. - /// Start position of the primitive. Top left corner. - /// End position of the primitive. Bottom right corner. - /// Color to draw this primitive with. + /// @param player Player screen to draw this primitive on. + /// @param topLeftPos Start position of the primitive. Top left corner. + /// @param bottomRightPos End position of the primitive. Bottom right corner. + /// @param color Color to draw this primitive with. BoxPrimitive(int player, const Vector& topLeftPos, const Vector& bottomRightPos, unsigned char color) { m_StartPos = topLeftPos; m_EndPos = bottomRightPos; @@ -219,21 +188,17 @@ namespace RTE { #pragma endregion #pragma region Filled Box Primitive - /// /// Class used to schedule drawing of filled box primitives created from Lua. - /// class BoxFillPrimitive : public GraphicalPrimitive { public: GraphicalPrimitiveOverrideMethods; - /// /// Constructor method for BoxFillPrimitive object. - /// - /// Player screen to draw this primitive on. - /// Start position of the primitive. Top left corner. - /// End position of the primitive. Bottom right corner. - /// Color to draw this primitive with. + /// @param player Player screen to draw this primitive on. + /// @param topLeftPos Start position of the primitive. Top left corner. + /// @param bottomRightPos End position of the primitive. Bottom right corner. + /// @param color Color to draw this primitive with. BoxFillPrimitive(int player, const Vector& topLeftPos, const Vector& bottomRightPos, unsigned char color) { m_StartPos = topLeftPos; m_EndPos = bottomRightPos; @@ -247,9 +212,7 @@ namespace RTE { #pragma endregion #pragma region Rounded Box Primitive - /// /// Class used to schedule drawing of box with round corners primitives created from Lua. - /// class RoundedBoxPrimitive : public GraphicalPrimitive { public: @@ -257,14 +220,12 @@ namespace RTE { int m_CornerRadius = 0; //!< The radius of the corners of the box. - /// /// Constructor method for RoundedBoxPrimitive object. - /// - /// Player screen to draw this primitive on. - /// Start position of the primitive. Top left corner. - /// End position of the primitive. Bottom right corner. - /// The radius of the corners of the box. Smaller radius equals sharper corners. - /// Color to draw this primitive with. + /// @param player Player screen to draw this primitive on. + /// @param topLeftPos Start position of the primitive. Top left corner. + /// @param bottomRightPos End position of the primitive. Bottom right corner. + /// @param cornerRadius The radius of the corners of the box. Smaller radius equals sharper corners. + /// @param color Color to draw this primitive with. RoundedBoxPrimitive(int player, const Vector& topLeftPos, const Vector& bottomRightPos, int cornerRadius, unsigned char color) : m_CornerRadius(cornerRadius) { @@ -280,9 +241,7 @@ namespace RTE { #pragma endregion #pragma region Filled Rounded Box Primitive - /// /// Class used to schedule drawing of filled box with round corners primitives created from Lua. - /// class RoundedBoxFillPrimitive : public GraphicalPrimitive { public: @@ -290,14 +249,12 @@ namespace RTE { int m_CornerRadius = 0; //!< The radius of the corners of the box. - /// /// Constructor method for RoundedBoxFillPrimitive object. - /// - /// Player screen to draw this primitive on. - /// Start position of the primitive. Top left corner. - /// End position of the primitive. Bottom right corner. - /// The radius of the corners of the box. Smaller radius equals sharper corners. - /// Color to draw this primitive with. + /// @param player Player screen to draw this primitive on. + /// @param topLeftPos Start position of the primitive. Top left corner. + /// @param bottomRightPos End position of the primitive. Bottom right corner. + /// @param cornerRadius The radius of the corners of the box. Smaller radius equals sharper corners. + /// @param color Color to draw this primitive with. RoundedBoxFillPrimitive(int player, const Vector& topLeftPos, const Vector& bottomRightPos, int cornerRadius, unsigned char color) : m_CornerRadius(cornerRadius) { @@ -313,9 +270,7 @@ namespace RTE { #pragma endregion #pragma region Cicrcle Primitive - /// /// Class used to schedule drawing of circle primitives created from Lua. - /// class CirclePrimitive : public GraphicalPrimitive { public: @@ -323,13 +278,11 @@ namespace RTE { int m_Radius = 0; //!< Radius of the circle primitive. - /// /// Constructor method for CirclePrimitive object. - /// - /// Player screen to draw this primitive on. - /// Position of this primitive's center. - /// Radius of the circle primitive. - /// Color to draw this primitive with. + /// @param player Player screen to draw this primitive on. + /// @param centerPos Position of this primitive's center. + /// @param radius Radius of the circle primitive. + /// @param color Color to draw this primitive with. CirclePrimitive(int player, const Vector& centerPos, int radius, unsigned char color) : m_Radius(radius) { @@ -344,9 +297,7 @@ namespace RTE { #pragma endregion #pragma region Filled Circle Primitive - /// /// Class used to schedule drawing of filled circle primitives created from Lua - /// class CircleFillPrimitive : public GraphicalPrimitive { public: @@ -354,13 +305,11 @@ namespace RTE { int m_Radius = 0; //!< Radius of the circle primitive. - /// /// Constructor method for CircleFillPrimitive object. - /// - /// Player screen to draw this primitive on. - /// Position of this primitive's center. - /// Radius of the circle primitive. - /// Color to draw this primitive with. + /// @param player Player screen to draw this primitive on. + /// @param centerPos Position of this primitive's center. + /// @param radius Radius of the circle primitive. + /// @param color Color to draw this primitive with. CircleFillPrimitive(int player, const Vector& centerPos, int radius, unsigned char color) : m_Radius(radius) { @@ -375,9 +324,7 @@ namespace RTE { #pragma endregion #pragma region Ellipse Primitive - /// /// Class used to schedule drawing of ellipse primitives created from Lua. - /// class EllipsePrimitive : public GraphicalPrimitive { public: @@ -386,14 +333,12 @@ namespace RTE { int m_HorizRadius = 0; //!< The horizontal radius of the ellipse primitive. int m_VertRadius = 0; //!< The vertical radius of the ellipse primitive. - /// /// Constructor method for EllipsePrimitive object. - /// - /// Player screen to draw this primitive on. - /// Position of this primitive's center. - /// Horizontal radius of the ellipse primitive. - /// Vertical radius of the ellipse primitive. - /// Color to draw this primitive with. + /// @param player Player screen to draw this primitive on. + /// @param centerPos Position of this primitive's center. + /// @param horizRadius Horizontal radius of the ellipse primitive. + /// @param vertRadius Vertical radius of the ellipse primitive. + /// @param color Color to draw this primitive with. EllipsePrimitive(int player, const Vector& centerPos, int horizRadius, int vertRadius, unsigned char color) : m_HorizRadius(horizRadius), m_VertRadius(vertRadius) { @@ -408,9 +353,7 @@ namespace RTE { #pragma endregion #pragma region Filled Ellipse Primitive - /// /// Class used to schedule drawing of filled ellipse primitives created from Lua - /// class EllipseFillPrimitive : public GraphicalPrimitive { public: @@ -419,13 +362,11 @@ namespace RTE { int m_HorizRadius = 0; //!< The horizontal radius of the ellipse primitive. int m_VertRadius = 0; //!< The vertical radius of the ellipse primitive. - /// /// Constructor method for EllipseFillPrimitive object. - /// - /// Player screen to draw this primitive on. - /// Position of this primitive's center. - /// Radius of the circle primitive. - /// Color to draw this primitive with. + /// @param player Player screen to draw this primitive on. + /// @param centerPos Position of this primitive's center. + /// @param radius Radius of the circle primitive. + /// @param color Color to draw this primitive with. EllipseFillPrimitive(int player, const Vector& centerPos, int horizRadius, int vertRadius, unsigned char color) : m_HorizRadius(horizRadius), m_VertRadius(vertRadius) { @@ -440,9 +381,7 @@ namespace RTE { #pragma endregion #pragma region Triangle Primitive - /// /// Class used to schedule drawing of triangle primitives created from Lua. - /// class TrianglePrimitive : public GraphicalPrimitive { public: @@ -452,14 +391,12 @@ namespace RTE { Vector m_PointBPos; //!< Second point of the triangle. Vector m_PointCPos; //!< Third point of the triangle. - /// /// Constructor method for TrianglePrimitive object. - /// - /// Player screen to draw this primitive on. - /// Position of the first point of the triangle. - /// Position of the second point of the triangle - /// Position of the third point of the triangle - /// Color to draw this primitive with. + /// @param player Player screen to draw this primitive on. + /// @param pointA Position of the first point of the triangle. + /// @param pointB Position of the second point of the triangle + /// @param pointC Position of the third point of the triangle + /// @param color Color to draw this primitive with. TrianglePrimitive(int player, const Vector& pointA, const Vector& pointB, const Vector& pointC, unsigned char color) : m_PointAPos(pointA), m_PointBPos(pointB), m_PointCPos(pointC) { @@ -473,9 +410,7 @@ namespace RTE { #pragma endregion #pragma region Filled Triangle Primitive - /// /// Class used to schedule drawing of filled triangle primitives created from Lua. - /// class TriangleFillPrimitive : public GraphicalPrimitive { public: @@ -485,14 +420,12 @@ namespace RTE { Vector m_PointBPos; //!< Second point of the triangle. Vector m_PointCPos; //!< Third point of the triangle. - /// /// Constructor method for TriangleFillPrimitive object. - /// - /// Player screen to draw this primitive on. - /// Position of the first point of the triangle. - /// Position of the second point of the triangle - /// Position of the third point of the triangle - /// Color to draw this primitive with. + /// @param player Player screen to draw this primitive on. + /// @param pointA Position of the first point of the triangle. + /// @param pointB Position of the second point of the triangle + /// @param pointC Position of the third point of the triangle + /// @param color Color to draw this primitive with. TriangleFillPrimitive(int player, const Vector& pointA, const Vector& pointB, const Vector& pointC, unsigned char color) : m_PointAPos(pointA), m_PointBPos(pointB), m_PointCPos(pointC) { @@ -506,9 +439,7 @@ namespace RTE { #pragma endregion #pragma region Polygon Primitive - /// /// Class used to schedule drawing of polygon primitives created from Lua. - /// class PolygonPrimitive : public GraphicalPrimitive { public: @@ -516,13 +447,11 @@ namespace RTE { std::vector m_Vertices = {}; //!< Positions of the vertices of the polygon, relative to the center position. - /// /// Constructor method for PolygonPrimitive object. - /// - /// Player screen to draw this primitive on. - /// Start position of the primitive. - /// A vector containing the positions of the vertices of the polygon, relative to the center position. - /// Color to draw this primitive with. + /// @param player Player screen to draw this primitive on. + /// @param startPos Start position of the primitive. + /// @param vertices A vector containing the positions of the vertices of the polygon, relative to the center position. + /// @param color Color to draw this primitive with. PolygonPrimitive(int player, const Vector& startPos, unsigned char color, const std::vector& vertices) : m_Vertices(vertices) { @@ -537,9 +466,7 @@ namespace RTE { #pragma endregion #pragma region Filled Polygon Primitive - /// /// Class used to schedule drawing of filled polygon primitives created from Lua. - /// class PolygonFillPrimitive : public GraphicalPrimitive { public: @@ -547,13 +474,11 @@ namespace RTE { std::vector m_Vertices = {}; //!< Positions of the vertices of the polygon, relative to the center position. - /// /// Constructor method for PolygonFillPrimitive object. - /// - /// Player screen to draw this primitive on. - /// Start position of the primitive. - /// A vector containing the positions of the vertices of the polygon, relative to the center position. - /// Color to draw this primitive with. + /// @param player Player screen to draw this primitive on. + /// @param startPos Start position of the primitive. + /// @param vertices A vector containing the positions of the vertices of the polygon, relative to the center position. + /// @param color Color to draw this primitive with. PolygonFillPrimitive(int player, const Vector& startPos, unsigned char color, const std::vector& vertices) : m_Vertices(vertices) { @@ -568,9 +493,7 @@ namespace RTE { #pragma endregion #pragma region Text Primitive - /// /// Class used to schedule drawing of text primitives created from Lua. - /// class TextPrimitive : public GraphicalPrimitive { public: @@ -581,15 +504,13 @@ namespace RTE { int m_Alignment = 0; //!< Alignment of text. float m_RotAngle = 0; //!< Angle to rotate text in radians. - /// /// Constructor method for TextPrimitive object. - /// - /// Player screen to draw this primitive on. - /// Position of this primitive. - /// String containing text to draw. - /// Use small or large font. True for small font. - /// Alignment of text. - /// Angle to rotate text in radians. + /// @param player Player screen to draw this primitive on. + /// @param pos Position of this primitive. + /// @param text String containing text to draw. + /// @param isSmall Use small or large font. True for small font. + /// @param alignment Alignment of text. + /// @param rotAngle Angle to rotate text in radians. TextPrimitive(int player, const Vector& pos, const std::string& text, bool isSmall, int alignment, float rotAngle) : m_Text(text), m_IsSmall(isSmall), m_Alignment(alignment), m_RotAngle(rotAngle) { @@ -603,9 +524,7 @@ namespace RTE { #pragma endregion #pragma region Bitmap Primitive - /// /// Class used to schedule drawing of bitmap primitives created from Lua. - /// class BitmapPrimitive : public GraphicalPrimitive { public: @@ -616,15 +535,13 @@ namespace RTE { bool m_HFlipped = false; //!< Whether the Bitmap to draw should be horizontally flipped. bool m_VFlipped = false; //!< Whether the Bitmap to draw should be vertically flipped. - /// /// Constructor method for BitmapPrimitive object. - /// - /// Player screen to draw this primitive on. - /// Position of this primitive's center. - /// BITMAP to draw. - /// Angle to rotate BITMAP in radians. - /// Whether the BITMAP to draw should be horizontally flipped. - /// Whether the BITMAP to draw should be vertically flipped. + /// @param player Player screen to draw this primitive on. + /// @param centerPos Position of this primitive's center. + /// @param bitmap BITMAP to draw. + /// @param rotAngle Angle to rotate BITMAP in radians. + /// @param hFlipped Whether the BITMAP to draw should be horizontally flipped. + /// @param vFlipped Whether the BITMAP to draw should be vertically flipped. BitmapPrimitive(int player, const Vector& centerPos, BITMAP* bitmap, float rotAngle, bool hFlipped, bool vFlipped) : m_Bitmap(bitmap), m_RotAngle(rotAngle), m_HFlipped(hFlipped), m_VFlipped(vFlipped) { @@ -632,16 +549,14 @@ namespace RTE { m_Player = player; } - /// /// Constructor method for BitmapPrimitive object. - /// - /// Player screen to draw this primitive on. - /// Position of this primitive's center. - /// The MOSprite to get the BITMAP to draw from. - /// Angle to rotate BITMAP in radians. - /// Frame number of the MOSprite that will be drawn. - /// Whether the BITMAP to draw should be horizontally flipped. - /// Whether the BITMAP to draw should be vertically flipped. + /// @param player Player screen to draw this primitive on. + /// @param centerPos Position of this primitive's center. + /// @param moSprite The MOSprite to get the BITMAP to draw from. + /// @param rotAngle Angle to rotate BITMAP in radians. + /// @param frame Frame number of the MOSprite that will be drawn. + /// @param hFlipped Whether the BITMAP to draw should be horizontally flipped. + /// @param vFlipped Whether the BITMAP to draw should be vertically flipped. BitmapPrimitive(int player, const Vector& centerPos, const MOSprite* moSprite, float rotAngle, int frame, bool hFlipped, bool vFlipped) : m_Bitmap(moSprite->GetSpriteFrame(frame)), m_RotAngle(rotAngle), m_HFlipped(hFlipped), m_VFlipped(vFlipped) { @@ -649,15 +564,13 @@ namespace RTE { m_Player = player; } - /// /// Constructor method for BitmapPrimitive object. - /// - /// Player screen to draw this primitive on. - /// Position of this primitive's center. - /// The path to get the BITMAP to draw from. - /// Angle to rotate BITMAP in radians. - /// Whether the BITMAP to draw should be horizontally flipped. - /// Whether the BITMAP to draw should be vertically flipped. + /// @param player Player screen to draw this primitive on. + /// @param centerPos Position of this primitive's center. + /// @param filePath The path to get the BITMAP to draw from. + /// @param rotAngle Angle to rotate BITMAP in radians. + /// @param hFlipped Whether the BITMAP to draw should be horizontally flipped. + /// @param vFlipped Whether the BITMAP to draw should be vertically flipped. BitmapPrimitive(int player, const Vector& centerPos, const std::string& filePath, float rotAngle, bool hFlipped, bool vFlipped) : m_Bitmap(ContentFile(filePath.c_str()).GetAsBitmap()), m_RotAngle(rotAngle), m_HFlipped(hFlipped), m_VFlipped(vFlipped) { diff --git a/Source/System/InputMapping.cpp b/Source/System/InputMapping.cpp index cb2578c0c4..dfb66c6c1e 100644 --- a/Source/System/InputMapping.cpp +++ b/Source/System/InputMapping.cpp @@ -4,8 +4,6 @@ namespace RTE { const std::string InputMapping::c_ClassName = "InputMapping"; - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void InputMapping::Clear() { m_PresetDescription.clear(); m_KeyMap = 0; @@ -16,8 +14,6 @@ namespace RTE { m_DirectionMap = 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int InputMapping::Create(const InputMapping& reference) { m_KeyMap = reference.m_KeyMap; m_MouseButtonMap = reference.m_MouseButtonMap; @@ -29,8 +25,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int InputMapping::ReadProperty(const std::string_view& propName, Reader& reader) { StartPropertyList(return Serializable::ReadProperty(propName, reader)); @@ -49,8 +43,6 @@ namespace RTE { EndPropertyList; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int InputMapping::Save(Writer& writer) const { Serializable::Save(writer); diff --git a/Source/System/InputMapping.h b/Source/System/InputMapping.h index 40bc2229de..ae49f29ee0 100644 --- a/Source/System/InputMapping.h +++ b/Source/System/InputMapping.h @@ -5,9 +5,7 @@ namespace RTE { - /// /// A map between an input element and specific input device elements. - /// class InputMapping : public Serializable { public: @@ -15,108 +13,78 @@ namespace RTE { SerializableOverrideMethods; #pragma region Creation - /// /// Constructor method used to instantiate an InputMapping object in system memory. Create() should be called before using the object. - /// InputMapping() { Clear(); } - /// /// Creates an InputMapping to be identical to another, by deep copy. - /// - /// A reference to the InputMapping to deep copy. - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @param reference A reference to the InputMapping to deep copy. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create(const InputMapping& reference); #pragma endregion #pragma region Destruction - /// /// Resets the entire InputMapping, including its inherited members, to their default settings or values. - /// void Reset() override { Clear(); } #pragma endregion #pragma region Getters and Setters - /// /// Gets the description of the input scheme preset that this element is part of, if any preset has been set for this element's scheme. - /// - /// The description associated with this element by the scheme preset, if any has been set. This string is empty otherwise. + /// @return The description associated with this element by the scheme preset, if any has been set. This string is empty otherwise. std::string GetPresetDescription() const { return m_PresetDescription; } - /// /// Sets the description of the input scheme preset that this element is part of, if any preset has been set for this element's scheme. - /// - /// The description associated with this element by the scheme preset, if any has been set. This string should be empty otherwise. + /// @param presetDescription The description associated with this element by the scheme preset, if any has been set. This string should be empty otherwise. void SetPresetDescription(const std::string& presetDescription) { m_PresetDescription = presetDescription; } #pragma endregion #pragma region Keyboard Getters and Setters - /// /// Gets the keyboard key mapping. - /// - /// The keyboard key this is mapped to. + /// @return The keyboard key this is mapped to. int GetKey() const { return m_KeyMap; } - /// /// Sets the keyboard button mapping. - /// - /// The scan code of the new key to map to. + /// @param newKey The scan code of the new key to map to. void SetKey(int newKey) { m_KeyMap = newKey; } #pragma endregion #pragma region Mouse Getters and Setters - /// /// Gets the mouse button mapping. - /// - /// The number of the mouse button this is mapped to. + /// @return The number of the mouse button this is mapped to. int GetMouseButton() const { return m_MouseButtonMap; } - /// /// Sets the mouse button mapping. - /// - /// The number of the mouse button this should be mapped to. + /// @param newButton The number of the mouse button this should be mapped to. void SetMouseButton(int newButton) { m_MouseButtonMap = newButton; } #pragma endregion #pragma region Joystick Getters and Setters - /// /// Shows whether this is mapped to a joy direction or not. - /// - /// Joy direction mapped or not. + /// @return Joy direction mapped or not. bool JoyDirMapped() const { return m_DirectionMapped; } - /// /// Gets the joystick stick number that this is mapped to. - /// - /// The direction, UInputMan::JOYDIR_ONE or UInputMan::JOYDIR_TWO. + /// @return The direction, UInputMan::JOYDIR_ONE or UInputMan::JOYDIR_TWO. int GetDirection() const { return m_DirectionMap; } - /// /// Sets the joystick direction mapping. - /// - /// The number of the axis this should be mapped to. - /// The number of the direction this should be mapped to. + /// @param newAxis The number of the axis this should be mapped to. + /// @param newDirection The number of the direction this should be mapped to. void SetDirection(int newAxis, int newDirection) { m_DirectionMapped = true; m_AxisMap = newAxis; m_DirectionMap = newDirection; } - /// /// Gets the joystick button mapping. - /// - /// The number of the joystick button this is mapped to. + /// @return The number of the joystick button this is mapped to. int GetJoyButton() const { return m_JoyButtonMap; } - /// /// Sets the joystick button mapping. - /// - /// The number of the joystick button this should be mapped to. + /// @param newButton The number of the joystick button this should be mapped to. void SetJoyButton(int newButton) { m_JoyButtonMap = newButton; } - /// /// Gets the joystick axis number that this is mapped to. - /// - /// The joystick axis number. + /// @return The joystick axis number. int GetAxis() const { return m_AxisMap; } #pragma endregion @@ -135,9 +103,7 @@ namespace RTE { private: static const std::string c_ClassName; //!< A string with the friendly-formatted type name of this object. - /// /// Clears all the member variables of this InputMapping, effectively resetting the members of this abstraction level only. - /// void Clear(); }; } // namespace RTE diff --git a/Source/System/InputScheme.cpp b/Source/System/InputScheme.cpp index 3c8d4b19a1..e8092c95d9 100644 --- a/Source/System/InputScheme.cpp +++ b/Source/System/InputScheme.cpp @@ -5,8 +5,6 @@ namespace RTE { const std::string InputScheme::c_ClassName = "InputScheme"; - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void InputScheme::Clear() { m_ActiveDevice = InputDevice::DEVICE_KEYB_ONLY; m_SchemePreset = InputPreset::NoPreset; @@ -19,8 +17,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int InputScheme::Create(const InputScheme& reference) { m_ActiveDevice = reference.m_ActiveDevice; m_SchemePreset = reference.m_SchemePreset; @@ -34,8 +30,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int InputScheme::ReadProperty(const std::string_view& propName, Reader& reader) { StartPropertyList(return Serializable::ReadProperty(propName, reader)); @@ -75,8 +69,6 @@ namespace RTE { EndPropertyList; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int InputScheme::Save(Writer& writer) const { Serializable::Save(writer); @@ -120,8 +112,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void InputScheme::ResetToPlayerDefaults(Players player) { switch (player) { case Players::PlayerOne: @@ -149,8 +139,6 @@ namespace RTE { m_DigitalAimSpeed = 1.0F; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void InputScheme::SetPreset(InputPreset schemePreset) { m_SchemePreset = schemePreset; @@ -365,8 +353,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - std::string InputScheme::GetMappingName(int whichElement) const { const InputMapping* inputElement = &(m_InputMappings.at(whichElement)); if (m_SchemePreset != InputScheme::InputPreset::NoPreset && !inputElement->GetPresetDescription().empty()) { @@ -404,8 +390,6 @@ namespace RTE { return ""; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool InputScheme::CaptureKeyMapping(int whichInput) { for (int whichKey = SDL_SCANCODE_A; whichKey < SDL_NUM_SCANCODES; ++whichKey) { // Don't allow mapping special keys used by UInputMan. @@ -421,8 +405,6 @@ namespace RTE { return false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool InputScheme::CaptureJoystickMapping(int whichJoy, int whichInput) { if (whichJoy < 0) { return false; diff --git a/Source/System/InputScheme.h b/Source/System/InputScheme.h index 8eef7b10d5..89efe8f8e4 100644 --- a/Source/System/InputScheme.h +++ b/Source/System/InputScheme.h @@ -6,18 +6,14 @@ namespace RTE { - /// /// A complete input configuration scheme description for a single player. - /// class InputScheme : public Serializable { public: SerializableClassNameGetter; SerializableOverrideMethods; - /// /// Enumeration for different input scheme presets. - /// enum InputPreset { NoPreset, PresetArrowKeys, @@ -32,151 +28,107 @@ namespace RTE { }; #pragma region Creation - /// /// Constructor method used to instantiate an InputScheme object in system memory. Create() should be called before using the object. - /// InputScheme() { Clear(); } - /// /// Creates an InputScheme to be identical to another, by deep copy. - /// - /// A reference to the InputScheme to deep copy. - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @param reference A reference to the InputScheme to deep copy. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create(const InputScheme& reference); #pragma endregion #pragma region Destruction - /// /// Resets the entire InputScheme, including its inherited members, to their default settings or values. - /// void Reset() override { Clear(); } - /// /// Resets this InputScheme to the specified player's default input device and mappings. - /// - /// The preset player defaults this InputScheme should reset to. + /// @param player The preset player defaults this InputScheme should reset to. void ResetToPlayerDefaults(Players player); #pragma endregion #pragma region Getters and Setters - /// /// Gets the InputDevice that this scheme is using. - /// - /// The InputDevice of this scheme. See InputDevice enumeration. + /// @return The InputDevice of this scheme. See InputDevice enumeration. InputDevice GetDevice() const { return m_ActiveDevice; } - /// /// Sets the InputDevice this scheme is supposed to use. - /// - /// The InputDevice this scheme should use. See InputDevice enumeration. + /// @param activeDevice The InputDevice this scheme should use. See InputDevice enumeration. void SetDevice(InputDevice activeDevice = InputDevice::DEVICE_KEYB_ONLY) { m_ActiveDevice = activeDevice; } - /// /// Gets the InputPreset that this scheme is using. - /// - /// The InputPreset of this scheme. See InputPreset enumeration. + /// @return The InputPreset of this scheme. See InputPreset enumeration. InputPreset GetPreset() const { return m_SchemePreset; } - /// /// Sets up a specific preset scheme that is sensible and recommended. - /// - /// The preset number to set the scheme to match. See InputPreset enumeration. + /// @param schemePreset The preset number to set the scheme to match. See InputPreset enumeration. void SetPreset(InputPreset schemePreset = InputPreset::NoPreset); - /// /// Gets the InputMappings for this. - /// - /// The input mappings array, which is INPUT_COUNT large. + /// @return The input mappings array, which is INPUT_COUNT large. std::array* GetInputMappings() { return &m_InputMappings; } #pragma endregion #pragma region Input Mapping Getters and Setters - /// /// Gets the name of the key/mouse/joystick button/direction that a particular input element is mapped to. - /// - /// Which input element to look up. - /// A string with the appropriate clear text description of the mapped thing. + /// @param whichElement Which input element to look up. + /// @return A string with the appropriate clear text description of the mapped thing. std::string GetMappingName(int whichElement) const; - /// /// Gets which keyboard key is mapped to a specific input element. - /// - /// Which input element to look up. - /// Which keyboard key is mapped to the specified element. + /// @param whichInput Which input element to look up. + /// @return Which keyboard key is mapped to the specified element. int GetKeyMapping(int whichInput) const { return m_InputMappings.at(whichInput).GetKey(); } - /// /// Sets a keyboard key as mapped to a specific input element. - /// - /// Which input element to map to. - /// The scan code of which keyboard key to map to above input element. + /// @param whichInput Which input element to map to. + /// @param whichKey The scan code of which keyboard key to map to above input element. void SetKeyMapping(int whichInput, int whichKey) { m_InputMappings.at(whichInput).SetKey(whichKey); } - /// /// Gets which joystick button is mapped to a specific input element. - /// - /// Which input element to look up. - /// Which joystick button is mapped to the specified element. + /// @param whichInput Which input element to look up. + /// @return Which joystick button is mapped to the specified element. int GetJoyButtonMapping(int whichInput) const { return m_InputMappings.at(whichInput).GetJoyButton(); } - /// /// Sets a joystick button as mapped to a specific input element. - /// - /// Which input element to map to. - /// Which joystick button to map to the specified input element. + /// @param whichInput Which input element to map to. + /// @param whichButton Which joystick button to map to the specified input element. void SetJoyButtonMapping(int whichInput, int whichButton) { m_InputMappings.at(whichInput).SetJoyButton(whichButton); } - /// /// Get the deadzone value for this control scheme. - /// - /// Joystick dead zone from 0.0 to 1.0. + /// @return Joystick dead zone from 0.0 to 1.0. float GetJoystickDeadzone() const { return m_JoystickDeadzone; } - /// /// Set the deadzone value for this control scheme. - /// - /// Joystick dead zone from 0.0 to 1.0. + /// @param deadzoneValue Joystick dead zone from 0.0 to 1.0. void SetJoystickDeadzone(float deadzoneValue) { m_JoystickDeadzone = deadzoneValue; } - /// /// Get the DeadZoneType for this control scheme. - /// - /// The DeadZoneType this scheme is set to use. See DeadZoneType enumeration. + /// @return The DeadZoneType this scheme is set to use. See DeadZoneType enumeration. DeadZoneType GetJoystickDeadzoneType() const { return m_JoystickDeadzoneType; } - /// /// Set the DeadZoneType for this control scheme. - /// - /// The DeadZoneType this scheme should use. See DeadZoneType enumeration. + /// @param deadzoneType The DeadZoneType this scheme should use. See DeadZoneType enumeration. void SetJoystickDeadzoneType(DeadZoneType deadzoneType) { m_JoystickDeadzoneType = deadzoneType; } - /// /// Get the digital aim speed multiplier for this control scheme. - /// - /// The digital aim speed set to this scheme. + /// @return The digital aim speed set to this scheme. float GetDigitalAimSpeed() const { return m_DigitalAimSpeed; } #pragma endregion #pragma region Input Mapping Capture Handling - /// /// Clears all mappings for a specific input element. - /// - /// Which input element to clear all mappings of. + /// @param whichInput Which input element to clear all mappings of. void ClearMapping(int whichInput) { m_InputMappings.at(whichInput).Reset(); } - /// /// Checks for any key press this frame and creates an input mapping accordingly. - /// - /// Which input element to map for. - /// Whether there were any key presses this frame and therefore whether a mapping was successfully captured or not. + /// @param whichInput Which input element to map for. + /// @return Whether there were any key presses this frame and therefore whether a mapping was successfully captured or not. bool CaptureKeyMapping(int whichInput); - /// /// Checks for any button or direction press this frame and creates an input mapping accordingly. - /// - /// Which joystick to scan for button and stick presses. - /// Which input element to map for. - /// Whether there were any button or stick presses this frame and therefore whether a mapping was successfully captured or not. + /// @param whichJoy Which joystick to scan for button and stick presses. + /// @param whichInput Which input element to map for. + /// @return Whether there were any button or stick presses this frame and therefore whether a mapping was successfully captured or not. bool CaptureJoystickMapping(int whichJoy, int whichInput); #pragma endregion @@ -193,9 +145,7 @@ namespace RTE { private: static const std::string c_ClassName; //!< A string with the friendly-formatted type name of this object. - /// /// Clears all the member variables of this InputScheme, effectively resetting the members of this abstraction level only. - /// void Clear(); }; } // namespace RTE diff --git a/Source/System/Matrix.cpp b/Source/System/Matrix.cpp index a85df72cab..73aa25abc2 100644 --- a/Source/System/Matrix.cpp +++ b/Source/System/Matrix.cpp @@ -4,8 +4,6 @@ namespace RTE { const std::string Matrix::c_ClassName = "Matrix"; - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void Matrix::Clear() { m_Rotation = 0; m_Flipped[X] = false; @@ -17,8 +15,6 @@ namespace RTE { m_Elements[1][1] = 1.0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int Matrix::Create() { // Read all the properties if (Serializable::Create() < 0) { @@ -29,8 +25,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int Matrix::Create(float angle) { m_Rotation = angle; m_ElementsUpdated = true; @@ -46,8 +40,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int Matrix::Create(const Matrix& reference) { m_Rotation = reference.m_Rotation; m_Flipped[X] = reference.m_Flipped[X]; @@ -57,8 +49,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int Matrix::ReadProperty(const std::string_view& propName, Reader& reader) { StartPropertyList(return Serializable::ReadProperty(propName, reader)); @@ -72,8 +62,6 @@ namespace RTE { EndPropertyList; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int Matrix::Save(Writer& writer) const { Serializable::Save(writer); @@ -82,8 +70,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - float Matrix::GetRadAngleTo(float otherAngle) const { // Rotate this' angle with the other angle so that the sought after difference angle is between the resulting angle and the x-axis float difference = otherAngle - GetRadAngle(); @@ -100,8 +86,6 @@ namespace RTE { return difference; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - float Matrix::GetDegAngleTo(float otherAngle) const { // Rotate this' angle with the other angle so that the sought after difference angle is between the resulting angle and the x-axis float difference = otherAngle - GetDegAngle(); @@ -118,8 +102,6 @@ namespace RTE { return difference; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - Matrix& Matrix::operator=(const Matrix& rhs) { if (*this == rhs) { return *this; @@ -132,8 +114,6 @@ namespace RTE { return *this; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - Vector Matrix::operator*(const Vector& rhs) { if (!m_ElementsUpdated) { UpdateElements(); @@ -150,8 +130,6 @@ namespace RTE { return retVec; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - Vector Matrix::operator/(const Vector& rhs) { if (!m_ElementsUpdated) { UpdateElements(); @@ -168,8 +146,6 @@ namespace RTE { return retVec; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - Matrix Matrix::operator-() { m_Rotation = -m_Rotation; @@ -182,8 +158,6 @@ namespace RTE { return *this; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void Matrix::UpdateElements() { // Negative angle to Account for upside-down coordinate system. const float CosAngle = std::cos(-m_Rotation); diff --git a/Source/System/Matrix.h b/Source/System/Matrix.h index d9a45f0190..5704d406b9 100644 --- a/Source/System/Matrix.h +++ b/Source/System/Matrix.h @@ -6,9 +6,7 @@ namespace RTE { - /// /// A 2x2 matrix to rotate 2D Vectors with. - /// class Matrix : public Serializable { public: @@ -21,250 +19,190 @@ namespace RTE { bool m_ElementsUpdated; //!< Whether the elements are currently updated to the set angle. #pragma region Creation - /// /// Constructor method used to instantiate a Matrix object. - /// Matrix() { Clear(); } - /// /// Constructor method used to instantiate a Matrix object from an angle. - /// - /// A float of an angle in radians that this Matrix should be set to represent. + /// @param radAng A float of an angle in radians that this Matrix should be set to represent. Matrix(float radAng) { Clear(); Create(radAng); } - /// /// Copy constructor method used to instantiate a Matrix object identical to an already existing one. - /// - /// A Matrix object which is passed in by reference. + /// @param reference A Matrix object which is passed in by reference. Matrix(const Matrix& reference) { Clear(); Create(reference); } - /// /// Makes the Matrix object ready for use. - /// - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create() override; - /// /// Makes the Matrix object ready for use. - /// - /// The float angle in radians which this rotational matrix should represent. - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @param angle The float angle in radians which this rotational matrix should represent. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create(float angle); - /// /// Creates a Matrix to be identical to another, by deep copy. - /// - /// A reference to the Matrix to deep copy. - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @param reference A reference to the Matrix to deep copy. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create(const Matrix& reference); #pragma endregion #pragma region Destruction - /// /// Resets this Matrix to an identity Matrix, representing a 0 angle. - /// void Reset() { Clear(); } #pragma endregion #pragma region Getters and Setters - /// /// Gets whether or not this Matrix also mirrors the X component of any Vector it is multiplied with. - /// - /// A bool with the setting whether flipping the X components or not. + /// @return A bool with the setting whether flipping the X components or not. bool GetXFlipped() const { return m_Flipped[X]; } - /// /// Sets whether or not this Matrix should also mirror the X component of any Vector it is multiplied with. - /// - /// A bool with the setting whether to flip the X components or not. + /// @param flipX A bool with the setting whether to flip the X components or not. void SetXFlipped(bool flipX = true) { m_Flipped[X] = flipX; } - /// /// Gets whether or not this Matrix also mirrors the Y component of any Vector it is multiplied with. - /// - /// A bool with the setting whether flipping the Y components or not. + /// @return A bool with the setting whether flipping the Y components or not. bool GetYFlipped() const { return m_Flipped[Y]; } - /// /// Sets whether or not this Matrix should also mirror the Y component of any Vector it is multiplied with. - /// - /// A bool with the setting whether to flip the Y components or not. + /// @param flipY A bool with the setting whether to flip the Y components or not. void SetYFlipped(bool flipY = true) { m_Flipped[Y] = flipY; } - /// /// Returns the angle this rotational Matrix is currently representing. - /// - /// A float with the represented angle in radians. + /// @return A float with the represented angle in radians. float GetRadAngle() const { return m_Rotation; } - /// /// Sets the angle that this rotational Matrix should represent. - /// - /// A float with the new angle, in radians. + /// @param newAngle A float with the new angle, in radians. void SetRadAngle(float newAngle) { m_Rotation = newAngle; m_ElementsUpdated = false; } - /// /// Returns the angle this rotational Matrix is currently representing. - /// - /// A float with the represented angle in degrees. + /// @return A float with the represented angle in degrees. float GetDegAngle() const { return (m_Rotation / c_PI) * 180.0F; } - /// /// Sets the angle that this rotational Matrix should represent. - /// - /// A float with the new angle, in degrees. + /// @param newAngle A float with the new angle, in degrees. void SetDegAngle(float newAngle) { m_Rotation = (newAngle / 180.0F) * c_PI; m_ElementsUpdated = false; } - /// /// Returns the angle difference between what this is currently representing, to another angle in radians. /// It will wrap and normalize and give the smallest angle difference between this and the passed in. - /// - /// A float with the angle to get the difference to from this, in radians. - /// A float with the difference angle between this and the passed-in angle. + /// @param otherAngle A float with the angle to get the difference to from this, in radians. + /// @return A float with the difference angle between this and the passed-in angle. float GetRadAngleTo(float otherAngle) const; - /// /// Returns the angle difference between what this is currently representing, to another angle in degrees. /// It will wrap and normalize and give the smallest angle difference between this and the passed in. - /// - /// A float with the angle to get the difference to from this, in degrees. - /// A float with the difference angle between this and the passed-in angle. + /// @param otherAngle A float with the angle to get the difference to from this, in degrees. + /// @return A float with the difference angle between this and the passed-in angle. float GetDegAngleTo(float otherAngle) const; - /// /// Returns the angle this rotational Matrix is currently representing. - /// - /// A float with the represented angle as full rotations being 256. + /// @return A float with the represented angle as full rotations being 256. float GetAllegroAngle() const { return (m_Rotation / c_PI) * -128.0F; } #pragma endregion #pragma region Operator Overloads - /// /// An assignment operator for setting one Matrix equal to another. - /// - /// A Matrix reference. - /// A reference to the changed Matrix. + /// @param rhs A Matrix reference. + /// @return A reference to the changed Matrix. Matrix& operator=(const Matrix& rhs); - /// /// An assignment operator for setting one Matrix to represent an angle. - /// - /// A float in radians to set this rotational Matrix to. - /// A reference to the changed Matrix. + /// @param rhs A float in radians to set this rotational Matrix to. + /// @return A reference to the changed Matrix. Matrix& operator=(const float& rhs) { m_Rotation = rhs; m_ElementsUpdated = false; return *this; } - /// /// Unary negation overload for single Matrices. - /// - /// The resulting Matrix. + /// @return The resulting Matrix. Matrix operator-(); - /// /// An equality operator for testing if any two Matrices are equal. - /// - /// A Matrix reference as the left hand side operand. - /// A Matrix reference as the right hand side operand. - /// A boolean indicating whether the two operands are equal or not. + /// @param lhs A Matrix reference as the left hand side operand. + /// @param rhs A Matrix reference as the right hand side operand. + /// @return A boolean indicating whether the two operands are equal or not. friend bool operator==(const Matrix& lhs, const Matrix& rhs) { return lhs.m_Rotation == rhs.m_Rotation; } - /// /// An inequality operator for testing if any two Matrices are unequal. - /// - /// A Matrix reference as the left hand side operand. - /// A Matrix reference as the right hand side operand. - /// A boolean indicating whether the two operands are unequal or not. + /// @param lhs A Matrix reference as the left hand side operand. + /// @param rhs A Matrix reference as the right hand side operand. + /// @return A boolean indicating whether the two operands are unequal or not. friend bool operator!=(const Matrix& lhs, const Matrix& rhs) { return !operator==(lhs, rhs); } - /// /// Self-addition operator overload for a Matrix and a float. - /// - /// A float reference as the right hand side operand. - /// A reference to the resulting Matrix. + /// @param rhs A float reference as the right hand side operand. + /// @return A reference to the resulting Matrix. Matrix& operator+=(const float& rhs) { m_Rotation += rhs; m_ElementsUpdated = false; return *this; } - /// /// Self-addition operator overload for Matrices. - /// - /// A Matrix reference as the left hand side operand. - /// A Matrix reference as the right hand side operand. - /// A reference to the resulting Matrix (the left one). + /// @param lhs A Matrix reference as the left hand side operand. + /// @param rhs A Matrix reference as the right hand side operand. + /// @return A reference to the resulting Matrix (the left one). friend Matrix& operator+=(Matrix& lhs, const Matrix& rhs) { lhs.m_Rotation += rhs.m_Rotation; lhs.m_ElementsUpdated = false; return lhs; } - /// /// Self-subtraction operator overload for a Matrix and a float. - /// - /// A float reference as the right hand side operand. - /// A reference to the resulting Matrix. + /// @param rhs A float reference as the right hand side operand. + /// @return A reference to the resulting Matrix. Matrix& operator-=(const float& rhs) { m_Rotation -= rhs; m_ElementsUpdated = false; return *this; } - /// /// Self-subtraction operator overload for Matrices. - /// - /// A Matrix reference as the left hand side operand. - /// A Matrix reference as the right hand side operand. - /// A reference to the resulting Matrix (the left one). + /// @param lhs A Matrix reference as the left hand side operand. + /// @param rhs A Matrix reference as the right hand side operand. + /// @return A reference to the resulting Matrix (the left one). friend Matrix& operator-=(Matrix& lhs, const Matrix& rhs) { lhs.m_Rotation -= rhs.m_Rotation; lhs.m_ElementsUpdated = false; return lhs; } - /// /// Self-multiplication operator overload for a Matrix and a float. - /// - /// A float reference as the right hand side operand. - /// A reference to the resulting Matrix. + /// @param rhs A float reference as the right hand side operand. + /// @return A reference to the resulting Matrix. Matrix& operator*=(const float& rhs) { m_Rotation *= rhs; m_ElementsUpdated = false; return *this; } - /// /// Self-multiplication operator overload for Matrices. - /// - /// A Matrix reference as the left hand side operand. - /// A Matrix reference as the right hand side operand. - /// A reference to the resulting Matrix (the left one). + /// @param lhs A Matrix reference as the left hand side operand. + /// @param rhs A Matrix reference as the right hand side operand. + /// @return A reference to the resulting Matrix (the left one). friend Matrix& operator*=(Matrix& lhs, const Matrix& rhs) { lhs.m_Rotation *= rhs.m_Rotation; lhs.m_ElementsUpdated = false; return lhs; } - /// /// self-division operator overload for a Matrix and a float. - /// - /// A float reference as the right hand side operand. - /// A reference to the resulting Matrix. + /// @param rhs A float reference as the right hand side operand. + /// @return A reference to the resulting Matrix. Matrix& operator/=(const float& rhs) { if (rhs) { m_Rotation /= rhs; @@ -273,12 +211,10 @@ namespace RTE { return *this; } - /// /// Self-division operator overload for Matrices. - /// - /// A Matrix reference as the left hand side operand. - /// A Matrix reference as the right hand side operand. - /// A reference to the resulting Matrix (the left one). + /// @param lhs A Matrix reference as the left hand side operand. + /// @param rhs A Matrix reference as the right hand side operand. + /// @return A reference to the resulting Matrix (the left one). friend Matrix& operator/=(Matrix& lhs, const Matrix& rhs) { if (rhs.m_Rotation) { lhs.m_Rotation /= rhs.m_Rotation; @@ -287,68 +223,52 @@ namespace RTE { return lhs; } - /// /// Multiplication operator overload for a Matrix and a Vector. The vector will be transformed according to the Matrix's elements. /// Flipping, if set, is performed before rotating. - /// - /// A Vector reference as the right hand side operand. - /// The resulting transformed Vector. + /// @param rhs A Vector reference as the right hand side operand. + /// @return The resulting transformed Vector. Vector operator*(const Vector& rhs); - /// /// Multiplication operator overload for Vectors with Matrices. - /// - /// A Vector reference as the left hand side operand. - /// A Matrix reference as the right hand side operand. - /// A reference to the resulting Vector. + /// @param lhs A Vector reference as the left hand side operand. + /// @param rhs A Matrix reference as the right hand side operand. + /// @return A reference to the resulting Vector. friend Vector operator*(const Vector& lhs, const Matrix& rhs) { Matrix m(rhs); return m * lhs; } - /// /// Division operator overload for a Matrix and a Vector. The vector will be transformed according to the Matrix's elements. - /// - /// A Vector reference as the right hand side operand. - /// The resulting transformed Vector. + /// @param rhs A Vector reference as the right hand side operand. + /// @return The resulting transformed Vector. Vector operator/(const Vector& rhs); - /// /// Division operator overload for Vector:s with Matrices. - /// - /// A Vector reference as the left hand side operand. - /// A Matrix reference as the right hand side operand. - /// A reference to the resulting Vector. + /// @param lhs A Vector reference as the left hand side operand. + /// @param rhs A Matrix reference as the right hand side operand. + /// @return A reference to the resulting Vector. friend Vector operator/(const Vector& lhs, Matrix& rhs) { return rhs / lhs; } - /// /// Self-multiplication operator overload for Vector with a Matrix. - /// - /// A Vector reference as the left hand side operand. - /// A Matrix reference as the right hand side operand. - /// A reference to the resulting Vector (the left one) + /// @param lhs A Vector reference as the left hand side operand. + /// @param rhs A Matrix reference as the right hand side operand. + /// @return A reference to the resulting Vector (the left one) friend Vector& operator*=(Vector& lhs, Matrix& rhs) { return lhs = rhs * lhs; } - /// /// Self-division operator overload for Vector with a Matrix. - /// - /// A Vector reference as the left hand side operand. - /// A Matrix reference as the right hand side operand. - /// A reference to the resulting Vector (the left one). + /// @param lhs A Vector reference as the left hand side operand. + /// @param rhs A Matrix reference as the right hand side operand. + /// @return A reference to the resulting Vector (the left one). friend Vector& operator/=(Vector& lhs, Matrix& rhs) { return lhs = rhs / lhs; } #pragma endregion private: static const std::string c_ClassName; //!< A string with the friendly-formatted type name of this. - /// /// Makes the elements of this matrix update to represent the set angle. - /// void UpdateElements(); - /// /// Clears all the member variables of this Matrix, effectively resetting the members of this abstraction level only. - /// void Clear(); }; } // namespace RTE diff --git a/Source/System/NetworkMessages.h b/Source/System/NetworkMessages.h index dd9d61c50e..68f6582b84 100644 --- a/Source/System/NetworkMessages.h +++ b/Source/System/NetworkMessages.h @@ -6,9 +6,7 @@ namespace RTE { - /// /// Enumeration for the different types of network message IDs. - /// enum CustomMessageIDTypes { ID_CUSTOM_START = ID_USER_PACKET_ENUM, ID_NAT_SERVER_REGISTER_SERVER, @@ -42,9 +40,7 @@ namespace RTE { // TODO: Figure out all these and add comments. - /// /// - /// struct MsgRegisterServer { unsigned char Id; @@ -53,16 +49,12 @@ namespace RTE { char ServerGuid[64]; }; - /// /// - /// struct MsgRegisterServerAccepted { unsigned char Id; }; - /// /// - /// struct MsgGetServerRequest { unsigned char Id; @@ -70,25 +62,19 @@ namespace RTE { char ServerPassword[64]; }; - /// /// - /// struct MsgGetServerAnswer { unsigned char Id; char ServerGuid[64]; }; - /// /// - /// struct MsgGetServerNoAnswer { unsigned char Id; }; - /// /// - /// struct MsgRegister { unsigned char Id; @@ -98,9 +84,7 @@ namespace RTE { char Name[64]; }; - /// /// - /// struct MsgFrameSetup { unsigned char Id; unsigned char FrameNumber; @@ -118,9 +102,7 @@ namespace RTE { float OffsetY[c_MaxLayersStoredForNetwork]; }; - /// /// - /// struct MsgFrameLine { unsigned char Id; unsigned char FrameNumber; @@ -131,9 +113,7 @@ namespace RTE { unsigned short int UncompressedSize; }; - /// /// - /// struct MsgFrameBox { unsigned char Id; @@ -143,23 +123,17 @@ namespace RTE { unsigned short int DataSize; }; - /// /// - /// struct MsgDisconnect { unsigned char Id; }; - /// /// - /// struct MsgAccepted { unsigned char Id; }; - /// /// - /// struct LightweightSceneLayer { size_t BitmapHash; bool DrawTrans; @@ -185,9 +159,7 @@ namespace RTE { unsigned char FillDownColor; }; - /// /// - /// struct MsgSceneSetup { unsigned char Id; unsigned char SceneId; @@ -199,9 +171,7 @@ namespace RTE { LightweightSceneLayer BackgroundLayers[c_MaxLayersStoredForNetwork]; }; - /// /// - /// struct MsgSceneLine { unsigned char Id; unsigned char SceneId; @@ -213,23 +183,17 @@ namespace RTE { unsigned short int UncompressedSize; }; - /// /// - /// struct MsgSceneEnd { unsigned char Id; }; - /// /// - /// struct MsgSceneAccepted { unsigned char Id; }; - /// /// - /// struct MsgTerrainChange { unsigned char Id; @@ -244,9 +208,7 @@ namespace RTE { unsigned short int UncompressedSize; }; - /// /// - /// struct PostEffectNetworkData { short int X; short int Y; @@ -255,36 +217,28 @@ namespace RTE { float Angle; }; - /// /// - /// struct MsgPostEffects { unsigned char Id; unsigned char FrameNumber; int PostEffectsCount; }; - /// /// - /// struct MsgSoundEvents { unsigned char Id; unsigned char FrameNumber; int SoundEventsCount; }; - /// /// - /// struct MsgMusicEvents { unsigned char Id; unsigned char FrameNumber; int MusicEventsCount; }; - /// /// - /// struct MsgInput { unsigned char Id; diff --git a/Source/System/PathFinder.cpp b/Source/System/PathFinder.cpp index fc8e8c6d50..acd7c5c051 100644 --- a/Source/System/PathFinder.cpp +++ b/Source/System/PathFinder.cpp @@ -29,8 +29,6 @@ namespace RTE { // TODO: Enhance MicroPather to add that capability (or write our own pather)! thread_local float s_DigStrength = 0.0F; - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - PathNode::PathNode(const Vector& pos) : Pos(pos) { const Material* outOfBounds = g_SceneMan.GetMaterialFromID(MaterialColorKeys::g_MaterialOutOfBounds); @@ -40,15 +38,11 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PathFinder::Clear() { m_NodeGrid.clear(); m_NodeDimension = SCENEGRIDSIZE; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int PathFinder::Create(int nodeDimension) { RTEAssert(g_SceneMan.GetScene(), "Scene doesn't exist or isn't loaded when creating PathFinder!"); @@ -112,14 +106,10 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PathFinder::Destroy() { Clear(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - MicroPather* PathFinder::GetPather() { // TODO: cache a collection of pathers. For async pathfinding right now we create a new pather for every thread! if (!s_Pather.m_Instance || s_Pather.m_Instance->GetGraph() != this) { @@ -136,8 +126,6 @@ namespace RTE { return s_Pather.m_Instance; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int PathFinder::CalculatePath(Vector start, Vector end, std::list& pathResult, float& totalCostResult, float digStrength) { ZoneScoped; @@ -205,8 +193,6 @@ namespace RTE { return result; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - std::shared_ptr PathFinder::CalculatePathAsync(Vector start, Vector end, float digStrength, PathCompleteCallback callback) { std::shared_ptr pathRequest = std::make_shared(); @@ -235,8 +221,6 @@ namespace RTE { return pathRequest; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PathFinder::RecalculateAllCosts() { RTEAssert(g_SceneMan.GetScene(), "Scene doesn't exist or isn't loaded when recalculating PathFinder!"); @@ -253,8 +237,6 @@ namespace RTE { UpdateNodeList(pathNodesIdsVec); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - std::vector PathFinder::RecalculateAreaCosts(std::deque& boxList, int nodeUpdateLimit) { ZoneScoped; @@ -285,14 +267,10 @@ namespace RTE { return nodeVec; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - float PathFinder::LeastCostEstimate(void* startState, void* endState) { return g_SceneMan.ShortestDistance((static_cast(startState))->Pos, (static_cast(endState))->Pos).GetMagnitude() / m_NodeDimension; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PathFinder::AdjacentCost(void* state, std::vector* adjacentList) { const PathNode* node = static_cast(state); micropather::StateCost adjCost; @@ -350,8 +328,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool PathFinder::PositionsAreTheSamePathNode(const Vector& pos1, const Vector& pos2) const { int startNodeX = std::floor(pos1.m_X / static_cast(m_NodeDimension)); int startNodeY = std::floor(pos1.m_Y / static_cast(m_NodeDimension)); @@ -360,8 +336,6 @@ namespace RTE { return startNodeX == endNodeX && startNodeY == endNodeY; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - float PathFinder::GetMaterialTransitionCost(const Material& material) const { float strength = material.GetIntegrity(); // Always treat doors as diggable. @@ -371,14 +345,10 @@ namespace RTE { return strength; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - const Material* PathFinder::StrongestMaterialAlongLine(const Vector& start, const Vector& end) const { return g_SceneMan.CastMaxStrengthRayMaterial(start, end, 0, MaterialColorKeys::g_MaterialAir); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool PathFinder::UpdateNodeCosts(PathNode* node) const { if (!node) { return false; @@ -426,8 +396,6 @@ namespace RTE { return false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - std::vector PathFinder::GetNodeIdsInBox(Box box) { std::vector result; @@ -452,8 +420,6 @@ namespace RTE { return result; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - float PathFinder::GetNodeAverageTransitionCost(const PathNode& node) const { float totalCostOfAdjacentNodes = 0.0F; int count = 0; @@ -468,8 +434,6 @@ namespace RTE { return totalCostOfAdjacentNodes / std::max(static_cast(count), 1.0F); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool PathFinder::UpdateNodeList(const std::vector& nodeVec) { ZoneScoped; @@ -513,8 +477,6 @@ namespace RTE { return anyChange; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PathFinder::MarkBoxNavigatable(Box box, bool navigatable) { std::vector pathNodesInBox = GetNodeIdsInBox(box); std::for_each( @@ -527,8 +489,6 @@ namespace RTE { }); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PathFinder::MarkAllNodesNavigatable(bool navigatable) { std::vector pathNodesIdsVec; pathNodesIdsVec.reserve(m_NodeGrid.size()); @@ -546,15 +506,11 @@ namespace RTE { }); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - PathNode* PathFinder::GetPathNodeAtGridCoords(int x, int y) { int nodeId = ConvertCoordsToNodeId(x, y); return nodeId != -1 ? &m_NodeGrid[nodeId] : nullptr; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int PathFinder::ConvertCoordsToNodeId(int x, int y) { if (m_WrapsX) { x = x % m_GridWidth; diff --git a/Source/System/PathFinder.h b/Source/System/PathFinder.h index 284d131131..7485e0ae15 100644 --- a/Source/System/PathFinder.h +++ b/Source/System/PathFinder.h @@ -11,9 +11,7 @@ namespace RTE { class Scene; class Material; - /// /// Information required to make an async pathing request. - /// struct PathRequest { bool complete = false; int status = MicroPather::NO_SOLUTION; @@ -26,9 +24,7 @@ namespace RTE { using PathCompleteCallback = std::function)>; - /// /// Contains everything related to a PathNode on the path grid used by PathFinder. - /// struct PathNode { static constexpr int c_MaxAdjacentNodeCount = 8; //!< The maximum number of adjacent PathNodes to any given PathNode. Thusly, also the number of directions for PathNodes to be in. @@ -37,9 +33,7 @@ namespace RTE { bool m_Navigatable; //!< Whether this node can be navigated through. - /// /// Pointers to all adjacent PathNodes, in clockwise order with top first. These are not owned, and may be 0 if adjacent to non-wrapping scene border. - /// std::array AdjacentNodes; PathNode*& Up = AdjacentNodes[0]; PathNode*& UpRight = AdjacentNodes[1]; @@ -50,9 +44,7 @@ namespace RTE { PathNode*& Left = AdjacentNodes[6]; PathNode*& LeftUp = AdjacentNodes[7]; - /// /// The strongest material between us and our adjacent PathNodes, in clockwise order with top first. - /// std::array AdjacentNodeBlockingMaterials; const Material*& UpMaterial = AdjacentNodeBlockingMaterials[0]; const Material*& UpRightMaterial = AdjacentNodeBlockingMaterials[1]; @@ -63,152 +55,115 @@ namespace RTE { const Material*& LeftMaterial = AdjacentNodeBlockingMaterials[6]; const Material*& LeftUpMaterial = AdjacentNodeBlockingMaterials[7]; - /// /// Constructor method used to instantiate a PathNode object in system memory and make it ready for use. - /// - /// Absolute position of the center of the PathNode in the scene. + /// @param pos Absolute position of the center of the PathNode in the scene. explicit PathNode(const Vector& pos); }; - /// /// A class encapsulating and implementing the MicroPather A* pathfinding library. - /// class PathFinder : public Graph { public: #pragma region Creation - /// /// Constructor method used to instantiate a PathFinder object. - /// - /// The width and height in scene pixels that of each PathNode should represent. - /// The block size that the PathNode cache is allocated from. Should be about a fourth of the total number of PathNodes. + /// @param nodeDimension The width and height in scene pixels that of each PathNode should represent. + /// @param allocate The block size that the PathNode cache is allocated from. Should be about a fourth of the total number of PathNodes. PathFinder(int nodeDimension) { Clear(); Create(nodeDimension); } - /// /// Makes the PathFinder object ready for use. - /// - /// The width and height in scene pixels that of each PathNode should represent. - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @param nodeDimension The width and height in scene pixels that of each PathNode should represent. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create(int nodeDimension); #pragma endregion #pragma region Destruction - /// /// Destructor method used to clean up a PathFinder object before deletion. - /// ~PathFinder() override { Destroy(); } - /// /// Destroys and resets (through Clear()) this PathFinder object. - /// void Destroy(); - /// /// Resets the entire PathFinder object to the default settings or values. - /// void Reset() { Clear(); } #pragma endregion #pragma region PathFinding - /// /// Calculates and returns the least difficult path between two points on the current scene. /// This is synchronous, and will block the current thread! - /// - /// Start positions on the scene to find the path between. - /// End positions on the scene to find the path between. - /// A list which will be filled out with waypoints between the start and end. - /// The total minimum difficulty cost calculated between the two points on the scene. - /// What material strength the search is capable of digging through. - /// Success or failure, expressed as SOLVED, NO_SOLUTION, or START_END_SAME. + /// @param start Start positions on the scene to find the path between. + /// @param end End positions on the scene to find the path between. + /// @param pathResult A list which will be filled out with waypoints between the start and end. + /// @param totalCostResult The total minimum difficulty cost calculated between the two points on the scene. + /// @param digStrength What material strength the search is capable of digging through. + /// @return Success or failure, expressed as SOLVED, NO_SOLUTION, or START_END_SAME. int CalculatePath(Vector start, Vector end, std::list& pathResult, float& totalCostResult, float digStrength); - /// /// Calculates and returns the least difficult path between two points on the current scene. /// This is asynchronous and thus will not block the current thread. - /// - /// Start positions on the scene to find the path between. - /// End positions on the scene to find the path between. - /// What material strength the search is capable of digging through. - /// The callback function to be run when the path calculation is completed. - /// A shared pointer to the volatile PathRequest to be used to track whether the asynchronous path calculation has been completed, and check its results. + /// @param start Start positions on the scene to find the path between. + /// @param end End positions on the scene to find the path between. + /// @param digStrength What material strength the search is capable of digging through. + /// @param callback The callback function to be run when the path calculation is completed. + /// @return A shared pointer to the volatile PathRequest to be used to track whether the asynchronous path calculation has been completed, and check its results. std::shared_ptr CalculatePathAsync(Vector start, Vector end, float digStrength, PathCompleteCallback callback = nullptr); // /// Returns how many pathfinding requests are currently active. - /// - /// How many pathfinding requests are currently active. + /// @return How many pathfinding requests are currently active. int GetCurrentPathingRequests() const { return m_CurrentPathingRequests.load(); } - /// /// Recalculates all the costs between all the PathNodes by tracing lines in the material layer and summing all the material strengths for each encountered pixel. Also resets the pather itself. - /// void RecalculateAllCosts(); - /// /// Recalculates the costs between all the PathNodes touching a deque of specific rectangular areas (which will be wrapped). Also resets the pather itself, if necessary. - /// - /// The deque of Boxes representing the updated areas. - /// The maximum number of PathNodes we'll try to update this frame. True PathNode update count can be higher if we received a big box, as we always do at least 1 box. - /// The set of PathNode ids that were updated. + /// @param boxList The deque of Boxes representing the updated areas. + /// @param nodeUpdateLimit The maximum number of PathNodes we'll try to update this frame. True PathNode update count can be higher if we received a big box, as we always do at least 1 box. + /// @return The set of PathNode ids that were updated. std::vector RecalculateAreaCosts(std::deque& boxList, int nodeUpdateLimit); - /// /// Updates a set of PathNodes, adjusting their transitions. /// This does NOT update the pather, which is required if PathNode costs changed. - /// - /// The set of PathNode IDs to update. - /// Whether any PathNode costs changed. + /// @param nodeVec The set of PathNode IDs to update. + /// @return Whether any PathNode costs changed. bool UpdateNodeList(const std::vector& nodeVec); - /// /// Implementation of the abstract interface of Graph. /// Gets the least possible cost to get from PathNode A to B, if it all was air. - /// - /// Pointer to PathNode to start from. OWNERSHIP IS NOT TRANSFERRED! - /// PathNode to end up at. OWNERSHIP IS NOT TRANSFERRED! - /// The cost of the absolutely fastest possible way between the two points, as if traveled through air all the way. + /// @param startState Pointer to PathNode to start from. OWNERSHIP IS NOT TRANSFERRED! + /// @param endState PathNode to end up at. OWNERSHIP IS NOT TRANSFERRED! + /// @return The cost of the absolutely fastest possible way between the two points, as if traveled through air all the way. float LeastCostEstimate(void* startState, void* endState) override; - /// /// Implementation of the abstract interface of Graph. /// Gets the cost to go to any adjacent PathNode of the one passed in. - /// - /// Pointer to PathNode to get to cost of all adjacents for. OWNERSHIP IS NOT TRANSFERRED! - /// An empty vector which will be filled out with all the valid PathNodes adjacent to the one passed in. If at non-wrapping edge of seam, those non existent PathNodes won't be added. + /// @param state Pointer to PathNode to get to cost of all adjacents for. OWNERSHIP IS NOT TRANSFERRED! + /// @param adjacentList An empty vector which will be filled out with all the valid PathNodes adjacent to the one passed in. If at non-wrapping edge of seam, those non existent PathNodes won't be added. void AdjacentCost(void* state, std::vector* adjacentList) override; - /// /// Returns whether two position represent the same path nodes. - /// - /// First coordinates to compare. - /// Second coordinates to compare. - /// Whether both coordinates represent the same path node. + /// @param pos1 First coordinates to compare. + /// @param pos2 Second coordinates to compare. + /// @return Whether both coordinates represent the same path node. bool PositionsAreTheSamePathNode(const Vector& pos1, const Vector& pos2) const; - /// /// Marks a box as being navigatable or not. - /// - /// The Box of which all PathNodes that should have their navigatable status changed. - /// Whether or not the nodes in this box should be navigatable. + /// @param box The Box of which all PathNodes that should have their navigatable status changed. + /// @param navigatable Whether or not the nodes in this box should be navigatable. void MarkBoxNavigatable(Box box, bool navigatable); - /// /// Marks a box as being navigatable or not. - /// - /// The Box of which all PathNodes that should have their navigatable status changed. - /// Whether or not the nodes in this box should be navigatable. + /// @param box The Box of which all PathNodes that should have their navigatable status changed. + /// @param navigatable Whether or not the nodes in this box should be navigatable. void MarkAllNodesNavigatable(bool navigatable); #pragma endregion #pragma region Misc - /// /// Implementation of the abstract interface of Graph. This function is only used in DEBUG mode - it dumps output to stdout. /// Since void* aren't really human readable, this will print out some concise info without an ending newline. - /// - /// The state to print out info about. + /// @param state The state to print out info about. void PrintStateInfo(void* state) override {} #pragma endregion @@ -224,70 +179,52 @@ namespace RTE { bool m_WrapsY; //!< Whether the pathing grid wraps on the Y axis. std::atomic m_CurrentPathingRequests; //!< The number of active async pathing requests. - /// /// Gets the pather for this thread. Lazily-initialized for each new thread that needs a pather. - /// - /// The pather for this thread. + /// @return The pather for this thread. MicroPather* GetPather(); #pragma region Path Cost Updates - /// /// Helper function for getting the strongest material we need to path though between PathNodes. - /// - /// Origin point. - /// Destination point. - /// The strongest material. + /// @param start Origin point. + /// @param end Destination point. + /// @return The strongest material. const Material* StrongestMaterialAlongLine(const Vector& start, const Vector& end) const; - /// /// Helper function for updating all the values of cost edges going out from a specific PathNodes. /// This does NOT update the pather, which is required before solving more paths after calling this. - /// - /// The PathNode to update all costs of. It's safe to pass nullptr here. OWNERSHIP IS NOT TRANSFERRED! - /// Whether the PathNodes costs changed. + /// @param node The PathNode to update all costs of. It's safe to pass nullptr here. OWNERSHIP IS NOT TRANSFERRED! + /// @return Whether the PathNodes costs changed. bool UpdateNodeCosts(PathNode* node) const; - /// /// Helper function for getting the PathNode ids in a Box. - /// - /// The Box of which all PathNodes it touches should be returned. - /// A list of the PathNode ids inside the box. + /// @param box The Box of which all PathNodes it touches should be returned. + /// @return A list of the PathNode ids inside the box. std::vector GetNodeIdsInBox(Box box); - /// /// Gets the cost for transitioning through this Material. - /// - /// The Material to get the transition cost for. - /// The transition cost for the Material. + /// @param material The Material to get the transition cost for. + /// @return The transition cost for the Material. float GetMaterialTransitionCost(const Material& material) const; - /// /// Gets the average cost for all transitions out of this PathNode, ignoring infinities/unpathable transitions. - /// - /// The PathNode to get the average transition cost for. - /// The average transition cost. + /// @param node The PathNode to get the average transition cost for. + /// @return The average transition cost. float GetNodeAverageTransitionCost(const PathNode& node) const; #pragma endregion - /// /// Gets the PathNode at the given coordinates. - /// - /// The X coordinate, in PathNodes. - /// The Y coordinate, in PathNodes. - /// The PathNode at the given coordinates. + /// @param x The X coordinate, in PathNodes. + /// @param y The Y coordinate, in PathNodes. + /// @return The PathNode at the given coordinates. PathNode* GetPathNodeAtGridCoords(int x, int y); - /// /// Gets the PathNode id at the given coordinates. - /// - /// The X coordinate, in PathNodes. - /// The Y coordinate, in PathNodes. - /// The PathNode id at the given coordinates. + /// @param x The X coordinate, in PathNodes. + /// @param y The Y coordinate, in PathNodes. + /// @return The PathNode id at the given coordinates. int ConvertCoordsToNodeId(int x, int y); - /// /// Clears all the member variables of this PathFinder, effectively resetting the members of this abstraction level only. - /// void Clear(); // Disallow the use of some implicit methods. diff --git a/Source/System/PieQuadrant.cpp b/Source/System/PieQuadrant.cpp index 1c6b610d38..588a2cc88a 100644 --- a/Source/System/PieQuadrant.cpp +++ b/Source/System/PieQuadrant.cpp @@ -4,8 +4,6 @@ namespace RTE { - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PieQuadrant::Clear() { m_Enabled = true; m_Direction = Directions::None; @@ -19,8 +17,6 @@ namespace RTE { m_SlotsForPieSlices.fill(nullptr); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PieQuadrant::Create(const PieQuadrant& reference, const Entity* oldOriginalPieSliceSourceToCheck, const Entity* newOriginalPieSliceSourceToSet) { m_Enabled = reference.m_Enabled; m_Direction = reference.m_Direction; @@ -33,8 +29,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - std::vector PieQuadrant::GetFlattenedPieSlices(bool inCCWOrder) const { std::vector pieSlices; if (inCCWOrder) { @@ -69,8 +63,6 @@ namespace RTE { return pieSlices; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void PieQuadrant::RealignPieSlices() { if ((m_RightPieSlices[0] && !m_LeftPieSlices[0]) || (m_RightPieSlices[1] && !m_LeftPieSlices[1])) { for (const PieSlice* pieSliceToRealign: GetFlattenedPieSlices()) { @@ -105,8 +97,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool PieQuadrant::AddPieSlice(PieSlice* pieSliceToAdd) { if (!pieSliceToAdd) { return false; @@ -128,8 +118,6 @@ namespace RTE { return sliceWasAdded; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - PieSlice* PieQuadrant::RemovePieSlice(const PieSlice* pieSliceToRemove) { if (pieSliceToRemove == m_MiddlePieSlice.get()) { return m_MiddlePieSlice.release(); diff --git a/Source/System/PieQuadrant.h b/Source/System/PieQuadrant.h index e3c666ed2e..22be3834b1 100644 --- a/Source/System/PieQuadrant.h +++ b/Source/System/PieQuadrant.h @@ -5,9 +5,7 @@ namespace RTE { - /// /// A quadrant in a PieMenu, for easy PieSlice organization. - /// class PieQuadrant { public: @@ -23,65 +21,47 @@ namespace RTE { std::array m_SlotsForPieSlices; //!< An array representing the slots in this PieQuadrant, via pointers to the PieSlices filling each slot. #pragma region Creation - /// /// Constructor method used to instantiate a PieQuadrant object in system memory and make it ready for use. - /// PieQuadrant() { Clear(); } - /// /// Creates a PieQuadrant to be identical to another, by deep copy. - /// - /// A reference to the PieQuadrant to deep copy. - /// A pointer to the old original source to check. This is generally the PieMenu the reference quadrant belongs to. - /// A pointer to the new original source to be set for PieSlices whose reference's original source is the old original source to check. This is generally the PieMenu this quadrant belongs to. + /// @param reference A reference to the PieQuadrant to deep copy. + /// @param oldOriginalPieSliceSourceToCheck A pointer to the old original source to check. This is generally the PieMenu the reference quadrant belongs to. + /// @param newOriginalPieSliceSourceToSet A pointer to the new original source to be set for PieSlices whose reference's original source is the old original source to check. This is generally the PieMenu this quadrant belongs to. void Create(const PieQuadrant& reference, const Entity* oldOriginalPieSliceSourceToCheck, const Entity* newOriginalPieSliceSourceToSet); #pragma endregion #pragma region Destruction - /// /// Resets this PieQuadrant and deletes all slices in it. - /// void Reset() { Clear(); } #pragma endregion #pragma region Getters - /// /// Gets whether or not this PieQuadrant contains the given PieSlice. - /// - /// Whether or not this PieQuadrant contains the given PieSlice. + /// @return Whether or not this PieQuadrant contains the given PieSlice. bool ContainsPieSlice(const PieSlice* sliceToCheck) const { return sliceToCheck == m_MiddlePieSlice.get() || sliceToCheck == m_LeftPieSlices[0].get() || sliceToCheck == m_RightPieSlices[0].get() || sliceToCheck == m_LeftPieSlices[1].get() || sliceToCheck == m_RightPieSlices[1].get(); } - /// /// Gets a vector of non-owning pointers to the PieSlices in this PieQuadrant. /// The vector of PieSlices will default to INI order, i.e. starting with the middle and interleaving left and right slices in order. /// Alternatively it can go in CCW order, getting the outermost right slice and moving inwards through the middle and then left slices. - /// - /// Whether to get flattened slices in counter-clockwise order. Defaults to false. + /// @param inCCWOrder Whether to get flattened slices in counter-clockwise order. Defaults to false. std::vector GetFlattenedPieSlices(bool inCCWOrder = false) const; #pragma endregion #pragma region Concrete Methods - /// /// Balances this PieQuadrant be removing and re-adding all PieSlices if needed, then aligns all PieSlices in this PieQuadrant, setting their angle and size details. - /// void RealignPieSlices(); - /// /// Adds the PieSlice to the quadrant. PieSlices are added to the middle, then the left side, then the right side so things fill evenly. Ownership IS transferred! - /// bool AddPieSlice(PieSlice* pieSliceToAdd); - /// /// Removes the passed in PieSlice from this PieQuadrant. Ownership IS transferred to the caller! - /// - /// The PieSlice to be removed from this PieQuadrant. Ownership IS transferred to the caller! + /// @param pieSliceToRemove The PieSlice to be removed from this PieQuadrant. Ownership IS transferred to the caller! PieSlice* RemovePieSlice(const PieSlice* pieSliceToRemove); #pragma endregion private: - /// /// Clears all the member variables of this PieQuadrant. - /// void Clear(); // Disallow the use of some implicit methods. diff --git a/Source/System/RTEError.cpp b/Source/System/RTEError.cpp index 4fc5c9d5f6..bd805a1d66 100644 --- a/Source/System/RTEError.cpp +++ b/Source/System/RTEError.cpp @@ -20,8 +20,6 @@ namespace RTE { std::string RTEError::s_LastIgnoredAssertDescription = ""; std::source_location RTEError::s_LastIgnoredAssertLocation = {}; - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - #ifdef _WIN32 /// /// Custom exception handler for Windows SEH. @@ -146,8 +144,6 @@ namespace RTE { } #endif - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void RTEError::SetExceptionHandlers() { // Basic handling for C++ exceptions. Doesn't give us much meaningful information. [[maybe_unused]] static const std::terminate_handler terminateHandler = []() { @@ -179,14 +175,10 @@ namespace RTE { #endif } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void RTEError::ShowMessageBox(const std::string& message) { SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_WARNING, "RTE Warning! (>_<)", message.c_str(), nullptr); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool RTEError::ShowAbortMessageBox(const std::string& message) { enum AbortMessageButton { ButtonInvalid, @@ -220,8 +212,6 @@ namespace RTE { return pressedButton == AbortMessageButton::ButtonRestart; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool RTEError::ShowAssertMessageBox(const std::string& message) { enum AssertMessageButton { ButtonInvalid, @@ -254,8 +244,6 @@ namespace RTE { return pressedButton == AssertMessageButton::ButtonAbort; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void RTEError::UnhandledExceptionFunc(const std::string& description, const std::string& callstack) { s_CurrentlyAborting = true; @@ -308,8 +296,6 @@ namespace RTE { AbortAction; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void RTEError::AbortFunc(const std::string& description, const std::source_location& srcLocation) { s_CurrentlyAborting = true; @@ -375,8 +361,6 @@ namespace RTE { AbortAction; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void RTEError::AssertFunc(const std::string& description, const std::source_location& srcLocation) { if (System::IsInExternalModuleValidationMode()) { AbortFunc(description, srcLocation); @@ -413,8 +397,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool RTEError::DumpAbortScreen() { int success = -1; if (glReadPixels != nullptr) { @@ -443,8 +425,6 @@ namespace RTE { return success == 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool RTEError::DumpAbortSave() { bool success = false; if (g_ActivityMan.GetActivity() && g_ActivityMan.GetActivity()->CanBeUserSaved()) { @@ -453,8 +433,6 @@ namespace RTE { return success; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void RTEError::FormatFunctionSignature(std::string& symbolName) { // TODO: Expand this with more dumb signatures, or make something that makes more sense. static const std::array, 3> stlSigs{{{std::regex("( >)"), ">"}, diff --git a/Source/System/RTEError.h b/Source/System/RTEError.h index 28823a7c46..5302f4e304 100644 --- a/Source/System/RTEError.h +++ b/Source/System/RTEError.h @@ -20,9 +20,7 @@ namespace RTE { - /// /// Class for runtime error handling. - /// class RTEError { public: @@ -31,69 +29,49 @@ namespace RTE { static std::string s_LastIgnoredAssertDescription; //!< The last ignored assert message. static std::source_location s_LastIgnoredAssertLocation; //!< The last ignored assert call site. - /// /// Sets custom handlers for C++ and platform specific exceptions. - /// static void SetExceptionHandlers(); - /// /// Pops up a message box dialog in the OS. For debug purposes mostly. - /// - /// The string that the message box should display. + /// @param message The string that the message box should display. static void ShowMessageBox(const std::string& message); - /// /// Abort on unhandled exception function. Will try save the current game, to dump a screenshot, dump the console log and show an abort message. Then quit the program immediately. - /// - /// Message explaining the exception. - /// The call stack in string form. + /// @param description Message explaining the exception. + /// @param callstack The call stack in string form. static void UnhandledExceptionFunc(const std::string& description, const std::string& callstack = ""); - /// /// Abort on Error function. Will try save the current game, to dump a screenshot, dump the console log and show an abort message. Then quit the program immediately. - /// - /// Message explaining the reason for aborting. - /// std::source_location corresponding to the location of the call site. + /// @param description Message explaining the reason for aborting. + /// @param srcLocation std::source_location corresponding to the location of the call site. [[noreturn]] static void AbortFunc(const std::string& description, const std::source_location& srcLocation); - /// /// An assert, which will prompt to abort or ignore it. - /// - /// The description of the assertion. - /// std::source_location corresponding to the location of the call site. + /// @param description The description of the assertion. + /// @param srcLocation std::source_location corresponding to the location of the call site. static void AssertFunc(const std::string& description, const std::source_location& srcLocation); - /// /// Formats function signatures so they're slightly more sane. - /// - /// Reference to the function signature to format. + /// @param funcSig Reference to the function signature to format. static void FormatFunctionSignature(std::string& funcSig); private: - /// /// Pops up the abort message box dialog in the OS, notifying the user about a runtime error. - /// - /// The string that the message box should display. - /// Whether to restart the game by launching a new instance, or proceed to exit. + /// @param message The string that the message box should display. + /// @return Whether to restart the game by launching a new instance, or proceed to exit. static bool ShowAbortMessageBox(const std::string& message); - /// /// Pops up the assert message box dialog in the OS, notifying the user about a runtime error. - /// - /// The string that the message box should display. - /// Whether to abort, or ignore the assert and continue execution. + /// @param message The string that the message box should display. + /// @return Whether to abort, or ignore the assert and continue execution. static bool ShowAssertMessageBox(const std::string& message); - /// /// Saves the current frame to a file. - /// - /// Whether the file was saved successfully. + /// @return Whether the file was saved successfully.@return static bool DumpAbortScreen(); - /// /// Attempts to save the current running Activity, so the player can hopefully resume where they were. - /// - /// Whether the Activity was saved successfully. + /// @return Whether the Activity was saved successfully. static bool DumpAbortSave(); }; diff --git a/Source/System/RTEStackTrace.cpp b/Source/System/RTEStackTrace.cpp index b47fb95b95..b669be718f 100644 --- a/Source/System/RTEStackTrace.cpp +++ b/Source/System/RTEStackTrace.cpp @@ -2,8 +2,6 @@ namespace RTE { - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - std::string RTEStackTrace::GetCallStackAsString(const HANDLE& handle, const CONTEXT* context) { m_CallstackStream.clear(); @@ -17,8 +15,6 @@ namespace RTE { return m_CallstackStream.str(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void RTEStackTrace::OnOutput(LPCSTR text) { this->StackWalker::OnOutput(text); m_CallstackStream << text; diff --git a/Source/System/RTEStackTrace.h b/Source/System/RTEStackTrace.h index dbc5d8bf40..cf759364c6 100644 --- a/Source/System/RTEStackTrace.h +++ b/Source/System/RTEStackTrace.h @@ -5,38 +5,28 @@ namespace RTE { - /// /// Class for dumping stack traces on Windows. /// Wraps the StackWalker class which uses WinAPI Debug Help Library routines. - /// class RTEStackTrace : public StackWalker { public: - /// /// Constructor method used to instantiate an RTEStackTrace object in system memory and make it ready for use. - /// - /// + /// @param options RTEStackTrace() : StackWalker() {} - /// /// Destructor method used to clean up a RTEStackTrace object before deletion from system memory. - /// ~RTEStackTrace() override = default; - /// /// Gets the current call stack as a string. - /// - /// Handle to the current process. If none provided will get the current thread handle. - /// Register data. If none provided will get it from the caller. - /// A string with the call stack. + /// @param handle Handle to the current process. If none provided will get the current thread handle. + /// @param context Register data. If none provided will get it from the caller. + /// @return A string with the call stack. std::string GetCallStackAsString(const HANDLE& handle = nullptr, const CONTEXT* context = nullptr); protected: - /// /// Redirects the output string to the member string stream. - /// - /// The output string. Provided by the base class method. + /// @param text The output string. Provided by the base class method. void OnOutput(LPCSTR text) override; private: diff --git a/Source/System/RTETools.cpp b/Source/System/RTETools.cpp index efeef0812d..149c574f73 100644 --- a/Source/System/RTETools.cpp +++ b/Source/System/RTETools.cpp @@ -6,8 +6,6 @@ namespace RTE { RandomGenerator g_RandomGenerator; - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SeedRNG() { // Use a constant seed for determinism. static constexpr uint32_t constSeed = []() { @@ -29,8 +27,6 @@ namespace RTE { g_RandomGenerator.Seed(constSeed); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - float LERP(float scaleStart, float scaleEnd, float startValue, float endValue, float progressScalar) { if (progressScalar <= scaleStart) { return startValue; @@ -40,8 +36,6 @@ namespace RTE { return startValue + ((progressScalar - scaleStart) * ((endValue - startValue) / (scaleEnd - scaleStart))); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - float EaseIn(float start, float end, float progressScalar) { if (progressScalar <= 0) { return start; @@ -52,8 +46,6 @@ namespace RTE { return (end - start) * (std::sin(-t * c_HalfPI) + 1) + start; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - float EaseOut(float start, float end, float progressScalar) { if (progressScalar <= 0) { return start; @@ -63,14 +55,10 @@ namespace RTE { return (end - start) * -std::sin(-progressScalar * c_HalfPI) + start; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - float EaseInOut(float start, float end, float progressScalar) { return start * (2 * std::pow(progressScalar, 3) - 3 * std::pow(progressScalar, 2) + 1) + end * (3 * std::pow(progressScalar, 2) - 2 * std::pow(progressScalar, 3)); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool Clamp(float& value, float upperLimit, float lowerLimit) { // Straighten out the limits if (upperLimit < lowerLimit) { @@ -89,8 +77,6 @@ namespace RTE { return false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - float Limit(float value, float upperLimit, float lowerLimit) { // Straighten out the limits if (upperLimit < lowerLimit) { @@ -108,8 +94,6 @@ namespace RTE { return value; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - float NormalizeAngleBetween0And2PI(float angle) { while (angle < 0) { angle += c_TwoPI; @@ -117,8 +101,6 @@ namespace RTE { return (angle > c_TwoPI) ? fmodf(angle + c_TwoPI, c_TwoPI) : angle; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - float NormalizeAngleBetweenNegativePIAndPI(float angle) { while (angle < 0) { angle += c_TwoPI; @@ -126,8 +108,6 @@ namespace RTE { return (angle > c_PI) ? fmodf(angle + c_PI, c_TwoPI) - c_PI : angle; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool AngleWithinRange(float angleToCheck, float startAngle, float endAngle) { angleToCheck = NormalizeAngleBetween0And2PI(angleToCheck); startAngle = NormalizeAngleBetween0And2PI(startAngle); @@ -136,8 +116,6 @@ namespace RTE { return endAngle >= startAngle ? (angleToCheck >= startAngle && angleToCheck <= endAngle) : (angleToCheck >= startAngle || angleToCheck <= endAngle); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - float ClampAngle(float angleToClamp, float startAngle, float endAngle) { angleToClamp = NormalizeAngleBetween0And2PI(angleToClamp); @@ -153,20 +131,14 @@ namespace RTE { return angleToClamp; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool WithinBox(const Vector& point, float left, float top, float right, float bottom) { return point.m_X >= left && point.m_X < right && point.m_Y >= top && point.m_Y < bottom; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool WithinBox(const Vector& point, const Vector& boxPos, float width, float height) { return point.m_X >= boxPos.m_X && point.m_X < (boxPos.m_X + width) && point.m_Y >= boxPos.m_Y && point.m_Y < (boxPos.m_Y + height); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - std::string RoundFloatToPrecision(float input, int precision, int roundingMode) { if (roundingMode == 0) { std::stringstream floatStream; @@ -201,8 +173,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // From https://stackoverflow.com/a/66764681, under license https://creativecommons.org/licenses/by-sa/4.0/. Minor modifications uint64_t Hash(const std::string& text) { constexpr uint64_t fnv_prime = 1099511628211ULL; @@ -218,8 +188,6 @@ namespace RTE { return hash; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - std::string GetCaseInsensitiveFullPath(const std::string& fullPath) { if (std::filesystem::exists(fullPath)) { return fullPath; diff --git a/Source/System/RTETools.h b/Source/System/RTETools.h index e69f66454b..16c504d948 100644 --- a/Source/System/RTETools.h +++ b/Source/System/RTETools.h @@ -15,53 +15,41 @@ namespace RTE { std::mt19937 m_RNG; //!< The random number generator used for all random functions. public: - /// /// Seed the random number generator. - /// void Seed(uint64_t seed) { m_RNG.seed(seed); }; - /// /// Function template which returns a uniformly distributed random number in the range [-1, 1]. - /// - /// Uniformly distributed random number in the range [-1, 1]. + /// @return Uniformly distributed random number in the range [-1, 1]. template typename std::enable_if::value, floatType>::type RandomNormalNum() { return std::uniform_real_distribution(floatType(-1.0), std::nextafter(floatType(1.0), std::numeric_limits::max()))(m_RNG); } - /// /// Function template specialization for int types which returns a uniformly distributed random number in the range [-1, 1]. - /// - /// Uniformly distributed random number in the range [-1, 1]. + /// @return Uniformly distributed random number in the range [-1, 1]. template typename std::enable_if::value, intType>::type RandomNormalNum() { return std::uniform_int_distribution(intType(-1), intType(1))(m_RNG); } - /// /// Function template which returns a uniformly distributed random number in the range [0, 1]. - /// - /// Uniformly distributed random number in the range [0, 1]. + /// @return Uniformly distributed random number in the range [0, 1]. template typename std::enable_if::value, floatType>::type RandomNum() { return std::uniform_real_distribution(floatType(0.0), std::nextafter(floatType(1.0), std::numeric_limits::max()))(m_RNG); } - /// /// Function template specialization for int types which returns a uniformly distributed random number in the range [0, 1]. - /// - /// Uniformly distributed random number in the range [0, 1]. + /// @return Uniformly distributed random number in the range [0, 1]. template typename std::enable_if::value, intType>::type RandomNum() { return std::uniform_int_distribution(intType(0), intType(1))(m_RNG); } - /// /// Function template which returns a uniformly distributed random number in the range [min, max]. - /// - /// Lower boundary of the range to pick a number from. - /// Upper boundary of the range to pick a number from. - /// Uniformly distributed random number in the range [min, max]. + /// @param min Lower boundary of the range to pick a number from. + /// @param max Upper boundary of the range to pick a number from. + /// @return Uniformly distributed random number in the range [min, max]. template typename std::enable_if::value, floatType>::type RandomNum(floatType min, floatType max) { if (max < min) { @@ -70,12 +58,10 @@ namespace RTE { return (std::uniform_real_distribution(floatType(0.0), std::nextafter(max - min, std::numeric_limits::max()))(m_RNG) + min); } - /// /// Function template specialization for int types which returns a uniformly distributed random number in the range [min, max]. - /// - /// Lower boundary of the range to pick a number from. - /// Upper boundary of the range to pick a number from. - /// Uniformly distributed random number in the range [min, max]. + /// @param min Lower boundary of the range to pick a number from. + /// @param max Upper boundary of the range to pick a number from. + /// @return Uniformly distributed random number in the range [min, max]. template typename std::enable_if::value, intType>::type RandomNum(intType min, intType max) { if (max < min) { @@ -87,9 +73,7 @@ namespace RTE { extern RandomGenerator g_RandomGenerator; //!< The global random number generator used in our simulation thread. - /// /// Seed global the global random number generators. - /// void SeedRNG(); // TODO: Maybe remove these passthrough functions and force the user to manually specify if they want the simulation thread random, @@ -126,200 +110,158 @@ namespace RTE { #pragma endregion #pragma region Interpolation - /// /// Simple Linear Interpolation, with an added bonus: scaleStart and scaleEnd let you define your scale, where 0 and 1 would be standard scale. /// This scale is used to normalize your progressScalar value and LERP accordingly. - /// - /// The start of the scale to LERP along. - /// The end of the scale to LERP along. - /// The start value of your LERP. - /// The end value of your LERP. - /// How far your LERP has progressed. Automatically normalized through use of scaleStart and scaleEnd. - /// Interpolated value. + /// @param scaleStart The start of the scale to LERP along. + /// @param scaleEnd The end of the scale to LERP along. + /// @param startValue The start value of your LERP. + /// @param endValue The end value of your LERP. + /// @param progressScalar How far your LERP has progressed. Automatically normalized through use of scaleStart and scaleEnd. + /// @return Interpolated value. float LERP(float scaleStart, float scaleEnd, float startValue, float endValue, float progressScalar); - /// /// Nonlinear ease-in interpolation. Starts slow. - /// - /// Start value. - /// End value. - /// Normalized positive progress scalar (0 - 1.0). - /// Interpolated value. + /// @param start Start value. + /// @param end End value. + /// @param progressScalar Normalized positive progress scalar (0 - 1.0). + /// @return Interpolated value. float EaseIn(float start, float end, float progressScalar); - /// /// Nonlinear ease-out interpolation. Slows down toward the end. - /// - /// Start value. - /// End value. - /// Normalized positive progress scalar (0 - 1.0). - /// Interpolated value. + /// @param start Start value. + /// @param end End value. + /// @param progressScalar Normalized positive progress scalar (0 - 1.0). + /// @return Interpolated value. float EaseOut(float start, float end, float progressScalar); - /// /// Nonlinear ease-in-out interpolation. Slows down in the start and end. - /// - /// Start value. - /// End value. - /// Normalized positive progress scalar (0 - 1.0). - /// Interpolated value. + /// @param start Start value. + /// @param end End value. + /// @param progressScalar Normalized positive progress scalar (0 - 1.0). + /// @return Interpolated value. float EaseInOut(float start, float end, float progressScalar); #pragma endregion #pragma region Clamping - /// /// Clamps a value between two limit values. - /// - /// Value to clamp. - /// Upper limit of value. - /// Lower limit of value. - /// True if either limit is currently reached, False if not. + /// @param value Value to clamp. + /// @param upperLimit Upper limit of value. + /// @param lowerLimit Lower limit of value. + /// @return True if either limit is currently reached, False if not. bool Clamp(float& value, float upperLimit, float lowerLimit); - /// /// Clamps a value between two limit values. - /// - /// Value to clamp. - /// Upper limit of value. - /// Lower limit of value. - /// Upper/Lower limit value if limit is currently reached, value between limits if not. + /// @param value Value to clamp. + /// @param upperLimit Upper limit of value. + /// @param lowerLimit Lower limit of value. + /// @return Upper/Lower limit value if limit is currently reached, value between limits if not. float Limit(float value, float upperLimit, float lowerLimit); #pragma endregion #pragma region Rounding - /// /// Rounds a float to a set fixed point precision (digits after decimal point) with option to always ceil or always floor the remainder. - /// - /// The input float to round. - /// The precision to round to, i.e. the number of digits after the decimal points. - /// Method of rounding to use. 0 for system default, 1 for floored remainder, 2 for ceiled remainder. - /// A string of the float, rounded and displayed to chosen precision. + /// @param inputFloat The input float to round. + /// @param precision The precision to round to, i.e. the number of digits after the decimal points. + /// @param roundingMode Method of rounding to use. 0 for system default, 1 for floored remainder, 2 for ceiled remainder. + /// @return A string of the float, rounded and displayed to chosen precision. std::string RoundFloatToPrecision(float input, int precision, int roundingMode = 0); - /// /// Rounds an integer to the specified nearest multiple. /// For example, if the arguments are 63 and 5, the returned value will be 65. - /// - /// The number to round to the nearest multiple. - /// The multiple to round to. - /// An integer rounded to the specified nearest multiple. + /// @param num The number to round to the nearest multiple. + /// @param multiple The multiple to round to. + /// @return An integer rounded to the specified nearest multiple. inline int RoundToNearestMultiple(int num, int multiple) { return static_cast(std::round(static_cast(num) / static_cast(multiple)) * static_cast(multiple)); } #pragma endregion #pragma region Angle Helpers - /// /// Returns a copy of the angle normalized so it's between 0 and 2PI. - /// - /// The angle to normalize, in radians. - /// The angle, normalized so it's between 0 and 2PI + /// @param angle The angle to normalize, in radians. + /// @return The angle, normalized so it's between 0 and 2PI float NormalizeAngleBetween0And2PI(float angle); - /// /// Returns a copy of the angle normalized so it's between -PI and PI. - /// - /// The angle to normalize, in radians. - /// The angle, normalized so it's between -PI and PI + /// @param angle The angle to normalize, in radians. + /// @return The angle, normalized so it's between -PI and PI float NormalizeAngleBetweenNegativePIAndPI(float angle); - /// /// Returns whether or not the angle to check is between the start and end angles. Note that, because of how angles work (when normalized), the start angle may be greater than the end angle. - /// - /// The angle to check, in radians. - /// The starting angle for the range. - /// The ending angle for the range. - /// Whether or not the angle to check is between the start and end angle. + /// @param angleToCheck The angle to check, in radians. + /// @param startAngle The starting angle for the range. + /// @param endAngle The ending angle for the range. + /// @return Whether or not the angle to check is between the start and end angle. bool AngleWithinRange(float angleToCheck, float startAngle, float endAngle); - /// /// Clamps the passed in angle between the specified lower and upper limits, in a CCW direction. - /// - /// The angle to clamp. - /// The lower limit for clamping. - /// The upper limit for clamping. - /// The angle, clamped between the start and end angle. + /// @param angleToClamp The angle to clamp. + /// @param startAngle The lower limit for clamping. + /// @param endAngle The upper limit for clamping. + /// @return The angle, clamped between the start and end angle. float ClampAngle(float angleToClamp, float startAngle, float endAngle); #pragma endregion #pragma region Detection - /// /// Tells whether a point is within a specified box. - /// - /// Vector position of the point we're checking. - /// Vector position of the box. - /// Width of the box. - /// Height of the box. - /// True if point is inside box bounds. + /// @param point Vector position of the point we're checking. + /// @param boxPos Vector position of the box. + /// @param width Width of the box. + /// @param height Height of the box. + /// @return True if point is inside box bounds. bool WithinBox(const Vector& point, const Vector& boxPos, float width, float height); - /// /// Tells whether a point is within a specified box. - /// - /// Vector position of the point we're checking. - /// Position of box left plane (X start). - /// Position of box top plane (Y start). - /// Position of box right plane (X end). - /// Position of box bottom plane (Y end). - /// True if point is inside box bounds. + /// @param point Vector position of the point we're checking. + /// @param left Position of box left plane (X start). + /// @param top Position of box top plane (Y start). + /// @param right Position of box right plane (X end). + /// @param bottom Position of box bottom plane (Y end). + /// @return True if point is inside box bounds. bool WithinBox(const Vector& point, float left, float top, float right, float bottom); #pragma endregion #pragma region Conversion - /// /// Returns a corrected angle value that can be used with Allegro fixed point math routines where 256 equals 360 degrees. - /// - /// The angle value to correct. In degrees. - /// A float with the represented angle as full rotations being 256. + /// @param angleDegrees The angle value to correct. In degrees. + /// @return A float with the represented angle as full rotations being 256. inline float GetAllegroAngle(float angleDegrees) { return (angleDegrees / 360) * 256; } - /// /// Returns the given angle converted from degrees to radians. - /// - /// The angle in degrees to be converted. - /// The converted angle in radians. + /// @param angleDegrees The angle in degrees to be converted. + /// @return The converted angle in radians. inline float DegreesToRadians(float angleDegrees) { return angleDegrees / 180.0F * c_PI; } - /// /// Returns the given angle converted from radians to degrees. - /// - /// The angle in radians to be converted. - /// The converted angle in degrees. + /// @param angleRadians The angle in radians to be converted. + /// @return The converted angle in degrees. inline float RadiansToDegrees(float angleRadians) { return angleRadians / c_PI * 180.0F; } #pragma endregion #pragma region Strings - /// /// Checks whether two strings are equal when the casing is disregarded. - /// - /// First string. - /// Second string. - /// Whether the two strings are equal case insensitively. + /// @param strA First string. + /// @param strB Second string. + /// @return Whether the two strings are equal case insensitively. inline bool StringsEqualCaseInsensitive(const std::string_view& strA, const std::string_view& strB) { return std::equal(strA.begin(), strA.end(), strB.begin(), strB.end(), [](char strAChar, char strBChar) { return std::tolower(strAChar) == std::tolower(strBChar); }); } - /// /// If a file "foo/Bar.txt" exists, and this method is passed "FOO/BAR.TXT", then this method will return "foo/Bar.txt". /// This method's purpose is to enable Linux to get the real path using a case-insensitive search. /// The real path is used by the Lua file I/O handling methods to ensure full Windows compatibility. - /// - /// Path to case-insensitively translate to a real path. - /// The real path. If the path doesn't exist, it returns the fullPath argument with all the existing parent directories correctly capitalized. + /// @param fullPath Path to case-insensitively translate to a real path. + /// @return The real path. If the path doesn't exist, it returns the fullPath argument with all the existing parent directories correctly capitalized. std::string GetCaseInsensitiveFullPath(const std::string& fullPath); - /// /// Hashes a string in a cross-compiler/platform safe way (std::hash gives different results on different compilers). - /// - /// Text string to hash. - /// The hash result value. + /// @param text Text string to hash. + /// @return The hash result value. uint64_t Hash(const std::string& text); #pragma endregion #pragma region Misc - /// /// Convenience method that takes in a double pointer array and returns a std::vector with its contents, because pointers-to-pointers are the devil. The passed in array is deleted in the process so no need to delete it manually. - /// - /// The double pointer to convert to a std::vector. - /// The size of the double pointer array. + /// @param arrayOfType The double pointer to convert to a std::vector. + /// @param arraySize The size of the double pointer array. template std::vector ConvertDoublePointerToVectorOfPointers(Type** arrayOfType, size_t arraySize) { std::unique_ptr doublePointerArray = std::unique_ptr(arrayOfType); std::vector outputVector; @@ -329,10 +271,8 @@ namespace RTE { return outputVector; } - /// /// Returns the sign of the given input value. - /// - /// The sign as an integer -1, 0 or +1. + /// @return The sign as an integer -1, 0 or +1. template int Sign(const Type& value) { return (Type(0) < value) - (Type(0) > value); } diff --git a/Source/System/Reader.cpp b/Source/System/Reader.cpp index bd204a0034..1e5c8e2807 100644 --- a/Source/System/Reader.cpp +++ b/Source/System/Reader.cpp @@ -5,8 +5,6 @@ namespace RTE { - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void Reader::Clear() { m_Stream = nullptr; m_FilePath.clear(); @@ -26,23 +24,17 @@ namespace RTE { m_NonModulePath = false; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - Reader::Reader(const std::string& fileName, bool overwrites, const ProgressCallback& progressCallback, bool failOK, bool nonModulePath) { Clear(); m_NonModulePath = nonModulePath; Create(fileName, overwrites, progressCallback, failOK); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - Reader::Reader(std::unique_ptr&& stream, bool overwrites, const ProgressCallback& progressCallback, bool failOK) { Clear(); Create(std::move(stream), overwrites, progressCallback, failOK); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int Reader::Create(const std::string& fileName, bool overwrites, const ProgressCallback& progressCallback, bool failOK) { if (fileName.empty()) { return -1; @@ -65,8 +57,6 @@ namespace RTE { return Create(std::make_unique(m_FilePath), overwrites, progressCallback, failOK); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int Reader::Create(std::unique_ptr&& stream, bool overwrites, const ProgressCallback& progressCallback, bool failOK) { m_CanFail = failOK; @@ -87,22 +77,16 @@ namespace RTE { return m_Stream->good() ? 0 : -1; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int Reader::GetReadModuleID() const { return (m_DataModuleID < 0) ? g_PresetMan.GetModuleID(m_DataModuleName) : m_DataModuleID; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - std::string Reader::WholeFileAsString() const { std::stringstream stringStream; stringStream << m_Stream->rdbuf(); return stringStream.str(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - std::string Reader::ReadLine() { DiscardEmptySpace(); @@ -132,8 +116,6 @@ namespace RTE { return TrimString(retString); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - std::string Reader::ReadPropName() { DiscardEmptySpace(); @@ -183,8 +165,6 @@ namespace RTE { return retString; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - std::string Reader::ReadPropValue() { std::string fullLine = ReadLine(); size_t valuePos = fullLine.find_first_of('='); @@ -192,8 +172,6 @@ namespace RTE { return TrimString(propValue); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool Reader::NextProperty() { if (!DiscardEmptySpace() || m_EndOfStreams) { return false; @@ -207,8 +185,6 @@ namespace RTE { return true; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - std::string Reader::TrimString(const std::string& stringToTrim) const { if (stringToTrim.empty()) { return ""; @@ -219,8 +195,6 @@ namespace RTE { return stringToTrim.substr(start, (end - start + 1)); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool Reader::DiscardEmptySpace() { char peek; int indent = 0; @@ -328,8 +302,6 @@ namespace RTE { return true; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void Reader::ReportError(const std::string& errorDesc) const { if (!m_CanFail) { RTEAbort(errorDesc + "\nError happened in " + m_FilePath + " at line " + std::to_string(m_CurrentLine) + "!"); @@ -340,8 +312,6 @@ namespace RTE { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool Reader::StartIncludeFile() { // Report that we're including a file if (m_ReportProgress) { @@ -390,8 +360,6 @@ namespace RTE { return true; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool Reader::EndIncludeFile() { if (m_ReportProgress) { m_ReportProgress(m_ReportTabs + m_FileName + " - done! " + static_cast(-42), false); diff --git a/Source/System/Reader.h b/Source/System/Reader.h index 4e9d315426..0c16d9fa91 100644 --- a/Source/System/Reader.h +++ b/Source/System/Reader.h @@ -5,186 +5,134 @@ namespace RTE { using ProgressCallback = std::function; //!< Convenient name definition for the progress report callback function. - /// /// Reads RTE objects from std::istreams. - /// class Reader { public: #pragma region Creation - /// /// Constructor method used to instantiate a Reader object in system memory. Create() should be called before using the object. - /// Reader() { Clear(); } - /// /// Constructor method used to instantiate a Reader object in system memory and make it ready for reading from the passed in file path. - /// - /// Path to the file to open for reading. If the file doesn't exist the stream will fail to open. - /// Whether object definitions read here overwrite existing ones with the same names. - /// A function pointer to a function that will be called and sent a string with information about the progress of this Reader's reading. - /// Whether it's ok for the file to not be there, ie we're only trying to open, and if it's not there, then fail silently. - /// Whether this Reader is reading from path that is not a DataModule and should just read it as provided. + /// @param fileName Path to the file to open for reading. If the file doesn't exist the stream will fail to open. + /// @param overwrites Whether object definitions read here overwrite existing ones with the same names. + /// @param progressCallback A function pointer to a function that will be called and sent a string with information about the progress of this Reader's reading. + /// @param failOK Whether it's ok for the file to not be there, ie we're only trying to open, and if it's not there, then fail silently. + /// @param nonModulePath Whether this Reader is reading from path that is not a DataModule and should just read it as provided. Reader(const std::string& fileName, bool overwrites = false, const ProgressCallback& progressCallback = nullptr, bool failOK = false, bool nonModulePath = false); - /// /// Constructor method used to instantiate a Reader object in system memory and make it ready for reading from the passed in file path. - /// - /// Stream to read from. - /// Whether object definitions read here overwrite existing ones with the same names. - /// A function pointer to a function that will be called and sent a string with information about the progress of this Reader's reading. - /// Whether it's ok for the file to not be there, ie we're only trying to open, and if it's not there, then fail silently. + /// @param stream Stream to read from. + /// @param overwrites Whether object definitions read here overwrite existing ones with the same names. + /// @param progressCallback A function pointer to a function that will be called and sent a string with information about the progress of this Reader's reading. + /// @param failOK Whether it's ok for the file to not be there, ie we're only trying to open, and if it's not there, then fail silently. Reader(std::unique_ptr&& stream, bool overwrites = false, const ProgressCallback& progressCallback = nullptr, bool failOK = false); - /// /// Makes the Reader object ready for use. - /// - /// Path to the file to open for reading. If the file doesn't exist the stream will fail to open. - /// Whether object definitions read here overwrite existing ones with the same names. - /// A function pointer to a function that will be called and sent a string with information about the progress of this Reader's reading. - /// Whether it's ok for the file to not be there, ie we're only trying to open, and if it's not there, then fail silently. - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @param fileName Path to the file to open for reading. If the file doesn't exist the stream will fail to open. + /// @param overwrites Whether object definitions read here overwrite existing ones with the same names. + /// @param progressCallback A function pointer to a function that will be called and sent a string with information about the progress of this Reader's reading. + /// @param failOK Whether it's ok for the file to not be there, ie we're only trying to open, and if it's not there, then fail silently. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create(const std::string& fileName, bool overwrites = false, const ProgressCallback& progressCallback = nullptr, bool failOK = false); - /// /// Makes the Reader object ready for use. - /// - /// Stream to read from. - /// Whether object definitions read here overwrite existing ones with the same names. - /// A function pointer to a function that will be called and sent a string with information about the progress of this Reader's reading. - /// Whether it's ok for the file to not be there, ie we're only trying to open, and if it's not there, then fail silently. - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @param stream Stream to read from. + /// @param overwrites Whether object definitions read here overwrite existing ones with the same names. + /// @param progressCallback A function pointer to a function that will be called and sent a string with information about the progress of this Reader's reading. + /// @param failOK Whether it's ok for the file to not be there, ie we're only trying to open, and if it's not there, then fail silently. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create(std::unique_ptr&& stream, bool overwrites = false, const ProgressCallback& progressCallback = nullptr, bool failOK = false); #pragma endregion #pragma region Getters and Setters - /// /// Gets the name of the DataModule this Reader is reading from. - /// - /// The name of the DataModule this reader is reading from. + /// @return The name of the DataModule this reader is reading from. const std::string& GetReadModuleName() const { return m_DataModuleName; } - /// /// Gets the ID of the DataModule this Reader is reading from. If the ID is invalid, attempts to get a valid ID using the DataModule name. - /// - /// The DataModule ID that this Reader is reading from. + /// @return The DataModule ID that this Reader is reading from. int GetReadModuleID() const; - /// /// Gets a pointer to the istream of this reader. - /// - /// A pointer to the istream object for this reader. + /// @return A pointer to the istream object for this reader. std::istream* GetStream() const { return m_Stream.get(); } - /// /// Gets the path of the current file this reader is reading from. - /// - /// A string with the path, relative from the working directory. + /// @return A string with the path, relative from the working directory. std::string GetCurrentFilePath() const { return m_FilePath; } - /// /// Gets the line of the current file line this reader is reading from. - /// - /// A string with the line number that will be read from next. + /// @return A string with the line number that will be read from next. std::string GetCurrentFileLine() const { return std::to_string(m_CurrentLine); } - /// /// Shows whether objects read from this will be overwriting any existing ones with the same names. - /// - /// Whether this overwrites or not. + /// @return Whether this overwrites or not. bool GetPresetOverwriting() const { return m_OverwriteExisting; } - /// /// Sets whether objects read from this will be overwriting any existing ones with the same names. - /// - /// Whether this should overwrite existing definitions or not. + /// @param overwrites Whether this should overwrite existing definitions or not. void SetPresetOverwriting(bool overwrites = true) { m_OverwriteExisting = overwrites; } - /// /// Returns true if reader was told to skip InlcudeFile statements - /// - /// Returns whether reader was told to skip included files. + /// @return Returns whether reader was told to skip included files. bool GetSkipIncludes() const { return m_SkipIncludes; }; - /// /// Set whether this reader should skip included files. - /// - /// To make reader skip included files pass true, pass false otherwise. + /// @param skip To make reader skip included files pass true, pass false otherwise. void SetSkipIncludes(bool skip) { m_SkipIncludes = skip; }; #pragma endregion #pragma region Reading Operations - /// /// Reads a file and constructs a string from all its contents. - /// - /// A string containing the whole file contents. + /// @return A string containing the whole file contents. std::string WholeFileAsString() const; - /// /// Reads the rest of the line from the context object Reader's stream current location. - /// - /// The std::string that will hold the line's contents. + /// @return The std::string that will hold the line's contents. std::string ReadLine(); - /// /// Reads the next property name from the context object Reader's stream after eating all whitespace including newlines up till the first newline char. /// Basically gets anything between the last newline before text to the next "=" after that. - /// - /// The whitespace-trimmed std::string that will hold the next property's name. + /// @return The whitespace-trimmed std::string that will hold the next property's name. std::string ReadPropName(); - /// /// Reads the next property value from the context object Reader's stream after eating all whitespace including newlines up till the first newline char. /// Basically gets anything after the last "=" and up to the next newline after that. - /// - /// The whitespace-trimmed std::string that will hold the next property value. + /// @return The whitespace-trimmed std::string that will hold the next property value. std::string ReadPropValue(); - /// /// Lines up the reader with the next property of the current object. - /// - /// Whether there are any more properties to be read by the current object. + /// @return Whether there are any more properties to be read by the current object. bool NextProperty(); - /// /// Notifies the reader that we're starting reading a new object, by making it expect another level of indentation. - /// void StartObject() { --m_ObjectEndings; } - /// /// Takes out whitespace from the beginning and the end of a string. - /// - /// String to remove whitespace from. - /// The string that was passed in, sans whitespace in the front and end. + /// @param stringToTrim String to remove whitespace from. + /// @return The string that was passed in, sans whitespace in the front and end. std::string TrimString(const std::string& stringToTrim) const; - /// /// Discards all whitespace, newlines and comment lines (which start with '//') so that the next thing to be read will be actual data. - /// - /// Whether there is more data to read from the file streams after this eat. + /// @return Whether there is more data to read from the file streams after this eat. bool DiscardEmptySpace(); #pragma endregion #pragma region Reader Status - /// /// Shows whether this is still OK to read from. If file isn't present, etc, this will return false. - /// - /// Whether this Reader's stream is OK or not. + /// @return Whether this Reader's stream is OK or not. bool ReaderOK() const { return m_Stream.get() && m_Stream->good(); } - /// /// Makes an error message box pop up for the user that tells them something went wrong with the reading, and where. - /// - /// The message describing what's wrong. + /// @param errorDesc The message describing what's wrong. void ReportError(const std::string& errorDesc) const; #pragma endregion #pragma region Operator Overloads - /// /// Stream extraction operator overloads for all the elemental types. - /// - /// A reference to the variable that will be filled by the extracted data. - /// A Reader reference for further use in an expression. + /// @param var A reference to the variable that will be filled by the extracted data. + /// @return A Reader reference for further use in an expression. Reader& operator>>(bool& var) { DiscardEmptySpace(); *m_Stream >> var; @@ -253,13 +201,9 @@ namespace RTE { #pragma endregion protected: - /// /// A struct containing information from the currently used stream. - /// struct StreamInfo { - /// /// Constructor method used to instantiate a StreamInfo object in system memory. - /// StreamInfo(std::istream* stream, const std::string& filePath, int currentLine, int prevIndent) : Stream(stream), FilePath(filePath), CurrentLine(currentLine), PreviousIndent(prevIndent) {} @@ -294,32 +238,24 @@ namespace RTE { std::stack m_BlockCommentOpenTagLines; // /// When NextProperty() has returned false, indicating that there were no more properties to read on that object, /// this is incremented until it matches -m_IndentDifference, and then NextProperty will start returning true again. - /// int m_ObjectEndings; private: #pragma region Reading Operations - /// /// When ReadPropName encounters the property name "IncludeFile", it will automatically call this function to get started reading on that file. /// This will create a new stream to the include file. - /// - /// Whether the include file was found and opened ok or not. + /// @return Whether the include file was found and opened ok or not. bool StartIncludeFile(); - /// /// This should be called when end-of-file is detected in an included file stream. /// It will destroy the current stream pop the top stream off the stream stack to resume reading from it instead. - /// - /// Whether there were any stream on the stack to resume. + /// @return Whether there were any stream on the stack to resume. bool EndIncludeFile(); #pragma endregion - /// /// Clears all the member variables of this Reader, effectively resetting the members of this abstraction level only. - /// void Clear(); // Disallow the use of some implicit methods. diff --git a/Source/System/Serializable.cpp b/Source/System/Serializable.cpp index 97f0376616..b3b891c9e2 100644 --- a/Source/System/Serializable.cpp +++ b/Source/System/Serializable.cpp @@ -2,8 +2,6 @@ namespace RTE { - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int Serializable::CreateSerializable(Reader& reader, bool checkType, bool doCreate, bool skipStartingObject) { if (checkType && reader.ReadPropValue() != GetClassName()) { reader.ReportError("Wrong type in Reader when passed to Serializable::Create()"); @@ -26,23 +24,17 @@ namespace RTE { return doCreate ? Create() : 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int Serializable::ReadProperty(const std::string_view& propName, Reader& reader) { reader.ReadPropValue(); reader.ReportError("Could not match property '" + std::string(propName) + "'!"); return -1; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - Reader& operator>>(Reader& reader, Serializable& operand) { operand.Create(reader); return reader; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - Reader& operator>>(Reader& reader, Serializable* operand) { if (operand) { operand->Create(reader); @@ -50,16 +42,12 @@ namespace RTE { return reader; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - Writer& operator<<(Writer& writer, const Serializable& operand) { operand.Save(writer); writer.ObjectEnd(); return writer; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - Writer& operator<<(Writer& writer, const Serializable* operand) { if (operand) { operand->Save(writer); diff --git a/Source/System/Serializable.h b/Source/System/Serializable.h index 4d7d59127c..1d35855cf3 100644 --- a/Source/System/Serializable.h +++ b/Source/System/Serializable.h @@ -10,24 +10,18 @@ namespace RTE { - /// /// This base class specifies common creation/destruction patterns associated with reading and writing member data from disk. /// Is only intended to be inherited from in one level. - /// class Serializable { public: #pragma region Global Macro Definitions -/// /// Convenience macro to cut down on duplicate ReadProperty and Save methods in classes that extend Serializable. -/// #define SerializableOverrideMethods \ int ReadProperty(const std::string_view& propName, Reader& reader) override; \ int Save(Writer& writer) const override; -/// /// Convenience macro to cut down on duplicate GetClassName methods in non-poolable classes that extend Serializable. -/// #define SerializableClassNameGetter \ const std::string& GetClassName() const override { return c_ClassName; } @@ -72,137 +66,104 @@ namespace RTE { #pragma endregion #pragma region Creation - /// /// Constructor method used to instantiate a Serializable object in system memory. Create() should be called before using the object. - /// Serializable() = default; - /// /// Makes the Serializable object ready for use, usually after all necessary properties have been set with Create(Reader). - /// - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. virtual int Create() { return 0; } - /// /// Makes the Serializable object ready for use. - /// - /// A Reader that the Serializable will create itself from. - /// Whether there is a class name in the stream to check against to make sure the correct type is being read from the stream. - /// Whether to do any additional initialization of the object after reading in all the properties from the Reader. This is done by calling Create(). - /// A Reader that the Serializable will create itself from. - /// Whether there is a class name in the stream to check against to make sure the correct type is being read from the stream. - /// Whether to do any additional initialization of the object after reading in all the properties from the Reader. This is done by calling Create(). - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @param reader A Reader that the Serializable will create itself from. + /// @param checkType Whether there is a class name in the stream to check against to make sure the correct type is being read from the stream. + /// @param doCreate Whether to do any additional initialization of the object after reading in all the properties from the Reader. This is done by calling Create(). + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. virtual int Create(Reader& reader, bool checkType = true, bool doCreate = true) { return CreateSerializable(reader, checkType, doCreate, false); } #pragma endregion #pragma region Destruction - /// /// Destructor method used to clean up a Serializable object before deletion from system memory. - /// virtual ~Serializable() = default; - /// /// Resets the entire Serializable, including its inherited members, to their default settings or values. - /// virtual void Reset() { Clear(); } #pragma endregion #pragma region INI Handling - /// /// Reads a property value from a Reader stream. /// If the name isn't recognized by this class, then ReadProperty of the parent class is called. /// If the property isn't recognized by any of the base classes, false is returned, and the Reader's position is untouched. - /// - /// The name of the property to be read. - /// A Reader lined up to the value of the property to be read. - /// + /// @param propName The name of the property to be read. + /// @param reader A Reader lined up to the value of the property to be read. + /// @return /// An error return value signaling whether the property was successfully read or not. /// 0 means it was read successfully, and any nonzero indicates that a property of that name could not be found in this or base classes. - /// virtual int ReadProperty(const std::string_view& propName, Reader& reader); - /// /// Saves the complete state of this Serializable to an output stream for later recreation with Create(istream &stream). - /// - /// A Writer that the Serializable will save itself to. - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @param writer A Writer that the Serializable will save itself to. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. virtual int Save(Writer& writer) const { writer.ObjectStart(GetClassName()); return 0; } - /// /// Replaces backslashes with forward slashes in file paths to eliminate issues with cross-platform compatibility or invalid escape sequences. - /// - /// Reference to the file path string to correct slashes in. + /// @param pathToCorrect Reference to the file path string to correct slashes in. // TODO: Add a warning log entry if backslashes are found in a data path. Perhaps overwrite them in the ini file itself. std::string CorrectBackslashesInPath(const std::string& pathToCorrect) const { return std::filesystem::path(pathToCorrect).generic_string(); } #pragma endregion #pragma region Logging - /// /// Sets the file and line that are currently being read. Formatted to be used for logging warnings and errors. /// Because we're often used as a parent for basic types (i.e, Vector, Matrix, Color), where we don't want to spend any time doing string construction we don't actually store this data here. /// This just acts as an abstract base for child classes to implement. - /// - /// A string containing the currently read file path and the line being read. + /// @param newPosition A string containing the currently read file path and the line being read. virtual void SetFormattedReaderPosition(const std::string& newPosition) {} #pragma endregion #pragma region Operator Overloads - /// /// A Reader extraction operator for filling a Serializable from a Reader. - /// - /// A Reader reference as the left hand side operand. - /// An Serializable reference as the right hand side operand. - /// A Reader reference for further use in an expression. + /// @param reader A Reader reference as the left hand side operand. + /// @param operand An Serializable reference as the right hand side operand. + /// @return A Reader reference for further use in an expression. friend Reader& operator>>(Reader& reader, Serializable& operand); - /// /// A Reader extraction operator for filling an Serializable from a Reader. - /// - /// A Reader reference as the left hand side operand. - /// An Serializable pointer as the right hand side operand. - /// A Reader reference for further use in an expression. + /// @param reader A Reader reference as the left hand side operand. + /// @param operand An Serializable pointer as the right hand side operand. + /// @return A Reader reference for further use in an expression. friend Reader& operator>>(Reader& reader, Serializable* operand); - /// /// A Writer insertion operator for sending a Serializable to a Writer. - /// - /// A Writer reference as the left hand side operand. - /// A Serializable reference as the right hand side operand. - /// A Writer reference for further use in an expression. + /// @param writer A Writer reference as the left hand side operand. + /// @param operand A Serializable reference as the right hand side operand. + /// @return A Writer reference for further use in an expression. friend Writer& operator<<(Writer& writer, const Serializable& operand); - /// /// A Writer insertion operator for sending a Serializable to a Writer. - /// - /// A Writer reference as the left hand side operand. - /// A Serializable pointer as the right hand side operand. - /// A Writer reference for further use in an expression. + /// @param writer A Writer reference as the left hand side operand. + /// @param operand A Serializable pointer as the right hand side operand. + /// @return A Writer reference for further use in an expression. friend Writer& operator<<(Writer& writer, const Serializable* operand); #pragma endregion #pragma region Class Info - /// /// Gets the class name of this Serializable. - /// - /// A string with the friendly-formatted type name of this Serializable. + /// @return A string with the friendly-formatted type name of this Serializable. virtual const std::string& GetClassName() const = 0; #pragma endregion private: - /// /// Clears all the member variables of this Object, effectively resetting the members of this abstraction level only. - /// void Clear() {} }; } // namespace RTE diff --git a/Source/System/Shader.cpp b/Source/System/Shader.cpp index 07c9b13811..cc0f7ecb05 100644 --- a/Source/System/Shader.cpp +++ b/Source/System/Shader.cpp @@ -12,20 +12,17 @@ namespace RTE { Shader::Shader() : m_ProgramID(0), m_TextureUniform(-1), m_ColorUniform(-1), m_TransformUniform(-1), m_ProjectionUniform(-1) {} - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// Shader::Shader(const std::string& vertexFilename, const std::string& fragPath) : m_ProgramID(glCreateProgram()), m_TextureUniform(-1), m_ColorUniform(-1), m_TransformUniform(-1), m_ProjectionUniform(-1) { Compile(vertexFilename, fragPath); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// Shader::~Shader() { if (m_ProgramID) { GL_CHECK(glDeleteProgram(m_ProgramID)); } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// bool Shader::Compile(const std::string& vertexPath, const std::string& fragPath) { assert(m_ProgramID != 0); GLuint vertexShader = glCreateShader(GL_VERTEX_SHADER); @@ -59,54 +56,38 @@ namespace RTE { return true; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void Shader::Use() { GL_CHECK(glUseProgram(m_ProgramID)); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// GLint Shader::GetUniformLocation(const std::string& name) { return glGetUniformLocation(m_ProgramID, name.c_str()); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void Shader::SetBool(const std::string& name, bool value) { GL_CHECK(glUniform1i(glGetUniformLocation(m_ProgramID, name.c_str()), static_cast(value))); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void Shader::SetInt(const std::string& name, int value) { GL_CHECK(glUniform1i(glGetUniformLocation(m_ProgramID, name.c_str()), value)); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void Shader::SetFloat(const std::string& name, float value) { GL_CHECK(glUniform1f(glGetUniformLocation(m_ProgramID, name.c_str()), value)); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void Shader::SetMatrix4f(const std::string& name, const glm::mat4& value) { GL_CHECK(glUniformMatrix4fv(glGetUniformLocation(m_ProgramID, name.c_str()), 1, GL_FALSE, glm::value_ptr(value))); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void Shader::SetVector2f(const std::string& name, const glm::vec2& value) { GL_CHECK(glUniform2fv(glGetUniformLocation(m_ProgramID, name.c_str()), 1, glm::value_ptr(value))); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void Shader::SetVector3f(const std::string& name, const glm::vec3& value) { GL_CHECK(glUniform3fv(glGetUniformLocation(m_ProgramID, name.c_str()), 1, glm::value_ptr(value))); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void Shader::SetVector4f(const std::string& name, const glm::vec4& value) { GL_CHECK(glUniform4fv(glGetUniformLocation(m_ProgramID, name.c_str()), 1, glm::value_ptr(value))); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void Shader::SetBool(int32_t uniformLoc, bool value) { GL_CHECK(glUniform1i(uniformLoc, value)); } void Shader::SetInt(int32_t uniformLoc, int value) { GL_CHECK(glUniform1i(uniformLoc, value)); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void Shader::SetFloat(int32_t uniformLoc, float value) { GL_CHECK(glUniform1f(uniformLoc, value)); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void Shader::SetMatrix4f(int32_t uniformLoc, const glm::mat4& value) { GL_CHECK(glUniformMatrix4fv(uniformLoc, 1, GL_FALSE, glm::value_ptr(value))); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void Shader::SetVector2f(int32_t uniformLoc, const glm::vec2& value) { GL_CHECK(glUniform2fv(uniformLoc, 1, glm::value_ptr(value))); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void Shader::SetVector3f(int32_t uniformLoc, const glm::vec3& value) { GL_CHECK(glUniform3fv(uniformLoc, 1, glm::value_ptr(value))); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void Shader::SetVector4f(int32_t uniformLoc, const glm::vec4& value) { GL_CHECK(glUniform4fv(uniformLoc, 1, glm::value_ptr(value))); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// bool Shader::CompileShader(GLuint shaderID, const std::string& filename, std::string& error) { if (!System::PathExistsCaseSensitive(filename)) { error += "File " + filename + " doesn't exist."; @@ -140,7 +121,6 @@ namespace RTE { return true; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// bool Shader::Link(GLuint vtxShader, GLuint fragShader) { GL_CHECK(glAttachShader(m_ProgramID, vtxShader)); GL_CHECK(glAttachShader(m_ProgramID, fragShader)); @@ -155,7 +135,6 @@ namespace RTE { return true; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void Shader::ApplyDefaultUniforms() { Use(); SetInt("rteTexture", 0); diff --git a/Source/System/Shader.h b/Source/System/Shader.h index e731b405cf..21c8671bc9 100644 --- a/Source/System/Shader.h +++ b/Source/System/Shader.h @@ -7,286 +7,186 @@ namespace RTE { class Shader { public: - /// /// Constructs an empty shader program, which can be initialized using `Shader::Compile` - /// Shader(); - /// /// Constructs a Shader from vertex shader file and fragment shader file. - /// - /// + /// @param vertexFilename /// Filepath to the vertex shader file. - /// - /// + /// @param fragPath /// Filepath to the fragment shader file. - /// Shader(const std::string& vertexFilename, const std::string& fragPath); - /// /// Destructor. - /// virtual ~Shader(); - /// /// Create this shader from a vertex shader file and a fragment shader file. - /// - /// + /// @param vertexFilename /// Filepath to the vertex shader. - /// - /// + /// @param fragPath /// Filepath to the fragment shader - /// bool Compile(const std::string& vertexFilename, const std::string& fragPath); void Use(); #pragma region Uniform handling - /// /// Returns the location of a uniform given by name. - /// - /// + /// @param name /// String containing the name of a uniform in this shader program. - /// - /// + /// @return /// A GLint containing the location of the requested uniform. - /// int32_t GetUniformLocation(const std::string& name); - /// /// Set a boolean uniform value in the active program by name. - /// - /// + /// @param name /// The name of the uniform to set. - /// - /// + /// @param value /// The boolean value to set the uniform to. - /// void SetBool(const std::string& name, bool value); - /// /// Set an integer uniform value in the active program by name. - /// - /// + /// @param name /// The name of the uniform to set. - /// - /// + /// @param value /// The integer value to set the uniform to. - /// void SetInt(const std::string& name, int value); - /// /// Set a float uniform value in the active program by name. - /// - /// + /// @param name /// The name of the uniform to set. - /// - /// + /// @param value /// The float value to set the uniform to. - /// void SetFloat(const std::string& name, float value); - /// /// Set a float mat4 uniform value in the active program by name. - /// - /// + /// @param name /// The name of the uniform to set. - /// - /// + /// @param value /// The float mat4 value to set the uniform to. - /// void SetMatrix4f(const std::string& name, const glm::mat4& value); - /// /// Set a float vec2 uniform value in the active program by name. - /// - /// + /// @param name /// The name of the uniform to set. - /// - /// + /// @param value /// The float vec2 value to set the uniform to. - /// void SetVector2f(const std::string& name, const glm::vec2& value); - /// /// Set a float vec3 uniform value in the active program by name. - /// - /// + /// @param name /// The name of the uniform to set. - /// - /// + /// @param value /// The float vec3 value to set the uniform to. - /// void SetVector3f(const std::string& name, const glm::vec3& value); - /// /// Set a float vec4 uniform value in the active program by name. - /// - /// + /// @param name /// The name of the uniform to set. - /// - /// + /// @param value /// The float vec4 value to set the uniform to. - /// void SetVector4f(const std::string& name, const glm::vec4& value); - /// /// Set a boolean uniform value in the active program by location. - /// - /// + /// @param uniformLoc /// The location of the uniform to set. - /// - /// + /// @param value /// The boolean value to set the uniform to. - /// static void SetBool(int32_t uniformLoc, bool value); - /// /// Set an integer uniform value in the active program by location. - /// - /// + /// @param uniformLoc /// The location of the uniform to set. - /// - /// + /// @param value /// The integer value to set the uniform to. - /// static void SetInt(int32_t uniformLoc, int value); - /// /// Set a float uniform value in the active program by location. - /// - /// + /// @param uniformLoc /// The location of the uniform to set. - /// - /// + /// @param value /// The float value to set the uniform to. - /// static void SetFloat(int32_t uniformLoc, float value); - /// /// Set a float mat4 uniform value in the active program by location. - /// - /// + /// @param uniformLoc /// The location of the uniform to set. - /// - /// + /// @param value /// The float mat4 value to set the uniform to. - /// static void SetMatrix4f(int32_t uniformLoc, const glm::mat4& value); - /// /// Set a float vec2 uniform value in the active program by location. - /// - /// + /// @param uniformLoc /// The location of the uniform to set. - /// - /// + /// @param value /// The float vec2 value to set the uniform to. - /// static void SetVector2f(int32_t uniformLoc, const glm::vec2& value); - /// /// Set a float vec3 uniform value in the active program by location. - /// - /// + /// @param uniformLoc /// The location of the uniform to set. - /// - /// + /// @param value /// The float vec3 value to set the uniform to. - /// static void SetVector3f(int32_t uniformLoc, const glm::vec3& value); - /// /// Set a float vec4 uniform value in the active program by location. - /// - /// + /// @param uniformLoc /// The location of the uniform to set. - /// - /// + /// @param value /// The float vec4 value to set the uniform to. - /// static void SetVector4f(int32_t uniformLoc, const glm::vec4& value); #pragma endregion #pragma region Engine Defined Uniforms - /// /// Get the location of the texture sampler uniform. - /// - /// + /// @return /// The location of the texture uniform. This may be -1 if the shader doesn't use textures, in which case the value will be ignored. - /// int GetTextureUniform() { return m_TextureUniform; } - /// /// Get the location of the color modifier uniform. - /// - /// + /// @return /// The location of the color modifier uniform. This may be -1 if the shader doesn't use the color mod, in which case the value will be ignored. - /// int GetColorUniform() { return m_ColorUniform; } - /// /// Get the location of the transformation matrix uniform. - /// - /// + /// @return /// The location of the transformation matrix uniform. This may be -1 if the shader doesn't use transforms, in which case the value will be ignored. - /// int GetTransformUniform() { return m_TransformUniform; } - /// /// Get the location of the transformation matrix uniform. - /// - /// + /// @return /// The location of the UV transformation matrix uniform. This may be -1 if the shader doesn't use UV transforms, in which case the value will be ignored. - /// int GetUVTransformUniform() { return m_UVTransformUniform; } - /// /// Get the location of the projection matrix uniform. - /// - /// + /// @return /// The location of the color modifier uniform. This may be -1 if the shader doesn't apply projection, in which case the value will be ignored. - /// int GetProjectionUniform() { return m_ProjectionUniform; } #pragma endregion private: uint32_t m_ProgramID; - /// /// Compiles a shader component from a data string. - /// - /// + /// @param shaderID /// ID of the shader component to compile. - /// - /// + /// @param data /// The shader code string. - /// - /// + /// @param error /// String to contain error data returned by opengl during compilation. - /// - /// + /// @return /// Whether compilation was successful. - /// bool CompileShader(uint32_t shaderID, const std::string& data, std::string& error); - /// /// Links a shader program from a vertex and fragment shader. - /// - /// + /// @param vtxShader /// The compiled vertex shader. - /// - /// + /// @param fragShader /// The compiled fragment shader. - /// - /// + /// @return /// Whether linking was successful. - /// bool Link(uint32_t vtxShader, uint32_t fragShader); - /// /// Sets default values for the shader uniforms (may not persist across frames!) - /// void ApplyDefaultUniforms(); int m_TextureUniform; //!< Location of the texture uniform (sampler2d rteTexture). diff --git a/Source/System/Singleton.h b/Source/System/Singleton.h index 36e886d136..9415fd5df6 100644 --- a/Source/System/Singleton.h +++ b/Source/System/Singleton.h @@ -7,36 +7,26 @@ namespace RTE { template - /// /// Anything derived from this class will adhere to the Singleton pattern. /// To convert any class into a Singleton, do the three following steps: /// 1. Publicly derive your class MyClass from Singleton. /// 2. Make sure to instantiate MyClass once before using it. /// 3. Call MyClass::Instance() to use the MyClass object from anywhere. - /// class Singleton { public: - /// /// Destructor method used to clean up a Singleton object before deletion. - /// ~Singleton() = default; - /// /// Returns the sole instance of this Singleton. - /// - /// A reference to the sole instance of this Singleton. + /// @return A reference to the sole instance of this Singleton. inline static Type& Instance() { return *s_Instance; } - /// /// Constructs this Singleton. - /// inline static void Construct() { s_Instance = new Type(); } protected: - /// /// Constructor method used to instantiate a Singleton object. - /// Singleton() { RTEAssert(!s_Instance, "Trying to create a second instance of a Singleton!"); } private: diff --git a/Source/System/SpatialPartitionGrid.cpp b/Source/System/SpatialPartitionGrid.cpp index bc32a59191..cbf283d22f 100644 --- a/Source/System/SpatialPartitionGrid.cpp +++ b/Source/System/SpatialPartitionGrid.cpp @@ -6,8 +6,6 @@ namespace RTE { - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SpatialPartitionGrid::Clear() { m_Width = 0; m_Height = 0; @@ -19,8 +17,6 @@ namespace RTE { m_UsedCellIds.clear(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int SpatialPartitionGrid::Create(int width, int height, int cellSize) { m_Width = width / cellSize; m_Height = height / cellSize; @@ -32,8 +28,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int SpatialPartitionGrid::Create(const SpatialPartitionGrid& reference) { m_Width = reference.m_Width; m_Height = reference.m_Height; @@ -44,8 +38,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SpatialPartitionGrid::Reset() { const Activity* activity = g_ActivityMan.GetActivity(); RTEAssert(activity, "Tried to reset spatial partition grid with no running Activity!"); @@ -62,8 +54,6 @@ namespace RTE { m_UsedCellIds.clear(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SpatialPartitionGrid::Add(const IntRect& rect, const MovableObject& mo) { const Activity* activity = g_ActivityMan.GetActivity(); RTEAssert(activity, "Tried to add to spatial partition grid with no running Activity!"); @@ -102,7 +92,6 @@ namespace RTE { } } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// std::vector SpatialPartitionGrid::GetMOsInBox(const Box& box, int ignoreTeam, bool getsHitByMOsOnly) const { RTEAssert(ignoreTeam >= Activity::NoTeam && ignoreTeam < Activity::MaxTeamCount, "Invalid ignoreTeam given to SpatialPartitioningGrid::GetMOsInBox()!"); @@ -142,8 +131,6 @@ namespace RTE { return MOList; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - std::vector SpatialPartitionGrid::GetMOsInRadius(const Vector& center, float radius, int ignoreTeam, bool getsHitByMOsOnly) const { RTEAssert(ignoreTeam >= Activity::NoTeam && ignoreTeam < Activity::MaxTeamCount, "Invalid ignoreTeam given to SpatialPartitioningGrid::GetMOsInRadius()!"); @@ -176,8 +163,6 @@ namespace RTE { return MOList; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - const std::vector& SpatialPartitionGrid::GetMOIDsAtPosition(int x, int y, int ignoreTeam, bool getsHitByMOsOnly) const { int cellX = x / m_CellSize; int cellY = y / m_CellSize; @@ -191,8 +176,6 @@ namespace RTE { return cells[ignoreTeam + 1][GetCellIdForCellCoords(cellX, cellY)]; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int SpatialPartitionGrid::GetCellIdForCellCoords(int cellX, int cellY) const { // We act like we wrap, even if the Scene doesn't. The only cost is some duplicate collision checks, but that's a minor cost to pay :) int wrappedX = cellX % m_Width; diff --git a/Source/System/SpatialPartitionGrid.h b/Source/System/SpatialPartitionGrid.h index 937aad172b..4ac10952de 100644 --- a/Source/System/SpatialPartitionGrid.h +++ b/Source/System/SpatialPartitionGrid.h @@ -14,80 +14,60 @@ namespace RTE { struct IntRect; class MovableObject; - /// /// A spatial partitioning grid, used to optimize MOID collision checks. - /// class SpatialPartitionGrid { public: #pragma region Creation - /// /// Constructor method used to instantiate a SpatialPartitionGrid object. - /// SpatialPartitionGrid() { Clear(); } - /// /// Constructor method used to instantiate a SpatialPartitionGrid object. - /// SpatialPartitionGrid(int width, int height, int cellSize) { Clear(); Create(width, height, cellSize); } - /// /// Makes the SpatialPartitionGrid object ready for use. - /// - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create(int width, int height, int cellSize); - /// /// Creates a SpatialPartitionGrid to be identical to another, by deep copy. - /// - /// A reference to the SpatialPartitionGrid to deep copy. - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @param reference A reference to the SpatialPartitionGrid to deep copy. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create(const SpatialPartitionGrid& reference); #pragma endregion #pragma region Grid Management - /// /// Resets the spatial partitioning grid, removing everything from it - /// void Reset(); - /// /// Adds the given MovableObject to this SpatialPartitionGrid. - /// - /// A rectangle defining the space the MovableObject takes up. - /// The MovableObject to add. + /// @param rect A rectangle defining the space the MovableObject takes up. + /// @param mo The MovableObject to add. void Add(const IntRect& rect, const MovableObject& mo); - /// /// Gets a vector of pointers to all MovableObjects within the given Box, who aren't of the ignored team. - /// - /// The Box to get MovableObjects within. - /// The team to ignore when getting MovableObjects. - /// Whether to only include MOs that have GetsHitByMOs enabled, or all MOs. - /// A vector of pointers to all MovableObjects within the given Box, who aren't of the ignored team. + /// @param box The Box to get MovableObjects within. + /// @param ignoreTeam The team to ignore when getting MovableObjects. + /// @param getsHitByMOsOnly Whether to only include MOs that have GetsHitByMOs enabled, or all MOs. + /// @return A vector of pointers to all MovableObjects within the given Box, who aren't of the ignored team. std::vector GetMOsInBox(const Box& box, int ignoreTeam, bool getsHitByMOsOnly) const; - /// /// Get a vector of pointers to all the MovableObjects within the specified radius of the given center point, who aren't of the ignored team. - /// - /// The center point to get MovableObjects around. - /// The radius to get MovableObjects within. - /// The team to ignore when getting MovableObjects. - /// Whether to only include MOs that have GetsHitByMOs enabled, or all MOs. - /// A vector of pointers to all the MovableObjects within the specified radius of the given center point, who aren't of the ignored team. + /// @param center The center point to get MovableObjects around. + /// @param radius The radius to get MovableObjects within. + /// @param ignoreTeam The team to ignore when getting MovableObjects. + /// @param getsHitByMOsOnly Whether to only include MOs that have GetsHitByMOs enabled, or all MOs. + /// @return A vector of pointers to all the MovableObjects within the specified radius of the given center point, who aren't of the ignored team. std::vector GetMOsInRadius(const Vector& center, float radius, int ignoreTeam, bool getsHitByMOsOnly) const; - /// /// Gets the MOIDs that are potentially overlapping the given X and Y Scene coordinates. - /// - /// The X coordinate to check. - /// The Y coordinate to check. - /// The team to ignore when getting MOIDs. - /// Whether to only include MOs that have GetsHitByMOs enabled, or all MOs. - /// A vector of MOIDs that are potentially overlapping the x and y coordinates. + /// @param x The X coordinate to check. + /// @param y The Y coordinate to check. + /// @param ignoreTeam The team to ignore when getting MOIDs. + /// @param getsHitByMOsOnly Whether to only include MOs that have GetsHitByMOs enabled, or all MOs. + /// @return A vector of MOIDs that are potentially overlapping the x and y coordinates. const std::vector& GetMOIDsAtPosition(int x, int y, int ignoreTeam, bool getsHitByMOsOnly) const; #pragma endregion @@ -103,17 +83,13 @@ namespace RTE { tsl::hopscotch_set m_UsedCellIds; //!< Set of used cell Ids, maintained to avoid wasting time looping through and clearing unused cells. - /// /// Gets the Id of the cell at the given SpatialPartitionGrid coordinates, automatically accounting for wrapping. - /// - /// The x coordinate of the cell to get the Id of. - /// The y coordinate of the cell to get the Id of. - /// The Id of the cell at the given SpatialPartitionGrid coordinates. + /// @param cellX The x coordinate of the cell to get the Id of. + /// @param cellY The y coordinate of the cell to get the Id of. + /// @return The Id of the cell at the given SpatialPartitionGrid coordinates. int GetCellIdForCellCoords(int cellX, int cellY) const; - /// /// Clears all the member variables of this SpatialPartitionGrid. - /// void Clear(); // Disallow the use of an implicit method. diff --git a/Source/System/StandardIncludes.h b/Source/System/StandardIncludes.h index 929636a98e..a5530e3942 100644 --- a/Source/System/StandardIncludes.h +++ b/Source/System/StandardIncludes.h @@ -89,9 +89,7 @@ namespace std { - /// /// Custom std::hash specialization to allow using std::array as key in hash table based containers. - /// template struct hash> { size_t operator()(const array& arr) const { hash hasher; diff --git a/Source/System/System.cpp b/Source/System/System.cpp index 30fc6465da..a8099d291c 100644 --- a/Source/System/System.cpp +++ b/Source/System/System.cpp @@ -33,8 +33,6 @@ namespace RTE { const std::string System::s_ZippedModulePackageExtension = ".zip"; const std::unordered_set System::s_SupportedExtensions = {".ini", ".txt", ".lua", ".cfg", ".bmp", ".png", ".jpg", ".jpeg", ".wav", ".ogg", ".mp3", ".flac"}; - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void System::Initialize(const char* thisExePathAndName) { s_ThisExePathAndName = std::filesystem::path(thisExePathAndName).generic_string(); @@ -114,8 +112,6 @@ namespace RTE { #endif } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool System::MakeDirectory(const std::string& pathToMake) { bool createResult = std::filesystem::create_directory(pathToMake); if (createResult) { @@ -124,8 +120,6 @@ namespace RTE { return createResult; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool System::PathExistsCaseSensitive(const std::string& pathToCheck) { // Use Hash for compiler independent hashing. if (s_CaseSensitive) { @@ -145,8 +139,6 @@ namespace RTE { return std::filesystem::exists(pathToCheck); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void System::EnableLoggingToCLI() { #ifdef _WIN32 // Create a console instance for the current process @@ -167,8 +159,6 @@ namespace RTE { s_LogToCLI = true; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void System::PrintLoadingToCLI(const std::string& reportString, bool newItem) { if (newItem) { std::cout << std::endl; @@ -209,8 +199,6 @@ namespace RTE { std::cout << unicodedOutput << std::flush; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void System::PrintToCLI(const std::string& stringToPrint) { #if _LINUX_OR_MACOSX_ std::string outputString = stringToPrint; @@ -233,8 +221,6 @@ namespace RTE { #endif } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - std::string System::ExtractZippedDataModule(const std::string& zippedModulePath) { std::string zippedModuleName = System::GetModDirectory() + std::filesystem::path(zippedModulePath).filename().generic_string(); @@ -369,8 +355,6 @@ namespace RTE { return extractionProgressReport.str(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int System::ASCIIFileContainsString(const std::string& filePath, const std::string_view& findString) { std::ifstream inputStream(filePath, std::ios::binary); if (!inputStream.is_open()) { diff --git a/Source/System/System.h b/Source/System/System.h index ea19eaf2eb..8c135d13b7 100644 --- a/Source/System/System.h +++ b/Source/System/System.h @@ -3,176 +3,124 @@ namespace RTE { - /// /// Class for the system functionality. - /// class System { public: #pragma region Creation - /// /// Store the current working directory and create any missing subdirectories. - /// - /// The path and name of this executable. + /// @param thisExePathAndName The path and name of this executable. static void Initialize(const char* thisExePathAndName); #pragma endregion #pragma region Program Termination - /// /// Gets whether the program was set to be terminated by the user. - /// - /// Whether the program was set to be terminated by the user. + /// @return Whether the program was set to be terminated by the user. static bool IsSetToQuit() { return s_Quit; } - /// /// Sets the program to be terminated. - /// - /// Terminate or not. + /// @param quitOrNot Terminate or not. static void SetQuit(bool quitOrNot = true) { s_Quit = quitOrNot; } - /// /// Sets termination when the close button (X) is pressed on the program window. - /// static void WindowCloseButtonHandler() { SetQuit(); } #pragma endregion #pragma region Directories - /// /// Gets the absolute path to this executable. - /// - /// Absolute path to this executable. + /// @return Absolute path to this executable. static const std::string& GetThisExePathAndName() { return s_ThisExePathAndName; } - /// /// Gets the current working directory. - /// - /// Absolute path to current working directory. + /// @return Absolute path to current working directory. static const std::string& GetWorkingDirectory() { return s_WorkingDirectory; } - /// /// Gets the game data directory name. - /// - /// Folder name of the game data directory. + /// @return Folder name of the game data directory. static const std::string& GetDataDirectory() { return s_DataDirectory; } - /// /// Gets the screenshot directory name. - /// - /// Folder name of the screenshots directory. + /// @return Folder name of the screenshots directory. static const std::string& GetScreenshotDirectory() { return s_ScreenshotDirectory; } - /// /// Gets the mod directory name. - /// - /// Folder name of the mod directory. + /// @return Folder name of the mod directory. static const std::string& GetModDirectory() { return s_ModDirectory; } - /// /// Gets the userdata directory name. - /// - /// Folder name of the userdata directory. + /// @return Folder name of the userdata directory. static const std::string& GetUserdataDirectory() { return s_UserdataDirectory; } - /// /// Gets the extension that determines a directory/file is an RTE module. - /// - /// String containing the RTE module extension. + /// @return String containing the RTE module extension. static const std::string& GetModulePackageExtension() { return s_ModulePackageExtension; } - /// /// Gets the extension that determines a file is a zipped RTE module. - /// - /// String containing the zipped RTE module extension. + /// @return String containing the zipped RTE module extension. static const std::string& GetZippedModulePackageExtension() { return s_ZippedModulePackageExtension; } - /// /// Create a directory. - /// - /// Path to create. - /// Returns 0 if successful. + /// @param path Path to create. + /// @return Returns 0 if successful. static bool MakeDirectory(const std::string& pathToMake); #pragma endregion #pragma region Filesystem - /// /// Gets whether case sensitivity is enforced when checking for file existence. - /// - /// Whether case sensitivity is enforced. + /// @return Whether case sensitivity is enforced. static bool FilePathsCaseSensitive() { return s_CaseSensitive; } - /// /// Sets whether case sensitivity should be enforced when checking for file existence. - /// - /// Whether case sensitivity should be enforced or not. + /// @param enable Whether case sensitivity should be enforced or not. static void EnableFilePathCaseSensitivity(bool enable) { s_CaseSensitive = enable; } - /// /// Checks if a file exists. On case sensitive filesystems returns std::filesystem::exists, otherwise the working directory will be checked for a matching file. - /// - /// The path to check. - /// Whether the file exists. + /// @param pathToCheck The path to check. + /// @return Whether the file exists. static bool PathExistsCaseSensitive(const std::string& pathToCheck); #pragma endregion #pragma region Command - Line Interface - /// /// Tells whether printing loading progress report and console to command-line is enabled or not. - /// - /// Whether printing to command-line is enabled or not. + /// @return Whether printing to command-line is enabled or not. static bool IsLoggingToCLI() { return s_LogToCLI; } - /// /// Enables printing the loading progress report and console to command-line. For Windows, also allocates a console instance and redirects cout to it. - /// static void EnableLoggingToCLI(); - /// /// Prints the loading progress report to command-line. - /// static void PrintLoadingToCLI(const std::string& reportString, bool newItem = false); - /// /// Prints console output to command-line. - /// - /// + /// @param inputString static void PrintToCLI(const std::string& stringToPrint); #pragma endregion #pragma region Archived DataModule Handling - /// /// Extracts all files from a zipped DataModule, overwriting any corresponding files already existing. - /// - /// Path to the module to extract. - /// A string containing the progress report of the extraction. + /// @param zippedModulePath Path to the module to extract. + /// @return A string containing the progress report of the extraction. static std::string ExtractZippedDataModule(const std::string& zippedModulePath); #pragma endregion #pragma region Module Validation - /// /// Gets Whether the program is running in module validation mode that is used by an external tool. - /// - /// Whether the program is running in module validation mode. + /// @return Whether the program is running in module validation mode. static bool IsInExternalModuleValidationMode() { return s_ExternalModuleValidation; } - /// /// Sets the program to run in module validation mode to be used by an external tool. - /// static void EnableExternalModuleValidationMode() { s_ExternalModuleValidation = true; } #pragma endregion #pragma region Misc - /// /// Fires up the default browser for the current OS on a specific URL. - /// - /// A string with the URL to send the browser to. + /// @param goToURL A string with the URL to send the browser to. static void OpenBrowserToURL(const std::string_view& goToURL) { std::system(std::string("start ").append(goToURL).c_str()); } - /// /// Searches through an ASCII file on disk for a specific string and tells whether it was found or not. - /// - /// The path to the ASCII file to search. - /// The exact string to look for. Case sensitive! - /// 0 if the string was found in the file or 1 if not. -1 if the file was inaccessible. + /// @param The path to the ASCII file to search. + /// @param The exact string to look for. Case sensitive! + /// @return 0 if the string was found in the file or 1 if not. -1 if the file was inaccessible. static int ASCIIFileContainsString(const std::string& filePath, const std::string_view& findString); #pragma endregion diff --git a/Source/System/Timer.cpp b/Source/System/Timer.cpp index e022708dd2..c36ad6d68b 100644 --- a/Source/System/Timer.cpp +++ b/Source/System/Timer.cpp @@ -2,8 +2,6 @@ namespace RTE { - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void Timer::Clear() { m_StartRealTime = g_TimerMan.GetRealTickCount(); m_StartSimTime = g_TimerMan.GetSimTickCount(); @@ -11,15 +9,11 @@ namespace RTE { m_SimTimeLimit = -1; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int Timer::Create() { m_TicksPerMS = static_cast(g_TimerMan.GetTicksPerSecond()) * 0.001; return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int Timer::Create(double simTimeLimit, double elapsedSimTime) { m_TicksPerMS = static_cast(g_TimerMan.GetTicksPerSecond()) * 0.001; SetSimTimeLimitMS(simTimeLimit); @@ -29,8 +23,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int Timer::Create(const Timer& reference) { m_StartRealTime = reference.m_StartRealTime; m_StartSimTime = reference.m_StartSimTime; diff --git a/Source/System/Timer.h b/Source/System/Timer.h index 50091118b3..abfb579e17 100644 --- a/Source/System/Timer.h +++ b/Source/System/Timer.h @@ -5,82 +5,62 @@ namespace RTE { - /// /// A precise timer for FPS sync etc. - /// class Timer { public: #pragma region Creation - /// /// Constructor method used to instantiate a Timer object. - /// Timer() { Clear(); Create(); } - /// /// Constructor method used to instantiate a Timer object with a set sim time elapsed. - /// - /// A unsigned long defining this Timer's sim time limit in ms. + /// @param simTimeLimit A unsigned long defining this Timer's sim time limit in ms. Timer(double simTimeLimit) { Clear(); Create(simTimeLimit); } - /// /// Constructor method used to instantiate a Timer object with a set sim time elapsed. - /// - /// A unsigned long defining this Timer's sim time limit in ms. - /// A unsigned long defining the amount of time (in ms) that this Timer should start with elapsed. + /// @param simTimeLimit A unsigned long defining this Timer's sim time limit in ms. + /// @param elapsedSimTime A unsigned long defining the amount of time (in ms) that this Timer should start with elapsed. Timer(double simTimeLimit, double elapsedSimTime) { Clear(); Create(simTimeLimit, elapsedSimTime); } - /// /// Copy constructor method used to instantiate a Timer object identical to an already existing one. - /// - /// A Timer object which is passed in by reference. + /// @param reference A Timer object which is passed in by reference. Timer(const Timer& reference) { Clear(); Create(reference); } - /// /// Makes the Timer object ready for use. - /// - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create(); - /// /// Makes the Timer object ready for use. - /// - /// A unsigned long defining this Timer's sim time limit in ms. - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @param simTimeLimit A unsigned long defining this Timer's sim time limit in ms. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create(double simTimeLimit) { return Create(simTimeLimit, 0); } - /// /// Makes the Timer object ready for use. - /// - /// A unsigned long defining this Timer's sim time limit in ms. - /// A unsigned long defining the amount of time (in ms) that this Timer should start with elapsed. - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @param simTimeLimit A unsigned long defining this Timer's sim time limit in ms. + /// @param elapsedSimTime A unsigned long defining the amount of time (in ms) that this Timer should start with elapsed. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create(double simTimeLimit, double elapsedSimTime); - /// /// Creates a Timer to be identical to another, by deep copy. - /// - /// A reference to the Timer to deep copy. - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @param reference A reference to the Timer to deep copy. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create(const Timer& reference); #pragma endregion #pragma region Destruction - /// /// Resets the timer so that the elapsed time is 0 ms. - /// // TODO: Figure out why calling Clear() here breaks time. void Reset() { m_StartRealTime = g_TimerMan.GetRealTickCount(); @@ -89,228 +69,160 @@ namespace RTE { #pragma endregion #pragma region Real Time - /// /// Gets the start real time value of this Timer. - /// - /// An int64 value that represents the amount of real time in ms from when windows was started to when Reset() of this Timer was called. + /// @return An int64 value that represents the amount of real time in ms from when windows was started to when Reset() of this Timer was called. int64_t GetStartRealTimeMS() const { return m_StartRealTime; } - /// /// Sets the start real time value of this Timer. - /// - /// An int64 with the new real time value (ms since the OS was started). + /// @param newStartTime An int64 with the new real time value (ms since the OS was started). void SetStartRealTimeMS(const int64_t newStartTime) { m_StartRealTime = newStartTime * m_TicksPerMS; } - /// /// Gets the real time limit value of this Timer, RELATVE to the start time. /// This is when the timer is supposed to show that it has 'expired' or reached whatever time limit it is supposed to keep track of. - /// - /// A positive double with the real time limit relative to the start time. + /// @return A positive double with the real time limit relative to the start time. double GetRealTimeLimitMS() const { return m_RealTimeLimit / m_TicksPerMS; } - /// /// Sets the real time limit value of this Timer, RELATVE to the start time. /// This is when the timer is supposed to show that it has 'expired' or reached whatever time limit it is supposed to keep track of. - /// - /// A positive double with the new real time limit relative to the start time. + /// @param newTimeLimit A positive double with the new real time limit relative to the start time. void SetRealTimeLimitMS(double newTimeLimit) { m_RealTimeLimit = newTimeLimit * m_TicksPerMS; } - /// /// Gets the real time limit value of this Timer, RELATVE to the start time. /// This is when the timer is supposed to show that it has 'expired' or reached whatever time limit it is supposed to keep track of. - /// - /// A positive double with the real time limit relative to the start time. + /// @return A positive double with the real time limit relative to the start time. double GetRealTimeLimitS() const { return m_RealTimeLimit / static_cast(g_TimerMan.GetTicksPerSecond()); } - /// /// Sets the real time limit value of this Timer, RELATVE to the start time. /// This is when the timer is supposed to show that it has 'expired' or reached whatever time limit it is supposed to keep track of. - /// - /// A positive double with the new real time limit relative to the start time. + /// @param newTimeLimit A positive double with the new real time limit relative to the start time. void SetRealTimeLimitS(double newTimeLimit) { m_RealTimeLimit = newTimeLimit * static_cast(g_TimerMan.GetTicksPerSecond()); } - /// /// Gets the elapsed real time in ms since this Timer was Reset(). - /// - /// A unsigned long value that represents the elapsed real time since Reset() in ms. + /// @return A unsigned long value that represents the elapsed real time since Reset() in ms. double GetElapsedRealTimeMS() const { return static_cast(g_TimerMan.GetRealTickCount() - m_StartRealTime) / m_TicksPerMS; } - /// /// Sets the start real time value of this Timer, in seconds. - /// - /// An int64 with the new elapsed time value. + /// @param newElapsedRealTime An int64 with the new elapsed time value. void SetElapsedRealTimeMS(const double newElapsedRealTime) { m_StartRealTime = g_TimerMan.GetRealTickCount() - (newElapsedRealTime * m_TicksPerMS); } - /// /// Gets the elapsed real time in seconds since this Timer was Reset(). - /// - /// A double value that represents the elapsed real time since Reset() in s. + /// @return A double value that represents the elapsed real time since Reset() in s. double GetElapsedRealTimeS() const { return static_cast(g_TimerMan.GetRealTickCount() - m_StartRealTime) / static_cast(g_TimerMan.GetTicksPerSecond()); } - /// /// Sets the start real time value of this Timer. - /// - /// An int64 with the new elapsed time value in seconds. + /// @param newElapsedRealTime An int64 with the new elapsed time value in seconds. void SetElapsedRealTimeS(const double newElapsedRealTime) { m_StartRealTime = g_TimerMan.GetRealTickCount() - (newElapsedRealTime * static_cast(g_TimerMan.GetTicksPerSecond())); } - /// /// Returns how much time in ms that there is left till this Timer reaches a certain time limit. - /// - /// A unsigned long specifying till when there is time. - /// A unsigned long with the time left till the passed in value, or negative if this Timer is already past that point in time. + /// @param when A unsigned long specifying till when there is time. + /// @return A unsigned long with the time left till the passed in value, or negative if this Timer is already past that point in time. unsigned long LeftTillRealMS(int64_t when) { return when - GetElapsedRealTimeMS(); } - /// /// Returns true if the elapsed real time is past a certain amount of time relative to this' start. - /// - /// A long specifying the threshold amount of real time in ms. - /// A bool only yielding true if the elapsed real time is greater than the passed in value. + /// @param limit A long specifying the threshold amount of real time in ms. + /// @return A bool only yielding true if the elapsed real time is greater than the passed in value. bool IsPastRealMS(long limit) { return GetElapsedRealTimeMS() > limit; } - /// /// Returns how much time in ms that there is left till this Timer reaches a certain time limit previously set by SetRealTimeLimitMS. - /// - /// How many MS left till the real time limit, or negative if this Timer is already past that point in time. + /// @return How many MS left till the real time limit, or negative if this Timer is already past that point in time. double LeftTillRealTimeLimitMS() { return GetRealTimeLimitMS() - GetElapsedRealTimeMS(); } - /// /// Returns how much time in ms that there is left till this Timer reaches a certain time limit previously set by SetRealTimeLimitS. - /// - /// How many S left till the real time limit, or negative if this Timer is already past that point in time. + /// @return How many S left till the real time limit, or negative if this Timer is already past that point in time. double LeftTillRealTimeLimitS() { return GetRealTimeLimitS() - GetElapsedRealTimeS(); } - /// /// Returns true if the elapsed real time is past a certain amount of time after the start previously set by SetRealTimeLimit. - /// - /// A bool only yielding true if the elapsed real time is greater than the set limit value. If no limit has been set, this returns false. + /// @return A bool only yielding true if the elapsed real time is greater than the set limit value. If no limit has been set, this returns false. bool IsPastRealTimeLimit() const { return (m_RealTimeLimit == 0) ? true : (m_RealTimeLimit > 0 && (g_TimerMan.GetRealTickCount() - m_StartRealTime) > m_RealTimeLimit); } - /// /// Returns how much progress has been made toward the set time limit previously set by SetRealTimeLimitMS. /// 0 means no progress, 1.0 means the timer has reached, or is beyond the limit. - /// - /// A normalized scalar between 0.0 - 1.0 showing the progress toward the limit. + /// @return A normalized scalar between 0.0 - 1.0 showing the progress toward the limit. double RealTimeLimitProgress() const { return (m_RealTimeLimit == 0) ? 1.0 : (std::min(1.0, GetElapsedRealTimeMS() / (m_RealTimeLimit / m_TicksPerMS))); } - /// /// Returns true or false, depending on whether the elapsed time falls in one of two repeating intervals which divide it. /// This is useful for blink animations etc. - /// - /// An int with the alternating period in ms. The time specified here is how long it will take for the switch to alternate. - /// Whether the elapsed time is in the first state or not. + /// @param period An int with the alternating period in ms. The time specified here is how long it will take for the switch to alternate. + /// @return Whether the elapsed time is in the first state or not. bool AlternateReal(int period) const { return (static_cast(GetElapsedRealTimeMS()) % (period * 2)) > period; } #pragma endregion #pragma region Simulation Time - /// /// Gets the start time value of this Timer. - /// - /// An int64 value that represents the amount of time in ticks from when windows was started to when Reset() of this Timer was called. + /// @return An int64 value that represents the amount of time in ticks from when windows was started to when Reset() of this Timer was called. int64_t GetStartSimTimeMS() const { return m_StartSimTime; } - /// /// Sets the start time value of this Timer, in ticks - /// - /// An int64 with the new time value (ms since windows was started). + /// @param newStartTime An int64 with the new time value (ms since windows was started). void SetStartSimTimeMS(const int64_t newStartTime) { m_StartSimTime = newStartTime * m_TicksPerMS; } - /// /// Sets the sim time limit value of this Timer, RELATVE to the start time. /// This is when the timer is supposed to show that it has 'expired' or reached whatever time limit it is supposed to keep track of. - /// - /// A positive double with the sim time limit relative to the start time. + /// @return A positive double with the sim time limit relative to the start time. double GetSimTimeLimitMS() const { return m_SimTimeLimit / m_TicksPerMS; } - /// /// Sets the sim time limit value of this Timer, RELATVE to the start time. /// This is when the timer is supposed to show that it has 'expired' or reached whatever time limit it is supposed to keep track of. - /// - /// A positive double with the new sim time limit relative to the start time. + /// @param newTimeLimit A positive double with the new sim time limit relative to the start time. void SetSimTimeLimitMS(double newTimeLimit) { m_SimTimeLimit = newTimeLimit * m_TicksPerMS; } - /// /// Sets the sim time limit value of this Timer, RELATVE to the start time. /// This is when the timer is supposed to show that it has 'expired' or reached whatever time limit it is supposed to keep track of. - /// - /// A positive double with the sim time limit relative to the start time. + /// @return A positive double with the sim time limit relative to the start time. double GetSimTimeLimitS() const { return m_SimTimeLimit / static_cast(g_TimerMan.GetTicksPerSecond()); } - /// /// Sets the sim time limit value of this Timer, RELATVE to the start time. /// This is when the timer is supposed to show that it has 'expired' or reached whatever time limit it is supposed to keep track of. - /// - /// A positive double with the new sim time limit relative to the start time. + /// @param newTimeLimit A positive double with the new sim time limit relative to the start time. void SetSimTimeLimitS(double newTimeLimit) { m_SimTimeLimit = newTimeLimit * static_cast(g_TimerMan.GetTicksPerSecond()); } - /// /// Gets the elapsed time in ms since this Timer was Reset(). - /// - /// A unsigned long value that represents the elapsed time since Reset() in ms. + /// @return A unsigned long value that represents the elapsed time since Reset() in ms. double GetElapsedSimTimeMS() const { return static_cast(g_TimerMan.GetSimTickCount() - m_StartSimTime) / m_TicksPerMS; } - /// /// Sets the start time value of this Timer, in ms. - /// - /// A double with the new elapsed time value. + /// @param newElapsedSimTime A double with the new elapsed time value. void SetElapsedSimTimeMS(const double newElapsedSimTime) { m_StartSimTime = g_TimerMan.GetSimTickCount() - (newElapsedSimTime * m_TicksPerMS); } - /// /// Gets the elapsed time in s since this Timer was Reset(). - /// - /// A unsigned long value that represents the elapsed time since Reset() in s. + /// @return A unsigned long value that represents the elapsed time since Reset() in s. double GetElapsedSimTimeS() const { return static_cast(g_TimerMan.GetSimTickCount() - m_StartSimTime) / static_cast(g_TimerMan.GetTicksPerSecond()); } - /// /// Sets the start time value of this Timer, in seconds. - /// - /// An int64 with the new elapsed time value in seconds. + /// @param newElapsedSimTime An int64 with the new elapsed time value in seconds. void SetElapsedSimTimeS(const double newElapsedSimTime) { m_StartSimTime = g_TimerMan.GetSimTickCount() - (newElapsedSimTime * static_cast(g_TimerMan.GetTicksPerSecond())); } - /// /// Returns how much time in ms that there is left till this Timer reaches a certain time limit.a certain time limit. - /// - /// A unsigned long specifying till when there is time. - /// A unsigned long with the time left till the passed in value, or negative if this Timer is already past that point in time. + /// @param when A unsigned long specifying till when there is time. + /// @return A unsigned long with the time left till the passed in value, or negative if this Timer is already past that point in time. double LeftTillSimMS(double when) const { return when - GetElapsedSimTimeMS(); } - /// /// Returns true if the elapsed time is past a certain amount of time. - /// - /// A unsigned long specifying the threshold amount of time in ms. - /// A bool only yielding true if the elapsed time is greater than the passed in value. + /// @param limit A unsigned long specifying the threshold amount of time in ms. + /// @return A bool only yielding true if the elapsed time is greater than the passed in value. bool IsPastSimMS(double limit) const { return GetElapsedSimTimeMS() > limit; } - /// /// Returns how much time in ms that there is left till this Timer reaches a certain time limit previously set by SetSimTimeLimitMS. - /// - /// How many MS left till the sim time limit, or negative if this Timer is already past that point in time. + /// @return How many MS left till the sim time limit, or negative if this Timer is already past that point in time. double LeftTillSimTimeLimitMS() const { return GetSimTimeLimitMS() - GetElapsedSimTimeMS(); } - /// /// Returns how much time in ms that there is left till this Timer reaches a certain time limit previously set by SetSimTimeLimitS. - /// - /// How many S left till the real time limit, or negative if this Timer is already past that point in time. + /// @return How many S left till the real time limit, or negative if this Timer is already past that point in time. double LeftTillSimTimeLimitS() const { return GetSimTimeLimitS() - GetElapsedSimTimeS(); } - /// /// Returns true if the elapsed sim time is past a certain amount of time after the start previously set by SetSimTimeLimit. - /// - /// A bool only yielding true if the elapsed real time is greater than the set limit value. If no limit has been set, this returns false. + /// @return A bool only yielding true if the elapsed real time is greater than the set limit value. If no limit has been set, this returns false. bool IsPastSimTimeLimit() const { return (m_SimTimeLimit == 0) ? true : (m_SimTimeLimit > 0 && (g_TimerMan.GetSimTickCount() - m_StartSimTime) > m_SimTimeLimit); } - /// /// Returns how much progress has been made toward the set time limit previously set by SetSimTimeLimitMS. /// 0 means no progress, 1.0 means the timer has reached, or is beyond the limit. - /// - /// A normalized scalar between 0.0 - 1.0 showing the progress toward the limit. + /// @return A normalized scalar between 0.0 - 1.0 showing the progress toward the limit. double SimTimeLimitProgress() const { return (m_SimTimeLimit == 0) ? 1.0 : (std::min(1.0, GetElapsedSimTimeMS() / (m_SimTimeLimit / m_TicksPerMS))); } - /// /// Returns true or false, depending on whether the elapsed time falls in one of two repeating intervals which divide it. /// This is useful for blink animations etc. - /// - /// An int with the alternating period in ms. The time specified here is how long it will take for the switch to alternate. - /// Whether the elapsed time is in the first state or not. + /// @param period An int with the alternating period in ms. The time specified here is how long it will take for the switch to alternate. + /// @return Whether the elapsed time is in the first state or not. bool AlternateSim(int period) const { return (period == 0) ? true : (static_cast(GetElapsedSimTimeMS()) % (period * 2)) > period; } #pragma endregion @@ -324,9 +236,7 @@ namespace RTE { int64_t m_SimTimeLimit; //!< Tick count, relative to the start time, when this should indicate end or expired in simulation time. private: - /// /// Clears all the member variables of this Timer, effectively resetting the members of this abstraction level only. - /// void Clear(); }; } // namespace RTE diff --git a/Source/System/Vector.cpp b/Source/System/Vector.cpp index 6a825e07e0..7f5f315315 100644 --- a/Source/System/Vector.cpp +++ b/Source/System/Vector.cpp @@ -6,8 +6,6 @@ namespace RTE { const std::string Vector::c_ClassName = "Vector"; - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int Vector::ReadProperty(const std::string_view& propName, Reader& reader) { StartPropertyList(return Serializable::ReadProperty(propName, reader)); @@ -17,8 +15,6 @@ namespace RTE { EndPropertyList; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int Vector::Save(Writer& writer) const { Serializable::Save(writer); diff --git a/Source/System/Vector.h b/Source/System/Vector.h index d91fb772c8..ddbc1e96d1 100644 --- a/Source/System/Vector.h +++ b/Source/System/Vector.h @@ -11,9 +11,7 @@ namespace RTE { Y = 1 }; - /// /// A useful 2D float vector. - /// class Vector : public Serializable { public: @@ -24,24 +22,18 @@ namespace RTE { float m_Y = 0.0F; //!< Y value of this vector. #pragma region Creation - /// /// Constructor method used to instantiate a Vector object with values (0, 0). - /// inline Vector() = default; - /// /// Constructor method used to instantiate a Vector object from X and Y values. - /// - /// Float defining the initial X value of this Vector. - /// Float defining the initial Y value of this Vector. + /// @param inputX Float defining the initial X value of this Vector. + /// @param inputY Float defining the initial Y value of this Vector. inline Vector(const float inputX, const float inputY) : m_X(inputX), m_Y(inputY){}; #pragma endregion #pragma region Destruction - /// /// Sets both the X and Y of this Vector to zero. - /// inline void Reset() override { m_X = 0.0F; m_Y = 0.0F; @@ -49,154 +41,114 @@ namespace RTE { #pragma endregion #pragma region Getters and Setters - /// /// Gets the X value of this Vector. - /// - /// A float value that represents the X value of this Vector. + /// @return A float value that represents the X value of this Vector. inline float GetX() const { return m_X; } - /// /// Sets the X value of this Vector. - /// - /// A float value that the X value will be set to. - /// Vector reference to this after the operation. + /// @param newX A float value that the X value will be set to. + /// @return Vector reference to this after the operation. inline Vector& SetX(const float newX) { m_X = newX; return *this; } - /// /// Gets the Y value of this Vector. - /// - /// A float value that represents the Y value of this Vector. + /// @return A float value that represents the Y value of this Vector. inline float GetY() const { return m_Y; } - /// /// Sets the Y value of this Vector. - /// - /// A float value that the Y value will be set to. - /// Vector reference to this after the operation. + /// @param newY A float value that the Y value will be set to. + /// @return Vector reference to this after the operation. inline Vector& SetY(const float newY) { m_Y = newY; return *this; } - /// /// Sets both the X and Y values of this Vector. - /// - /// A float value that the X value will be set to. - /// A float value that the Y value will be set to. - /// Vector reference to this after the operation. + /// @param newX A float value that the X value will be set to. + /// @param newY A float value that the Y value will be set to. + /// @return Vector reference to this after the operation. inline Vector& SetXY(const float newX, const float newY) { m_X = newX; m_Y = newY; return *this; } - /// /// Gets the absolute largest of the two elements. Will always be positive. - /// - /// A float describing the largest value of the two, but not the magnitude. + /// @return A float describing the largest value of the two, but not the magnitude. inline float GetLargest() const { return std::max(std::abs(m_X), std::abs(m_Y)); } - /// /// Gets the absolute smallest of the two elements. Will always be positive. - /// - /// A float describing the smallest value of the two, but not the magnitude. + /// @return A float describing the smallest value of the two, but not the magnitude. inline float GetSmallest() const { return std::min(std::abs(m_X), std::abs(m_Y)); } - /// /// Gets a Vector identical to this except that its X component is flipped. - /// - /// Whether to flip the X axis of the return vector or not. - /// A copy of this vector with flipped X axis. + /// @param xFlip Whether to flip the X axis of the return vector or not. + /// @return A copy of this vector with flipped X axis. inline Vector GetXFlipped(const bool xFlip = true) const { return Vector(xFlip ? -m_X : m_X, m_Y); } - /// /// Flips the X element of this Vector. - /// - /// Whether or not to flip the X element or not. - /// Vector reference to this after the operation. + /// @param flipX Whether or not to flip the X element or not. + /// @return Vector reference to this after the operation. inline Vector& FlipX(const bool flipX = true) { *this = GetXFlipped(flipX); return *this; } - /// /// Gets a Vector identical to this except that its Y component is flipped. - /// - /// Whether to flip the Y axis of the return vector or not. - /// A copy of this vector with flipped Y axis. + /// @param yFlip Whether to flip the Y axis of the return vector or not. + /// @return A copy of this vector with flipped Y axis. inline Vector GetYFlipped(const bool yFlip = true) const { return Vector(m_X, yFlip ? -m_Y : m_Y); } - /// /// Flips the Y element of this Vector. - /// - /// Whether or not to flip the Y element or not. - /// Vector reference to this after the operation. + /// @param flipY Whether or not to flip the Y element or not. + /// @return Vector reference to this after the operation. inline Vector& FlipY(const bool flipY = true) { *this = GetYFlipped(flipY); return *this; } - /// /// Indicates whether the X component of this Vector is 0. - /// - /// Whether the X component of this Vector is 0. + /// @return Whether the X component of this Vector is 0. inline bool XIsZero() const { return m_X == 0; } - /// /// Indicates whether the Y component of this Vector is 0. - /// - /// Whether the Y component of this Vector is 0. + /// @return Whether the Y component of this Vector is 0. inline bool YIsZero() const { return m_Y == 0; } - /// /// Indicates whether both X and Y components of this Vector are 0. - /// - /// Whether both X and Y components of this Vector are 0. + /// @return Whether both X and Y components of this Vector are 0. inline bool IsZero() const { return XIsZero() && YIsZero(); } - /// /// Indicates whether the X and Y components of this Vector each have opposite signs to their corresponding components of a passed in Vector. - /// - /// The Vector to compare with. - /// Whether the X and Y components of this Vector each have opposite signs to their corresponding components of a passed in Vector. + /// @param opp The Vector to compare with. + /// @return Whether the X and Y components of this Vector each have opposite signs to their corresponding components of a passed in Vector. inline bool IsOpposedTo(const Vector& opp) const { return ((XIsZero() && opp.XIsZero()) || (std::signbit(m_X) != std::signbit(opp.m_X))) && ((YIsZero() && opp.YIsZero()) || (std::signbit(m_Y) != std::signbit(opp.m_Y))); } #pragma endregion #pragma region Magnitude - /// /// Gets the squared magnitude of this Vector. - /// - /// A float describing the squared magnitude. + /// @return A float describing the squared magnitude. inline float GetSqrMagnitude() const { return m_X * m_X + m_Y * m_Y; } - /// /// Gets the magnitude of this Vector. - /// - /// A float describing the magnitude. + /// @return A float describing the magnitude. inline float GetMagnitude() const { return std::sqrt(GetSqrMagnitude()); } - /// /// Gets whether this Vector's magnitude is less than the specified value. - /// - /// A float value that this Vector's magnitude will be compared against. - /// Whether this Vector's magnitude is less than the specified value. + /// @param magnitude A float value that this Vector's magnitude will be compared against. + /// @return Whether this Vector's magnitude is less than the specified value. inline bool MagnitudeIsLessThan(float magnitude) const { return GetSqrMagnitude() < magnitude * magnitude; } - /// /// Gets whether this Vector's magnitude is greater than the specified value. - /// - /// A float value that this Vector's magnitude will be compared against. - /// Whether this Vector's magnitude is greater than the specified value. + /// @param magnitude A float value that this Vector's magnitude will be compared against. + /// @return Whether this Vector's magnitude is greater than the specified value. inline bool MagnitudeIsGreaterThan(float magnitude) const { return GetSqrMagnitude() > magnitude * magnitude; } - /// /// Sets the magnitude of this Vector. A negative magnitude will invert the Vector's direction. - /// - /// A float value that the magnitude will be set to. - /// Vector reference to this after the operation. + /// @param newMag A float value that the magnitude will be set to. + /// @return Vector reference to this after the operation. inline Vector& SetMagnitude(const float newMag) { if (IsZero()) { SetXY(newMag, 0.0F); @@ -206,11 +158,9 @@ namespace RTE { return *this; } - /// /// Caps the magnitude of this Vector to a max value and keeps its angle intact. - /// - /// A float value that the magnitude will be capped by. - /// Vector reference to this after the operation. + /// @param capMag A float value that the magnitude will be capped by. + /// @return Vector reference to this after the operation. inline Vector& CapMagnitude(const float capMag) { if (capMag == 0.0F) { Reset(); @@ -221,12 +171,10 @@ namespace RTE { return *this; } - /// /// Clamps the magnitude of this Vector between the upper and lower limits, and keeps its angle intact. - /// - /// A float value that defines the lower limit for the magnitude of this Vector. - /// A float value that defines the upper limit for the magnitude of this Vector. - /// A reference to this after the change. + /// @param lowerMagnitudeLimit A float value that defines the lower limit for the magnitude of this Vector. + /// @param upperMagnitudeLimit A float value that defines the upper limit for the magnitude of this Vector. + /// @return A reference to this after the change. inline Vector& ClampMagnitude(float lowerMagnitudeLimit, float upperMagnitudeLimit) { if (upperMagnitudeLimit < lowerMagnitudeLimit) { std::swap(upperMagnitudeLimit, lowerMagnitudeLimit); @@ -241,16 +189,12 @@ namespace RTE { return *this; } - /// /// Returns a Vector that has the same direction as this but with a magnitude of 1.0. - /// - /// A normalized copy of this vector. + /// @return A normalized copy of this vector. inline Vector GetNormalized() const { return *this / GetMagnitude(); } - /// /// Scales this vector to have the same direction but a magnitude of 1.0. - /// - /// Vector reference to this after the operation. + /// @return Vector reference to this after the operation. inline Vector& Normalize() { *this = GetNormalized(); return *this; @@ -258,38 +202,28 @@ namespace RTE { #pragma endregion #pragma region Rotation - /// /// Get this Vector's absolute angle in radians. e.g: when x = 1, y = 0, the value returned here will be 0. x = 0, y = 1 yields -pi/2 here. - /// - /// The absolute angle in radians, in the interval [-0.5 pi, 1.5 pi). + /// @return The absolute angle in radians, in the interval [-0.5 pi, 1.5 pi). inline float GetAbsRadAngle() const { const float radAngle = -std::atan2(m_Y, m_X); return (radAngle < -c_HalfPI) ? (radAngle + c_TwoPI) : radAngle; } - /// /// Sets this Vector's absolute angle in radians. - /// - /// The Vector's new absolute angle in radians. + /// @param newAbsRadAngle The Vector's new absolute angle in radians. inline void SetAbsRadAngle(float newAbsRadAngle) { RadRotate(newAbsRadAngle - GetAbsRadAngle()); } - /// /// Get this Vector's absolute angle in degrees. e.g: when x = 1, y = 0, the value returned here will be 0. x = 0, y = 1 yields -90 here. - /// - /// The absolute angle in degrees, in the interval [-90, 270). + /// @return The absolute angle in degrees, in the interval [-90, 270). inline float GetAbsDegAngle() const { return GetAbsRadAngle() / c_PI * 180.0F; } - /// /// Sets this Vector's absolute angle in degrees. - /// - /// The Vector's new absolute angle in degrees. + /// @param newAbsDegAngle The Vector's new absolute angle in degrees. inline void SetAbsDegAngle(float newAbsDegAngle) { DegRotate(newAbsDegAngle - GetAbsDegAngle()); } - /// /// Returns a copy of this Vector, rotated relatively by an angle in radians. - /// - /// The angle in radians to rotate by. Positive angles rotate counter-clockwise, and negative angles clockwise. - /// A rotated copy of this Vector. + /// @param angle The angle in radians to rotate by. Positive angles rotate counter-clockwise, and negative angles clockwise. + /// @return A rotated copy of this Vector. inline Vector GetRadRotatedCopy(const float angle) { Vector returnVector = *this; const float adjustedAngle = -angle; @@ -298,50 +232,38 @@ namespace RTE { return returnVector; } - /// /// Rotate this Vector relatively by an angle in radians. - /// - /// The angle in radians to rotate by. Positive angles rotate counter-clockwise, and negative angles clockwise. - /// Vector reference to this after the operation. + /// @param angle The angle in radians to rotate by. Positive angles rotate counter-clockwise, and negative angles clockwise. + /// @return Vector reference to this after the operation. inline Vector& RadRotate(const float angle) { *this = GetRadRotatedCopy(angle); return *this; } - /// /// Returns a copy of this Vector, rotated relatively by an angle in degrees. - /// - /// The angle in degrees to rotate by. Positive angles rotate counter-clockwise, and negative angles clockwise. - /// A rotated copy of this Vector. + /// @param angle The angle in degrees to rotate by. Positive angles rotate counter-clockwise, and negative angles clockwise. + /// @return A rotated copy of this Vector. inline Vector GetDegRotatedCopy(const float angle) { return GetRadRotatedCopy(angle * c_PI / 180.0F); }; - /// /// Rotate this Vector relatively by an angle in degrees. - /// - /// The angle in degrees to rotate by. Positive angles rotate counter-clockwise, and negative angles clockwise. - /// Vector reference to this after the operation. + /// @param angle The angle in degrees to rotate by. Positive angles rotate counter-clockwise, and negative angles clockwise. + /// @return Vector reference to this after the operation. inline Vector& DegRotate(const float angle) { *this = GetDegRotatedCopy(angle); return *this; } - /// /// Set this Vector to an absolute rotation based on the absolute rotation of another Vector. - /// - /// The reference Vector whose absolute angle from positive X (0 degrees) this Vector will be rotated to. - /// Vector reference to this after the operation. + /// @param refVector The reference Vector whose absolute angle from positive X (0 degrees) this Vector will be rotated to. + /// @return Vector reference to this after the operation. inline Vector& AbsRotateTo(const Vector& refVector) { return RadRotate(refVector.GetAbsRadAngle() - GetAbsRadAngle()); } - /// /// Returns a Vector that is perpendicular to this, rotated PI/2. - /// - /// A Vector that is perpendicular to this, rotated PI/2. + /// @return A Vector that is perpendicular to this, rotated PI/2. inline Vector GetPerpendicular() const { return Vector(m_Y, -m_X); } - /// /// Makes this vector perpendicular to its previous state, rotated PI/2. Much faster than RadRotate by PI/2. - /// - /// Vector reference to this after the operation. + /// @return Vector reference to this after the operation. inline Vector& Perpendicularize() { *this = GetPerpendicular(); return *this; @@ -349,257 +271,195 @@ namespace RTE { #pragma endregion #pragma region Rounding - /// /// Rounds the X and Y values of this Vector upwards. E.g. 0.49 -> 0.0 and 0.5 -> 1.0. - /// - /// Vector reference to this after the operation. + /// @return Vector reference to this after the operation. inline Vector& Round() { *this = GetRounded(); return *this; } - /// /// Sets the X and Y of this Vector to the nearest half value. E.g. 1.0 -> 1.5 and 0.9 -> 0.5. - /// - /// Vector reference to this after the operation. + /// @return Vector reference to this after the operation. inline Vector& ToHalf() { m_X = std::round(m_X * 2) / 2; m_Y = std::round(m_Y * 2) / 2; return *this; } - /// /// Sets the X and Y of this Vector to the greatest integers that are not greater than their original values. E.g. -1.02 becomes -2.0. - /// - /// Vector reference to this after the operation. + /// @return Vector reference to this after the operation. inline Vector& Floor() { *this = GetFloored(); return *this; } - /// /// Sets the X and Y of this Vector to the lowest integers that are not less than their original values. E.g. -1.02 becomes -1.0. - /// - /// Vector reference to this after the operation. + /// @return Vector reference to this after the operation. inline Vector& Ceiling() { *this = GetCeilinged(); return *this; } - /// /// Returns a rounded copy of this Vector. Does not alter this Vector. - /// - /// A rounded copy of this Vector. + /// @return A rounded copy of this Vector. inline Vector GetRounded() const { return Vector(std::round(m_X), std::round(m_Y)); } - /// /// Returns the rounded integer X value of this Vector. - /// - /// An int value that represents the X value of this Vector. + /// @return An int value that represents the X value of this Vector. inline int GetRoundIntX() const { return static_cast(std::round(m_X)); } - /// /// Returns the rounded integer Y value of this Vector. - /// - /// An int value that represents the Y value of this Vector. + /// @return An int value that represents the Y value of this Vector. inline int GetRoundIntY() const { return static_cast(std::round(m_Y)); } - /// /// Returns a floored copy of this Vector. Does not alter this Vector. - /// - /// A floored copy of this Vector. + /// @return A floored copy of this Vector. inline Vector GetFloored() const { return Vector(std::floor(m_X), std::floor(m_Y)); } - /// /// Returns the greatest integer that is not greater than the X value of this Vector. - /// - /// An int value that represents the X value of this Vector. + /// @return An int value that represents the X value of this Vector. inline int GetFloorIntX() const { return static_cast(std::floor(m_X)); } - /// /// Returns the greatest integer that is not greater than the Y value of this Vector. - /// - /// An int value that represents the Y value of this Vector. + /// @return An int value that represents the Y value of this Vector. inline int GetFloorIntY() const { return static_cast(std::floor(m_Y)); } - /// /// Returns a ceilinged copy of this Vector. Does not alter this Vector. - /// - /// A ceilinged copy of this Vector. + /// @return A ceilinged copy of this Vector. inline Vector GetCeilinged() const { return Vector(std::ceil(m_X), std::ceil(m_Y)); } - /// /// Returns the lowest integer that is not less than the X value of this Vector. - /// - /// An int value that represents the X value of this Vector. + /// @return An int value that represents the X value of this Vector. inline int GetCeilingIntX() const { return static_cast(std::ceil(m_X)); } - /// /// Returns the lowest integer that is not less than the Y value of this Vector. - /// - /// An int value that represents the Y value of this Vector. + /// @return An int value that represents the Y value of this Vector. inline int GetCeilingIntY() const { return static_cast(std::ceil(m_Y)); } #pragma endregion #pragma region Vector Products - /// /// Returns the dot product of this Vector and the passed in Vector. - /// - /// The Vector which will be the right hand side operand of the dot product operation. - /// The resulting dot product scalar float. + /// @param rhs The Vector which will be the right hand side operand of the dot product operation. + /// @return The resulting dot product scalar float. inline float Dot(const Vector& rhs) const { return (m_X * rhs.m_X) + (m_Y * rhs.m_Y); } - /// /// Returns the 2D cross product of this Vector and the passed in Vector. This is really the area of the parallelogram that the two vectors form. - /// - /// The Vector which will be the right hand side operand of the cross product operation. - /// The resulting 2D cross product parallelogram area. + /// @param rhs The Vector which will be the right hand side operand of the cross product operation. + /// @return The resulting 2D cross product parallelogram area. inline float Cross(const Vector& rhs) const { return (m_X * rhs.m_Y) - (rhs.m_X * m_Y); } #pragma endregion #pragma region Operator Overloads - /// /// Copy assignment operator for Vectors. - /// - /// A Vector reference. - /// A reference to the changed Vector. + /// @param rhs A Vector reference. + /// @return A reference to the changed Vector. inline Vector& operator=(const Vector& rhs) { m_X = rhs.m_X; m_Y = rhs.m_Y; return *this; } - /// /// Unary negation overload for single Vectors. - /// - /// The resulting Vector. + /// @return The resulting Vector. inline Vector operator-() { return Vector(-m_X, -m_Y); } - /// /// An equality operator for testing if any two Vectors are equal. - /// - /// A Vector reference as the left hand side operand. - /// A Vector reference as the right hand side operand. - /// A boolean indicating whether the two operands are equal or not. + /// @param lhs A Vector reference as the left hand side operand. + /// @param rhs A Vector reference as the right hand side operand. + /// @return A boolean indicating whether the two operands are equal or not. inline friend bool operator==(const Vector& lhs, const Vector& rhs) { return lhs.m_X == rhs.m_X && lhs.m_Y == rhs.m_Y; } - /// /// An inequality operator for testing if any two Vectors are unequal. - /// - /// A Vector reference as the left hand side operand. - /// A Vector reference as the right hand side operand. - /// A boolean indicating whether the two operands are unequal or not. + /// @param lhs A Vector reference as the left hand side operand. + /// @param rhs A Vector reference as the right hand side operand. + /// @return A boolean indicating whether the two operands are unequal or not. inline friend bool operator!=(const Vector& lhs, const Vector& rhs) { return !(lhs == rhs); } - /// /// A stream insertion operator for sending a Vector to an output stream. - /// - /// An ostream reference as the left hand side operand. - /// A Vector reference as the right hand side operand. - /// An ostream reference for further use in an expression. + /// @param stream An ostream reference as the left hand side operand. + /// @param operand A Vector reference as the right hand side operand. + /// @return An ostream reference for further use in an expression. inline friend std::ostream& operator<<(std::ostream& stream, const Vector& operand) { stream << "{" << operand.m_X << ", " << operand.m_Y << "}"; return stream; } - /// /// Addition operator overload for Vectors. - /// - /// A Vector reference as the left hand side operand. - /// A Vector reference as the right hand side operand. - /// The resulting Vector. + /// @param lhs A Vector reference as the left hand side operand. + /// @param rhs A Vector reference as the right hand side operand. + /// @return The resulting Vector. inline friend Vector operator+(const Vector& lhs, const Vector& rhs) { return Vector(lhs.m_X + rhs.m_X, lhs.m_Y + rhs.m_Y); } - /// /// Subtraction operator overload for Vectors. - /// - /// A Vector reference as the left hand side operand. - /// A Vector reference as the right hand side operand. - /// The resulting Vector. + /// @param lhs A Vector reference as the left hand side operand. + /// @param rhs A Vector reference as the right hand side operand. + /// @return The resulting Vector. inline friend Vector operator-(const Vector& lhs, const Vector& rhs) { return Vector(lhs.m_X - rhs.m_X, lhs.m_Y - rhs.m_Y); } - /// /// Multiplication operator overload for a Vector and a float. - /// - /// A float reference as the right hand side operand. - /// The resulting Vector. + /// @param rhs A float reference as the right hand side operand. + /// @return The resulting Vector. inline Vector operator*(const float& rhs) const { return Vector(m_X * rhs, m_Y * rhs); } - /// /// Multiplication operator overload for Vectors. - /// - /// A Vector reference as the left hand side operand. - /// A Vector reference as the right hand side operand. - /// The resulting Vector. + /// @param lhs A Vector reference as the left hand side operand. + /// @param rhs A Vector reference as the right hand side operand. + /// @return The resulting Vector. inline friend Vector operator*(const Vector& lhs, const Vector& rhs) { return Vector(lhs.m_X * rhs.m_X, lhs.m_Y * rhs.m_Y); } - /// /// Division operator overload for a Vector and a float. - /// - /// A float reference as the right hand side operand. - /// The resulting Vector. + /// @param rhs A float reference as the right hand side operand. + /// @return The resulting Vector. Vector operator/(const float& rhs) const { return (rhs != 0) ? Vector(m_X / rhs, m_Y / rhs) : Vector(0, 0); } - /// /// Division operator overload for Vectors. - /// - /// A Vector reference as the left hand side operand. - /// A Vector reference as the right hand side operand. - /// The resulting Vector. + /// @param lhs A Vector reference as the left hand side operand. + /// @param rhs A Vector reference as the right hand side operand. + /// @return The resulting Vector. inline friend Vector operator/(const Vector& lhs, const Vector& rhs) { return (rhs.m_X != 0 && rhs.m_Y != 0) ? Vector(lhs.m_X / rhs.m_X, lhs.m_Y / rhs.m_Y) : Vector(0, 0); } - /// /// Self-addition operator overload for Vectors. - /// - /// A Vector reference as the left hand side operand. - /// A Vector reference as the right hand side operand. - /// A reference to the resulting Vector (the left one). + /// @param lhs A Vector reference as the left hand side operand. + /// @param rhs A Vector reference as the right hand side operand. + /// @return A reference to the resulting Vector (the left one). inline friend Vector& operator+=(Vector& lhs, const Vector& rhs) { lhs.m_X += rhs.m_X; lhs.m_Y += rhs.m_Y; return lhs; } - /// /// Self-subtraction operator overload for Vectors. - /// - /// A Vector reference as the left hand side operand. - /// A Vector reference as the right hand side operand. - /// A reference to the resulting Vector (the left one). + /// @param lhs A Vector reference as the left hand side operand. + /// @param rhs A Vector reference as the right hand side operand. + /// @return A reference to the resulting Vector (the left one). inline friend Vector& operator-=(Vector& lhs, const Vector& rhs) { lhs.m_X -= rhs.m_X; lhs.m_Y -= rhs.m_Y; return lhs; } - /// /// Self-multiplication operator overload for a Vector and a float. - /// - /// A float reference as the right hand side operand. - /// A reference to the resulting Vector. + /// @param rhs A float reference as the right hand side operand. + /// @return A reference to the resulting Vector. inline Vector& operator*=(const float& rhs) { m_X *= rhs; m_Y *= rhs; return *this; } - /// /// Self-multiplication operator overload for Vectors. - /// - /// A Vector reference as the left hand side operand. - /// A Vector reference as the right hand side operand. - /// A reference to the resulting Vector (the left one). + /// @param lhs A Vector reference as the left hand side operand. + /// @param rhs A Vector reference as the right hand side operand. + /// @return A reference to the resulting Vector (the left one). inline friend Vector& operator*=(Vector& lhs, const Vector& rhs) { lhs.m_X *= rhs.m_X; lhs.m_Y *= rhs.m_Y; return lhs; } - /// /// self-division operator overload for a Vector and a float. - /// - /// A float reference as the right hand side operand. - /// A reference to the resulting Vector. + /// @param rhs A float reference as the right hand side operand. + /// @return A reference to the resulting Vector. inline Vector& operator/=(const float& rhs) { if (rhs != 0) { m_X /= rhs; @@ -608,30 +468,24 @@ namespace RTE { return *this; } - /// /// Self-division operator overload for Vectors. - /// - /// A Vector reference as the left hand side operand. - /// A Vector reference as the right hand side operand. - /// A reference to the resulting Vector (the left one). + /// @param lhs A Vector reference as the left hand side operand. + /// @param rhs A Vector reference as the right hand side operand. + /// @return A reference to the resulting Vector (the left one). inline friend Vector& operator/=(Vector& lhs, const Vector& rhs) { lhs.m_X /= rhs.m_X; lhs.m_Y /= rhs.m_Y; return lhs; } - /// /// Array subscripting to access either the X or Y element of this Vector. - /// - /// An int index indicating which element is requested (X = 0, Y = 1). - /// The requested element. + /// @param rhs An int index indicating which element is requested (X = 0, Y = 1). + /// @return The requested element. inline const float& operator[](const int& rhs) const { return (rhs == 0) ? m_X : m_Y; } - /// /// Array subscripting to access either the X or Y element of this Vector. - /// - /// An int index indicating which element is requested (X = 0, Y = 1). - /// The requested element. + /// @param rhs An int index indicating which element is requested (X = 0, Y = 1). + /// @return The requested element. inline float& operator[](const int& rhs) { return (rhs == 0) ? m_X : m_Y; } #pragma endregion diff --git a/Source/System/Writer.cpp b/Source/System/Writer.cpp index fce6a592c1..a26f24af4a 100644 --- a/Source/System/Writer.cpp +++ b/Source/System/Writer.cpp @@ -5,8 +5,6 @@ namespace RTE { - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void Writer::Clear() { m_Stream = nullptr; m_FilePath.clear(); @@ -15,22 +13,16 @@ namespace RTE { m_IndentCount = 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - Writer::Writer(const std::string& fileName, bool append, bool createDir) { Clear(); Create(fileName, append, createDir); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - Writer::Writer(std::unique_ptr&& stream) { Clear(); Create(std::move(stream)); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int Writer::Create(const std::string& fileName, bool append, bool createDir) { m_FilePath = fileName; @@ -48,8 +40,6 @@ namespace RTE { return Create(std::move(ofStream)); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int Writer::Create(std::unique_ptr&& stream) { m_Stream = std::move(stream); if (!m_Stream->good()) { @@ -59,8 +49,6 @@ namespace RTE { return 0; } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void Writer::NewLine(bool toIndent, int lineCount) const { for (int lines = 0; lines < lineCount; ++lines) { *m_Stream << "\n"; diff --git a/Source/System/Writer.h b/Source/System/Writer.h index 3f2b9dcfe4..5ce0171809 100644 --- a/Source/System/Writer.h +++ b/Source/System/Writer.h @@ -3,82 +3,60 @@ namespace RTE { - /// /// Writes RTE objects to std::ostreams. - /// class Writer { public: #pragma region Creation - /// /// Constructor method used to instantiate a Writer object in system memory. Create() should be called before using the object. - /// Writer() { Clear(); } - /// /// Constructor method used to instantiate a Writer object in system memory and make it ready for writing to the passed in file path. - /// - /// Path to the file to open for writing. If the directory doesn't exist the stream will fail to open. - /// Whether to append to the file if it exists, or to overwrite it. - /// Whether to create the directory path to the file name before attempting to open the stream, in case it doesn't exist. + /// @param filename Path to the file to open for writing. If the directory doesn't exist the stream will fail to open. + /// @param append Whether to append to the file if it exists, or to overwrite it. + /// @param createDir Whether to create the directory path to the file name before attempting to open the stream, in case it doesn't exist. Writer(const std::string& fileName, bool append = false, bool createDir = false); - /// /// Constructor method used to instantiate a Writer object in system memory and make it ready for writing to the passed in file path. - /// - /// Stream to write to. + /// @param stream Stream to write to. Writer(std::unique_ptr&& stream); - /// /// Makes the Writer object ready for use. - /// - /// Path to the file to open for writing. If the directory doesn't exist the stream will fail to open. - /// Whether to append to the file if it exists, or to overwrite it. - /// Whether to create the directory path to the file name before attempting to open the stream, in case it doesn't exist. - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @param filename Path to the file to open for writing. If the directory doesn't exist the stream will fail to open. + /// @param append Whether to append to the file if it exists, or to overwrite it. + /// @param createDir Whether to create the directory path to the file name before attempting to open the stream, in case it doesn't exist. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create(const std::string& fileName, bool append = false, bool createDir = false); - /// /// Makes the Writer object ready for use. - /// - /// Stream to write to. - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + /// @param stream Stream to write to. + /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create(std::unique_ptr&& stream); #pragma endregion #pragma region Getters - /// /// Gets the path to the file being written. - /// - /// The full path to the file being written. + /// @return The full path to the file being written. std::string GetFilePath() const { return m_FilePath; } - /// /// Gets the name (without path) of the file being written. - /// - /// The name of file being written. + /// @return The name of file being written. std::string GetFileName() const { return m_FileName; } - /// /// Gets the folder path (without filename) to where the file is being written. - /// - /// The name of folder being written in. + /// @return The name of folder being written in. std::string GetFolderPath() const { return m_FolderPath; } #pragma endregion #pragma region Writing Operations - /// /// Used to specify the start of an object to be written. - /// - /// The class name of the object about to be written. + /// @param className The class name of the object about to be written. void ObjectStart(const std::string& className) { *m_Stream << className; ++m_IndentCount; } - /// /// Used to specify the end of an object that has just been written. - /// void ObjectEnd() { --m_IndentCount; if (m_IndentCount == 0) { @@ -86,68 +64,52 @@ namespace RTE { } } - /// /// Creates a new line that can be properly indented. - /// - /// Whether to indent the new line or not. - /// How many new lines to create. + /// @param toIndent Whether to indent the new line or not. + /// @param lineCount How many new lines to create. void NewLine(bool toIndent = true, int lineCount = 1) const; - /// /// Creates a new line and writes the specified string to it. - /// - /// The text string to write to the new line. - /// Whether to indent the new line or not. + /// @param textString The text string to write to the new line. + /// @param toIndent Whether to indent the new line or not. void NewLineString(const std::string& textString, bool toIndent = true) const { NewLine(toIndent); *m_Stream << textString; } - /// /// Creates a new line and fills it with slashes to create a divider line for INI. - /// - /// Whether to indent the new line or not. - /// The length of the divider (number of slashes). + /// @param toIndent Whether to indent the new line or not. + /// @param dividerLength The length of the divider (number of slashes). void NewDivider(bool toIndent = true, int dividerLength = 72) const { NewLine(toIndent); *m_Stream << std::string(dividerLength, '/'); } - /// /// Creates a new line and writes the name of the property in preparation to writing it's value. - /// - /// The name of the property to be written. + /// @param propName The name of the property to be written. void NewProperty(const std::string& propName) const { NewLine(); *m_Stream << propName + " = "; } - /// /// Creates a new line and writes the name of the specified property, followed by its set value. - /// - /// The name of the property to be written. - /// The value of the property. + /// @param propName The name of the property to be written. + /// @param propValue The value of the property. template void NewPropertyWithValue(const std::string& propName, const Type& propValue) { NewProperty(propName); *this << propValue; } - /// /// Marks that there is a null reference to an object here. - /// void NoObject() const { *m_Stream << "None"; } #pragma endregion #pragma region Writer Status - /// /// Shows whether the writer is ready to start accepting data streamed to it. - /// - /// Whether the writer is ready to start accepting data streamed to it or not. + /// @return Whether the writer is ready to start accepting data streamed to it or not. bool WriterOK() const { return m_Stream.get() && m_Stream->good(); } - /// /// Flushes and closes the output stream of this Writer. This happens automatically at destruction but needs to be called manually if a written file must be read from in the same scope. - /// void EndWrite() { m_Stream->flush(); m_Stream.reset(); @@ -155,11 +117,9 @@ namespace RTE { #pragma endregion #pragma region Operator Overloads - /// /// Elemental types stream insertions. Stream insertion operator overloads for all the elemental types. - /// - /// A reference to the variable that will be written to the ostream. - /// A Writer reference for further use in an expression. + /// @param var A reference to the variable that will be written to the ostream. + /// @return A Writer reference for further use in an expression. Writer& operator<<(const bool& var) { *m_Stream << var; return *this; @@ -231,9 +191,7 @@ namespace RTE { int m_IndentCount; //!< Indentation counter. private: - /// /// Clears all the member variables of this Writer, effectively resetting the members of this abstraction level only. - /// void Clear(); // Disallow the use of some implicit methods.