summaryrefslogtreecommitdiff
path: root/src/T2DLL/T2PaletteAnime.h
blob: 31497b247475a995ba0a4bad768b2487dc0305a6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#pragma once
#include "common.h"

class AFX_CLASS_EXPORT T2PaletteAnime {
public:
	T2PaletteAnime(T2WorldDef*, T2DateTime*);
	virtual ~T2PaletteAnime();

	int IsSETime();
	void ChangeSE();
	void RotateDayLightPalette(unsigned int, unsigned int) const;
	void MinuteChanged(T2DateTime*);
	void DoAnimatePalette();
	void ReplaceDayLightPalette(int);
	void SetSkyState(int, int);

	T2PaletteAnimeDef* GetPaletteAnimeDef() const { return mPaletteAnimeDef; }
	int GetSkyState() const { return mSkyState; }
	int GetSkyCount() const { return mSkyCount; }
    void IncSECount();
	int GetSECount() const { return mSECount; }
	LOGPALETTE* GetInterPalette() { return mInterCTab; }
	int GetSEKind() const { return mSEKind; }
	BOOL IsUpdated() const { return mPaletteUpdated; }
	void ClearUpdate() { mPaletteUpdated = false; }
	BOOL IsFine() const;
	BOOL IsSnow() const;
	BOOL IsShininDay() const;

protected:
	void RotatePalette(LOGPALETTE*, unsigned int, unsigned int) const;
	void AdjustSkyState(T2DateTime*);
	int IsChangeSkyTime();
	void ChangeSkyColor();

private:
	void Init();
	LOGPALETTE* MakeInterCTab();
	void AdjustWindowColor(T2DateTime*);

	T2WorldDef *mWorldDef;
	T2WorldPlugin *mWorldPlugin;
	T2PaletteAnimeDef *mPaletteAnimeDef;
	LOGPALETTE *mInterCTab;
	BOOL mPaletteUpdated;
	int mSkyState;
	int mSkyCount;
	int mSECount;
	int mSEKind;
	unsigned int mSETimeNextTick;
	T2DayLightFilter *mDayLightFilter;
	T2WeatherFilter *mWeatherFilter;
};

inline void T2PaletteAnime::IncSECount() {
    mSECount++;
    if (mSECount >= 60)
        mSECount = 0;
}

inline BOOL T2PaletteAnime::IsFine() const {
    BOOL result = true;
    if (mSkyState == 3 || mSkyState == 4)
        result = false;
    return result;
}

inline BOOL T2PaletteAnime::IsSnow() const {
    return (mSkyState == 4);
}

inline BOOL T2PaletteAnime::IsShininDay() const {
    switch (mSkyState) {
        case 3:
        case 4:
        case 9:
        case 10:
            return false;
        default:
            return true;
    }
}