88#define GDCORE_WHILEEVENT_H
99#include " GDCore/Events/Event.h"
1010#include " GDCore/Events/EventsList.h"
11+ #include " GDCore/Project/VariablesContainer.h"
1112namespace gd {
1213class Instruction ;
1314class Project ;
@@ -25,7 +26,10 @@ namespace gd {
2526 */
2627class GD_CORE_API WhileEvent : public gd::BaseEvent {
2728 public:
28- WhileEvent () : infiniteLoopWarning(true ), justCreatedByTheUser(true ){};
29+ WhileEvent ()
30+ : infiniteLoopWarning(true ),
31+ justCreatedByTheUser (true ),
32+ variables(gd::VariablesContainer::SourceType::Local){};
2933 virtual ~WhileEvent (){};
3034 virtual gd::WhileEvent* Clone () const { return new WhileEvent (*this ); }
3135
@@ -35,6 +39,12 @@ class GD_CORE_API WhileEvent : public gd::BaseEvent {
3539 virtual const gd::EventsList& GetSubEvents () const { return events; };
3640 virtual gd::EventsList& GetSubEvents () { return events; };
3741
42+ virtual bool CanHaveVariables () const { return true ; }
43+ virtual const gd::VariablesContainer& GetVariables () const {
44+ return variables;
45+ };
46+ virtual gd::VariablesContainer& GetVariables () { return variables; };
47+
3848 const gd::InstructionsList& GetConditions () const { return conditions; };
3949 gd::InstructionsList& GetConditions () { return conditions; };
4050
@@ -51,6 +61,9 @@ class GD_CORE_API WhileEvent : public gd::BaseEvent {
5161
5262 bool HasInfiniteLoopWarning () const { return infiniteLoopWarning; }
5363
64+ const gd::String& GetIndexVariableName () const { return indexVariableName; }
65+ void SetIndexVariableName (const gd::String& name) { indexVariableName = name; }
66+
5467 virtual std::vector<gd::InstructionsList*> GetAllConditionsVectors ();
5568 virtual std::vector<gd::InstructionsList*> GetAllActionsVectors ();
5669 virtual std::vector<const gd::InstructionsList*> GetAllConditionsVectors ()
@@ -71,6 +84,8 @@ class GD_CORE_API WhileEvent : public gd::BaseEvent {
7184 bool justCreatedByTheUser; // /< Used so as not to show message box to
7285 // /< de/activate infinite loop warning when the
7386 // /< user create the event
87+ gd::VariablesContainer variables;
88+ gd::String indexVariableName;
7489
7590 int GetConditionsHeight () const ;
7691 int GetActionsHeight () const ;
0 commit comments