| 91 | } |
| 92 | |
| 93 | void IDrawableModule::Init() |
| 94 | { |
| 95 | assert(mUIControlsCreated); //did you not call CreateUIControls() for this module? |
| 96 | assert(!mInitialized); |
| 97 | mInitialized = true; |
| 98 | |
| 99 | ModuleFactory::ModuleInfo moduleInfo = TheSynth->GetModuleFactory()->GetModuleInfo(mTypeName); |
| 100 | mModuleCategory = moduleInfo.mCategory; |
| 101 | if (mModuleCategory == kModuleCategory_Unknown) |
| 102 | { |
| 103 | if (dynamic_cast<IAudioEffect*>(this)) |
| 104 | mModuleCategory = kModuleCategory_Processor; |
| 105 | } |
| 106 | |
| 107 | mCanReceiveAudio = moduleInfo.mCanReceiveAudio; |
| 108 | mCanReceiveNotes = moduleInfo.mCanReceiveNotes; |
| 109 | mCanReceivePulses = moduleInfo.mCanReceivePulses; |
| 110 | |
| 111 | // if you hit these asserts, it means that, for example, your module's |
| 112 | // AcceptsPulses() returns false, but it inherits IPulseReceiver. |
| 113 | // the fix is to make AcceptsPulses() (or the appropriate method) match the |
| 114 | // list of inherited classes. |
| 115 | assert(mCanReceiveAudio == (dynamic_cast<IAudioReceiver*>(this) != nullptr)); |
| 116 | assert(mCanReceiveNotes == (dynamic_cast<INoteReceiver*>(this) != nullptr)); |
| 117 | assert(mCanReceivePulses == (dynamic_cast<IPulseReceiver*>(this) != nullptr)); |
| 118 | |
| 119 | bool wasEnabled = IsEnabled(); |
| 120 | bool showEnableToggle = false; |
| 121 | SetEnabled(!wasEnabled); |
| 122 | if (IsEnabled() == wasEnabled) //nothing changed |
| 123 | showEnableToggle = false; //so don't show toggle, this module doesn't support it |
| 124 | else |
| 125 | showEnableToggle = true; |
| 126 | SetEnabled(wasEnabled); |
| 127 | |
| 128 | if (showEnableToggle) |
| 129 | { |
| 130 | mEnabledCheckbox->SetDisplayText(false); |
| 131 | mEnabledCheckbox->UseCircleLook(GetColor(mModuleCategory)); |
| 132 | } |
| 133 | else |
| 134 | { |
| 135 | RemoveUIControl(mEnabledCheckbox, false); |
| 136 | mEnabledCheckbox->Delete(); |
| 137 | mEnabledCheckbox = nullptr; |
| 138 | } |
| 139 | |
| 140 | for (int i = 0; i < mUIControls.size(); ++i) |
| 141 | mUIControls[i]->Init(); |
| 142 | |
| 143 | for (int i = 0; i < mChildren.size(); ++i) |
| 144 | { |
| 145 | ModuleContainer* container = GetContainer(); |
| 146 | if (container != nullptr && VectorContains(mChildren[i], container->GetModules())) |
| 147 | continue; //stuff in module containers was already initialized |
| 148 | mChildren[i]->Init(); |
| 149 | } |
| 150 |
nothing calls this directly
no test coverage detected