mirror of https://github.com/snes9xgit/snes9x.git
win32: Add imgui overlay to direct3d.
memmap: Use multiline rom info message.
This commit is contained in:
parent
8d8e691c89
commit
82f7658574
11
gfx.cpp
11
gfx.cpp
|
@ -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)
|
void S9xVariableDisplayString(const char* string, int linesFromBottom, int pixelsFromLeft, bool allowWrap, int type)
|
||||||
{
|
{
|
||||||
|
if (GFX.ScreenBuffer.empty() || IPPU.RenderedScreenWidth == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
bool monospace = true;
|
bool monospace = true;
|
||||||
if (type == S9X_NO_INFO)
|
if (type == S9X_NO_INFO)
|
||||||
{
|
{
|
||||||
|
@ -1812,6 +1815,14 @@ void S9xVariableDisplayString(const char* string, int linesFromBottom, int pixel
|
||||||
monospace = false;
|
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_x = pixelsFromLeft;
|
||||||
int dst_y = IPPU.RenderedScreenHeight - (font_height)*linesFromBottom;
|
int dst_y = IPPU.RenderedScreenHeight - (font_height)*linesFromBottom;
|
||||||
int len = strlen(string);
|
int len = strlen(string);
|
||||||
|
|
|
@ -2444,7 +2444,8 @@ void CMemory::InitROM (void)
|
||||||
: ((Multi.cartType == 4) ? "no checksum"
|
: ((Multi.cartType == 4) ? "no checksum"
|
||||||
: "bad checksum"),
|
: "bad checksum"),
|
||||||
MapType(), Size(), KartContents(), Settings.PAL ? "PAL" : "NTSC", StaticRAMSize(), ROMId, ROMCRC32);
|
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.ForceLoROM = FALSE;
|
||||||
Settings.ForceHiROM = FALSE;
|
Settings.ForceHiROM = FALSE;
|
||||||
|
@ -3389,7 +3390,8 @@ static std::string sjis_to_utf8(std::string in)
|
||||||
out += "\357\276";
|
out += "\357\276";
|
||||||
c -= 0x40;
|
c -= 0x40;
|
||||||
}
|
}
|
||||||
out += c;
|
else if (c >= 32)
|
||||||
|
out += c;
|
||||||
}
|
}
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
|
@ -3401,6 +3403,7 @@ std::string CMemory::GetMultilineROMInfo()
|
||||||
(Memory.ROMChecksum == Memory.CalculatedChecksum);
|
(Memory.ROMChecksum == Memory.CalculatedChecksum);
|
||||||
std::string utf8_romname = sjis_to_utf8(Memory.ROMName);
|
std::string utf8_romname = sjis_to_utf8(Memory.ROMName);
|
||||||
std::string tvstandard = Settings.PAL ? "PAL" : "NTSC";
|
std::string tvstandard = Settings.PAL ? "PAL" : "NTSC";
|
||||||
|
std::string romid = sjis_to_utf8(Memory.ROMId);
|
||||||
std::string checksum = isChecksumOK ? "Checksum OK"
|
std::string checksum = isChecksumOK ? "Checksum OK"
|
||||||
: Settings.IsPatched == 3 ? "UPS patched"
|
: Settings.IsPatched == 3 ? "UPS patched"
|
||||||
: Settings.IsPatched == 2 ? "BPS patched"
|
: Settings.IsPatched == 2 ? "BPS patched"
|
||||||
|
@ -3410,7 +3413,7 @@ std::string CMemory::GetMultilineROMInfo()
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss << "\"" << utf8_romname << "\" (" + tvstandard + ") version " << Memory.Revision() << "\n";
|
ss << "\"" << utf8_romname << "\" (" + tvstandard + ") version " << Memory.Revision() << "\n";
|
||||||
ss << Memory.KartContents() << ": " << Memory.MapType() << ": " << Memory.Size() << ", SRAM: " << Memory.StaticRAMSize() << "\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();
|
return ss.str();
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,9 @@
|
||||||
#include "../filter/hq2x.h"
|
#include "../filter/hq2x.h"
|
||||||
#include "../filter/2xsai.h"
|
#include "../filter/2xsai.h"
|
||||||
|
|
||||||
|
#include "imgui_impl_dx9.h"
|
||||||
|
#include "snes9x_imgui.h"
|
||||||
|
|
||||||
#ifndef max
|
#ifndef max
|
||||||
#define max(a, b) (((a) > (b)) ? (a) : (b))
|
#define max(a, b) (((a) > (b)) ? (a) : (b))
|
||||||
#endif
|
#endif
|
||||||
|
@ -138,6 +141,16 @@ bool CDirect3D::Initialize(HWND hWnd)
|
||||||
|
|
||||||
init_done = true;
|
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();
|
ApplyDisplayChanges();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -146,6 +159,12 @@ bool CDirect3D::Initialize(HWND hWnd)
|
||||||
|
|
||||||
void CDirect3D::DeInitialize()
|
void CDirect3D::DeInitialize()
|
||||||
{
|
{
|
||||||
|
if (S9xImGuiRunning())
|
||||||
|
{
|
||||||
|
ImGui_ImplDX9_Shutdown();
|
||||||
|
S9xImGuiDeinit();
|
||||||
|
}
|
||||||
|
|
||||||
DestroyDrawSurface();
|
DestroyDrawSurface();
|
||||||
SetShader(NULL);
|
SetShader(NULL);
|
||||||
|
|
||||||
|
@ -327,6 +346,13 @@ void CDirect3D::Render(SSurface Src)
|
||||||
|
|
||||||
pDevice->BeginScene();
|
pDevice->BeginScene();
|
||||||
pDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP,0,2);
|
pDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP,0,2);
|
||||||
|
if (S9xImGuiRunning())
|
||||||
|
{
|
||||||
|
ImGui_ImplDX9_NewFrame();
|
||||||
|
if (S9xImGuiDraw(dPresentParams.BackBufferWidth, dPresentParams.BackBufferHeight))
|
||||||
|
ImGui_ImplDX9_RenderDrawData(ImGui::GetDrawData());
|
||||||
|
}
|
||||||
|
|
||||||
pDevice->EndScene();
|
pDevice->EndScene();
|
||||||
|
|
||||||
WinThrottleFramerate();
|
WinThrottleFramerate();
|
||||||
|
@ -530,6 +556,11 @@ bool CDirect3D::ResetDevice()
|
||||||
|
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
|
||||||
|
if (S9xImGuiRunning)
|
||||||
|
{
|
||||||
|
ImGui_ImplDX9_Shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
//release prior to reset
|
//release prior to reset
|
||||||
DestroyDrawSurface();
|
DestroyDrawSurface();
|
||||||
|
|
||||||
|
@ -579,6 +610,11 @@ bool CDirect3D::ResetDevice()
|
||||||
|
|
||||||
SetViewport();
|
SetViewport();
|
||||||
|
|
||||||
|
if (S9xImGuiRunning)
|
||||||
|
{
|
||||||
|
ImGui_ImplDX9_Init(pDevice);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -105,9 +105,9 @@ void CVulkan::DeInitialize()
|
||||||
context->wait_idle();
|
context->wait_idle();
|
||||||
if (ImGui::GetCurrentContext())
|
if (ImGui::GetCurrentContext())
|
||||||
{
|
{
|
||||||
imgui_descriptor_pool.reset();
|
|
||||||
ImGui_ImplVulkan_Shutdown();
|
ImGui_ImplVulkan_Shutdown();
|
||||||
ImGui::DestroyContext();
|
imgui_descriptor_pool.reset();
|
||||||
|
S9xImGuiDeinit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
shaderchain.reset();
|
shaderchain.reset();
|
||||||
|
|
Loading…
Reference in New Issue