Fies Issue 1584

OSD and Hotkey to do quick config toggling

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4984 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
ayuanx
2010-01-29 07:44:21 +00:00
parent fefcc6f5b5
commit 8b129fca0c
15 changed files with 214 additions and 40 deletions

View File

@ -84,15 +84,16 @@ void CopyEFB(const BPCmd &bp, const EFBRectangle &rc, const u32 &address, const
if (!g_ActiveConfig.bEFBCopyDisable)
{
//uncomment this to see the efb to ram work in progress
if (g_ActiveConfig.bCopyEFBToRAM)
if (g_ActiveConfig.bCopyEFBToTexture)
{
// To D3D Texture
TextureCache::CopyRenderTargetToTexture(address, fromZBuffer, isIntensityFmt, copyfmt, scaleByHalf, rc);
}
else
{
//ToRam
TextureConverter::EncodeToRam(address, fromZBuffer, isIntensityFmt, copyfmt, scaleByHalf, rc);
}
else // To D3D Texture
{
TextureCache::CopyRenderTargetToTexture(address, fromZBuffer, isIntensityFmt, copyfmt, scaleByHalf, rc);
}
}
}

View File

@ -152,6 +152,7 @@ struct TabAdvanced : public W32Util::Tab
//ComboBox_AddString(opt,"Recompile to vbuffers and shaders");
// ComboBox_SetCurSel(opt,g_Config.iCompileDLsLevel);
Button_SetCheck(GetDlgItem(hDlg,IDC_OSDHOTKEY), g_Config.bOSDHotKey);
Button_SetCheck(GetDlgItem(hDlg,IDC_OVERLAYFPS), g_Config.bShowFPS);
Button_SetCheck(GetDlgItem(hDlg,IDC_OVERLAYSTATS), g_Config.bOverlayStats);
Button_SetCheck(GetDlgItem(hDlg,IDC_OVERLAYPROJSTATS), g_Config.bOverlayProjStats);
@ -162,10 +163,10 @@ struct TabAdvanced : public W32Util::Tab
Button_SetCheck(GetDlgItem(hDlg,IDC_DISABLEFOG), g_Config.bDisableFog);
Button_SetCheck(GetDlgItem(hDlg,IDC_ENABLEEFBCOPY), !g_Config.bEFBCopyDisable);
if(g_Config.bCopyEFBToRAM)
Button_SetCheck(GetDlgItem(hDlg,IDC_EFBTORAM), TRUE);
if(g_Config.bCopyEFBToTexture)
Button_SetCheck(GetDlgItem(hDlg,IDC_EFBTOTEX), true);
else
Button_SetCheck(GetDlgItem(hDlg,IDC_EFBTOTEX), TRUE);
Button_SetCheck(GetDlgItem(hDlg,IDC_EFBTORAM), true);
Button_SetCheck(GetDlgItem(hDlg,IDC_TEXFMT_OVERLAY), g_Config.bTexFmtOverlayEnable);
@ -198,6 +199,7 @@ struct TabAdvanced : public W32Util::Tab
g_Config.bTexFmtOverlayEnable = Button_GetCheck(GetDlgItem(hDlg,IDC_TEXFMT_OVERLAY)) ? true : false;
g_Config.bTexFmtOverlayCenter = Button_GetCheck(GetDlgItem(hDlg,IDC_TEXFMT_CENTER)) ? true : false;
g_Config.bOSDHotKey = Button_GetCheck(GetDlgItem(hDlg,IDC_OSDHOTKEY)) ? true : false;
g_Config.bShowFPS = Button_GetCheck(GetDlgItem(hDlg,IDC_OVERLAYFPS)) ? true : false;
g_Config.bOverlayStats = Button_GetCheck(GetDlgItem(hDlg,IDC_OVERLAYSTATS)) ? true : false;
g_Config.bOverlayProjStats = Button_GetCheck(GetDlgItem(hDlg,IDC_OVERLAYPROJSTATS)) ? true : false;
@ -207,7 +209,7 @@ struct TabAdvanced : public W32Util::Tab
g_Config.bShowShaderErrors = Button_GetCheck(GetDlgItem(hDlg,IDC_SHOWSHADERERRORS)) ? true : false;
g_Config.bDisableFog = Button_GetCheck(GetDlgItem(hDlg,IDC_DISABLEFOG)) ? true : false;
g_Config.bEFBCopyDisable = Button_GetCheck(GetDlgItem(hDlg,IDC_ENABLEEFBCOPY)) ? false : true;
g_Config.bCopyEFBToRAM = Button_GetCheck(GetDlgItem(hDlg,IDC_EFBTORAM)) ? true : false;
g_Config.bCopyEFBToTexture = Button_GetCheck(GetDlgItem(hDlg,IDC_EFBTORAM)) ? false : true;
g_Config.Save(FULL_CONFIG_DIR "gfx_dx9.ini");

View File

@ -23,6 +23,9 @@
#include "D3DBase.h"
#include "Fifo.h"
int OSDChoice = 0 , OSDTime = 0, OSDInternalW = 0, OSDInternalH = 0;
namespace EmuWindow
{
HWND m_hWnd = NULL;
@ -104,6 +107,14 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam )
return 0;
}
break;
case '3': // OSD keys
case '4':
case '5':
case '6':
case '7':
if (g_Config.bOSDHotKey)
OSDMenu(wParam);
break;
}
// Tell the hotkey function that this key was pressed
g_VideoInitialize.pKeyPress(LOWORD(wParam), GetAsyncKeyState(VK_SHIFT) != 0, GetAsyncKeyState(VK_CONTROL) != 0);
@ -171,6 +182,57 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam )
return DefWindowProc(hWnd, iMsg, wParam, lParam);
}
// ---------------------------------------------------------------------
// OSD Menu
// -------------
// Let's begin with 3 since 1 and 2 are default Wii keys
// -------------
void OSDMenu(WPARAM wParam)
{
switch( LOWORD( wParam ))
{
case '3':
OSDChoice = 1;
// Toggle native resolution
/*
if (!(g_Config.bNativeResolution || g_Config.b2xResolution))
g_Config.bNativeResolution = true;
else if (g_Config.bNativeResolution && Renderer::AllowCustom())
{ g_Config.bNativeResolution = false; if (Renderer::Allow2x()) {g_Config.b2xResolution = true;} }
else if (Renderer::AllowCustom())
g_Config.b2xResolution = false;
*/
OSDInternalW = D3D::GetBackBufferWidth();
OSDInternalH = D3D::GetBackBufferHeight();
break;
case '4':
OSDChoice = 2;
// Toggle aspect ratio
g_Config.iAspectRatio = (g_Config.iAspectRatio + 1) & 3;
break;
case '5':
OSDChoice = 3;
// Toggle EFB copy
if (g_Config.bEFBCopyDisable || g_Config.bCopyEFBToTexture)
{
g_Config.bEFBCopyDisable = !g_Config.bEFBCopyDisable;
g_Config.bCopyEFBToTexture = false;
}
else
{
g_Config.bCopyEFBToTexture = !g_Config.bCopyEFBToTexture;
}
break;
case '6':
OSDChoice = 4;
g_Config.bDisableFog = !g_Config.bDisableFog;
break;
case '7':
OSDChoice = 5;
g_Config.bDisableLighting = !g_Config.bDisableLighting;
break;
}
}
HWND OpenWindow(HWND parent, HINSTANCE hInstance, int width, int height, const TCHAR *title)
{

View File

@ -14,6 +14,7 @@ void Close();
void SetSize(int displayWidth, int displayHeight);
void ToggleFullscreen(HWND hParent, bool bForceFull = false);
bool IsSizing();
void OSDMenu(WPARAM wParam);
}

View File

@ -19,6 +19,7 @@
#include <d3dx9.h>
#include <strsafe.h>
#include "StringUtil.h"
#include "Common.h"
#include "Thread.h"
#include "Timer.h"
@ -363,6 +364,88 @@ int Renderer::GetFullTargetHeight() { return s_Fulltarget_height; }
float Renderer::GetTargetScaleX() { return xScale; }
float Renderer::GetTargetScaleY() { return yScale; }
// Create On-Screen-Messages
void Renderer::DrawDebugText()
{
// OSD Menu messages
if (g_ActiveConfig.bOSDHotKey)
{
if (OSDChoice > 0)
{
OSDTime = Common::Timer::GetTimeMs() + 3000;
OSDChoice = -OSDChoice;
}
if ((u32)OSDTime > Common::Timer::GetTimeMs())
{
std::string T1 = "", T2 = "";
std::vector<std::string> T0;
/*
int W, H;
sscanf(g_ActiveConfig.cInternalRes, "%dx%d", &W, &H);
std::string OSDM1 =
g_ActiveConfig.bNativeResolution || g_ActiveConfig.b2xResolution ?
(g_ActiveConfig.bNativeResolution ?
StringFromFormat("%i x %i (native)", OSDInternalW, OSDInternalH)
: StringFromFormat("%i x %i (2x)", OSDInternalW, OSDInternalH))
: StringFromFormat("%i x %i (custom)", W, H);
*/
std::string OSDM1 = StringFromFormat("%i x %i", OSDInternalW, OSDInternalH);
std::string OSDM21;
switch(g_ActiveConfig.iAspectRatio)
{
case ASPECT_AUTO:
OSDM21 = "Auto";
break;
case ASPECT_FORCE_16_9:
OSDM21 = "16:9";
break;
case ASPECT_FORCE_4_3:
OSDM21 = "4:3";
break;
case ASPECT_STRETCH:
OSDM21 = "Stretch";
break;
}
std::string OSDM22 =
g_ActiveConfig.bCrop ? " (crop)" : "";
std::string OSDM3 = g_ActiveConfig.bEFBCopyDisable ? "Disabled" :
g_ActiveConfig.bCopyEFBToTexture ? "To Texture" : "To RAM";
// If there is more text than this we will have a collission
if (g_ActiveConfig.bShowFPS)
{ T1 += "\n\n"; T2 += "\n\n"; }
// The rows
T0.push_back(StringFromFormat("3: Internal Resolution: %s\n", OSDM1.c_str()));
T0.push_back(StringFromFormat("4: Aspect Ratio: %s%s\n", OSDM21.c_str(), OSDM22.c_str()));
T0.push_back(StringFromFormat("5: Copy EFB: %s\n", OSDM3.c_str()));
T0.push_back(StringFromFormat("6: Fog: %s\n", g_ActiveConfig.bDisableFog ? "Disabled" : "Enabled"));
T0.push_back(StringFromFormat("7: Material Lighting: %s\n", g_ActiveConfig.bDisableLighting ? "Disabled" : "Enabled"));
// The latest changed setting in yellow
T1 += (OSDChoice == -1) ? T0.at(0) : "\n";
T1 += (OSDChoice == -2) ? T0.at(1) : "\n";
T1 += (OSDChoice == -3) ? T0.at(2) : "\n";
T1 += (OSDChoice == -4) ? T0.at(3) : "\n";
T1 += (OSDChoice == -5) ? T0.at(4) : "\n";
// The other settings in cyan
T2 += (OSDChoice != -1) ? T0.at(0) : "\n";
T2 += (OSDChoice != -2) ? T0.at(1) : "\n";
T2 += (OSDChoice != -3) ? T0.at(2) : "\n";
T2 += (OSDChoice != -4) ? T0.at(3) : "\n";
T2 += (OSDChoice != -5) ? T0.at(4) : "\n";
// Render a shadow, and then the text
Renderer::RenderText(T1.c_str(), 21, 21, 0xDD000000);
Renderer::RenderText(T1.c_str(), 20, 20, 0xFFffff00);
Renderer::RenderText(T2.c_str(), 21, 21, 0xDD000000);
Renderer::RenderText(T2.c_str(), 20, 20, 0xFF00FFFF);
}
}
}
void Renderer::RenderText(const char *text, int left, int top, u32 color)
{
D3D::font.DrawTextScaled((float)left, (float)top, 20, 20, 0.0f, color, text, false);
@ -569,6 +652,8 @@ static void EFBTextureToD3DBackBuffer(const EFBRectangle& sourceRc)
StringCchPrintfA(fps, 20, "FPS: %d\n", s_fps);
D3D::font.DrawTextScaled(0,30,20,20,0.0f,0xFF00FFFF,fps,false);
}
Renderer::DrawDebugText();
if (g_ActiveConfig.bOverlayStats)
{
Statistics::ToString(st);

View File

@ -35,6 +35,7 @@
#define IDC_FORCEANISOTROPY 1027
#define IDC_LOADHIRESTEXTURE 1028
#define IDC_EFBSCALEDCOPY 1029
#define IDC_OSDHOTKEY 1030
#define IDC_COMBO2 1040
#define IDC_ASPECTRATIO 1040
#define IDC_CHECK1 1100

View File

@ -68,8 +68,9 @@ BEGIN
CONTROL "&Overlay some statistics",IDC_OVERLAYSTATS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,137,90,8
CONTROL "Show s&hader compilation errors",IDC_SHOWSHADERERRORS,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,151,114,8
CONTROL "Enable &Wireframe",IDC_WIREFRAME,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,18,78,8
CONTROL "Disable Fog",IDC_DISABLEFOG,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,114,33,87,8
CONTROL "Enable &Wireframe",IDC_WIREFRAME,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,114,48,87,8
CONTROL "Disable Fog",IDC_DISABLEFOG,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,18,78,8
CONTROL "Enable Hotkey",IDC_OSDHOTKEY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,114,33,87,8
CONTROL "Enable EFB copy",IDC_ENABLEEFBCOPY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,33,81,8
CONTROL "To RAM",IDC_EFBTORAM,"Button",BS_AUTORADIOBUTTON | WS_GROUP,29,44,59,10
CONTROL "To Texture",IDC_EFBTOTEX,"Button",BS_AUTORADIOBUTTON,29,57,60,10