Visual logger map texts

This commit is contained in:
Andrii Danylchenko
2024-08-10 13:04:35 +03:00
parent 9ffd6368d4
commit 47c77826c3
10 changed files with 228 additions and 66 deletions
+14 -1
View File
@@ -20,9 +20,10 @@ void VisualLogger::updateWithLock(std::string channel, std::function<void(IVisua
std::lock_guard<std::mutex> lock(mutex);
mapLines[channel].clear();
mapTexts[channel].clear();
battleTexts[channel].clear();
VisualLogBuilder builder(mapLines[channel], battleTexts[channel]);
VisualLogBuilder builder(mapLines[channel], mapTexts[channel], battleTexts[channel]);
func(builder);
}
@@ -35,6 +36,18 @@ void VisualLogger::visualize(IMapOverlayLogVisualizer & visulizer)
{
visulizer.drawLine(line.start, line.end);
}
std::map<int3, std::vector<std::string>> textMap;
for(auto line : mapTexts[keyToShow])
{
textMap[line.tile].push_back(line.text);
}
for(auto & pair : textMap)
{
visulizer.drawText(pair.first, pair.second);
}
}
void VisualLogger::visualize(IBattleOverlayLogVisualizer & visulizer)
+11 -1
View File
@@ -19,6 +19,7 @@ class IMapOverlayLogVisualizer
{
public:
virtual void drawLine(int3 start, int3 end) = 0;
virtual void drawText(int3 tile, std::vector<std::string> texts) = 0;
};
class IBattleOverlayLogVisualizer
@@ -31,6 +32,7 @@ class IVisualLogBuilder
{
public:
virtual void addLine(int3 start, int3 end) = 0;
virtual void addText(int3 tile, std::string text) = 0;
virtual void addText(BattleHex tile, std::string text) = 0;
};
@@ -67,12 +69,14 @@ private:
private:
std::vector<Line<int3>> & mapLines;
std::vector<Text<BattleHex>> & battleTexts;
std::vector<Text<int3>> & mapTexts;
public:
VisualLogBuilder(
std::vector<Line<int3>> & mapLines,
std::vector<Text<int3>> & mapTexts,
std::vector<Text<BattleHex>> & battleTexts)
:mapLines(mapLines), battleTexts(battleTexts)
:mapLines(mapLines), mapTexts(mapTexts), battleTexts(battleTexts)
{
}
@@ -85,10 +89,16 @@ private:
{
battleTexts.emplace_back(tile, text);
}
void addText(int3 tile, std::string text) override
{
mapTexts.emplace_back(tile, text);
}
};
private:
std::map<std::string, std::vector<Line<int3>>> mapLines;
std::map<std::string, std::vector<Text<int3>>> mapTexts;
std::map<std::string, std::vector<Text<BattleHex>>> battleTexts;
std::mutex mutex;
std::string keyToShow;