/
dieoska
/
ddnet
Обзор
Документация
Войти
/
dieoska
/
ddnet
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
src/game/editor/layer_selector.cpp
56 строк
1 KB
Robert Müller
Add `CEditor::Map` getter, make `CEditor::m_Map` private
20 дек 2025, 14:25
20 дек 2025, 14:25
6eee3c6
Код
Авторство
О чём код?
#include "layer_selector.h" #include "editor.h" #include <engine/shared/config.h> void CLayerSelector::OnInit(CEditor *pEditor) { CEditorComponent::OnInit(pEditor); m_SelectionOffset = 0; } bool CLayerSelector::SelectByTile() { // ctrl+right click a map index to select the layer that has a tile there if(Ui()->HotItem() != &Editor()->m_MapEditorId) return false; if(!Input()->ModifierIsPressed() || !Ui()->MouseButtonClicked(1)) return false; if(!g_Config.m_EdLayerSelector) return false; int MatchedGroup = -1; int MatchedLayer = -1; int Matches = 0; bool IsFound = false; for(const auto &HoverTile : Editor()->HoverTiles()) { if(!Editor()->Map()->m_vpGroups[HoverTile.m_Group]->m_Visible || !Editor()->Map()->m_vpGroups[HoverTile.m_Group]->m_vpLayers[HoverTile.m_Layer]->m_Visible) continue; if(MatchedGroup == -1) { MatchedGroup = HoverTile.m_Group; MatchedLayer = HoverTile.m_Layer; } if(++Matches > m_SelectionOffset) { m_SelectionOffset++; MatchedGroup = HoverTile.m_Group; MatchedLayer = HoverTile.m_Layer; IsFound = true; break; } } if(MatchedGroup != -1 && MatchedLayer != -1) { if(!IsFound) m_SelectionOffset = 1; Editor()->SelectLayer(MatchedLayer, MatchedGroup); return true; } return false; }