Skip to content

Commit

Permalink
HC-3 sample data and fix lights in browser
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul-Dempsey committed Sep 26, 2023
1 parent 2157b6a commit e191d47
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 4 deletions.
20 changes: 20 additions & 0 deletions src/HC-3/HC-3-ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ constexpr const float START_ROW = 47.5f;
constexpr const float ITEM_INTERVAL = 20.f;
constexpr const float DIVIDER_OFFSET = 5.f;

std::string hc3_sample_data[] = {
"Experimental", "Strings", "Winds", "Guitars", "Pads", "Leads", "Album 4", "Album 5",
"Mon practice", "", "Th Jam", "Blues setlist", "Recital 10/7", "Community Concert 8/21", "" ,"empty"
};

Hc3ModuleWidget::Hc3ModuleWidget(Hc3Module* module)
: my_module(module)
{
Expand Down Expand Up @@ -57,6 +62,21 @@ void Hc3ModuleWidget::step()
if (module && device_label->getText().empty()) {
my_module->getPartner();
}
if (!module && !hacked_lights) {
// Rack turns every light to full brightness in the module browser
// we hack it here to show a more representative state.
int n = 0;
for (auto child: children) {
auto light = dynamic_cast<BlueLight*>(child);
if (light) {
NVGcolor co = *light->baseColors.begin();
co.a = n == CHOSEN_SAMPLE ? 1.f : hc3_sample_data[n].empty() ? 0.f : .3f;
light->color = co;
++n;
}
}
hacked_lights = true;
}
}

void Hc3ModuleWidget::refreshDescriptions()
Expand Down
5 changes: 4 additions & 1 deletion src/HC-3/HC-3.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@

namespace pachde {

extern std::string hc3_sample_data[];
constexpr const int CHOSEN_SAMPLE = 11;

struct Hc3Module : Module, IHandleHcEvents
{
enum Params {
Expand All @@ -25,7 +28,6 @@ struct Hc3Module : Module, IHandleHcEvents
NUM_LIGHTS
};


int loaded_id;
std::vector<std::string> files;
PartnerBinding partner_binding;
Expand Down Expand Up @@ -64,6 +66,7 @@ struct Hc3ModuleWidget : ModuleWidget, IHandleHcEvents
Hc3Module* my_module;
DrawSquareButton drawButton;
StaticTextLabel* device_label = nullptr;
bool hacked_lights = false;

Hc3ModuleWidget(Hc3Module* module);

Expand Down
15 changes: 12 additions & 3 deletions src/HC-3/preset_file_widget.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,17 @@ struct PresetFileWidget : TipWidget
id = the_id;
}
int getId() { return id; }
bool haveFile() { return my_module && !my_module->files[id].empty(); }
bool isCurrent() { return my_module && my_module->loaded_id == id; }
std::string getLabel() { return my_module ? system::getStem(my_module->files[id]) : ""; }
bool haveFile() {
if (my_module) { return !my_module->files[id].empty(); }
return !hc3_sample_data[id].empty();
}
bool isCurrent() {
if (my_module) { return my_module->loaded_id == id; }
return id == CHOSEN_SAMPLE;
}
std::string getLabel() {
return my_module ? system::getStem(my_module->files[id]) : hc3_sample_data[id];
}

void onDragStart(const DragStartEvent& e) override {
if (e.button == GLFW_MOUSE_BUTTON_LEFT) {
Expand Down Expand Up @@ -99,6 +107,7 @@ struct PresetFileWidget : TipWidget

void step() override {
TipWidget::step();
if (!my_module) return;
if (!TipWidget::hasText() && haveFile()) {
describe(format_string("Open %s", my_module->files[id].c_str()));
}
Expand Down

0 comments on commit e191d47

Please sign in to comment.