MCPcopy Create free account
hub / github.com/ddnet/ddnet / DoSoundSource

Method DoSoundSource

src/game/editor/editor.cpp:748–839  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

746}
747
748void CEditor::DoSoundSource(int LayerIndex, CSoundSource *pSource, int Index)
749{
750 static ESoundSourceOp s_Operation = ESoundSourceOp::NONE;
751
752 float CenterX = fx2f(pSource->m_Position.x);
753 float CenterY = fx2f(pSource->m_Position.y);
754
755 const bool IgnoreGrid = Input()->AltIsPressed();
756
757 if(s_Operation == ESoundSourceOp::NONE)
758 {
759 if(!Ui()->MouseButton(0))
760 Map()->m_SoundSourceOperationTracker.End();
761 }
762
763 if(Ui()->CheckActiveItem(pSource))
764 {
765 if(s_Operation != ESoundSourceOp::NONE)
766 {
767 Map()->m_SoundSourceOperationTracker.Begin(pSource, s_Operation, LayerIndex);
768 }
769
770 if(m_MouseDeltaWorld != vec2(0.0f, 0.0f))
771 {
772 if(s_Operation == ESoundSourceOp::MOVE)
773 {
774 vec2 Pos = Ui()->MouseWorldPos();
775 if(MapView()->MapGrid()->IsEnabled() && !IgnoreGrid)
776 {
777 MapView()->MapGrid()->SnapToGrid(Pos);
778 }
779 pSource->m_Position.x = f2fx(Pos.x);
780 pSource->m_Position.y = f2fx(Pos.y);
781 }
782 }
783
784 if(s_Operation == ESoundSourceOp::CONTEXT_MENU)
785 {
786 if(!Ui()->MouseButton(1))
787 {
788 if(Map()->m_vSelectedLayers.size() == 1)
789 {
790 static SPopupMenuId s_PopupSourceId;
791 Ui()->DoPopupMenu(&s_PopupSourceId, Ui()->MouseX(), Ui()->MouseY(), 120, 200, this, PopupSource);
792 Ui()->DisableMouseLock();
793 }
794 s_Operation = ESoundSourceOp::NONE;
795 Ui()->SetActiveItem(nullptr);
796 }
797 }
798 else
799 {
800 if(!Ui()->MouseButton(0))
801 {
802 Ui()->DisableMouseLock();
803 s_Operation = ESoundSourceOp::NONE;
804 Ui()->SetActiveItem(nullptr);
805 }

Callers

nothing calls this directly

Calls 15

fx2fFunction · 0.85
InputFunction · 0.85
UiFunction · 0.85
MapFunction · 0.85
MapViewFunction · 0.85
f2fxFunction · 0.85
GraphicsFunction · 0.85
AltIsPressedMethod · 0.80
MouseButtonMethod · 0.80
CheckActiveItemMethod · 0.80
MouseWorldPosMethod · 0.80
MapGridMethod · 0.80

Tested by

no test coverage detected