| 1 |
/** |
| 2 |
* Furnace Tracker - multi-system chiptune tracker |
| 3 |
* Copyright (C) 2021-2025 tildearrow and contributors |
| 4 |
* |
| 5 |
* This program is free software; you can redistribute it and/or modify |
| 6 |
* it under the terms of the GNU General Public License as published by |
| 7 |
* the Free Software Foundation; either version 2 of the License, or |
| 8 |
* (at your option) any later version. |
| 9 |
* |
| 10 |
* This program is distributed in the hope that it will be useful, |
| 11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 |
* GNU General Public License for more details. |
| 14 |
* |
| 15 |
* You should have received a copy of the GNU General Public License along |
| 16 |
* with this program; if not, write to the Free Software Foundation, Inc., |
| 17 |
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 18 |
*/ |
| 19 |
|
| 20 |
#include "gui.h" |
| 21 |
#include "misc/cpp/imgui_stdlib.h" |
| 22 |
#include "IconsFontAwesome4.h" |
| 23 |
#include "guiConst.h" |
| 24 |
#include <imgui.h> |
| 25 |
|
| 26 |
DivSystem FurnaceGUI::systemPicker(bool fullWidth) { |
| 27 |
DivSystem ret=DIV_SYSTEM_NULL; |
| 28 |
DivSystem hoveredSys=DIV_SYSTEM_NULL; |
| 29 |
bool reissueSearch=false; |
| 30 |
if (curSysSection==NULL) { |
| 31 |
curSysSection=availableSystems; |
| 32 |
} |
| 33 |
|
| 34 |
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); |
| 35 |
if (ImGui::InputTextWithHint("##SysSearch",_("Search..."),&sysSearchQuery)) reissueSearch=true; |
| 36 |
if (ImGui::BeginTabBar("SysCats")) { |
| 37 |
for (int i=0; chipCategories[i]; i++) { |
| 38 |
if (ImGui::BeginTabItem(_(chipCategoryNames[i]))) { |
| 39 |
if (ImGui::IsItemActive()) { |
| 40 |
reissueSearch=true; |
| 41 |
} |
| 42 |
curSysSection=chipCategories[i]; |
| 43 |
ImGui::EndTabItem(); |
| 44 |
} |
| 45 |
} |
| 46 |
ImGui::EndTabBar(); |
| 47 |
} |
| 48 |
if (reissueSearch) { |
| 49 |
String lowerCase=sysSearchQuery; |
| 50 |
for (char& i: lowerCase) { |
| 51 |
if (i>='A' && i<='Z') i+='a'-'A'; |
| 52 |
} |
| 53 |
sysSearchResults.clear(); |
| 54 |
for (int j=0; curSysSection[j]; j++) { |
| 55 |
String lowerCase1=e->getSystemName((DivSystem)curSysSection[j]); |
| 56 |
for (char& i: lowerCase1) { |
| 57 |
if (i>='A' && i<='Z') i+='a'-'A'; |
| 58 |
} |
| 59 |
if (lowerCase1.find(lowerCase)!=String::npos) { |
| 60 |
sysSearchResults.push_back((DivSystem)curSysSection[j]); |
| 61 |
} |
| 62 |
} |
| 63 |
} |
| 64 |
if (ImGui::BeginTable("SysList",1,ImGuiTableFlags_ScrollY|ImGuiTableFlags_BordersOuterH,ImVec2(fullWidth ? ImGui::GetContentRegionAvail().x : 500.0f*dpiScale,200.0f*dpiScale))) { |
| 65 |
if (sysSearchQuery.empty()) { |
| 66 |
// display chip list |
| 67 |
for (int j=0; curSysSection[j]; j++) { |
| 68 |
if (!settings.hiddenSystems && CHECK_HIDDEN_SYSTEM(curSysSection[j])) continue; |
| 69 |
ImGui::TableNextRow(); |
| 70 |
ImGui::TableNextColumn(); |
| 71 |
if (ImGui::Selectable(e->getSystemName((DivSystem)curSysSection[j]),false,0,ImVec2(500.0f*dpiScale,0.0f))) ret=(DivSystem)curSysSection[j]; |
| 72 |
if (ImGui::IsItemHovered() && hoveredSys==DIV_SYSTEM_NULL) { |
| 73 |
hoveredSys=(DivSystem)curSysSection[j]; |
| 74 |
} |
| 75 |
} |
| 76 |
} else { |
| 77 |
// display search results |
| 78 |
for (DivSystem i: sysSearchResults) { |
| 79 |
if (!settings.hiddenSystems && CHECK_HIDDEN_SYSTEM(i)) continue; |
| 80 |
ImGui::TableNextRow(); |
| 81 |
ImGui::TableNextColumn(); |
| 82 |
if (ImGui::Selectable(e->getSystemName(i),false,0,ImVec2(500.0f*dpiScale,0.0f))) ret=i; |
| 83 |
if (ImGui::IsItemHovered() && hoveredSys==DIV_SYSTEM_NULL) { |
| 84 |
hoveredSys=i; |
| 85 |
} |
| 86 |
} |
| 87 |
} |
| 88 |
ImGui::EndTable(); |
| 89 |
} |
| 90 |
if (ImGui::BeginChild("SysDesc",ImVec2(0.0f,150.0f*dpiScale),0,ImGuiWindowFlags_NoScrollbar|ImGuiWindowFlags_NoScrollWithMouse)) { |
| 91 |
if (hoveredSys!=DIV_SYSTEM_NULL) { |
| 92 |
const DivSysDef* sysDef=e->getSystemDef(hoveredSys); |
| 93 |
ImGui::TextWrapped("%s",sysDef->description); |
| 94 |
ImGui::Separator(); |
| 95 |
drawSystemChannelInfoText(sysDef); |
| 96 |
drawSystemChannelInfo(sysDef); |
| 97 |
} |
| 98 |
} |
| 99 |
ImGui::EndChild(); |
| 100 |
return ret; |
| 101 |
} |