- add save console window position;
This commit is contained in:
mtabachenko 2013-08-26 23:43:32 +00:00
parent 31a9cb55de
commit b464ea0461
5 changed files with 65 additions and 12 deletions

View File

@ -1,5 +1,5 @@
/* /*
Copyright 2008-2011 DeSmuME team Copyright 2008-2013 DeSmuME team
This file is free software: you can redistribute it and/or modify This file is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -25,6 +25,7 @@
///////////////////////////////////////////////////////////////// Console ///////////////////////////////////////////////////////////////// Console
#define BUFFER_SIZE 100 #define BUFFER_SIZE 100
HANDLE hConsole = NULL; HANDLE hConsole = NULL;
HWND gConsoleWnd = NULL;
void printlog(const char *fmt, ...); void printlog(const char *fmt, ...);
std::wstring SkipEverythingButProgramInCommandLine(wchar_t* cmdLine) std::wstring SkipEverythingButProgramInCommandLine(wchar_t* cmdLine)
@ -112,7 +113,6 @@ void OpenConsole()
//newer and improved console title: //newer and improved console title:
SetConsoleTitleW(SkipEverythingButProgramInCommandLine(GetCommandLineW()).c_str()); SetConsoleTitleW(SkipEverythingButProgramInCommandLine(GetCommandLineW()).c_str());
if(shouldRedirectStdout) if(shouldRedirectStdout)
{ {
freopen("CONOUT$", "w", stdout); freopen("CONOUT$", "w", stdout);
@ -120,19 +120,47 @@ void OpenConsole()
freopen("CONIN$", "r", stdin); freopen("CONIN$", "r", stdin);
} }
gConsoleWnd = GetConsoleWindow();
if (gConsoleWnd)
{
RECT rc = {0};
if (GetWindowRect(gConsoleWnd, &rc))
{
rc.left = GetPrivateProfileInt("Console", "PosX", rc.left, IniName);
rc.top = GetPrivateProfileInt("Console", "PosY", rc.top, IniName);
rc.right = GetPrivateProfileInt("Console", "Width", (rc.right - rc.left), IniName);
rc.bottom = GetPrivateProfileInt("Console", "Height", (rc.bottom - rc.top), IniName);
SetWindowPos(gConsoleWnd, NULL, rc.left, rc.top, rc.right, rc.bottom, SWP_NOACTIVATE);
}
}
printlog("%s\n",EMU_DESMUME_NAME_AND_VERSION()); printlog("%s\n",EMU_DESMUME_NAME_AND_VERSION());
printlog("- compiled: %s %s\n",__DATE__,__TIME__); printlog("- compiled: %s %s\n",__DATE__,__TIME__);
if(attached) printf("\nuse cmd /c desmume.exe to get more sensible console behaviour\n"); if(attached) printf("\nuse cmd /c desmume.exe to get more sensible console behaviour\n");
printlog("\n"); printlog("\n");
} }
void CloseConsole() { void CloseConsole()
if (hConsole == NULL) return; {
printlog("Closing..."); RECT pos = {0};
if (GetWindowRect(gConsoleWnd, &pos))
{
WritePrivateProfileInt("Console", "PosX", pos.left, IniName);
WritePrivateProfileInt("Console", "PosY", pos.top, IniName);
WritePrivateProfileInt("Console", "Width", (pos.right - pos.left), IniName);
WritePrivateProfileInt("Console", "Height", (pos.bottom - pos.top), IniName);
}
FreeConsole(); FreeConsole();
hConsole = NULL; hConsole = NULL;
} }
void ConsoleTop(bool top)
{
if (!gConsoleWnd) return;
SetWindowPos(gConsoleWnd, (top?HWND_TOPMOST:HWND_NOTOPMOST), 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
}
void printlog(const char *fmt, ...) void printlog(const char *fmt, ...)
{ {
va_list args; va_list args;

View File

@ -1,5 +1,5 @@
/* /*
Copyright 2008-2009 DeSmuME team Copyright 2008-2013 DeSmuME team
This file is free software: you can redistribute it and/or modify This file is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -32,5 +32,6 @@
void OpenConsole(); void OpenConsole();
void CloseConsole(); void CloseConsole();
void ConsoleAlwaysTop(bool top);
#endif #endif

View File

@ -441,6 +441,8 @@ int romnum = 0;
DWORD threadID; DWORD threadID;
WINCLASS *MainWindow=NULL; WINCLASS *MainWindow=NULL;
bool gShowConsole = false;
bool gConsoleTopmost = false;
//HWND hwnd; //HWND hwnd;
//HDC hdc; //HDC hdc;
@ -2543,8 +2545,9 @@ int MenuInit()
ResetSaveStateTimes(); ResetSaveStateTimes();
HMENU configMenu = GetSubMenuByIdOfFirstChild(mainMenu,IDM_3DCONFIG); HMENU configMenu = GetSubMenuByIdOfFirstChild(mainMenu, IDM_3DCONFIG);
HMENU advancedMenu = GetSubMenuByIdOfFirstChild(configMenu,ID_ADVANCED); HMENU advancedMenu = GetSubMenuByIdOfFirstChild(configMenu, ID_ADVANCED);
HMENU toolsMenu = GetSubMenuByIdOfFirstChild(mainMenu, IDM_DISASSEMBLER);
DeleteMenu(advancedMenu,ID_ADVANCED,MF_BYCOMMAND); DeleteMenu(advancedMenu,ID_ADVANCED,MF_BYCOMMAND);
#ifndef DEVELOPER_MENU_ITEMS #ifndef DEVELOPER_MENU_ITEMS
@ -2575,6 +2578,9 @@ int MenuInit()
DeleteMenu(configMenu,GetSubMenuIndexByHMENU(configMenu,advancedMenu),MF_BYPOSITION); DeleteMenu(configMenu,GetSubMenuIndexByHMENU(configMenu,advancedMenu),MF_BYPOSITION);
#endif #endif
if (!gShowConsole)
DeleteMenu(toolsMenu, IDM_CONSOLE_ALWAYS_ON_TOP, MF_BYCOMMAND);
return 1; return 1;
} }
@ -3532,8 +3538,14 @@ int WINAPI WinMain (HINSTANCE hThisInstance,
static const bool defaultConsoleEnable = false; static const bool defaultConsoleEnable = false;
#endif #endif
if(GetPrivateProfileBool("Display", "Show Console", defaultConsoleEnable, IniName)) gShowConsole = GetPrivateProfileBool("Display", "Show Console", defaultConsoleEnable, IniName);
gConsoleTopmost = GetPrivateProfileBool("Console", "Always On Top", false, IniName);
if (gShowConsole)
{
OpenConsole(); // Init debug console OpenConsole(); // Init debug console
ConsoleAlwaysTop(gConsoleTopmost);
}
//-------------------------------- //--------------------------------
int ret = _main(); int ret = _main();
@ -4580,6 +4592,9 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
DesEnableMenuItem(mainMenu, IDM_SCREENSEP_COLORBLACK, false); DesEnableMenuItem(mainMenu, IDM_SCREENSEP_COLORBLACK, false);
} }
// Tools
MainWindow->checkMenu(IDM_CONSOLE_ALWAYS_ON_TOP, gConsoleTopmost);
UpdateHotkeyAssignments(); //Add current hotkey mappings to menu item names UpdateHotkeyAssignments(); //Add current hotkey mappings to menu item names
CallRegisteredLuaFunctions(LUACALL_ONINITMENU); CallRegisteredLuaFunctions(LUACALL_ONINITMENU);
@ -6064,6 +6079,14 @@ DOKEYDOWN:
} }
return 0; return 0;
case IDM_CONSOLE_ALWAYS_ON_TOP:
{
gConsoleTopmost = !gConsoleTopmost;
ConsoleAlwaysTop(gConsoleTopmost);
WritePrivateProfileBool("Console", "Always On Top", gConsoleTopmost, IniName);
}
return 0;
case IDM_SHOWTOOLBAR: case IDM_SHOWTOOLBAR:
{ {
bool maximized = IsZoomed(hwnd)==TRUE; bool maximized = IsZoomed(hwnd)==TRUE;

View File

@ -710,6 +710,7 @@
#define IDC_SNDCTRL_LEFTOUTTEXT 1468 #define IDC_SNDCTRL_LEFTOUTTEXT 1468
#define IDC_SNDCTRL_RIGHTOUT 1469 #define IDC_SNDCTRL_RIGHTOUT 1469
#define IDC_SNDCTRL_RIGHTOUTTEXT 1470 #define IDC_SNDCTRL_RIGHTOUTTEXT 1470
#define IDM_CONSOLE_ALWAYS_ON_TOP 1500
#define IDC_SOUND0MUTE 2001 #define IDC_SOUND0MUTE 2001
#define IDC_SOUND1MUTE 2002 #define IDC_SOUND1MUTE 2002
#define IDC_SOUND2MUTE 2003 #define IDC_SOUND2MUTE 2003

Binary file not shown.