commit 8e049691cd716e9679e7166c009614c0ca29bc16
parent b7be8684d37d72bde2a77f2d77e93ceea3ca9ec9
Author: Adam M <aemalone@gmail.com>
Date: Wed, 3 Nov 2021 12:48:22 -0500
show light emitting things when room dims
Diffstat:
5 files changed, 74 insertions(+), 25 deletions(-)
diff --git a/src/Computerscare.hpp b/src/Computerscare.hpp
@@ -438,6 +438,8 @@ struct ComputerscareTextField : ui::TextField {
int fontSize = 16;
bool inError = false;
int textColorState = 0;
+ bool dimWithRoom = false;
+
ComputerscareTextField() {
color = nvgRGB(0xff, 0xd7, 0x14);
@@ -446,9 +448,6 @@ struct ComputerscareTextField : ui::TextField {
void draw(const DrawArgs &args) override {
-
- std::shared_ptr<Font> font = APP->window->loadFont(asset::system(fontPath));
-
nvgScissor(args.vg, RECT_ARGS(args.clipBox));
// Background
@@ -462,9 +461,20 @@ struct ComputerscareTextField : ui::TextField {
}
nvgFill(args.vg);
- // Text
+ if (dimWithRoom) {
+ drawText(args);
+ }
+ }
+ void drawLayer(const BGPanel::DrawArgs& args, int layer) override {
+ if (layer == 1 && !dimWithRoom) {
+ drawText(args);
+ }
+ Widget::drawLayer(args, layer);
+ }
+ void drawText(const BGPanel::DrawArgs& args) {
+ std::shared_ptr<Font> font = APP->window->loadFont(asset::system(fontPath));
if (font) {
-
+ // Text
nvgFontFaceId(args.vg, font->handle);
bndSetFont(font->handle);
@@ -477,9 +487,8 @@ struct ComputerscareTextField : ui::TextField {
-1, color, fontSize, text.c_str(), highlightColor, begin, end);
bndSetFont(APP->window->uiFont->handle);
+ nvgResetScissor(args.vg);
}
-
- nvgResetScissor(args.vg);
}
int getTextPosition(Vec mousePos) override {
std::shared_ptr<Font> font = APP->window->loadFont(asset::system(fontPath));
diff --git a/src/ComputerscareDebug.cpp b/src/ComputerscareDebug.cpp
@@ -341,11 +341,10 @@ struct HidableSmallSnapKnob : SmallSnapKnob {
struct StringDisplayWidget3 : Widget {
std::string value;
- std::shared_ptr<Font> font;
- ComputerscareDebug *module;
+ std::string fontPath = "res/Oswald-Regular.ttf";
+ ComputerscareDebug * module;
StringDisplayWidget3() {
- font = APP->window->loadFont(asset::plugin(pluginInstance, "res/Oswald-Regular.ttf"));
};
void draw(const DrawArgs &ctx) override
@@ -361,19 +360,24 @@ struct StringDisplayWidget3 : Widget {
nvgRoundedRect(ctx.vg, 0.0, 0.0, box.size.x, box.size.y, 4.0);
nvgFillColor(ctx.vg, backgroundColor);
nvgFill(ctx.vg);
+ }
+ void drawLayer(const BGPanel::DrawArgs& args, int layer) override {
+ if (layer == 1) {
+ std::shared_ptr<Font> font = APP->window->loadFont(asset::plugin(pluginInstance, fontPath));
- nvgFontSize(ctx.vg, 15);
- nvgFontFaceId(ctx.vg, font->handle);
- nvgTextLetterSpacing(ctx.vg, 2.5);
-
- std::string textToDraw = module ? module->strValue : noModuleStringValue;
- Vec textPos = Vec(6.0f, 12.0f);
- NVGcolor textColor = nvgRGB(0xC0, 0xE7, 0xDE);
- nvgFillColor(ctx.vg, textColor);
-
- nvgTextBox(ctx.vg, textPos.x, textPos.y, 80, textToDraw.c_str(), NULL);
+ //text
+ nvgFontSize(args.vg, 15);
+ nvgFontFaceId(args.vg, font->handle);
+ nvgTextLetterSpacing(args.vg, 2.5);
+ std::string textToDraw = module ? module->strValue : noModuleStringValue;
+ Vec textPos = Vec(6.0f, 12.0f);
+ NVGcolor textColor = nvgRGB(0xC0, 0xE7, 0xDE);
+ nvgFillColor(args.vg, textColor);
+ nvgTextBox(args.vg, textPos.x, textPos.y, 80, textToDraw.c_str(), NULL);
+ }
+ Widget::drawLayer(args, layer);
}
};
struct ConnectedSmallLetter : SmallLetterDisplay {
diff --git a/src/ComputerscareFolyPace.cpp b/src/ComputerscareFolyPace.cpp
@@ -39,6 +39,8 @@ struct FolyPace : Module {
int C = 29;
int D = 2;
+ bool faceEmitsLight = true;
+
FolyPace() {
config(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS);
const float timeBase = (float) BUFFER_SIZE / 6;
@@ -351,9 +353,19 @@ struct FolyPaceDisplay : TransparentWidget {
drawFace(args, random::uniform() * 10, random::uniform() * 10, random::uniform() * 10, random::uniform() * 10, random::uniform() * 10, random::uniform() * 10, random::uniform() * 10, random::uniform() * 10, random::uniform() * 10, random::uniform() * 10, random::uniform() * 10, random::uniform() * 10, random::uniform() * 10, random::uniform() * 10, random::uniform() * 10, random::uniform() * 10);
}
else {
- drawFace(args, module->bufferX[0][0], module->bufferX[1][0], module->bufferX[2][0], module->bufferX[3][0], module->bufferX[4][0], module->bufferX[5][0], module->bufferX[6][0], module->bufferX[7][0], module->bufferX[8][0], module->bufferX[9][0], module->bufferX[10][0], module->bufferX[11][0], module->bufferX[12][0], module->bufferX[13][0], module->bufferX[14][0], module->bufferX[15][0]);
+ if (!module->faceEmitsLight) {
+ drawFace(args, module->bufferX[0][0], module->bufferX[1][0], module->bufferX[2][0], module->bufferX[3][0], module->bufferX[4][0], module->bufferX[5][0], module->bufferX[6][0], module->bufferX[7][0], module->bufferX[8][0], module->bufferX[9][0], module->bufferX[10][0], module->bufferX[11][0], module->bufferX[12][0], module->bufferX[13][0], module->bufferX[14][0], module->bufferX[15][0]);
+ }
}
}
+ void drawLayer(const BGPanel::DrawArgs& args, int layer) override {
+ if (layer == 1 && module) {
+ if (module->faceEmitsLight) {
+ drawFace(args, module->bufferX[0][0], module->bufferX[1][0], module->bufferX[2][0], module->bufferX[3][0], module->bufferX[4][0], module->bufferX[5][0], module->bufferX[6][0], module->bufferX[7][0], module->bufferX[8][0], module->bufferX[9][0], module->bufferX[10][0], module->bufferX[11][0], module->bufferX[12][0], module->bufferX[13][0], module->bufferX[14][0], module->bufferX[15][0]);
+ }
+ }
+ Widget::drawLayer(args, layer);
+ }
};
@@ -382,8 +394,14 @@ struct FolyPaceWidget : ModuleWidget {
addParam(createParam<SmallKnob>(Vec(31, 357), module, FolyPace::TRIM));
addParam(createParam<SmoothKnob>(Vec(51, 353), module, FolyPace::OFFSET));
addParam(createParam<ScrambleKnob>(Vec(81, 357), module, FolyPace::SCRAMBLE));
+ }
+
+ void appendContextMenu(Menu* menu) override {
+ FolyPace* module = dynamic_cast<FolyPace*>(this->module);
+ menu->addChild(new MenuSeparator);
+ menu->addChild(createBoolPtrMenuItem("Face Emits Light", "", &module->faceEmitsLight));
}
};
diff --git a/src/ComputerscareILoveCookies.cpp b/src/ComputerscareILoveCookies.cpp
@@ -477,12 +477,12 @@ struct CookiesKnobRangeItem : MenuItem {
struct CookiesTF2 : ComputerscareTextField
{
ComputerscareILoveCookies *module;
- //int fontSize = 16;
int rowIndex = 0;
CookiesTF2(int i)
{
rowIndex = i;
+ dimWithRoom = false;
ComputerscareTextField();
};
void draw(const DrawArgs &args) override
diff --git a/src/ComputerscareStolyFickPigure.cpp b/src/ComputerscareStolyFickPigure.cpp
@@ -40,6 +40,8 @@ struct StolyFickPigure : Module {
int C = 29;
int D = 2;
+ bool figureEmitsLight = true;
+
StolyFickPigure() {
config(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS);
@@ -285,8 +287,18 @@ struct StolyFickPigureDisplay : TransparentWidget {
drawStickFigure(args, random::uniform() * 10, random::uniform() * 10, random::uniform() * 10, random::uniform() * 10, random::uniform() * 10, random::uniform() * 10, random::uniform() * 10, random::uniform() * 10, random::uniform() * 10, random::uniform() * 10, random::uniform() * 10, random::uniform() * 10, random::uniform() * 10, random::uniform() * 10, random::uniform() * 10, random::uniform() * 10);
}
else {
- drawStickFigure(args, module->bufferX[0][0], module->bufferX[1][0], module->bufferX[2][0], module->bufferX[3][0], module->bufferX[4][0], module->bufferX[5][0], module->bufferX[6][0], module->bufferX[7][0], module->bufferX[8][0], module->bufferX[9][0], module->bufferX[10][0], module->bufferX[11][0], module->bufferX[12][0], module->bufferX[13][0], module->bufferX[14][0], module->bufferX[15][0]);
+ if (!module->figureEmitsLight) {
+ drawStickFigure(args, module->bufferX[0][0], module->bufferX[1][0], module->bufferX[2][0], module->bufferX[3][0], module->bufferX[4][0], module->bufferX[5][0], module->bufferX[6][0], module->bufferX[7][0], module->bufferX[8][0], module->bufferX[9][0], module->bufferX[10][0], module->bufferX[11][0], module->bufferX[12][0], module->bufferX[13][0], module->bufferX[14][0], module->bufferX[15][0]);
+ }
+ }
+ }
+ void drawLayer(const BGPanel::DrawArgs& args, int layer) override {
+ if (layer == 1 && module) {
+ if (module->figureEmitsLight) {
+ drawStickFigure(args, module->bufferX[0][0], module->bufferX[1][0], module->bufferX[2][0], module->bufferX[3][0], module->bufferX[4][0], module->bufferX[5][0], module->bufferX[6][0], module->bufferX[7][0], module->bufferX[8][0], module->bufferX[9][0], module->bufferX[10][0], module->bufferX[11][0], module->bufferX[12][0], module->bufferX[13][0], module->bufferX[14][0], module->bufferX[15][0]);
+ }
}
+ Widget::drawLayer(args, layer);
}
};
@@ -317,8 +329,6 @@ struct StolyFickPigureWidget : ModuleWidget {
addParam(createParam<SmoothKnob>(Vec(51, 353), module, StolyFickPigure::OFFSET));
addParam(createParam<ScrambleKnob>(Vec(81, 357), module, StolyFickPigure::SCRAMBLE));
-
-
}
void drawShadow(const DrawArgs& args) {
DEBUG("my draw shadow has been called");
@@ -332,6 +342,14 @@ struct StolyFickPigureWidget : ModuleWidget {
nvgFillPaint(args.vg, nvgBoxGradient(args.vg, b.x, b.y, box.size.x - 2 * b.x, box.size.y - 2 * b.y, c, r, shadowColor, transparentColor));
nvgFill(args.vg);
}
+
+ void appendContextMenu(Menu* menu) override {
+ StolyFickPigure* module = dynamic_cast<StolyFickPigure*>(this->module);
+
+ menu->addChild(new MenuSeparator);
+
+ menu->addChild(createBoolPtrMenuItem("Stick Figure Emits Light", "", &module->figureEmitsLight));
+ }
};