| 3962 | } |
| 3963 | |
| 3964 | void CEditor::RenderImagesList(CUIRect ToolBox) |
| 3965 | { |
| 3966 | const float RowHeight = 12.0f; |
| 3967 | |
| 3968 | static CScrollRegion s_ScrollRegion; |
| 3969 | vec2 ScrollOffset(0.0f, 0.0f); |
| 3970 | CScrollRegionParams ScrollParams; |
| 3971 | ScrollParams.m_ScrollbarWidth = 10.0f; |
| 3972 | ScrollParams.m_ScrollbarMargin = 3.0f; |
| 3973 | ScrollParams.m_ScrollUnit = RowHeight * 5; |
| 3974 | s_ScrollRegion.Begin(&ToolBox, &ScrollOffset, &ScrollParams); |
| 3975 | ToolBox.y += ScrollOffset.y; |
| 3976 | |
| 3977 | bool ScrollToSelection = false; |
| 3978 | if(m_Dialog == DIALOG_NONE && CLineInput::GetActiveInput() == nullptr && !Map()->m_vpImages.empty()) |
| 3979 | { |
| 3980 | if(Input()->KeyPress(KEY_DOWN)) |
| 3981 | { |
| 3982 | const int OldImage = Map()->m_SelectedImage; |
| 3983 | Map()->SelectNextImage(); |
| 3984 | ScrollToSelection = OldImage != Map()->m_SelectedImage; |
| 3985 | } |
| 3986 | else if(Input()->KeyPress(KEY_UP)) |
| 3987 | { |
| 3988 | const int OldImage = Map()->m_SelectedImage; |
| 3989 | Map()->SelectPreviousImage(); |
| 3990 | ScrollToSelection = OldImage != Map()->m_SelectedImage; |
| 3991 | } |
| 3992 | } |
| 3993 | |
| 3994 | for(int e = 0; e < 2; e++) // two passes, first embedded, then external |
| 3995 | { |
| 3996 | CUIRect Slot; |
| 3997 | ToolBox.HSplitTop(RowHeight + 3.0f, &Slot, &ToolBox); |
| 3998 | if(s_ScrollRegion.AddRect(Slot)) |
| 3999 | Ui()->DoLabel(&Slot, e == 0 ? "Embedded" : "External", 12.0f, TEXTALIGN_MC); |
| 4000 | |
| 4001 | for(int i = 0; i < (int)Map()->m_vpImages.size(); i++) |
| 4002 | { |
| 4003 | if((e && !Map()->m_vpImages[i]->m_External) || |
| 4004 | (!e && Map()->m_vpImages[i]->m_External)) |
| 4005 | { |
| 4006 | continue; |
| 4007 | } |
| 4008 | |
| 4009 | ToolBox.HSplitTop(RowHeight + 2.0f, &Slot, &ToolBox); |
| 4010 | int Selected = Map()->m_SelectedImage == i; |
| 4011 | if(!s_ScrollRegion.AddRect(Slot, Selected && ScrollToSelection)) |
| 4012 | continue; |
| 4013 | Slot.HSplitTop(RowHeight, &Slot, nullptr); |
| 4014 | |
| 4015 | const bool ImageUsed = std::any_of(Map()->m_vpGroups.cbegin(), Map()->m_vpGroups.cend(), [i](const auto &pGroup) { |
| 4016 | return std::any_of(pGroup->m_vpLayers.cbegin(), pGroup->m_vpLayers.cend(), [i](const auto &pLayer) { |
| 4017 | if(pLayer->m_Type == LAYERTYPE_QUADS) |
| 4018 | return std::static_pointer_cast<CLayerQuads>(pLayer)->m_Image == i; |
| 4019 | else if(pLayer->m_Type == LAYERTYPE_TILES) |
| 4020 | return std::static_pointer_cast<CLayerTiles>(pLayer)->m_Image == i; |
| 4021 | return false; |
nothing calls this directly
no test coverage detected