AniLevelPickerView.h 1.41 KB
//
//  AniLevelPickerView.h
//  HalloweenSpaceInvaders
//
//  Created by Katarzyna Kalinowska-Górska on 29/09/2019.
//

#ifndef AniLevelPickerView_h
#define AniLevelPickerView_h

#include "cocos2d.h"
#include "AniLevelView.h"
#include <vector>
#include <string>
#include "AniLayoutObject.h"

class AniLevelPickerView : public cocos2d::Node, public AniLayoutObject {
  
public:
    static AniLevelPickerView* create(const std::vector<std::string>& levelImagePaths, const std::vector<std::string>& levelNames);
    void selectLevelIndex(int index, bool animated = true);
    void startAnimatingLevelPicture(int index);
    int getPickedLevelIndex();
    void addOnLevelChangedCallback(std::function<void(int)> onLevelChanged);
    void reloadLevels(const std::vector<std::string>& levelImagePaths, const std::vector<std::string>& levelNames);
    void setEnabled(bool p_enabled) { _enabled = p_enabled; }
    
    virtual void loadPropertiesFromJSON(const rapidjson::Value& jsonValue, AniLayoutViewInterface* scene = NULL, const std::string resFolder = "", const std::string altResFolder = "") override;
    
protected:
    bool _enabled { true };
    int _selectedLevelIndex;
    std::vector<AniLevelView*> AniLevelViews;
    std::function<void(int)> _onLevelChanged;
    bool init(const std::vector<std::string>& levelImagePaths, const std::vector<std::string>& levelNames);
    void prepareTouchHandlers();
};

#endif /* AniLevelPickerView_h */