MiscUtils.h 2.05 KB
//
//  MiscUtils.h
//  SteveMaggieCpp
//
//  Created by Katarzyna Kalinowska-Górska on 17.05.2017.
//
//

#ifndef MiscUtils_h
#define MiscUtils_h

#include "PlainSprite.h"

class MiscUtils
{
    public:
    
        enum class ExtendDirectionX {
            BOTH = 0,
            LEFT = 1,
            RIGHT = 2
        };
    
        enum class ExtendDirectionY {
            BOTH = 0,
            UP = 1,
            DOWN = 2,
        };
    
    enum class Level {
        CHILD = 0,
        TEEN = 1,
        ADULT = 2
    };
    
    static const char* levelToString(Level level) {
        if(level == Level::CHILD){
            return "CHILD";
        } else if(level == Level::TEEN){
            return "TEEN";
        } else return "ADULT";
    }
    
    static float StandardAnimationTime;
    static float QuickAnimationTime;
    
    static const std::string WHICH_LEVEL_UD_KEY;
    static const std::string TOS_ACCEPTED_UD_KEY;

    static void saveTOSAccepted();
    static bool wasTOSAccepted();
    static void saveLastLevel(Level level);
    static void saveLastLevel(int level);
    static Level lastLevel();
    static int nextLevel();
    
    static std::string clockMinSecTimeString(int seconds);
    
    static void showView(cocos2d::Node*, bool animated, float toAlpha = 255);
    static void hideView(cocos2d::Node*, bool animated);
    static void hideAndRemoveView(cocos2d::Node*, bool animated);
    
    static cocos2d::Rect getExtendedActiveArea(cocos2d::Node* object, float extendPercentValueX = 0, float extendPercentValueY = 0, ExtendDirectionX extendDirX = ExtendDirectionX::BOTH, ExtendDirectionY extendDirY = ExtendDirectionY::BOTH);
    
    static bool isNodeVisible(cocos2d::Node* node);
static void changeAnchorPoint(cocos2d::Node* p_node, cocos2d::Point p_newAnchorPoint);

    static std::string boolToString(bool value);
    
//#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
    static void showAppCloseConfirmDialog(std::function<void()> onCancelCallback);
    static bool closeAppCloseConfirmDialogIfNecessary();
//#endif
};

#endif /* MiscUtils_h */