| 1 | #ifndef GAME_MAP_RENDER_MAP_H |
| 2 | #define GAME_MAP_RENDER_MAP_H |
| 3 | |
| 4 | #include <base/color.h> |
| 5 | |
| 6 | #include <game/map/render_interfaces.h> |
| 7 | #include <game/mapitems.h> |
| 8 | |
| 9 | #include <array> |
| 10 | #include <chrono> |
| 11 | #include <memory> |
| 12 | |
| 13 | enum |
| 14 | { |
| 15 | LAYERRENDERFLAG_OPAQUE = 1, |
| 16 | LAYERRENDERFLAG_TRANSPARENT = 2, |
| 17 | |
| 18 | TILERENDERFLAG_EXTEND = 4, |
| 19 | |
| 20 | OVERLAYRENDERFLAG_TEXT = 1, |
| 21 | OVERLAYRENDERFLAG_EDITOR = 2, |
| 22 | }; |
| 23 | |
| 24 | class IEnvelopePointAccess |
| 25 | { |
| 26 | public: |
| 27 | virtual ~IEnvelopePointAccess() = default; |
| 28 | virtual int NumPoints() const = 0; |
| 29 | virtual const CEnvPoint *GetPoint(int Index) const = 0; |
| 30 | virtual const CEnvPointBezier *GetBezier(int Index) const = 0; |
| 31 | int FindPointIndex(CFixedTime Time) const; |
| 32 | }; |
| 33 | |
| 34 | class CMapBasedEnvelopePointAccess : public IEnvelopePointAccess |
| 35 | { |
| 36 | int m_StartPoint; |
| 37 | int m_NumPoints; |
| 38 | int m_NumPointsMax; |
| 39 | CEnvPoint *m_pPoints; |
| 40 | CEnvPointBezier *m_pPointsBezier; |
| 41 | CEnvPointBezier_upstream *m_pPointsBezierUpstream; |
| 42 | |
| 43 | public: |
| 44 | CMapBasedEnvelopePointAccess(class IMap *pMap); |
| 45 | void SetPointsRange(int StartPoint, int NumPoints); |
| 46 | int StartPoint() const; |
| 47 | int NumPoints() const override; |
| 48 | int NumPointsMax() const; |
| 49 | const CEnvPoint *GetPoint(int Index) const override; |
| 50 | const CEnvPointBezier *GetBezier(int Index) const override; |
| 51 | }; |
| 52 | |
| 53 | class IGraphics; |
| 54 | class ITextRender; |
| 55 | |
| 56 | class CTuneColorMapper |
| 57 | { |
| 58 | public: |
| 59 | CTuneColorMapper(); |
| 60 | uint8_t TuneNumberToColorIndex(uint8_t TuneNumber); |
| 61 | ColorRGBA TuneColorIndexToColor(uint8_t TuneColorIndex) const; |
| 62 | void Reset(); |
| 63 | |
| 64 | private: |
| 65 | std::array<uint8_t, 255> m_aTuneNumberToColorIndex; |
| 66 | uint8_t m_NextTuneNumberIndex = 0; |
| 67 | }; |
| 68 | |
| 69 | class CRenderMap |
| 70 | { |
| 71 | IGraphics *m_pGraphics; |
| 72 | ITextRender *m_pTextRender; |
| 73 | |
| 74 | public: |
| 75 | void Init(IGraphics *pGraphics, ITextRender *pTextRender); |
| 76 | IGraphics *Graphics() { return m_pGraphics; } |
| 77 | ITextRender *TextRender() { return m_pTextRender; } |
| 78 | |
| 79 | // map render methods (render_map.cpp) |
| 80 | static void RenderEvalEnvelope(const IEnvelopePointAccess *pPoints, std::chrono::nanoseconds TimeNanos, ColorRGBA &Result, size_t Channels); |
| 81 | void ForceRenderQuads(CQuad *pQuads, int NumQuads, int Flags, IEnvelopeEval *pEnvEval, float Alpha = 1.0f); |
| 82 | void RenderTile(int x, int y, unsigned char Index, float Scale, ColorRGBA Color); |
| 83 | void RenderTilemap(CTile *pTiles, int w, int h, float Scale, ColorRGBA Color, int RenderFlags); |
| 84 | |
| 85 | // render a rectangle made of IndexIn tiles, over a background made of IndexOut tiles |
| 86 | // the rectangle include all tiles in [RectX, RectX+RectW-1] x [RectY, RectY+RectH-1] |
| 87 | void RenderTileRectangle(int RectX, int RectY, int RectW, int RectH, unsigned char IndexIn, unsigned char IndexOut, float Scale, ColorRGBA Color, int RenderFlags); |
| 88 | |
| 89 | // DDRace |
| 90 | void RenderTeleOverlay(CTeleTile *pTele, int w, int h, float Scale, int OverlayRenderFlags, float Alpha = 1.0f); |
| 91 | void RenderSpeedupOverlay(CSpeedupTile *pSpeedup, int w, int h, float Scale, int OverlayRenderFlags, float Alpha = 1.0f); |
| 92 | void RenderSwitchOverlay(CSwitchTile *pSwitch, int w, int h, float Scale, int OverlayRenderFlags, float Alpha = 1.0f); |
| 93 | void RenderTuneOverlay(CTuneTile *pTune, int w, int h, float Scale, int OverlayRenderFlags, float Alpha = 1.0f); |
| 94 | void RenderTelemap(CTeleTile *pTele, int w, int h, float Scale, ColorRGBA Color, int RenderFlags); |
| 95 | void RenderSwitchmap(CSwitchTile *pSwitch, int w, int h, float Scale, ColorRGBA Color, int RenderFlags); |
| 96 | void RenderTunemap(CTuneTile *pTune, int w, int h, float Scale, ColorRGBA Color, int RenderFlags, CTuneColorMapper *pTuneColorMapper); |
| 97 | |
| 98 | void RenderDebugClip(float ClipX, float ClipY, float ClipW, float ClipH, ColorRGBA Color, float Zoom, const char *pLabel); |
| 99 | }; |
| 100 | |
| 101 | #endif |
| 102 | |