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

#ifndef HLevelPickerView_h
#define HLevelPickerView_h

#include "cocos2d.h"
#include "HLevelView.h"
#include <vector>
#include <string>
#include "HLayoutObject.h"

class HLevelPickerView : public cocos2d::Node, public HLayoutObject {
  
public:
    static HLevelPickerView* create(const std::vector<std::string>& levelImagePaths, const std::vector<std::string>& levelNames);
    void selectLevelIndex(int index, bool animated = true);
    int getPickedLevelIndex();
    void addOnLevelChangedCallback(std::function<void(int)> onLevelChanged);
    void reloadLevels(const std::vector<std::string>& levelImagePaths, const std::vector<std::string>& levelNames);
    
    virtual void loadPropertiesFromJSON(const rapidjson::Value& jsonValue, HLayoutViewInterface* scene = NULL, const std::string resFolder = "", const std::string altResFolder = "") override;
    
protected:
    int _selectedLevelIndex;
    std::vector<HLevelView*> HLevelViews;
    std::function<void(int)> _onLevelChanged;
    bool init(const std::vector<std::string>& levelImagePaths, const std::vector<std::string>& levelNames);
    void prepareTouchHandlers();
};

#endif /* HLevelPickerView_h */