mirror of
https://github.com/Llennpie/Saturn.git
synced 2025-01-22 15:43:05 -05:00
Rework/fix expression checkboxes
This commit is contained in:
parent
5cc45a7c9b
commit
074c65cd3f
2 changed files with 40 additions and 20 deletions
|
@ -199,19 +199,22 @@ void OpenExpressionSelector() {
|
|||
for (int i = 0; i < current_model.Expressions.size(); i++) {
|
||||
Expression expression = current_model.Expressions[i];
|
||||
if (expression.Name == "eyes") continue;
|
||||
if (expression.Textures.size() <= 1) continue;
|
||||
|
||||
std::string label_name = "###exp_label_" + expression.Name;
|
||||
ImGui::Text(expression.Name.c_str());
|
||||
ImGui::SameLine(75);
|
||||
ImGui::PushItemWidth(120);
|
||||
|
||||
if (expression.Textures.size() >= 2) {
|
||||
if (expression.IsToggleFormat() &&
|
||||
// Use checkbox
|
||||
if (expression.Textures.size() == 2 && (
|
||||
expression.Textures[0].FileName.find("default") != std::string::npos ||
|
||||
(expression.Textures[0].FileName.find("default") != std::string::npos ||
|
||||
expression.Textures[1].FileName.find("default") != std::string::npos)) {
|
||||
|
||||
// Check which index "default.png" is (0 or 1) to determine default value
|
||||
int select_index = (expression.Textures[0].FileName.find("default") != std::string::npos) ? 0 : 1;
|
||||
int deselect_index = (expression.Textures[0].FileName.find("default") != std::string::npos) ? 1 : 0;
|
||||
int deselect_index = (select_index == 0) ? 1 : 0;
|
||||
bool is_selected = (expression.CurrentIndex == select_index);
|
||||
|
||||
if (ImGui::Checkbox(label_name.c_str(), &is_selected)) {
|
||||
|
@ -221,6 +224,7 @@ void OpenExpressionSelector() {
|
|||
// Popout showing the checkbox's actively displayed value
|
||||
// This is technically the opposite of the dropdowns and selectables, which shows the value-that-will-be, not current
|
||||
ShowTextureContextMenu(¤t_model.Expressions[i], current_model.Expressions[i].Textures[expression.CurrentIndex], i);
|
||||
|
||||
} else {
|
||||
// Use dropdown
|
||||
std::string defaultLabel = ((expression.Textures.size() > 0) ? expression.Textures[expression.CurrentIndex].FileName : expression.Name) + "###combo_" + expression.Name.c_str();
|
||||
|
@ -230,6 +234,7 @@ void OpenExpressionSelector() {
|
|||
}
|
||||
ShowTextureContextMenu(¤t_model.Expressions[i], current_model.Expressions[i].Textures[expression.CurrentIndex], i);
|
||||
}
|
||||
}
|
||||
ImGui::PopItemWidth();
|
||||
}
|
||||
|
||||
|
|
|
@ -48,6 +48,21 @@ public:
|
|||
path.find(prefix + this->Name + "_s") != std::string::npos ||
|
||||
path.find(prefix + this->Name.substr(0, this->Name.size() - 1) + "_") != std::string::npos);
|
||||
}
|
||||
|
||||
/* Returns true if the expression's textures are formatted for a checkbox
|
||||
This is when an expression has two non-model textures and no subfolders */
|
||||
bool IsToggleFormat() {
|
||||
if (this->Textures.size() >= 2 && this->Folders.size() == 0) {
|
||||
int countWithoutModelTextures = 0;
|
||||
for (int i = 0; i < this->Textures.size(); i++) {
|
||||
// Exclude model textures
|
||||
if (this->Textures[i].IsModelTexture) continue;
|
||||
countWithoutModelTextures++;
|
||||
}
|
||||
return(countWithoutModelTextures == 2);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
extern bool custom_eyes_enabled;
|
||||
|
|
Loading…
Reference in a new issue