| 4098 | } |
| 4099 | |
| 4100 | void CEditor::RenderSounds(CUIRect ToolBox) |
| 4101 | { |
| 4102 | const float RowHeight = 12.0f; |
| 4103 | |
| 4104 | static CScrollRegion s_ScrollRegion; |
| 4105 | vec2 ScrollOffset(0.0f, 0.0f); |
| 4106 | CScrollRegionParams ScrollParams; |
| 4107 | ScrollParams.m_ScrollbarWidth = 10.0f; |
| 4108 | ScrollParams.m_ScrollbarMargin = 3.0f; |
| 4109 | ScrollParams.m_ScrollUnit = RowHeight * 5; |
| 4110 | s_ScrollRegion.Begin(&ToolBox, &ScrollOffset, &ScrollParams); |
| 4111 | ToolBox.y += ScrollOffset.y; |
| 4112 | |
| 4113 | bool ScrollToSelection = false; |
| 4114 | if(m_Dialog == DIALOG_NONE && CLineInput::GetActiveInput() == nullptr && !Map()->m_vpSounds.empty()) |
| 4115 | { |
| 4116 | if(Input()->KeyPress(KEY_DOWN)) |
| 4117 | { |
| 4118 | Map()->SelectNextSound(); |
| 4119 | ScrollToSelection = true; |
| 4120 | } |
| 4121 | else if(Input()->KeyPress(KEY_UP)) |
| 4122 | { |
| 4123 | Map()->SelectPreviousSound(); |
| 4124 | ScrollToSelection = true; |
| 4125 | } |
| 4126 | } |
| 4127 | |
| 4128 | CUIRect Slot; |
| 4129 | ToolBox.HSplitTop(RowHeight + 3.0f, &Slot, &ToolBox); |
| 4130 | if(s_ScrollRegion.AddRect(Slot)) |
| 4131 | Ui()->DoLabel(&Slot, "Embedded", 12.0f, TEXTALIGN_MC); |
| 4132 | |
| 4133 | for(int i = 0; i < (int)Map()->m_vpSounds.size(); i++) |
| 4134 | { |
| 4135 | ToolBox.HSplitTop(RowHeight + 2.0f, &Slot, &ToolBox); |
| 4136 | int Selected = Map()->m_SelectedSound == i; |
| 4137 | if(!s_ScrollRegion.AddRect(Slot, Selected && ScrollToSelection)) |
| 4138 | continue; |
| 4139 | Slot.HSplitTop(RowHeight, &Slot, nullptr); |
| 4140 | |
| 4141 | const bool SoundUsed = std::any_of(Map()->m_vpGroups.cbegin(), Map()->m_vpGroups.cend(), [i](const auto &pGroup) { |
| 4142 | return std::any_of(pGroup->m_vpLayers.cbegin(), pGroup->m_vpLayers.cend(), [i](const auto &pLayer) { |
| 4143 | if(pLayer->m_Type == LAYERTYPE_SOUNDS) |
| 4144 | return std::static_pointer_cast<CLayerSounds>(pLayer)->m_Sound == i; |
| 4145 | return false; |
| 4146 | }); |
| 4147 | }); |
| 4148 | |
| 4149 | if(!SoundUsed) |
| 4150 | Selected += 2; // Sound is unused |
| 4151 | |
| 4152 | if(int Result = DoButton_Ex(&Map()->m_vpSounds[i], Map()->m_vpSounds[i]->m_aName, Selected, &Slot, |
| 4153 | BUTTONFLAG_LEFT | BUTTONFLAG_RIGHT, "Select sound.", IGraphics::CORNER_ALL)) |
| 4154 | { |
| 4155 | Map()->m_SelectedSound = i; |
| 4156 | |
| 4157 | if(Result == 2) |
nothing calls this directly
no test coverage detected