GUI: fix system detection
This commit is contained in:
parent
db45b0d7d7
commit
5848c48a76
|
|
@ -635,29 +635,9 @@ void FurnaceGUI::updateWindowTitle() {
|
|||
}
|
||||
}
|
||||
|
||||
void FurnaceGUI::autoDetectSystem() {
|
||||
std::map<DivSystem,int> sysCountMap;
|
||||
std::map<DivSystem,DivConfig> sysConfMap;
|
||||
for (int i=0; i<e->song.systemLen; i++) {
|
||||
auto it=sysCountMap.find(e->song.system[i]);
|
||||
if (it==sysCountMap.cend()) {
|
||||
sysCountMap[e->song.system[i]]=1;
|
||||
} else {
|
||||
it->second++;
|
||||
}
|
||||
sysConfMap[e->song.system[i]]=e->song.systemFlags[i];
|
||||
}
|
||||
|
||||
logV("sysCountMap:");
|
||||
for (std::pair<DivSystem,int> k: sysCountMap) {
|
||||
logV("%s: %d",e->getSystemName(k.first),k.second);
|
||||
}
|
||||
|
||||
bool isMatch=false;
|
||||
std::map<DivSystem,int> defCountMap;
|
||||
std::map<DivSystem,DivConfig> defConfMap;
|
||||
for (FurnaceGUISysCategory& i: sysCategories) {
|
||||
for (FurnaceGUISysDef& j: i.systems) {
|
||||
void FurnaceGUI::autoDetectSystemIter(std::vector<FurnaceGUISysDef>& category, bool& isMatch, std::map<DivSystem,int>& defCountMap, std::map<DivSystem,DivConfig>& defConfMap, std::map<DivSystem,int>& sysCountMap, std::map<DivSystem,DivConfig>& sysConfMap) {
|
||||
for (FurnaceGUISysDef& j: category) {
|
||||
if (!j.orig.empty()) {
|
||||
defCountMap.clear();
|
||||
defConfMap.clear();
|
||||
for (FurnaceGUISysDefChip& k: j.orig) {
|
||||
|
|
@ -671,12 +651,12 @@ void FurnaceGUI::autoDetectSystem() {
|
|||
dc.loadFromMemory(k.flags);
|
||||
defConfMap[k.sys]=dc;
|
||||
}
|
||||
if (defCountMap.size()!=sysCountMap.size()) continue;
|
||||
if (defCountMap.size()==sysCountMap.size()) {
|
||||
isMatch=true;
|
||||
/*logV("trying on defCountMap: %s",j.name);
|
||||
logV("trying on defCountMap: %s",j.name);
|
||||
for (std::pair<DivSystem,int> k: defCountMap) {
|
||||
logV("- %s: %d",e->getSystemName(k.first),k.second);
|
||||
}*/
|
||||
}
|
||||
for (std::pair<DivSystem,int> k: defCountMap) {
|
||||
auto countI=sysCountMap.find(k.first);
|
||||
if (countI==sysCountMap.cend()) {
|
||||
|
|
@ -716,6 +696,35 @@ void FurnaceGUI::autoDetectSystem() {
|
|||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!j.subDefs.empty()) autoDetectSystemIter(j.subDefs,isMatch,defCountMap,defConfMap,sysCountMap,sysConfMap);
|
||||
if (isMatch) break;
|
||||
}
|
||||
}
|
||||
|
||||
void FurnaceGUI::autoDetectSystem() {
|
||||
std::map<DivSystem,int> sysCountMap;
|
||||
std::map<DivSystem,DivConfig> sysConfMap;
|
||||
for (int i=0; i<e->song.systemLen; i++) {
|
||||
auto it=sysCountMap.find(e->song.system[i]);
|
||||
if (it==sysCountMap.cend()) {
|
||||
sysCountMap[e->song.system[i]]=1;
|
||||
} else {
|
||||
it->second++;
|
||||
}
|
||||
sysConfMap[e->song.system[i]]=e->song.systemFlags[i];
|
||||
}
|
||||
|
||||
logV("sysCountMap:");
|
||||
for (std::pair<DivSystem,int> k: sysCountMap) {
|
||||
logV("%s: %d",e->getSystemName(k.first),k.second);
|
||||
}
|
||||
|
||||
bool isMatch=false;
|
||||
std::map<DivSystem,int> defCountMap;
|
||||
std::map<DivSystem,DivConfig> defConfMap;
|
||||
for (FurnaceGUISysCategory& i: sysCategories) {
|
||||
autoDetectSystemIter(i.systems,isMatch,defCountMap,defConfMap,sysCountMap,sysConfMap);
|
||||
if (isMatch) break;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2511,6 +2511,7 @@ class FurnaceGUI {
|
|||
|
||||
void updateWindowTitle();
|
||||
void autoDetectSystem();
|
||||
void autoDetectSystemIter(std::vector<FurnaceGUISysDef>& category, bool& isMatch, std::map<DivSystem,int>& defCountMap, std::map<DivSystem,DivConfig>& defConfMap, std::map<DivSystem,int>& sysCountMap, std::map<DivSystem,DivConfig>& sysConfMap);
|
||||
void prepareLayout();
|
||||
ImVec4 channelColor(int ch);
|
||||
ImVec4 channelTextColor(int ch);
|
||||
|
|
|
|||
Loading…
Reference in a new issue