subbrute_attack_view.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. #pragma once
  2. #include "../subbrute_custom_event.h"
  3. #include <gui/view.h>
  4. #include <input/input.h>
  5. #include <gui/elements.h>
  6. typedef void (*SubBruteAttackViewCallback)(SubBruteCustomEvent event, void* context);
  7. typedef struct SubBruteAttackView SubBruteAttackView;
  8. /**
  9. * @brief Sets the callback function and context for the SubBruteAttackView.
  10. *
  11. * This function sets the callback function and context that will be used by the SubBruteAttackView
  12. * instance. The callback function will be called when a certain event occurs in the SubBruteAttackView.
  13. * The context parameter will be passed to the callback function as an argument.
  14. *
  15. * @param instance The SubBruteAttackView instance to set the callback for.
  16. * @param callback The callback function to be called when the event occurs.
  17. * @param context The context to be passed to the callback function when it is called.
  18. *
  19. * @note The callback function should have the following signature:
  20. * void callback(void* context)
  21. *
  22. * @note The callback function should not take ownership of the instance, it should only perform
  23. * the necessary logic based on the event.
  24. *
  25. * @warning The instance parameter must not be NULL.
  26. * @warning The callback parameter must not be NULL.
  27. *
  28. */
  29. void subbrute_attack_view_set_callback(
  30. SubBruteAttackView* instance,
  31. SubBruteAttackViewCallback callback,
  32. void* context);
  33. /**
  34. * @brief Allocates memory for a new SubBruteAttackView object.
  35. *
  36. * This function allocates memory for a new SubBruteAttackView object on the heap and returns a pointer to it.
  37. *
  38. * @return A pointer to a newly allocated SubBruteAttackView object.
  39. */
  40. SubBruteAttackView* subbrute_attack_view_alloc();
  41. /**
  42. * @brief Frees the memory allocated for a SubBruteAttackView instance.
  43. *
  44. * @param instance Pointer to the SubBruteAttackView instance to free.
  45. */
  46. void subbrute_attack_view_free(SubBruteAttackView* instance);
  47. /**
  48. * @brief Retrieves the view associated with the SubBruteAttackView instance.
  49. *
  50. * @param instance The SubBruteAttackView instance to retrieve the view from.
  51. *
  52. * @return A pointer to the associated view.
  53. */
  54. View* subbrute_attack_view_get_view(SubBruteAttackView* instance);
  55. /**
  56. * @brief Sets the current step for the SubBruteAttackView instance.
  57. *
  58. * This function sets the current step of the SubBruteAttackView instance
  59. * to the specified value.
  60. *
  61. * @param instance A pointer to the SubBruteAttackView instance.
  62. * @param current_step The value to set as the current step.
  63. *
  64. * @note The current step represents the current progress of the attack view.
  65. * It should be an unsigned 64-bit integer.
  66. */
  67. void subbrute_attack_view_set_current_step(SubBruteAttackView* instance, uint64_t current_step);
  68. /**
  69. * @class SubBruteAttackView
  70. * @brief Class for initializing the values of a SubBruteAttackView instance.
  71. *
  72. * The SubBruteAttackView class is used to store and initialize the values
  73. * of a SubBruteAttackView instance. These values include the index, maximum value,
  74. * current step, attack status, and extra repeats.
  75. */
  76. void subbrute_attack_view_init_values(
  77. SubBruteAttackView* instance,
  78. uint8_t index,
  79. uint64_t max_value,
  80. uint64_t current_step,
  81. bool is_attacking,
  82. uint8_t extra_repeats);