diff --git a/CasioEmuMsvc/Gui/AddressWindow.cpp b/CasioEmuMsvc/Gui/AddressWindow.cpp index 7116caf..d3294bd 100644 --- a/CasioEmuMsvc/Gui/AddressWindow.cpp +++ b/CasioEmuMsvc/Gui/AddressWindow.cpp @@ -15,7 +15,7 @@ class AddressWindow : public UIWindow { } void RenderCore() override { - ImGui::Text("%s", "AddressWindow.Header"_lc); + ImGui::TextUnformatted("AddressWindow.Header"_lc); ImGui::Separator(); RenderAddressTable(); @@ -65,7 +65,7 @@ class AddressWindow : public UIWindow { } void RenderAddAddressControls() { - ImGui::Text("%s", "AddressWindow.Add"_lc); + ImGui::TextUnformatted("AddressWindow.Add"_lc); ImGui::InputScalar("Address", ImGuiDataType_U32, &newAddress, 0, 0, "%x"); // ImGui::InputScalar("Value", ImGuiDataType_U8, &newValue); diff --git a/CasioEmuMsvc/Gui/CallAnalysis.cpp b/CasioEmuMsvc/Gui/CallAnalysis.cpp index 078c590..dd26986 100644 --- a/CasioEmuMsvc/Gui/CallAnalysis.cpp +++ b/CasioEmuMsvc/Gui/CallAnalysis.cpp @@ -86,7 +86,7 @@ struct CallAnalysis : public UIWindow { for (auto& func : funcs) { ImGui::TableNextRow(); ImGui::TableNextColumn(); - ImGui::Text("%s", lookup_symbol(func.first).c_str()); + ImGui::TextUnformatted(lookup_symbol(func.first).c_str()); ImGui::TableNextColumn(); ImGui::Text("%d", (int)func.second.size()); ImGui::TableNextColumn(); @@ -155,7 +155,7 @@ struct CallAnalysis : public UIWindow { funcs.clear(); } ImGui::Separator(); - ImGui::Text("%s", "CallAnalysis.Filters"_lc); + ImGui::TextUnformatted("CallAnalysis.Filters"_lc); ImGui::Checkbox("CallAnalysis.CalleeFilter"_lc, &check_callee); ImGui::SameLine(); diff --git a/CasioEmuMsvc/Gui/CodeViewer.cpp b/CasioEmuMsvc/Gui/CodeViewer.cpp index b6214e9..f159b16 100644 --- a/CasioEmuMsvc/Gui/CodeViewer.cpp +++ b/CasioEmuMsvc/Gui/CodeViewer.cpp @@ -305,7 +305,7 @@ void CodeViewer::RenderCore() { int w = ImGui::CalcTextSize("F").x; if (!is_loaded) { ImGui::SetCursorPos(ImVec2(w * 2, h * 5)); - ImGui::Text("%s", "CodeViewer.Loading"_lc); + ImGui::TextUnformatted("CodeViewer.Loading"_lc); return; } ImVec2 sz; @@ -338,7 +338,7 @@ void CodeViewer::RenderCore() { ImGui::EndChild(); ImGui::SameLine(); ImGui::Separator(); - ImGui::Text("%s", "CodeViewer.Goto"_lc); + ImGui::TextUnformatted("CodeViewer.Goto"_lc); ImGui::SameLine(); ImGui::SetNextItemWidth(ImGui::CalcTextSize("000000").x); ImGui::InputText("##input", adrbuf, 8); diff --git a/CasioEmuMsvc/Gui/Injector.cpp b/CasioEmuMsvc/Gui/Injector.cpp index 03ed6b9..a518327 100644 --- a/CasioEmuMsvc/Gui/Injector.cpp +++ b/CasioEmuMsvc/Gui/Injector.cpp @@ -181,7 +181,7 @@ void Injector::RenderInjectorTab(InjectorData& inj, int index, bool& show_info, return false; }; - ImGui::Text("%s", "Rop.InjectAddr"_lc); + ImGui::TextUnformatted("Rop.InjectAddr"_lc); ImGui::SameLine(); ImGui::SetNextItemWidth(80); ImGui::InputText(("##addr" + std::to_string(index)).c_str(), inj.addr, 10); @@ -252,7 +252,7 @@ void Injector::RenderCore() { if (ImGui::BeginTabBar("Rop.TabBar"_lc)) { if (ImGui::BeginTabItem("Rop.XAnMode"_lc)) { - ImGui::Text("%s", "Rop.InputSize"_lc); + ImGui::TextUnformatted("Rop.InputSize"_lc); ImGui::SameLine(); ImGui::SetNextItemWidth(80); ImGui::InputText("##off", buf, 9); @@ -336,7 +336,7 @@ void Injector::RenderCore() { } if (ImGui::BeginPopupModal("Rop.InfoPopup"_lc, nullptr, ImGuiWindowFlags_AlwaysAutoResize)) { - ImGui::Text("%s", info_msg.c_str()); + ImGui::TextUnformatted(info_msg.c_str()); if (ImGui::Button("Button.Positive"_lc)) { show_info = false; ImGui::CloseCurrentPopup(); diff --git a/CasioEmuMsvc/Gui/LabelViewer.cpp b/CasioEmuMsvc/Gui/LabelViewer.cpp index 1154be1..cf470df 100644 --- a/CasioEmuMsvc/Gui/LabelViewer.cpp +++ b/CasioEmuMsvc/Gui/LabelViewer.cpp @@ -6,7 +6,7 @@ #include "stringhelper.h" void LabelViewer::RenderCore() { - ImGui::Text("%s", "Label.GeneralHeader"_lc); + ImGui::TextUnformatted("Label.GeneralHeader"_lc); ImGui::Separator(); auto labels = casioemu::GetCommonMemLabels(m_emu->hardware_id); std::sort(labels.begin(), labels.end()); @@ -27,7 +27,7 @@ void LabelViewer::RenderCore() { ImGui::TextUnformatted(desc.c_str()); ImGui::Separator(); } - ImGui::Text("%s", "Label.SfrsHeader"_lc); + ImGui::TextUnformatted("Label.SfrsHeader"_lc); ImGui::Separator(); auto regs = me_mmu->GetRegions(); std::sort(regs.begin(), regs.end(), [](casioemu::MMURegion* a, casioemu::MMURegion* b) { return a->base < b->base; }); diff --git a/CasioEmuMsvc/Gui/MemBreakPoint.cpp b/CasioEmuMsvc/Gui/MemBreakPoint.cpp index 4b7ff8a..e3d7cdc 100644 --- a/CasioEmuMsvc/Gui/MemBreakPoint.cpp +++ b/CasioEmuMsvc/Gui/MemBreakPoint.cpp @@ -30,7 +30,7 @@ void MemBreakPoint::DrawContent() { if (ImGui::BeginPopupContextItem()) { selected = i; - ImGui::Text("%s", "MemBP.BPType"_lc); + ImGui::TextUnformatted("MemBP.BPType"_lc); if (ImGui::Button("HexEditors.ContextMenu.MonitorRead"_lc)) { target_addr = i; data.enableWrite = 0; diff --git a/CasioEmuMsvc/Gui/Theme.cpp b/CasioEmuMsvc/Gui/Theme.cpp index c2a4e6f..637ddd2 100644 --- a/CasioEmuMsvc/Gui/Theme.cpp +++ b/CasioEmuMsvc/Gui/Theme.cpp @@ -9,26 +9,34 @@ struct ThemeSettings { bool isDarkMode = true; char language[30] = ""; float scale = 1.0f; + + void Write(std::ostream& stm) const { + Binary::Write(stm, isDarkMode); + stm.write(language, sizeof(language)); + Binary::Write(stm, scale); + } + + void Read(std::istream& stm) { + Binary::Read(stm, isDarkMode); + stm.read(language, sizeof(language)); + Binary::Read(stm, scale); + } }; static ThemeSettings g_settings; void SaveThemeSettings() { - std::ofstream file("./theme.txt"); + std::ofstream file("./theme.bin", std::ios::binary); if (file.is_open()) { - file << g_settings.isDarkMode << std::endl; - file << g_settings.language << std::endl; - file << g_settings.scale << std::endl; + Binary::Write(file, g_settings); file.close(); } } void LoadThemeSettings() { - std::ifstream file("./theme.txt"); + std::ifstream file("./theme.bin", std::ios::binary); if (file.is_open()) { - file >> g_settings.isDarkMode; - file >> g_settings.language; - file >> g_settings.scale; + Binary::Read(file, g_settings); file.close(); if (g_settings.isDarkMode) { diff --git a/CasioEmuMsvc/Gui/Theme.h b/CasioEmuMsvc/Gui/Theme.h index f8f6293..a54965e 100644 --- a/CasioEmuMsvc/Gui/Theme.h +++ b/CasioEmuMsvc/Gui/Theme.h @@ -1,6 +1,8 @@ #pragma once #include +#include "Binary.h" + UIWindow* MakeThemeWindow(); void SaveThemeSettings(); -void LoadThemeSettings(); +void LoadThemeSettings(); \ No newline at end of file diff --git a/CasioEmuMsvc/Gui/VariableWindow.cpp b/CasioEmuMsvc/Gui/VariableWindow.cpp index 1ef430b..1f1e319 100644 --- a/CasioEmuMsvc/Gui/VariableWindow.cpp +++ b/CasioEmuMsvc/Gui/VariableWindow.cpp @@ -30,14 +30,14 @@ void VariableWindow::RenderCore() { static bool showhex = false; static bool showimg_auto = true; static bool showimg_f = false; - ImGui::Text("%s", "VarWindow.Variable"_lc); + ImGui::TextUnformatted("VarWindow.Variable"_lc); ImGui::SameLine(90); - ImGui::Text("%s", "VarWindow.ReP"_lc); + ImGui::TextUnformatted("VarWindow.ReP"_lc); bool is_in_im = (*(base_addr + casioemu::GetModeOffset(m_emu->hardware_id)) & 0xFF) == 0xC4; bool s_im = showimg_f ? 1 : (showimg_auto ? is_in_im : 0); if (s_im) { ImGui::SameLine(320); - ImGui::Text("%s", "VarWindow.ImP"_lc); + ImGui::TextUnformatted("VarWindow.ImP"_lc); } for (const auto& v : vars) { if (is_in_im && !strcmp(v.Name, "PreAns")) diff --git a/CasioEmuMsvc/Gui/WatchWindow.cpp b/CasioEmuMsvc/Gui/WatchWindow.cpp index fc5adb1..325a956 100644 --- a/CasioEmuMsvc/Gui/WatchWindow.cpp +++ b/CasioEmuMsvc/Gui/WatchWindow.cpp @@ -238,7 +238,7 @@ void WatchWindow::RenderCore() { } ImGui::EndChild(); ImGui::BeginChild("##stack_view"); - ImGui::Text("%s", "WatchWindow.StackMemViewRange"_lc); + ImGui::TextUnformatted("WatchWindow.StackMemViewRange"_lc); ImGui::SameLine(); ImGui::SliderInt("##range", &range, 64, 2048); uint16_t offset = chipset.cpu.reg_sp & 0xffff; diff --git a/CasioEmuMsvc/StartupUi/StartupUi.cpp b/CasioEmuMsvc/StartupUi/StartupUi.cpp index f80c6f3..1248016 100644 --- a/CasioEmuMsvc/StartupUi/StartupUi.cpp +++ b/CasioEmuMsvc/StartupUi/StartupUi.cpp @@ -239,31 +239,31 @@ class ModelEditor : public UIWindow { } ImGui::SetCursorPos({400, y}); if (ImGui::BeginChild("Model Info")) { - ImGui::Text("%s", "ModelEditor.Name"_lc); + ImGui::TextUnformatted("ModelEditor.Name"_lc); if (ImGui::InputText("##name", name, 260)) { mi.model_name = name; } - ImGui::Text("%s", "ModelEditor.InterfacePath"_lc); + ImGui::TextUnformatted("ModelEditor.InterfacePath"_lc); if (ImGui::InputText("##path1", path1, 260)) { mi.interface_path = path1; } - ImGui::Text("%s", "ModelEditor.RomPath"_lc); + ImGui::TextUnformatted("ModelEditor.RomPath"_lc); if (ImGui::InputText("##path2", path2, 260)) { mi.rom_path = path2; } - ImGui::Text("%s", "ModelEditor.FlashDumpPath"_lc); + ImGui::TextUnformatted("ModelEditor.FlashDumpPath"_lc); if (ImGui::InputText("##path3", path3, 260)) { mi.flash_path = path3; } - ImGui::Text("%s", "ModelEditor.CsrMask"_lc); + ImGui::TextUnformatted("ModelEditor.CsrMask"_lc); if (ImGui::SliderInt("##a", &v, 0, 15, "0x%X")) { mi.csr_mask = v; } - ImGui::Text("%s", "ModelEditor.PdValue"_lc); + ImGui::TextUnformatted("ModelEditor.PdValue"_lc); if (ImGui::SliderInt("##q", &k, 0, 15, "0x%X")) { mi.pd_value = k; } - ImGui::Text("%s", "ModelEditor.HardwareType"_lc); + ImGui::TextUnformatted("ModelEditor.HardwareType"_lc); ImGui::SetNextItemWidth(80); if (ImGui::BeginCombo("##cb", items[mi.hardware_id])) { for (int n = 0; n < IM_ARRAYSIZE(items); n++) { @@ -601,7 +601,7 @@ namespace casioemu { #endif if (ImGui::BeginPopupModal("StartupUI.EnterPassword"_lc, NULL, ImGuiWindowFlags_AlwaysAutoResize)) { - ImGui::Text("%s", "StartupUI.PasswordPopupHint"_lc); + ImGui::TextUnformatted("StartupUI.PasswordPopupHint"_lc); #ifdef __ANDROID__ float inputWidth = ImGui::GetContentRegionAvail().x - padding * 2; @@ -665,9 +665,9 @@ namespace casioemu { return; } - ImGui::Text("%s", "StartupUI.ChooseModelHint"_lc); + ImGui::TextUnformatted("StartupUI.ChooseModelHint"_lc); ImGui::Separator(); - ImGui::Text("%s", "StartupUI.RecentlyUsed"_lc); + ImGui::TextUnformatted("StartupUI.RecentlyUsed"_lc); if (ImGui::BeginTable("Recently", 4, pretty_table | ImGuiTableFlags_ScrollY, ImVec2(0, tableHeight))) { RenderHeaders();