C

Qt Quick Ultralite swipe_game 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 <platforminterface/allocator.h> typedef std::basic_string<char, std::char_traits<char>, Qul::PlatformInterface::Allocator<char> > QulString; class Globals : public Qul::Singleton<Globals> { public: QUL_ENUM(GameMode, Numbers, Countries); Globals(); Qul::Property<uint16_t> gameStartNumber; Qul::Property<uint16_t> gameCurrentNumber; Qul::Property<QulString> gameStartCountry; Qul::Property<QulString> gameCurrentCountry; Qul::Property<GameMode> currentGameMode; Qul::Property<uint16_t> score; Qul::Property<uint8_t> fails; // time in milliseconds Qul::Property<int> time; Qul::Property<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(); bool isNumberMode(); void requestNewValue(); void initGameData(); void checkAnswer(bool guessedGreater); void addFail(); private: int generateNewNumber() const; int generateRandomNumber() const; void updateScore(bool correctGuess); int m_startNumber; int m_currentNumber; }; #endif // GLOBALS_H