From 065db6b7bde7735320dfdb5587e1aa8de8c7ef49 Mon Sep 17 00:00:00 2001 From: tildearrow Date: Thu, 28 Mar 2024 13:50:15 -0500 Subject: [PATCH] GUI: make memory usage unit setting effective --- doc/2-interface/settings.md | 4 ++-- src/gui/memory.cpp | 19 +++++++++++++++---- src/gui/settings.cpp | 4 ++-- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/doc/2-interface/settings.md b/doc/2-interface/settings.md index 553a8c9a3..93eaa3be7 100644 --- a/doc/2-interface/settings.md +++ b/doc/2-interface/settings.md @@ -479,9 +479,9 @@ below all the binds, select a key from the dropdown list to add it. it will appe - **Use separate colors for carriers/modulators in FM editor** - **Unsigned FM detune values**: uses the internal representation of detune values, such that detune amounts of -1, -2, and -3 are shown as 5, 6, and 7. -### Statistics +### Memory Composition -- **Chip memory usage unit:** unit for displaying memory usage in the Statistics window. +- **Chip memory usage unit:** unit for displaying memory usage in the Memory Composition window. - **Bytes** - **Kilobytes** diff --git a/src/gui/memory.cpp b/src/gui/memory.cpp index 91b049277..ca86c9888 100644 --- a/src/gui/memory.cpp +++ b/src/gui/memory.cpp @@ -47,7 +47,11 @@ void FurnaceGUI::drawMemory() { ImGui::Text("%s: %s",e->getSystemName(e->song.system[i]),mc->name.c_str()); ImGui::SameLine(); - ImGui::Text("%d/%d (%.1f%%)",(int)mc->used,(int)mc->capacity,100.0*(double)mc->used/(double)mc->capacity); + if (mc->capacity>=1024 && settings.memUsageUnit==1) { + ImGui::Text("%dK/%dK (%.1f%%)",(int)mc->used>>10,(int)mc->capacity>>10,100.0*(double)mc->used/(double)mc->capacity); + } else { + ImGui::Text("%d/%d (%.1f%%)",(int)mc->used,(int)mc->capacity,100.0*(double)mc->used/(double)mc->capacity); + } ImVec2 size=ImVec2(ImGui::GetContentRegionAvail().x,36.0f*dpiScale); ImVec2 minArea=window->DC.CursorPos; @@ -141,13 +145,20 @@ void FurnaceGUI::drawMemory() { if ((int)entry.type>=(int)DIV_MEMORY_BANK0) { ImGui::Text("bank %d",(int)entry.type-(int)DIV_MEMORY_BANK0); } - ImGui::Text("%d-%d ($%x-$%x): %d bytes ($%x)",(int)entry.begin,(int)entry.end-1,(int)entry.begin,(int)entry.end-1,(int)(entry.end-entry.begin),(int)(entry.end-entry.begin)); - ImGui::Text("click to open sample editor"); + if ((entry.end-entry.begin)>=1024 && settings.memUsageUnit==1) { + ImGui::Text("%d-%d ($%x-$%x): %dK ($%x)",(int)entry.begin,(int)entry.end-1,(int)entry.begin,(int)entry.end-1,(int)(entry.end-entry.begin)>>10,(int)(entry.end-entry.begin)); + } else { + ImGui::Text("%d-%d ($%x-$%x): %d bytes ($%x)",(int)entry.begin,(int)entry.end-1,(int)entry.begin,(int)entry.end-1,(int)(entry.end-entry.begin),(int)(entry.end-entry.begin)); + } break; } default: ImGui::Text("%d: %s",curHover,entry.name.c_str()); - ImGui::Text("%d-%d ($%x-$%x): %d bytes ($%x)",(int)entry.begin,(int)entry.end-1,(int)entry.begin,(int)entry.end-1,(int)(entry.end-entry.begin),(int)(entry.end-entry.begin)); + if ((entry.end-entry.begin)>=1024 && settings.memUsageUnit==1) { + ImGui::Text("%d-%d ($%x-$%x): %dK ($%x)",(int)entry.begin,(int)entry.end-1,(int)entry.begin,(int)entry.end-1,(int)(entry.end-entry.begin)>>10,(int)(entry.end-entry.begin)); + } else { + ImGui::Text("%d-%d ($%x-$%x): %d bytes ($%x)",(int)entry.begin,(int)entry.end-1,(int)entry.begin,(int)entry.end-1,(int)(entry.end-entry.begin),(int)(entry.end-entry.begin)); + } break; } diff --git a/src/gui/settings.cpp b/src/gui/settings.cpp index 7a0cb3670..1b503c217 100644 --- a/src/gui/settings.cpp +++ b/src/gui/settings.cpp @@ -3179,8 +3179,8 @@ void FurnaceGUI::drawSettings() { settingsChanged=true; } - // SUBSECTION STATISTICS - CONFIG_SUBSECTION("Statistics"); + // SUBSECTION MEMORY COMPOSITION + CONFIG_SUBSECTION("Memory Composition"); ImGui::Text("Chip memory usage unit:"); ImGui::Indent(); if (ImGui::RadioButton("Bytes##MUU0",settings.memUsageUnit==0)) {