1 /***************************************************************************
2  *   Free Heroes of Might and Magic II: https://github.com/ihhub/fheroes2  *
3  *   Copyright (C) 2020                                                    *
4  *                                                                         *
5  *   This program is free software; you can redistribute it and/or modify  *
6  *   it under the terms of the GNU General Public License as published by  *
7  *   the Free Software Foundation; either version 2 of the License, or     *
8  *   (at your option) any later version.                                   *
9  *                                                                         *
10  *   This program is distributed in the hope that it will be useful,       *
11  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
12  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
13  *   GNU General Public License for more details.                          *
14  *                                                                         *
15  *   You should have received a copy of the GNU General Public License     *
16  *   along with this program; if not, write to the                         *
17  *   Free Software Foundation, Inc.,                                       *
18  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
19  ***************************************************************************/
20 
21 #ifndef H2GAME_DELAYS_H
22 #define H2GAME_DELAYS_H
23 
24 #include <cstdint>
25 #include <vector>
26 
27 namespace Game
28 {
29     enum DelayType : int
30     {
31         SCROLL_DELAY = 0,
32         SCROLL_START_DELAY,
33         MAIN_MENU_DELAY,
34         MAPS_DELAY,
35         CASTLE_TAVERN_DELAY,
36         CASTLE_AROUND_DELAY,
37         CASTLE_BUYHERO_DELAY,
38         CASTLE_BUILD_DELAY,
39         CASTLE_UNIT_DELAY,
40         HEROES_FADE_DELAY,
41         HEROES_PICKUP_DELAY,
42         PUZZLE_FADE_DELAY,
43         BATTLE_DIALOG_DELAY,
44         BATTLE_FRAME_DELAY,
45         BATTLE_MISSILE_DELAY,
46         BATTLE_SPELL_DELAY,
47         BATTLE_DISRUPTING_DELAY,
48         BATTLE_CATAPULT_DELAY,
49         BATTLE_CATAPULT_BOULDER_DELAY,
50         BATTLE_CATAPULT_CLOUD_DELAY,
51         BATTLE_BRIDGE_DELAY,
52         BATTLE_IDLE_DELAY,
53         BATTLE_OPPONENTS_DELAY,
54         BATTLE_FLAGS_DELAY,
55         BATTLE_POPUP_DELAY,
56         BATTLE_COLOR_CYCLE_DELAY,
57         BATTLE_SELECTED_UNIT_DELAY,
58 
59         CURRENT_HERO_DELAY,
60         CURRENT_AI_DELAY,
61         CUSTOM_DELAY,
62 
63         // IMPORTANT!!! All new entries must be put before this entry!
64         LAST_DELAY
65     };
66 
67     // If delay is passed reset it and return true. Otherwise return false. DelayType::CUSTOM_DELAY must not be passed!
68     bool validateAnimationDelay( const DelayType delayType );
69 
70     // If custom delay (DelayType::CUSTOM_DELAY) is passed reset it and return true. Otherwise return false.
71     bool validateCustomAnimationDelay( const uint64_t delayMs );
72 
73     // Explicitly pass delay. Useful for loops when first iterator must pass.
74     void passAnimationDelay( const DelayType delayType );
75 
76     void AnimateResetDelay( const DelayType delayType );
77     void UpdateGameSpeed();
78 
79     uint32_t ApplyBattleSpeed( uint32_t delay );
80 
81     int HumanHeroAnimSkip();
82     int AIHeroAnimSkip();
83 
84     // Returns true if every of delay type is not passed yet. DelayType::CUSTOM_DELAY must not be added in this function!
85     bool isDelayNeeded( const std::vector<Game::DelayType> & delayTypes );
86 
87     bool isCustomDelayNeeded( const uint64_t delayMs );
88 }
89 
90 #endif
91