@@ -39,8 +39,6 @@ extern bool frameRateSync; | |||||
extern float autosavePeriod; | extern float autosavePeriod; | ||||
extern bool skipLoadOnLaunch; | extern bool skipLoadOnLaunch; | ||||
extern std::string patchPath; | extern std::string patchPath; | ||||
// (plugin, model) -> score | |||||
extern std::map<std::tuple<std::string, std::string>, float> favoriteScores; | |||||
extern std::vector<NVGcolor> cableColors; | extern std::vector<NVGcolor> cableColors; | ||||
json_t *toJson(); | json_t *toJson(); | ||||
@@ -81,16 +81,6 @@ static bool isModelVisible(plugin::Model *model, const std::string &search, cons | |||||
return true; | return true; | ||||
} | } | ||||
static void stepFavoriteScore(const std::string &plugin, const std::string &model) { | |||||
// Decay all scores | |||||
const float decayLambda = 0.1; | |||||
for (auto &it : settings::favoriteScores) { | |||||
it.second *= 1 - decayLambda; | |||||
} | |||||
// Increment favorite score by 1 | |||||
settings::favoriteScores[std::make_tuple(plugin, model)] += 1; | |||||
} | |||||
static ModuleWidget *chooseModel(plugin::Model *model) { | static ModuleWidget *chooseModel(plugin::Model *model) { | ||||
// Create module | // Create module | ||||
ModuleWidget *moduleWidget = model->createModuleWidget(); | ModuleWidget *moduleWidget = model->createModuleWidget(); | ||||
@@ -103,9 +93,6 @@ static ModuleWidget *chooseModel(plugin::Model *model) { | |||||
h->setModule(moduleWidget); | h->setModule(moduleWidget); | ||||
APP->history->push(h); | APP->history->push(h); | ||||
// Step favorite | |||||
stepFavoriteScore(model->plugin->slug, model->slug); | |||||
// Hide Module Browser | // Hide Module Browser | ||||
APP->scene->moduleBrowser->hide(); | APP->scene->moduleBrowser->hide(); | ||||
@@ -506,13 +493,10 @@ struct ModuleBrowser : widget::OpaqueWidget { | |||||
} | } | ||||
// Sort ModelBoxes | // Sort ModelBoxes | ||||
// Sort by favorite score and then name | |||||
modelContainer->children.sort([&](Widget *w1, Widget *w2) { | modelContainer->children.sort([&](Widget *w1, Widget *w2) { | ||||
ModelBox *m1 = dynamic_cast<ModelBox*>(w1); | ModelBox *m1 = dynamic_cast<ModelBox*>(w1); | ||||
ModelBox *m2 = dynamic_cast<ModelBox*>(w2); | ModelBox *m2 = dynamic_cast<ModelBox*>(w2); | ||||
// Sort by favorite score if either is available | |||||
// float score1 = get_default(settings::favoriteScores, std::make_tuple(m1->model->plugin->slug, m1->model->slug), 0.f); | |||||
// float score2 = get_default(settings::favoriteScores, std::make_tuple(m2->model->plugin->slug, m2->model->slug), 0.f); | |||||
// Sort by (modifiedTimestamp descending, plugin brand, model name) | |||||
auto t1 = std::make_tuple(-m1->model->plugin->modifiedTimestamp, m1->model->plugin->brand, m1->model->name); | auto t1 = std::make_tuple(-m1->model->plugin->modifiedTimestamp, m1->model->plugin->brand, m1->model->name); | ||||
auto t2 = std::make_tuple(-m2->model->plugin->modifiedTimestamp, m2->model->plugin->brand, m2->model->name); | auto t2 = std::make_tuple(-m2->model->plugin->modifiedTimestamp, m2->model->plugin->brand, m2->model->name); | ||||
return t1 < t2; | return t1 < t2; | ||||
@@ -34,7 +34,6 @@ bool frameRateSync = true; | |||||
float autosavePeriod = 15.0; | float autosavePeriod = 15.0; | ||||
bool skipLoadOnLaunch = false; | bool skipLoadOnLaunch = false; | ||||
std::string patchPath; | std::string patchPath; | ||||
std::map<std::tuple<std::string, std::string>, float> favoriteScores; | |||||
std::vector<NVGcolor> cableColors = { | std::vector<NVGcolor> cableColors = { | ||||
nvgRGB(0xc9, 0xb7, 0x0e), // yellow | nvgRGB(0xc9, 0xb7, 0x0e), // yellow | ||||
nvgRGB(0x0c, 0x8e, 0x15), // green | nvgRGB(0x0c, 0x8e, 0x15), // green | ||||
@@ -88,19 +87,6 @@ json_t *toJson() { | |||||
json_object_set_new(rootJ, "patchPath", json_string(patchPath.c_str())); | json_object_set_new(rootJ, "patchPath", json_string(patchPath.c_str())); | ||||
json_t *favoriteModelsJ = json_array(); | |||||
for (auto &pair : favoriteScores) { | |||||
const std::string &plugin = std::get<0>(pair.first); | |||||
const std::string &model = std::get<1>(pair.first); | |||||
float score = pair.second; | |||||
json_t *favoriteJ = json_object(); | |||||
json_object_set_new(favoriteJ, "plugin", json_string(plugin.c_str())); | |||||
json_object_set_new(favoriteJ, "model", json_string(model.c_str())); | |||||
json_object_set_new(favoriteJ, "score", json_real(score)); | |||||
json_array_append_new(favoriteModelsJ, favoriteJ); | |||||
} | |||||
json_object_set_new(rootJ, "favoriteModels", favoriteModelsJ); | |||||
json_t *cableColorsJ = json_array(); | json_t *cableColorsJ = json_array(); | ||||
for (NVGcolor cableColor : cableColors) { | for (NVGcolor cableColor : cableColors) { | ||||
std::string colorStr = color::toHexString(cableColor); | std::string colorStr = color::toHexString(cableColor); | ||||
@@ -194,34 +180,6 @@ void fromJson(json_t *rootJ) { | |||||
if (patchPathJ) | if (patchPathJ) | ||||
patchPath = json_string_value(patchPathJ); | patchPath = json_string_value(patchPathJ); | ||||
json_t *favoriteModelsJ = json_object_get(rootJ, "favoriteModels"); | |||||
// Legacy: "favorites" was defined under "moduleBrowser" until 1.0. | |||||
if (!favoriteModelsJ) { | |||||
json_t *moduleBrowserJ = json_object_get(rootJ, "moduleBrowser"); | |||||
if (moduleBrowserJ) | |||||
favoriteModelsJ = json_object_get(rootJ, "favorites"); | |||||
} | |||||
if (favoriteModelsJ) { | |||||
favoriteScores.clear(); | |||||
size_t i; | |||||
json_t *favoriteJ; | |||||
json_array_foreach(favoriteModelsJ, i, favoriteJ) { | |||||
json_t *pluginJ = json_object_get(favoriteJ, "plugin"); | |||||
json_t *modelJ = json_object_get(favoriteJ, "model"); | |||||
if (!pluginJ || !modelJ) | |||||
continue; | |||||
std::string plugin = json_string_value(pluginJ); | |||||
std::string model = json_string_value(modelJ); | |||||
// Set default score when migrating favorites from v0.6 | |||||
float score = 1.f; | |||||
json_t *scoreJ = json_object_get(favoriteJ, "score"); | |||||
if (scoreJ) | |||||
score = json_number_value(scoreJ); | |||||
favoriteScores[std::make_tuple(plugin, model)] = score; | |||||
} | |||||
} | |||||
json_t *cableColorsJ = json_object_get(rootJ, "cableColors"); | json_t *cableColorsJ = json_object_get(rootJ, "cableColors"); | ||||
if (cableColorsJ) { | if (cableColorsJ) { | ||||
cableColors.clear(); | cableColors.clear(); | ||||