Skip to content

Commit f2e833e

Browse files
committed
Copy and Swap
1 parent 625bede commit f2e833e

File tree

12 files changed

+714
-39
lines changed

12 files changed

+714
-39
lines changed

Plateau2/Plateau2.cpp

Lines changed: 55 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,13 @@ Plateau2::Plateau2(const InstanceInfo& info)
213213

214214
const ISVG HelpButtonSVG = pGraphics->LoadSVG(HELPBUTTON_FN);
215215

216+
const ISVG CopyOffSVG = pGraphics->LoadSVG(COPYOFF_FN);
217+
const ISVG CopyOnSVG = pGraphics->LoadSVG(COPYON_FN);
218+
219+
const ISVG SwapOffSVG = pGraphics->LoadSVG(SWAPOFF_FN);
220+
const ISVG SwapOnSVG = pGraphics->LoadSVG(SWAPON_FN);
221+
222+
216223
//Main page Switches
217224
Switches[0] = new LEDSwitch(IRECT::MakeXYWH(-11.526f, 404.802f-45, 102, 102), LEDScale, LedOffSVG, LedOnBothSVG, LedOnBothSVG, kFreeze, kFreeze);
218225
Switches[1] = new LEDSwitch(IRECT::MakeXYWH(-11.526f, 404.802f+30, 102, 102), LEDScale, LedOffSVG, LedOn1SVG, LedOn2SVG, kFreeze1, kFreeze2);
@@ -238,11 +245,47 @@ Plateau2::Plateau2(const InstanceInfo& info)
238245

239246
//Help Button
240247
Buttons[2] = new LEDButton(IRECT::MakeXYWH(129.5f, 535, 56, 56), 1, HelpButtonSVG, HelpButtonSVG, HelpButtonSVG, [this](IControl* button) {this->GetUI()->OpenURL("https://github.com/rubyswolf/iPlateau/wiki");});
241-
Buttons[2]->Hide(true);
242248

243-
for (int i = 0; i < kNumButtons; i++) {
249+
//Tank Copy Button
250+
Buttons[3] = new LEDButton(IRECT::MakeXYWH(15, 460, 80, 80), 1, CopyOffSVG, CopyOnSVG, CopyOnSVG, [this](IControl* button) {
251+
for (int i = kEnable1; i <= k1to2HighDamp; i++) {
252+
GetParam(i + offset)->Set(GetParam(i)->Value());
253+
}
254+
for (int i = 0; i < kNumKnobs; i++) {
255+
Knobs[i]->SetValue(GetParam(tank2Selected ? Knobs[i]->Param2Idx : Knobs[i]->Param1Idx)->GetNormalized());
256+
Knobs[i]->SetDirty(true);
257+
}
258+
for (int i = 0; i < kNumSwitches; i++) {
259+
Switches[i]->SetValue(GetParam(tank2Selected ? Switches[i]->Param2Idx : Switches[i]->Param1Idx)->GetNormalized());
260+
Switches[i]->SetDirty(true);
261+
}
262+
});
263+
264+
//Tank Swap Button
265+
Buttons[4] = new LEDButton(IRECT::MakeXYWH(220, 460, 80, 80), 1, SwapOffSVG, SwapOnSVG, SwapOnSVG, [this](IControl* button) {
266+
for (int i = kEnable1; i <= k1to2HighDamp; i++) {
267+
double temp = GetParam(i)->Value();
268+
GetParam(i)->Set(GetParam(i + offset)->Value());
269+
GetParam(i + offset)->Set(temp);
270+
}
271+
for (int i = 0; i < kNumKnobs; i++) {
272+
Knobs[i]->SetValue(GetParam(tank2Selected ? Knobs[i]->Param2Idx : Knobs[i]->Param1Idx)->GetNormalized());
273+
Knobs[i]->SetDirty(true);
274+
}
275+
for (int i = 0; i < kNumSwitches; i++) {
276+
Switches[i]->SetValue(GetParam(tank2Selected ? Switches[i]->Param2Idx : Switches[i]->Param1Idx)->GetNormalized());
277+
Switches[i]->SetDirty(true);
278+
}
279+
});
280+
281+
for (int i = 0; i <= 1; i++) {
244282
pGraphics->AttachControl(Buttons[i]);
245283
}
284+
for (int i = 2; i <= 4; i++) {
285+
pGraphics->AttachControl(Buttons[i]);
286+
Buttons[i]->Hide(true);
287+
}
288+
246289

247290
//Dump Preset Button
248291
//pGraphics->AttachControl((new LEDButton(IRECT::MakeXYWH(0, 40, 102, 102), LEDScale, LedOffSVG, LedOnBothSVG, LedOnBothSVG, [this](IControl* button) {DumpMakePresetSrc("C:/dev/Plugins/Plateau/Plateau2/preset.txt");})));
@@ -303,25 +346,25 @@ Plateau2::Plateau2(const InstanceInfo& info)
303346

304347
void Plateau2::SelectTank(bool tank2) {
305348
tank2Selected = tank2;
349+
bool linkedTank2 = link1to2 ? false : tank2;
306350
for (int i = kDryKnob; i <= kWetKnob; i++) {
307351
Knobs[i]->SelectTank(tank2);
308352
}
309353
for (int i = kInputLowDampKnob; i <= kVarianceKnob; i++) {
310-
Knobs[i]->SelectTank(link1to2 ? false : tank2);
354+
Knobs[i]->SelectTank(linkedTank2);
311355
}
312356
for (int i = kInputKnob; i < kNumKnobs; i++) {
313357
Knobs[i]->SelectTank(tank2);
314358
}
315359

316-
317360
Switches[0]->SelectTank(tank2);
318361
Switches[1]->SelectTank(tank2);
319-
Switches[2]->SelectTank(link1to2 ? false : tank2);
320-
Switches[3]->SelectTank(link1to2 ? false : tank2);
362+
Switches[2]->SelectTank(linkedTank2);
363+
Switches[3]->SelectTank(linkedTank2);
321364
Switches[4]->SelectTank(tank2);
322-
Switches[5]->SelectTank(link1to2 ? false : tank2);
365+
Switches[5]->SelectTank(linkedTank2);
323366
Switches[6]->SelectTank(tank2);
324-
Switches[7]->SelectTank(link1to2 ? false : tank2);
367+
Switches[7]->SelectTank(linkedTank2);
325368
Switches[8]->SelectTank(tank2);
326369
Switches[9]->SelectTank(tank2);
327370

@@ -369,7 +412,9 @@ void Plateau2::UpdatePageVisibility()
369412
for (int i = 5; i <= 8; i++) {
370413
Switches[i]->Hide(currentPage != 1);
371414
}
372-
Buttons[2]->Hide(currentPage != 1);
415+
for (int i = 2; i <= 4; i++) {
416+
Buttons[i]->Hide(currentPage != 1);
417+
}
373418

374419
//Routing page
375420
Switches[9]->Hide(currentPage != 2);
@@ -403,7 +448,6 @@ void Plateau2::OnParamChange(int index) {
403448
if (index >= kInputLowDamp1 && index <= kSoftClip1 && index != kFreeze1 && index != kClear1) //Tank 1 range
404449
{
405450
UpdateParameter(index, index);
406-
constexpr int offset = kEnable2 - kEnable1;
407451
UpdateParameter(index, index + offset); //Copy to tank 2
408452
}
409453
else if (!(index >= kInputLowDamp2 && index <= kSoftClip2 && index != kFreeze2 && index != kClear2)) //Not tank 2 range
@@ -436,7 +480,6 @@ void Plateau2::UpdateParameter(int sourceIndex, int targetIndex)
436480
case kLink1to2:
437481
{
438482
link1to2 = GetParam(kLink1to2)->Value() >= 0.5;
439-
constexpr int offset = kEnable2 - kEnable1;
440483
if (link1to2) {
441484
for (int i = kInputLowDamp1; i <= kModVariance1; i++) {
442485
UpdateParameter(i, i + offset); //Copy to tank 2
@@ -708,7 +751,7 @@ void Plateau2::UpdateParameter(int sourceIndex, int targetIndex)
708751
SetParameterValue(kDiffusionDecay1, clip<double>(GetParam(kDiffusionDecay1)->Value(), 23.0769, 76.92307) / 100);
709752
SetParameterValue(kDiffusionDecay2, clip<double>(GetParam(kDiffusionDecay2)->Value(), 23.0769, 76.92307) / 100);
710753

711-
Knobs[kDiffusionDecayKnob]->SetValue((tank2Selected ? GetParam(kDiffusionDecay2)->Value() : GetParam(kDiffusionDecay1)->Value()) / 100);
754+
Knobs[kDiffusionDecayKnob]->SetValue(GetParam(tank2Selected ? kDiffusionDecay2 : kDiffusionDecay1)->Value() / 100);
712755
Knobs[kDiffusionDecayKnob]->SetDirty(false);
713756
}
714757
break;

Plateau2/Plateau2.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,11 @@ enum EKnobs {
118118
kNumKnobs
119119
};
120120

121-
const int kNumSwitches = 11;
122-
const int kNumButtons = 3;
121+
const int kNumSwitches = 10;
122+
const int kNumButtons = 5;
123123
const int kNumPages = 3;
124124
const int kNumSVGs = 5;
125+
constexpr int offset = kEnable2 - kEnable1;
125126

126127
using namespace iplug;
127128
using namespace igraphics;

Plateau2/config.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@
8484
#define LINKOFF_FN "LinkOff.svg"
8585
#define LINKON_FN "LinkOn.svg"
8686
#define HELPBUTTON_FN "HelpButton.svg"
87+
#define COPYOFF_FN "CopyOff.svg"
88+
#define COPYON_FN "CopyOn.svg"
89+
#define SWAPOFF_FN "SwapOff.svg"
90+
#define SWAPON_FN "SwapOn.svg"
8791
#define SEND1TO2_FN "Send1To2.svg"
8892
#define SEND2TO1_FN "Send2To1.svg"
8993
#define REQUIRESDANGER_FN "RequiresDanger.svg"

Plateau2/controls/LEDSwitch.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ class LEDSwitch : public ISwitchControlBase
1616
, mSVGOff(svgOff)
1717
, mSVGOn1(svgOn1)
1818
, mSVGOn2(svgOn2)
19-
, mParam1Idx(param1Idx)
20-
, mParam2Idx(param2Idx)
19+
, Param1Idx(param1Idx)
20+
, Param2Idx(param2Idx)
2121
{
2222
hitboxScale = hitboxScaleFactor;
2323
}
@@ -40,17 +40,17 @@ class LEDSwitch : public ISwitchControlBase
4040

4141
void SelectTank(bool isTank2) {
4242
tank2 = isTank2;
43-
SetParamIdx(tank2 ? mParam2Idx : mParam1Idx, 0, true);
43+
SetParamIdx(tank2 ? Param2Idx : Param1Idx, 0, true);
4444
}
4545

4646
double hitboxScale = 1.0f;
47+
int Param1Idx;
48+
int Param2Idx;
4749

4850
protected:
4951
ISVG mSVGOff;
5052
ISVG mSVGOn1;
5153
ISVG mSVGOn2;
52-
int mParam1Idx;
53-
int mParam2Idx;
5454
bool tank2 = false;
5555
};
5656
END_IGRAPHICS_NAMESPACE

Plateau2/controls/NeedleKnob.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ class NeedleKnob : public IKnobControlBase
1212
, mDialFg2(dialFg2Bmp)
1313
, mDialBg(dialBg)
1414
, mDialPointer(dialPointer)
15-
, mParam1Idx(kParam1Idx)
16-
, mParam2Idx(kParam2Idx)
15+
, Param1Idx(kParam1Idx)
16+
, Param2Idx(kParam2Idx)
1717
{
1818
}
1919

@@ -31,20 +31,20 @@ class NeedleKnob : public IKnobControlBase
3131

3232
void SelectTank(bool isTank2) {
3333
tank2 = isTank2;
34-
SetParamIdx(tank2 ? mParam2Idx : mParam1Idx, 0, true);
34+
SetParamIdx(tank2 ? Param2Idx : Param1Idx, 0, true);
3535
}
3636

3737
float StartAngle = -135.f;
3838
float EndAngle = 135.f;
3939
float Bound = 135.f;
40+
int Param1Idx;
41+
int Param2Idx;
4042

4143
private:
4244
IBitmap mDialFg1;
4345
IBitmap mDialFg2;
4446
ISVG mDialBg;
4547
ISVG mDialPointer;
46-
int mParam1Idx;
47-
int mParam2Idx;
4848
bool tank2 = false;
4949
};
5050

Plateau2/resources/img/CopyOff.svg

Lines changed: 128 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)