1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-04 09:42:40 +02:00
vcmi/client/battle/BattleRenderer.h
Ivan Savenko 49a6d056d9 Changes for BattleInterface classes according to code review:
- added documentation comments for classes, members and methods
- added const specifier to methods where applicable
- renamed some methods with more clear name
- removed some commented-out or unused code
2022-12-11 23:16:23 +02:00

55 lines
1.3 KiB
C++

/*
* BattleFieldController.h, part of VCMI engine
*
* Authors: listed in file AUTHORS in main folder
*
* License: GNU General Public License v2.0 or later
* Full text of license available in license.txt file, in main folder
*
*/
#pragma once
#include "../../lib/battle/BattleHex.h"
class Canvas;
class BattleInterface;
enum class EBattleFieldLayer {
// confirmed ordering requirements:
OBSTACLES = 0,
CORPSES = 0,
WALLS = 1,
HEROES = 1,
STACKS = 1, // after corpses, obstacles
BATTLEMENTS = 2, // after stacks
STACK_AMOUNTS = 2, // after stacks, obstacles, corpses
EFFECTS = 3, // after obstacles, battlements
};
class BattleRenderer
{
public:
using RendererPtr = Canvas &;
using RenderFunctor = std::function<void(RendererPtr)>;
private:
BattleInterface * owner;
struct RenderableInstance
{
RenderFunctor functor;
EBattleFieldLayer layer;
BattleHex tile;
};
std::vector<RenderableInstance> objects;
void collectObjects();
void sortObjects();
void renderObjects(RendererPtr targetCanvas);
public:
BattleRenderer(BattleInterface * owner);
void insert(EBattleFieldLayer layer, BattleHex tile, RenderFunctor functor);
void execute(RendererPtr targetCanvas);
};