Skip to content

Commit 95d4fd3

Browse files
committed
Interface ready for 2 tanks
1 parent 7c186e1 commit 95d4fd3

19 files changed

+986
-191
lines changed

Plateau/Plateau.cpp

Lines changed: 140 additions & 95 deletions
Large diffs are not rendered by default.

Plateau/Plateau.h

Lines changed: 37 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,43 @@
55
#include "./dsp/LinearEnvelope.cpp"
66
#include "./dsp/Dattorro.cpp"
77

8+
//Custom Controls
9+
#include "./controls/NeedleKnob.cpp"
10+
#include "./controls/LEDButton.cpp"
11+
#include "./controls/LEDSwitch.cpp"
12+
#include "./controls/LEDRadio.cpp"
13+
814
const int kNumPresets = 1;
915

1016
enum EParams
1117
{
1218
kDry,
13-
kWet,
14-
kPreDelay,
15-
kInputLowDamp,
16-
kInputHighDamp,
17-
kSize,
18-
kDiffusion,
19-
kDecay,
20-
kReverbLowDamp,
21-
kReverbHighDamp,
22-
kModSpeed,
23-
kModDepth,
24-
kModShape,
2519
kFreeze,
2620
kClear,
27-
kTunedMode,
28-
kDiffuseInput,
29-
kNumParams
21+
kEnabled1,
22+
kWet1,
23+
kInputLowDamp1,
24+
kInputHighDamp1,
25+
kSize1,
26+
kDiffusion1,
27+
kDecay1,
28+
kReverbLowDamp1,
29+
kReverbHighDamp1,
30+
kModSpeed1,
31+
kModDepth1,
32+
kModShape1,
33+
kFreeze1,
34+
kClear1,
35+
kTunedMode1,
36+
kDiffuseInput1,
37+
kPreDelay1,
38+
kNumParams
3039
};
3140

41+
const int kNumKnobs = 12;
42+
const int kNumSwitches = 5;
43+
const int kNumButtons = 2;
44+
3245
using namespace iplug;
3346
using namespace igraphics;
3447

@@ -41,15 +54,21 @@ class Plateau final : public Plugin
4154
#if IPLUG_DSP // http://bit.ly/2S64BDd
4255
void ProcessBlock(sample** inputs, sample** outputs, int nFrames) override;
4356
void OnParamChange(int index) override;
57+
void SelectTank(bool tank2);
4458
#endif
4559
private:
46-
Dattorro reverb;
47-
LinearEnvelope envelope;
60+
Dattorro reverb1;
61+
LinearEnvelope envelope1;
4862

4963
bool clear = false;
5064
bool cleared = true;
5165
bool fadeOut = false;
5266
bool fadeIn = false;
5367

5468
bool frozen = false;
55-
};
69+
70+
bool tank2Selected = false;
71+
NeedleKnob* Knobs[kNumKnobs];
72+
LEDSwitch* Switches[kNumSwitches];
73+
LEDButton* Buttons[kNumButtons];
74+
};

Plateau/config.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,10 @@
6161
#define BACKGROUND_FN "Background.svg"
6262
#define NEEDLE_FN "NeedleDial.svg"
6363
#define NEEDLEBG_FN "NeedleDial-bg.svg"
64-
#define NEEDLEFG_FN "NeedleDial-fg.png"
64+
#define NEEDLEFG1_FN "NeedleDialFG1.png"
65+
#define NEEDLEFG2_FN "NeedleDialFG2.png"
6566
//#define LED_FN "LEDButton.png"
66-
#define LEDON_FN "LEDButtonOn.svg"
6767
#define LEDOFF_FN "LEDButtonOff.svg"
68+
#define LEDON1_FN "LEDButtonOn1.svg"
69+
#define LEDON2_FN "LEDButtonOn2.svg"
70+
#define LEDONBOTH_FN "LEDButtonGradient.svg"

Plateau/controls/ColouredControl.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
class ColouredControl : public IControl {
2+
public:
3+
virtual void SetColour(bool alternative) = 0;
4+
};

Plateau/controls/LEDButton.cpp

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,25 @@ BEGIN_IGRAPHICS_NAMESPACE
66
class LEDButton : public IButtonControlBase
77
{
88
public:
9-
LEDButton(const IRECT& bounds, float hitboxScaleFactor, const std::initializer_list<ISVG>& svgs, IActionFunction aF)
9+
LEDButton(const IRECT& bounds, float hitboxScaleFactor, const ISVG& svgOff, const ISVG& svgOn1, const ISVG& svgOn2, IActionFunction aF, IControl* linkedControl = nullptr)
1010
: IButtonControlBase(bounds, aF)
11-
, mSVGs(svgs)
11+
, mSVGOff(svgOff)
12+
, mSVGOn1(svgOn1)
13+
, mSVGOn2(svgOn2)
14+
, mLinkedControl(linkedControl)
1215
{
1316
hitboxScale = hitboxScaleFactor;
1417
}
1518

16-
void Draw(IGraphics& g) override { g.DrawSVG(mSVGs[GetValue()], mRECT, &mBlend); }
19+
void Draw(IGraphics& g) override { g.DrawSVG(GetValue()>=1.?(tank2 ? mSVGOn2 : mSVGOn1) : mSVGOff, mRECT, &mBlend); }
1720
void OnMouseUp(float x, float y, const IMouseMod& mod) override {
1821
this->SetValue(0.);
19-
SetDirty(false);
22+
SetDirty();
23+
if (mLinkedControl)
24+
{
25+
mLinkedControl->SetValue(0.);
26+
mLinkedControl->SetDirty();
27+
}
2028
}
2129

2230
bool IsHit(float x, float y) const override {
@@ -25,9 +33,18 @@ class LEDButton : public IButtonControlBase
2533
return hitbox.Contains(x, y);
2634
}
2735

36+
void SelectTank(bool isTank2) {
37+
tank2 = isTank2;
38+
SetDirty(false);
39+
}
40+
2841
float hitboxScale = 1.0f;
2942
protected:
30-
std::vector<ISVG> mSVGs;
43+
ISVG mSVGOff;
44+
ISVG mSVGOn1;
45+
ISVG mSVGOn2;
46+
IControl* mLinkedControl;
47+
bool tank2 = false;
3148
};
3249

3350
END_IGRAPHICS_NAMESPACE

Plateau/controls/LEDRadio.cpp

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,52 @@ BEGIN_IPLUG_NAMESPACE
44
BEGIN_IGRAPHICS_NAMESPACE
55

66
class LEDRadio : public IButtonControlBase
7-
, public IBitmapBase
87
{
98
public:
10-
LEDRadio(const IRECT& bounds, float hitboxScaleFactor, const IBitmap& bitmap, IActionFunction aF)
9+
LEDRadio(const IRECT& bounds, float hitboxScaleFactor, const ISVG& svgOff, const ISVG& svgOn, IActionFunction aF)
1110
: IButtonControlBase(bounds, aF)
12-
, IBitmapBase(bitmap)
11+
, mSVGOff(svgOff)
12+
, mSVGOn(svgOn)
1313
{
14-
hitboxScale = hitboxScaleFactor;
15-
AttachIControl(this);
14+
hitboxScale = hitboxScaleFactor;
1615
}
1716

18-
void Draw(IGraphics& g) override { DrawBitmap(g); }
19-
void OnRescale() override { mBitmap = GetUI()->GetScaledBitmap(mBitmap); }
20-
void OnMouseUp(float x, float y, const IMouseMod& mod) override {
21-
this->SetValue(0.);
22-
SetDirty(false);
23-
}
17+
void Draw(IGraphics& g) override { g.DrawSVG(GetValue()>=1.? mSVGOn : mSVGOff, mRECT, &mBlend); }
2418

2519
bool IsHit(float x, float y) const override {
2620
ICircle hitbox = ICircle(mTargetRECT);
2721
hitbox.Scale(hitboxScale);
2822
return hitbox.Contains(x, y);
2923
}
3024

25+
void OnMouseDown(float x, float y, const IMouseMod& mod)
26+
{
27+
SetValue(1.);
28+
SetDirty(true);
29+
for (IControl* control : mLinkedControls)
30+
{
31+
control->SetValue(0.);
32+
control->SetDirty(false);
33+
}
34+
}
35+
36+
void linkControls(std::vector<IControl*> linkedControls)
37+
{
38+
//Exclude self from linked controls
39+
for (IControl* control : linkedControls)
40+
{
41+
if (control != this)
42+
{
43+
mLinkedControls.push_back(control);
44+
}
45+
}
46+
}
47+
3148
float hitboxScale = 1.0f;
49+
protected:
50+
ISVG mSVGOff;
51+
ISVG mSVGOn;
52+
std::vector<IControl*> mLinkedControls;
3253
};
3354

3455
END_IGRAPHICS_NAMESPACE

Plateau/controls/LEDSwitch.cpp

Lines changed: 60 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,36 @@ class LEDSwitch : public ISwitchControlBase
1010
* @param bounds The control's bounds
1111
* @param bitmap The bitmap resource for the control
1212
* @param paramIdx The parameter index to link this control to */
13-
LEDSwitch(const IRECT& bounds, float hitboxScaleFactor, const std::initializer_list<ISVG>& svgs, int paramIdx = kNoParameter)
14-
: ISwitchControlBase(bounds, paramIdx, nullptr, static_cast<int>(svgs.size()))
15-
, mSVGs(svgs)
13+
LEDSwitch(const IRECT& bounds, float hitboxScaleFactor, const ISVG& svgOff, const ISVG& svgOn1, const ISVG& svgOn2, int paramIdx = kNoParameter)
14+
: ISwitchControlBase(bounds, paramIdx, nullptr, 3)
15+
, mSVGOff(svgOff)
16+
, mSVGOn1(svgOn1)
17+
, mSVGOn2(svgOn2)
1618
{
1719
hitboxScale = hitboxScaleFactor;
18-
//AttachIControl(this);
1920
}
2021

2122
virtual ~LEDSwitch() {}
22-
void Draw(IGraphics& g) override { g.DrawSVG(mSVGs[GetSelectedIdx()], mRECT, &mBlend); }
23+
void Draw(IGraphics& g) override { g.DrawSVG(GetValue() >= 1. ? (tank2 ? mSVGOn2 : mSVGOn1) : mSVGOff, mRECT, &mBlend); }
2324
void OnMouseDown(float x, float y, const IMouseMod& mod) {
24-
if (mSVGs.size() > 1)
25-
SetValue(GetValue() + 1.0 / static_cast<double>(mSVGs.size() - 1));
26-
else
27-
SetValue(GetValue() + 1.0);
28-
29-
if (GetValue() > 1.001)
25+
//if (child) { // If this is a child, don't allow it to be toggled when the parent forces it on
26+
// if (linkedParent->GetValue() == 1.) {
27+
// return;
28+
// }
29+
// }
30+
SetValue(GetValue() + 1.);
31+
if (GetValue() > 1.) {
3032
SetValue(0.);
31-
33+
}
34+
preferedState = GetValue() >= 1.; //Set the state to return to when the parent turns back off
3235
SetDirty();
36+
if (child && !preferedState) {
37+
linkedParent->SetValue(0.);
38+
linkedParent->SetDirty();
39+
}
40+
if (parent) {
41+
linkedChild->Update();
42+
}
3343
};
3444

3545
bool IsHit(float x, float y) const override {
@@ -38,10 +48,47 @@ class LEDSwitch : public ISwitchControlBase
3848
return hitbox.Contains(x, y);
3949
}
4050

51+
void SelectTank(bool isTank2) {
52+
tank2 = isTank2;
53+
SetDirty();
54+
}
55+
4156
float hitboxScale = 1.0f;
4257

58+
void SetChild(LEDSwitch* child) {
59+
linkedChild = child;
60+
parent = true;
61+
child->SetParent(this);
62+
}
63+
64+
void Update() {
65+
if (child) {
66+
if (linkedParent->GetValue() >= 1) {
67+
SetValue(1.);
68+
}
69+
else {
70+
SetValue(preferedState);
71+
}
72+
SetDirty();
73+
}
74+
}
75+
4376
protected:
44-
std::vector<ISVG> mSVGs;
77+
ISVG mSVGOff;
78+
ISVG mSVGOn1;
79+
ISVG mSVGOn2;
80+
bool tank2 = false;
81+
bool parent = false;
82+
bool child = false;
83+
LEDSwitch* linkedChild;
84+
LEDSwitch* linkedParent;
85+
bool preferedState = false;
86+
87+
private:
88+
void SetParent(LEDSwitch* parent) {
89+
linkedParent = parent;
90+
child = true;
91+
}
4592
};
4693
END_IGRAPHICS_NAMESPACE
4794
END_IPLUG_NAMESPACE

Plateau/controls/NeedleKnob.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ BEGIN_IGRAPHICS_NAMESPACE
66
class NeedleKnob : public IKnobControlBase
77
{
88
public:
9-
NeedleKnob(const IRECT& bounds, const ISVG& dialPointer, const ISVG& dialBg, const IBitmap& dialFgBmp, int kParamIdx)
9+
NeedleKnob(const IRECT& bounds, const ISVG& dialPointer, const ISVG& dialBg, const IBitmap& dialFg1Bmp, const IBitmap& dialFg2Bmp, int kParamIdx)
1010
: IKnobControlBase(bounds, kParamIdx)
11-
, mDialFg(dialFgBmp)
11+
, mDialFg1(dialFg1Bmp)
12+
, mDialFg2(dialFg2Bmp)
1213
, mDialBg(dialBg)
1314
, mDialPointer(dialPointer)
1415
{
@@ -18,20 +19,27 @@ class NeedleKnob : public IKnobControlBase
1819
{
1920
g.DrawSVG(mDialBg, mRECT);
2021
g.DrawRotatedSVG(mDialPointer, mRECT.MW(), mRECT.MH(), mRECT.W(), mRECT.H(), mStartAngle + GetValue() * (mEndAngle - mStartAngle), &mBlend);
21-
g.DrawFittedBitmap(mDialFg, mRECT);
22+
g.DrawFittedBitmap(tank2 ? mDialFg2 : mDialFg1, mRECT);
2223
}
2324

2425
bool IsHit(float x, float y) const override {
2526
ICircle hitbox = ICircle(mTargetRECT);
2627
return hitbox.Contains(x, y);
2728
}
29+
30+
void SelectTank(bool isTank2) {
31+
tank2 = isTank2;
32+
SetDirty(false);
33+
}
2834

2935
private:
30-
IBitmap mDialFg;
36+
IBitmap mDialFg1;
37+
IBitmap mDialFg2;
3138
ISVG mDialBg;
3239
ISVG mDialPointer;
3340
float mStartAngle = -135.f;
3441
float mEndAngle = 135.f;
42+
bool tank2 = false;
3543
};
3644

3745
END_IGRAPHICS_NAMESPACE

Plateau/resources/img/Background.svg

Lines changed: 19 additions & 26 deletions
Loading

0 commit comments

Comments
 (0)