Qt Quick Ultralite swipegame Demo

#ifndef GLOBALS_H
#define GLOBALS_H
/****************************************************************************** ** ** Copyright (C) 2021 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the Qt Quick Ultralite module. ** ** $QT_BEGIN_LICENSE:COMM$ ** ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms ** and conditions see http://www.qt.io/terms-conditions. For further ** information use the contact form at http://www.qt.io/contact-us. ** ** $QT_END_LICENSE$ ** ******************************************************************************/
#include <qul/singleton.h> #include <qul/property.h> #include <platforminterface/screen.h> #include <string> #include <array> #include <random> class Globals : public Qul::Singleton<Globals> { public: using distribution = std::uniform_int_distribution<std::mt19937::result_type>; Globals(); Qul::Property<std::uint16_t> gameStartNumber; Qul::Property<std::uint16_t> gameCurrentNumber; Qul::Property<std::string> gameStartCountry; Qul::Property<std::string> gameCurrentCountry; Qul::Property<bool> useNumberMode; Qul::Property<std::uint16_t> score; Qul::Property<std::uint8_t> fails; // time in milliseconds Qul::Property<int> time; Qul::Property<std::uint16_t> tries; Qul::Property<bool> useSmallTouchAreas; Qul::Property<bool> showTouchAreas; Qul::Property<bool> useViewAnimations; void increaseTime(); void decreaseTime(); void increaseTries(); void decreaseTries(); void switchGameMode(); void requestNewValue(); void initGameData(); void checkAnswer(bool guessedGreater); void addFail(); private: std::random_device m_randDevice; std::mt19937 m_randGenerator; distribution m_newNumberDistribution; distribution m_startNumberDistribution; std::array<std::string, 56> m_countries; int m_startNumber{0}; int m_currentNumber{0}; int generateNewNumber(); }; #endif // GLOBALS_H