win32: Add imgui overlay to direct3d.

memmap: Use multiline rom info message.
This commit is contained in:
BearOso 2023-05-07 16:06:34 -05:00
parent 8d8e691c89
commit 82f7658574
4 changed files with 55 additions and 5 deletions

11
gfx.cpp
View File

@ -1792,6 +1792,9 @@ static void VariableDisplayChar(int x, int y, uint8 c, bool monospace = false, i
void S9xVariableDisplayString(const char* string, int linesFromBottom, int pixelsFromLeft, bool allowWrap, int type)
{
if (GFX.ScreenBuffer.empty() || IPPU.RenderedScreenWidth == 0)
return;
bool monospace = true;
if (type == S9X_NO_INFO)
{
@ -1812,6 +1815,14 @@ void S9xVariableDisplayString(const char* string, int linesFromBottom, int pixel
monospace = false;
}
int min_lines = 1;
std::string msg(string);
for (auto& c : msg)
if (c < 32)
min_lines++;
if (min_lines > linesFromBottom)
linesFromBottom = min_lines;
int dst_x = pixelsFromLeft;
int dst_y = IPPU.RenderedScreenHeight - (font_height)*linesFromBottom;
int len = strlen(string);

View File

@ -2444,7 +2444,8 @@ void CMemory::InitROM (void)
: ((Multi.cartType == 4) ? "no checksum"
: "bad checksum"),
MapType(), Size(), KartContents(), Settings.PAL ? "PAL" : "NTSC", StaticRAMSize(), ROMId, ROMCRC32);
S9xMessage(S9X_INFO, S9X_ROM_INFO, String);
S9xMessage(S9X_INFO, S9X_ROM_INFO, GetMultilineROMInfo().c_str());
Settings.ForceLoROM = FALSE;
Settings.ForceHiROM = FALSE;
@ -3389,7 +3390,8 @@ static std::string sjis_to_utf8(std::string in)
out += "\357\276";
c -= 0x40;
}
out += c;
else if (c >= 32)
out += c;
}
return out;
@ -3401,6 +3403,7 @@ std::string CMemory::GetMultilineROMInfo()
(Memory.ROMChecksum == Memory.CalculatedChecksum);
std::string utf8_romname = sjis_to_utf8(Memory.ROMName);
std::string tvstandard = Settings.PAL ? "PAL" : "NTSC";
std::string romid = sjis_to_utf8(Memory.ROMId);
std::string checksum = isChecksumOK ? "Checksum OK"
: Settings.IsPatched == 3 ? "UPS patched"
: Settings.IsPatched == 2 ? "BPS patched"
@ -3410,7 +3413,7 @@ std::string CMemory::GetMultilineROMInfo()
std::stringstream ss;
ss << "\"" << utf8_romname << "\" (" + tvstandard + ") version " << Memory.Revision() << "\n";
ss << Memory.KartContents() << ": " << Memory.MapType() << ": " << Memory.Size() << ", SRAM: " << Memory.StaticRAMSize() << "\n";
ss << "ID: " << Memory.ROMId << ", CRC32: " << std::setfill('0') << std::setw(8) << std::setbase(16) << Memory.ROMCRC32 << ", " << checksum;
ss << "ID: " << romid << ", CRC32: " << std::setfill('0') << std::setw(8) << std::setbase(16) << Memory.ROMCRC32 << ", " << checksum;
return ss.str();
}

View File

@ -18,6 +18,9 @@
#include "../filter/hq2x.h"
#include "../filter/2xsai.h"
#include "imgui_impl_dx9.h"
#include "snes9x_imgui.h"
#ifndef max
#define max(a, b) (((a) > (b)) ? (a) : (b))
#endif
@ -138,6 +141,16 @@ bool CDirect3D::Initialize(HWND hWnd)
init_done = true;
if (!Settings.AutoDisplayMessages)
{
auto defaults = S9xImGuiGetDefaults();
defaults.font_size = GUI.OSDSize;
defaults.spacing = defaults.font_size / 2.4;
S9xImGuiInit(&defaults);
ImGui_ImplDX9_Init(pDevice);
Settings.DisplayIndicators = true;
}
ApplyDisplayChanges();
return true;
@ -146,6 +159,12 @@ bool CDirect3D::Initialize(HWND hWnd)
void CDirect3D::DeInitialize()
{
if (S9xImGuiRunning())
{
ImGui_ImplDX9_Shutdown();
S9xImGuiDeinit();
}
DestroyDrawSurface();
SetShader(NULL);
@ -327,6 +346,13 @@ void CDirect3D::Render(SSurface Src)
pDevice->BeginScene();
pDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP,0,2);
if (S9xImGuiRunning())
{
ImGui_ImplDX9_NewFrame();
if (S9xImGuiDraw(dPresentParams.BackBufferWidth, dPresentParams.BackBufferHeight))
ImGui_ImplDX9_RenderDrawData(ImGui::GetDrawData());
}
pDevice->EndScene();
WinThrottleFramerate();
@ -530,6 +556,11 @@ bool CDirect3D::ResetDevice()
HRESULT hr;
if (S9xImGuiRunning)
{
ImGui_ImplDX9_Shutdown();
}
//release prior to reset
DestroyDrawSurface();
@ -579,6 +610,11 @@ bool CDirect3D::ResetDevice()
SetViewport();
if (S9xImGuiRunning)
{
ImGui_ImplDX9_Init(pDevice);
}
return true;
}

View File

@ -105,9 +105,9 @@ void CVulkan::DeInitialize()
context->wait_idle();
if (ImGui::GetCurrentContext())
{
imgui_descriptor_pool.reset();
ImGui_ImplVulkan_Shutdown();
ImGui::DestroyContext();
imgui_descriptor_pool.reset();
S9xImGuiDeinit();
}
}
shaderchain.reset();