Remove the embedded Console from the possible logging options.

Note I do not mean the Logging window, but the console window.
It's literally rarely, if at all used, and offers less advantages over the built-in logging window (ie. it breaks on different locales: http://i.imgur.com/Cs92tQE.png)

This commit should remove all of the console logging.
This commit is contained in:
Lioncash 2014-02-16 00:52:20 -05:00
parent b18a33377d
commit ca7bdf1d5d
22 changed files with 16 additions and 830 deletions

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations"> <ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32"> <ProjectConfiguration Include="Debug|Win32">
@ -54,7 +54,6 @@
<ClInclude Include="CommonFuncs.h" /> <ClInclude Include="CommonFuncs.h" />
<ClInclude Include="CommonPaths.h" /> <ClInclude Include="CommonPaths.h" />
<ClInclude Include="CommonTypes.h" /> <ClInclude Include="CommonTypes.h" />
<ClInclude Include="ConsoleListener.h" />
<ClInclude Include="CPUDetect.h" /> <ClInclude Include="CPUDetect.h" />
<ClInclude Include="Crypto\tools.h" /> <ClInclude Include="Crypto\tools.h" />
<ClInclude Include="DebugInterface.h" /> <ClInclude Include="DebugInterface.h" />
@ -93,7 +92,6 @@
<ClCompile Include="BreakPoints.cpp" /> <ClCompile Include="BreakPoints.cpp" />
<ClCompile Include="CDUtils.cpp" /> <ClCompile Include="CDUtils.cpp" />
<ClCompile Include="ColorUtil.cpp" /> <ClCompile Include="ColorUtil.cpp" />
<ClCompile Include="ConsoleListener.cpp" />
<ClCompile Include="Crypto\bn.cpp" /> <ClCompile Include="Crypto\bn.cpp" />
<ClCompile Include="Crypto\ec.cpp" /> <ClCompile Include="Crypto\ec.cpp" />
<ClCompile Include="ExtendedTrace.cpp" /> <ClCompile Include="ExtendedTrace.cpp" />

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup> <ItemGroup>
<Filter Include="Crypto"> <Filter Include="Crypto">
@ -52,9 +52,6 @@
<ClInclude Include="Crypto\tools.h"> <ClInclude Include="Crypto\tools.h">
<Filter>Crypto</Filter> <Filter>Crypto</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="ConsoleListener.h">
<Filter>Logging</Filter>
</ClInclude>
<ClInclude Include="Log.h"> <ClInclude Include="Log.h">
<Filter>Logging</Filter> <Filter>Logging</Filter>
</ClInclude> </ClInclude>
@ -97,9 +94,6 @@
<ClCompile Include="Crypto\ec.cpp"> <ClCompile Include="Crypto\ec.cpp">
<Filter>Crypto</Filter> <Filter>Crypto</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="ConsoleListener.cpp">
<Filter>Logging</Filter>
</ClCompile>
<ClCompile Include="LogManager.cpp"> <ClCompile Include="LogManager.cpp">
<Filter>Logging</Filter> <Filter>Logging</Filter>
</ClCompile> </ClCompile>

View File

@ -1,334 +0,0 @@
// Copyright 2013 Dolphin Emulator Project
// Licensed under GPLv2
// Refer to the license.txt file included.
#include <algorithm> // min
#include <cstdlib>
#include <string> // System: To be able to add strings with "+"
#include <stdio.h>
#include <math.h>
#ifdef _WIN32
#include <windows.h>
#include <array>
#endif
#include "ConsoleListener.h" // Common
ConsoleListener::ConsoleListener()
{
#ifdef _WIN32
hConsole = NULL;
bUseColor = true;
#else
bUseColor = isatty(fileno(stdout));
#endif
}
ConsoleListener::~ConsoleListener()
{
Close();
}
// 100, 100, "Dolphin Log Console"
// Open console window - width and height is the size of console window
// Name is the window title
void ConsoleListener::Open(bool Hidden, int Width, int Height, const char *Title)
{
#ifdef _WIN32
if (!GetConsoleWindow())
{
// Open the console window and create the window handle for GetStdHandle()
AllocConsole();
// Hide
if (Hidden) ShowWindow(GetConsoleWindow(), SW_HIDE);
// Save the window handle that AllocConsole() created
hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
// Set the console window title
SetConsoleTitle(UTF8ToTStr(Title).c_str());
// Set letter space
LetterSpace(80, 4000);
//MoveWindow(GetConsoleWindow(), 200,200, 800,800, true);
}
else
{
hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
}
#endif
}
void ConsoleListener::UpdateHandle()
{
#ifdef _WIN32
hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
#endif
}
// Close the console window and close the eventual file handle
void ConsoleListener::Close()
{
#ifdef _WIN32
if (hConsole == NULL)
return;
FreeConsole();
hConsole = NULL;
#else
fflush(NULL);
#endif
}
bool ConsoleListener::IsOpen()
{
#ifdef _WIN32
return (hConsole != NULL);
#else
return true;
#endif
}
/*
LetterSpace: SetConsoleScreenBufferSize and SetConsoleWindowInfo are
dependent on each other, that's the reason for the additional checks.
*/
void ConsoleListener::BufferWidthHeight(int BufferWidth, int BufferHeight, int ScreenWidth, int ScreenHeight, bool BufferFirst)
{
#ifdef _WIN32
BOOL SB, SW;
if (BufferFirst)
{
// Change screen buffer size
COORD Co = {BufferWidth, BufferHeight};
SB = SetConsoleScreenBufferSize(hConsole, Co);
// Change the screen buffer window size
SMALL_RECT coo = {0,0,ScreenWidth, ScreenHeight}; // top, left, right, bottom
SW = SetConsoleWindowInfo(hConsole, TRUE, &coo);
}
else
{
// Change the screen buffer window size
SMALL_RECT coo = {0,0, ScreenWidth, ScreenHeight}; // top, left, right, bottom
SW = SetConsoleWindowInfo(hConsole, TRUE, &coo);
// Change screen buffer size
COORD Co = {BufferWidth, BufferHeight};
SB = SetConsoleScreenBufferSize(hConsole, Co);
}
#endif
}
void ConsoleListener::LetterSpace(int Width, int Height)
{
#ifdef _WIN32
// Get console info
CONSOLE_SCREEN_BUFFER_INFO ConInfo;
GetConsoleScreenBufferInfo(hConsole, &ConInfo);
//
int OldBufferWidth = ConInfo.dwSize.X;
int OldBufferHeight = ConInfo.dwSize.Y;
int OldScreenWidth = (ConInfo.srWindow.Right - ConInfo.srWindow.Left);
int OldScreenHeight = (ConInfo.srWindow.Bottom - ConInfo.srWindow.Top);
//
int NewBufferWidth = Width;
int NewBufferHeight = Height;
int NewScreenWidth = NewBufferWidth - 1;
int NewScreenHeight = OldScreenHeight;
// Width
BufferWidthHeight(NewBufferWidth, OldBufferHeight, NewScreenWidth, OldScreenHeight, (NewBufferWidth > OldScreenWidth-1));
// Height
BufferWidthHeight(NewBufferWidth, NewBufferHeight, NewScreenWidth, NewScreenHeight, (NewBufferHeight > OldScreenHeight-1));
// Resize the window too
//MoveWindow(GetConsoleWindow(), 200,200, (Width*8 + 50),(NewScreenHeight*12 + 200), true);
#endif
}
#ifdef _WIN32
COORD ConsoleListener::GetCoordinates(int BytesRead, int BufferWidth)
{
COORD Ret = {0, 0};
// Full rows
int Step = (int)floor((float)BytesRead / (float)BufferWidth);
Ret.Y += Step;
// Partial row
Ret.X = BytesRead - (BufferWidth * Step);
return Ret;
}
#endif
void ConsoleListener::PixelSpace(int Left, int Top, int Width, int Height, bool Resize)
{
#ifdef _WIN32
// Check size
if (Width < 8 || Height < 12) return;
bool DBef = true;
bool DAft = true;
std::string SLog = "";
const HWND hWnd = GetConsoleWindow();
const HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
// Get console info
CONSOLE_SCREEN_BUFFER_INFO ConInfo;
GetConsoleScreenBufferInfo(hConsole, &ConInfo);
DWORD BufferSize = ConInfo.dwSize.X * ConInfo.dwSize.Y;
// ---------------------------------------------------------------------
// Save the current text
// ------------------------
DWORD cCharsRead = 0;
COORD coordScreen = { 0, 0 };
static const int MAX_BYTES = 1024 * 16;
std::vector<std::array<TCHAR, MAX_BYTES>> Str;
std::vector<std::array<WORD, MAX_BYTES>> Attr;
// ReadConsoleOutputAttribute seems to have a limit at this level
static const int ReadBufferSize = MAX_BYTES - 32;
DWORD cAttrRead = ReadBufferSize;
DWORD BytesRead = 0;
while (BytesRead < BufferSize)
{
Str.resize(Str.size() + 1);
if (!ReadConsoleOutputCharacter(hConsole, Str.back().data(), ReadBufferSize, coordScreen, &cCharsRead))
SLog += StringFromFormat("WriteConsoleOutputCharacter error");
Attr.resize(Attr.size() + 1);
if (!ReadConsoleOutputAttribute(hConsole, Attr.back().data(), ReadBufferSize, coordScreen, &cAttrRead))
SLog += StringFromFormat("WriteConsoleOutputAttribute error");
// Break on error
if (cAttrRead == 0) break;
BytesRead += cAttrRead;
coordScreen = GetCoordinates(BytesRead, ConInfo.dwSize.X);
}
// Letter space
int LWidth = (int)(floor((float)Width / 8.0f) - 1.0f);
int LHeight = (int)(floor((float)Height / 12.0f) - 1.0f);
int LBufWidth = LWidth + 1;
int LBufHeight = (int)floor((float)BufferSize / (float)LBufWidth);
// Change screen buffer size
LetterSpace(LBufWidth, LBufHeight);
ClearScreen(true);
coordScreen.Y = 0;
coordScreen.X = 0;
DWORD cCharsWritten = 0;
int BytesWritten = 0;
DWORD cAttrWritten = 0;
for (size_t i = 0; i < Attr.size(); i++)
{
if (!WriteConsoleOutputCharacter(hConsole, Str[i].data(), ReadBufferSize, coordScreen, &cCharsWritten))
SLog += StringFromFormat("WriteConsoleOutputCharacter error");
if (!WriteConsoleOutputAttribute(hConsole, Attr[i].data(), ReadBufferSize, coordScreen, &cAttrWritten))
SLog += StringFromFormat("WriteConsoleOutputAttribute error");
BytesWritten += cAttrWritten;
coordScreen = GetCoordinates(BytesWritten, LBufWidth);
}
const int OldCursor = ConInfo.dwCursorPosition.Y * ConInfo.dwSize.X + ConInfo.dwCursorPosition.X;
COORD Coo = GetCoordinates(OldCursor, LBufWidth);
SetConsoleCursorPosition(hConsole, Coo);
if (SLog.length() > 0) Log(LogTypes::LNOTICE, SLog.c_str());
// Resize the window too
if (Resize) MoveWindow(GetConsoleWindow(), Left,Top, (Width + 100),Height, true);
#endif
}
void ConsoleListener::Log(LogTypes::LOG_LEVELS Level, const char *Text)
{
#if defined(_WIN32)
/*
const int MAX_BYTES = 1024*10;
char Str[MAX_BYTES];
va_list ArgPtr;
int Cnt;
va_start(ArgPtr, Text);
Cnt = vsnprintf(Str, MAX_BYTES, Text, ArgPtr);
va_end(ArgPtr);
*/
DWORD cCharsWritten;
WORD Color;
switch (Level)
{
case NOTICE_LEVEL: // light green
Color = FOREGROUND_GREEN | FOREGROUND_INTENSITY;
break;
case ERROR_LEVEL: // light red
Color = FOREGROUND_RED | FOREGROUND_INTENSITY;
break;
case WARNING_LEVEL: // light yellow
Color = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_INTENSITY;
break;
case INFO_LEVEL: // cyan
Color = FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY;
break;
case DEBUG_LEVEL: // gray
Color = FOREGROUND_INTENSITY;
break;
default: // off-white
Color = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE;
break;
}
if (strlen(Text) > 10)
{
// First 10 chars white
SetConsoleTextAttribute(hConsole, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY);
WriteConsole(hConsole, Text, 10, &cCharsWritten, NULL);
Text += 10;
}
SetConsoleTextAttribute(hConsole, Color);
WriteConsole(hConsole, Text, (DWORD)strlen(Text), &cCharsWritten, NULL);
#else
char ColorAttr[16] = "";
char ResetAttr[16] = "";
if (bUseColor)
{
strcpy(ResetAttr, "\033[0m");
switch (Level)
{
case NOTICE_LEVEL: // light green
strcpy(ColorAttr, "\033[92m");
break;
case ERROR_LEVEL: // light red
strcpy(ColorAttr, "\033[91m");
break;
case WARNING_LEVEL: // light yellow
strcpy(ColorAttr, "\033[93m");
break;
default:
break;
}
}
fprintf(stderr, "%s%s%s", ColorAttr, Text, ResetAttr);
#endif
}
// Clear console screen
void ConsoleListener::ClearScreen(bool Cursor)
{
#if defined(_WIN32)
COORD coordScreen = { 0, 0 };
DWORD cCharsWritten;
CONSOLE_SCREEN_BUFFER_INFO csbi;
DWORD dwConSize;
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
GetConsoleScreenBufferInfo(hConsole, &csbi);
dwConSize = csbi.dwSize.X * csbi.dwSize.Y;
// Write space to the entire console
FillConsoleOutputCharacter(hConsole, TEXT(' '), dwConSize, coordScreen, &cCharsWritten);
GetConsoleScreenBufferInfo(hConsole, &csbi);
FillConsoleOutputAttribute(hConsole, csbi.wAttributes, dwConSize, coordScreen, &cCharsWritten);
// Reset cursor
if (Cursor) SetConsoleCursorPosition(hConsole, coordScreen);
#endif
}

View File

@ -1,38 +0,0 @@
// Copyright 2013 Dolphin Emulator Project
// Licensed under GPLv2
// Refer to the license.txt file included.
#pragma once
#include "LogManager.h"
#ifdef _WIN32
#include <windows.h>
#endif
class ConsoleListener : public LogListener
{
public:
ConsoleListener();
~ConsoleListener();
void Open(bool Hidden = false, int Width = 100, int Height = 100, const char * Name = "Console");
void UpdateHandle();
void Close();
bool IsOpen();
void LetterSpace(int Width, int Height);
void BufferWidthHeight(int BufferWidth, int BufferHeight, int ScreenWidth, int ScreenHeight, bool BufferFirst);
void PixelSpace(int Left, int Top, int Width, int Height, bool);
#ifdef _WIN32
COORD GetCoordinates(int BytesRead, int BufferWidth);
#endif
void Log(LogTypes::LOG_LEVELS, const char *Text);
void ClearScreen(bool Cursor = true);
private:
#ifdef _WIN32
HWND GetHwnd(void);
HANDLE hConsole;
#endif
bool bUseColor;
};

View File

@ -8,7 +8,6 @@
#include "Host.h" #include "Host.h"
#endif #endif
#include "LogManager.h" #include "LogManager.h"
#include "ConsoleListener.h"
#include "Timer.h" #include "Timer.h"
#include "Thread.h" #include "Thread.h"
#include "FileUtil.h" #include "FileUtil.h"
@ -77,18 +76,11 @@ LogManager::LogManager()
m_Log[LogTypes::NETPLAY] = new LogContainer("NETPLAY", "Netplay"); m_Log[LogTypes::NETPLAY] = new LogContainer("NETPLAY", "Netplay");
m_fileLog = new FileLogListener(File::GetUserPath(F_MAINLOG_IDX).c_str()); m_fileLog = new FileLogListener(File::GetUserPath(F_MAINLOG_IDX).c_str());
m_consoleLog = new ConsoleListener();
m_debuggerLog = new DebuggerLogListener();
for (LogContainer* container : m_Log) for (LogContainer* container : m_Log)
{ {
container->SetEnable(true); container->SetEnable(true);
container->AddListener(m_fileLog); container->AddListener(m_fileLog);
container->AddListener(m_consoleLog);
#ifdef _MSC_VER
if (IsDebuggerPresent())
container->AddListener(m_debuggerLog);
#endif
} }
} }
@ -97,16 +89,12 @@ LogManager::~LogManager()
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i) for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i)
{ {
m_logManager->RemoveListener((LogTypes::LOG_TYPE)i, m_fileLog); m_logManager->RemoveListener((LogTypes::LOG_TYPE)i, m_fileLog);
m_logManager->RemoveListener((LogTypes::LOG_TYPE)i, m_consoleLog);
m_logManager->RemoveListener((LogTypes::LOG_TYPE)i, m_debuggerLog);
} }
for (LogContainer* container : m_Log) for (LogContainer* container : m_Log)
delete container; delete container;
delete m_fileLog; delete m_fileLog;
delete m_consoleLog;
delete m_debuggerLog;
} }
void LogManager::Log(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type, void LogManager::Log(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type,
@ -187,10 +175,3 @@ void FileLogListener::Log(LogTypes::LOG_LEVELS, const char *msg)
std::lock_guard<std::mutex> lk(m_log_lock); std::lock_guard<std::mutex> lk(m_log_lock);
m_logfile << msg << std::flush; m_logfile << msg << std::flush;
} }
void DebuggerLogListener::Log(LogTypes::LOG_LEVELS, const char *msg)
{
#if _MSC_VER
::OutputDebugStringA(msg);
#endif
}

View File

@ -44,12 +44,6 @@ private:
bool m_enable; bool m_enable;
}; };
class DebuggerLogListener : public LogListener
{
public:
void Log(LogTypes::LOG_LEVELS, const char *msg);
};
class LogContainer class LogContainer
{ {
public: public:
@ -81,15 +75,11 @@ private:
std::set<LogListener*> m_listeners; std::set<LogListener*> m_listeners;
}; };
class ConsoleListener;
class LogManager : NonCopyable class LogManager : NonCopyable
{ {
private: private:
LogContainer* m_Log[LogTypes::NUMBER_OF_LOGS]; LogContainer* m_Log[LogTypes::NUMBER_OF_LOGS];
FileLogListener *m_fileLog; FileLogListener *m_fileLog;
ConsoleListener *m_consoleLog;
DebuggerLogListener *m_debuggerLog;
static LogManager *m_logManager; // Singleton. Ugh. static LogManager *m_logManager; // Singleton. Ugh.
LogManager(); LogManager();
@ -141,16 +131,6 @@ public:
return m_fileLog; return m_fileLog;
} }
ConsoleListener *GetConsoleListener() const
{
return m_consoleLog;
}
DebuggerLogListener *GetDebuggerListener() const
{
return m_debuggerLog;
}
static LogManager* GetInstance() static LogManager* GetInstance()
{ {
return m_logManager; return m_logManager;

View File

@ -184,7 +184,6 @@ void SConfig::SaveSettings()
ini.Set("Interface", "ShowStatusbar", m_InterfaceStatusbar); ini.Set("Interface", "ShowStatusbar", m_InterfaceStatusbar);
ini.Set("Interface", "ShowLogWindow", m_InterfaceLogWindow); ini.Set("Interface", "ShowLogWindow", m_InterfaceLogWindow);
ini.Set("Interface", "ShowLogConfigWindow", m_InterfaceLogConfigWindow); ini.Set("Interface", "ShowLogConfigWindow", m_InterfaceLogConfigWindow);
ini.Set("Interface", "ShowConsole", m_InterfaceConsole);
ini.Set("Interface", "ThemeName40", m_LocalCoreStartupParameter.theme_name); ini.Set("Interface", "ThemeName40", m_LocalCoreStartupParameter.theme_name);
// Hotkeys // Hotkeys
@ -331,7 +330,6 @@ void SConfig::LoadSettings()
ini.Get("Interface", "ShowStatusbar", &m_InterfaceStatusbar, true); ini.Get("Interface", "ShowStatusbar", &m_InterfaceStatusbar, true);
ini.Get("Interface", "ShowLogWindow", &m_InterfaceLogWindow, false); ini.Get("Interface", "ShowLogWindow", &m_InterfaceLogWindow, false);
ini.Get("Interface", "ShowLogConfigWindow", &m_InterfaceLogConfigWindow, false); ini.Get("Interface", "ShowLogConfigWindow", &m_InterfaceLogConfigWindow, false);
ini.Get("Interface", "ShowConsole", &m_InterfaceConsole, false);
ini.Get("Interface", "ThemeName40", &m_LocalCoreStartupParameter.theme_name, "Clean"); ini.Get("Interface", "ThemeName40", &m_LocalCoreStartupParameter.theme_name, "Clean");
// Hotkeys // Hotkeys

View File

@ -55,7 +55,6 @@ struct SConfig : NonCopyable
bool m_InterfaceStatusbar; bool m_InterfaceStatusbar;
bool m_InterfaceLogWindow; bool m_InterfaceLogWindow;
bool m_InterfaceLogConfigWindow; bool m_InterfaceLogConfigWindow;
bool m_InterfaceConsole;
bool m_ListDrives; bool m_ListDrives;
bool m_ListWad; bool m_ListWad;

View File

@ -1,146 +0,0 @@
// Copyright 2013 Dolphin Emulator Project
// Licensed under GPLv2
// Refer to the license.txt file included.
#include <iostream>
#include <cstring>
#include "Common.h"
#include "Thread.h"
#include "HW/Memmap.h"
#include "PowerPC/PPCAnalyst.h"
#include "PowerPC/PPCTables.h"
#include "CoreTiming.h"
#include "Core.h"
#include "PowerPC/JitCommon/JitBase.h"
#include "PowerPC/PPCSymbolDB.h"
#include "PowerPCDisasm.h"
#include "Console.h"
#define CASE1(x) if (!strcmp(cmd, (x)))
#define CASE(x) else if (!strcmp(cmd, (x)))
void Console_Submit(const char *cmd)
{
CASE1("r")
{
Core::StartTrace(false);
INFO_LOG(CONSOLE, "Read tracing started.");
}
CASE("w")
{
Core::StartTrace(true);
INFO_LOG(CONSOLE, "Write tracing started.");
}
CASE("trans")
{
TCHAR temp[256];
u32 addr;
sscanf(cmd, "%s %08x", temp, &addr);
if (addr)
{
#if MAX_LOGLEVEL >= INFO_LEVEL
u32 EA =
Memory::TranslateAddress(addr, Memory::FLAG_NO_EXCEPTION);
INFO_LOG(CONSOLE, "EA 0x%08x to 0x%08x", addr, EA);
#endif
}
else
{
DEBUG_LOG(CONSOLE, "Syntax: trans ADDR");
}
}
CASE("call")
{
TCHAR temp[256];
u32 addr;
sscanf(cmd, "%s %08x", temp, &addr);
if (addr)
{
g_symbolDB.PrintCalls(addr);
}
else
{
DEBUG_LOG(CONSOLE, "Syntax: call ADDR");
}
}
CASE("llac")
{
TCHAR temp[256];
u32 addr;
sscanf(cmd, "%s %08x", temp, &addr);
if (addr)
{
g_symbolDB.PrintCallers(addr);
}
else
{
DEBUG_LOG(CONSOLE, "Syntax: llac ADDR");
}
}
CASE("pend")
{
CoreTiming::LogPendingEvents();
}
CASE("dump")
{
char temp[256];
char filename[256];
u32 start;
u32 end;
sscanf(cmd, "%s %08x %08x %s", temp, &start, &end, filename);
File::IOFile f(filename, "wb");
for (u32 i = start; i < end; i++)
{
u8 b = Memory::ReadUnchecked_U8(i);
fputc(b, f.GetHandle());
}
INFO_LOG(CONSOLE, "Dumped from %08x to %08x to %s",start,end,filename);
}
CASE("disa")
{
u32 start;
u32 end;
TCHAR temp[256];
sscanf(cmd, "%s %08x %08x", temp, &start, &end);
char disasm[256];
for (u32 addr = start; addr <= end; addr += 4)
{
u32 data = Memory::ReadUnchecked_U32(addr);
DisassembleGekko(data, addr, disasm, 256);
DEBUG_LOG(CONSOLE, "%08x: %08x: %s\n", addr, data, disasm);
}
}
CASE("help")
{
ERROR_LOG(CONSOLE, "Dolphin Console Command List");
ERROR_LOG(CONSOLE, "scan ADDR - will find functions that are called by this function");
ERROR_LOG(CONSOLE, "call ADDR - will find functions that call this function");
ERROR_LOG(CONSOLE, "dump START_A END_A FILENAME - will dump memory between START_A and END_A");
ERROR_LOG(CONSOLE, "help - guess what this does :P");
ERROR_LOG(CONSOLE, "lisd - list signature database");
ERROR_LOG(CONSOLE, "lisf - list functions");
ERROR_LOG(CONSOLE, "trans ADDR - translate address");
}
CASE("lisd")
{
// PPCAnalyst::ListDB();
}
CASE("ipro")
{
PPCTables::PrintInstructionRunCounts();
}
CASE("lisf")
{
g_symbolDB.List();
}
else
{
ERROR_LOG(CONSOLE, "Invalid command");
}
}
#undef CASE1
#undef CASE

View File

@ -1,10 +0,0 @@
// Copyright 2013 Dolphin Emulator Project
// Licensed under GPLv2
// Refer to the license.txt file included.
// Simple debugging console currently residing in the Logging window. Not used much.
#pragma once
void Console_Submit(const char *cmd);

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations"> <ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32"> <ProjectConfiguration Include="Debug|Win32">
@ -53,7 +53,6 @@
<ClCompile Include="Boot\Boot_WiiWAD.cpp" /> <ClCompile Include="Boot\Boot_WiiWAD.cpp" />
<ClCompile Include="Boot\ElfReader.cpp" /> <ClCompile Include="Boot\ElfReader.cpp" />
<ClCompile Include="ConfigManager.cpp" /> <ClCompile Include="ConfigManager.cpp" />
<ClCompile Include="Console.cpp" />
<ClCompile Include="Core.cpp" /> <ClCompile Include="Core.cpp" />
<ClCompile Include="CoreParameter.cpp" /> <ClCompile Include="CoreParameter.cpp" />
<ClCompile Include="CoreTiming.cpp" /> <ClCompile Include="CoreTiming.cpp" />
@ -258,7 +257,6 @@
<ClInclude Include="Boot\ElfReader.h" /> <ClInclude Include="Boot\ElfReader.h" />
<ClInclude Include="Boot\ElfTypes.h" /> <ClInclude Include="Boot\ElfTypes.h" />
<ClInclude Include="ConfigManager.h" /> <ClInclude Include="ConfigManager.h" />
<ClInclude Include="Console.h" />
<ClInclude Include="Core.h" /> <ClInclude Include="Core.h" />
<ClInclude Include="CoreParameter.h" /> <ClInclude Include="CoreParameter.h" />
<ClInclude Include="CoreTiming.h" /> <ClInclude Include="CoreTiming.h" />

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup> <ItemGroup>
<Filter Include="ActionReplay"> <Filter Include="ActionReplay">
@ -140,7 +140,6 @@
<ItemGroup> <ItemGroup>
<ClCompile Include="BootManager.cpp" /> <ClCompile Include="BootManager.cpp" />
<ClCompile Include="ConfigManager.cpp" /> <ClCompile Include="ConfigManager.cpp" />
<ClCompile Include="Console.cpp" />
<ClCompile Include="Core.cpp" /> <ClCompile Include="Core.cpp" />
<ClCompile Include="CoreParameter.cpp" /> <ClCompile Include="CoreParameter.cpp" />
<ClCompile Include="CoreTiming.cpp" /> <ClCompile Include="CoreTiming.cpp" />
@ -713,7 +712,6 @@
<ItemGroup> <ItemGroup>
<ClInclude Include="BootManager.h" /> <ClInclude Include="BootManager.h" />
<ClInclude Include="ConfigManager.h" /> <ClInclude Include="ConfigManager.h" />
<ClInclude Include="Console.h" />
<ClInclude Include="Core.h" /> <ClInclude Include="Core.h" />
<ClInclude Include="CoreParameter.h" /> <ClInclude Include="CoreParameter.h" />
<ClInclude Include="CoreTiming.h" /> <ClInclude Include="CoreTiming.h" />

View File

@ -408,8 +408,6 @@ void CCodeWindow::OpenPages()
Parent->ToggleLogWindow(true); Parent->ToggleLogWindow(true);
if (bShowOnStart[IDM_LOGCONFIGWINDOW - IDM_LOGWINDOW]) if (bShowOnStart[IDM_LOGCONFIGWINDOW - IDM_LOGWINDOW])
Parent->ToggleLogConfigWindow(true); Parent->ToggleLogConfigWindow(true);
if (bShowOnStart[IDM_CONSOLEWINDOW - IDM_LOGWINDOW])
Parent->ToggleConsole(true);
if (bShowOnStart[IDM_REGISTERWINDOW - IDM_LOGWINDOW]) if (bShowOnStart[IDM_REGISTERWINDOW - IDM_LOGWINDOW])
ToggleRegisterWindow(true); ToggleRegisterWindow(true);
if (bShowOnStart[IDM_BREAKPOINTWINDOW - IDM_LOGWINDOW]) if (bShowOnStart[IDM_BREAKPOINTWINDOW - IDM_LOGWINDOW])

View File

@ -20,7 +20,6 @@
#include "CheatsWindow.h" #include "CheatsWindow.h"
#include "GameListCtrl.h" #include "GameListCtrl.h"
#include "BootManager.h" #include "BootManager.h"
#include "ConsoleListener.h"
#include "ConfigManager.h" // Core #include "ConfigManager.h" // Core
#include "Core.h" #include "Core.h"
@ -281,11 +280,8 @@ CFrame::CFrame(wxFrame* parent,
for (int i = 0; i <= IDM_CODEWINDOW - IDM_LOGWINDOW; i++) for (int i = 0; i <= IDM_CODEWINDOW - IDM_LOGWINDOW; i++)
bFloatWindow[i] = false; bFloatWindow[i] = false;
if (ShowLogWindow) SConfig::GetInstance().m_InterfaceLogWindow = true; if (ShowLogWindow)
SConfig::GetInstance().m_InterfaceLogWindow = true;
// Give it a console early to show potential messages from this onward
ConsoleListener *Console = LogManager::GetInstance()->GetConsoleListener();
if (SConfig::GetInstance().m_InterfaceConsole) Console->Open();
// Start debugging maximized // Start debugging maximized
if (UseDebugger) this->Maximize(true); if (UseDebugger) this->Maximize(true);
@ -363,8 +359,6 @@ CFrame::CFrame(wxFrame* parent,
ToggleLogWindow(true); ToggleLogWindow(true);
if (SConfig::GetInstance().m_InterfaceLogConfigWindow) if (SConfig::GetInstance().m_InterfaceLogConfigWindow)
ToggleLogConfigWindow(true); ToggleLogConfigWindow(true);
if (SConfig::GetInstance().m_InterfaceConsole)
ToggleConsole(true);
} }
// Show window // Show window
@ -652,7 +646,6 @@ void CFrame::OnRenderWindowSizeRequest(int width, int height)
// Add space for the log/console/debugger window // Add space for the log/console/debugger window
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bRenderToMain && if (SConfig::GetInstance().m_LocalCoreStartupParameter.bRenderToMain &&
(SConfig::GetInstance().m_InterfaceLogWindow || (SConfig::GetInstance().m_InterfaceLogWindow ||
SConfig::GetInstance().m_InterfaceConsole ||
SConfig::GetInstance().m_InterfaceLogConfigWindow) && SConfig::GetInstance().m_InterfaceLogConfigWindow) &&
!m_Mgr->GetPane(wxT("Pane 1")).IsFloating()) !m_Mgr->GetPane(wxT("Pane 1")).IsFloating())
{ {

View File

@ -121,7 +121,6 @@ public:
void UpdateGameList(); void UpdateGameList();
void ToggleLogWindow(bool bShow); void ToggleLogWindow(bool bShow);
void ToggleLogConfigWindow(bool bShow); void ToggleLogConfigWindow(bool bShow);
void ToggleConsole(bool bShow);
void PostEvent(wxCommandEvent& event); void PostEvent(wxCommandEvent& event);
void StatusBarMessage(const char * Text, ...); void StatusBarMessage(const char * Text, ...);
void ClearStatusBar(); void ClearStatusBar();
@ -232,7 +231,6 @@ private:
void ResetToolbarStyle(); void ResetToolbarStyle();
void TogglePaneStyle(bool On, int EventId); void TogglePaneStyle(bool On, int EventId);
void ToggleNotebookStyle(bool On, long Style); void ToggleNotebookStyle(bool On, long Style);
void ResizeConsole();
// Float window // Float window
void DoUnfloatPage(int Id); void DoUnfloatPage(int Id);
void OnFloatingPageClosed(wxCloseEvent& event); void OnFloatingPageClosed(wxCloseEvent& event);

View File

@ -3,7 +3,6 @@
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include "Common.h" // Common #include "Common.h" // Common
#include "ConsoleListener.h"
#include "Globals.h" // Local #include "Globals.h" // Local
#include "Frame.h" #include "Frame.h"
@ -26,7 +25,6 @@ void CFrame::OnManagerResize(wxAuiManagerEvent& event)
m_LogWindow->winpos = m_Mgr->GetPane(_T("Pane 1")).dock_direction; m_LogWindow->winpos = m_Mgr->GetPane(_T("Pane 1")).dock_direction;
} }
event.Skip(); event.Skip();
ResizeConsole();
} }
void CFrame::OnPaneClose(wxAuiManagerEvent& event) void CFrame::OnPaneClose(wxAuiManagerEvent& event)
@ -39,14 +37,10 @@ void CFrame::OnPaneClose(wxAuiManagerEvent& event)
if (!g_pCodeWindow) if (!g_pCodeWindow)
{ {
if (nb->GetPage(0)->GetId() == IDM_LOGWINDOW || if (nb->GetPage(0)->GetId() == IDM_LOGWINDOW ||
nb->GetPage(0)->GetId() == IDM_LOGCONFIGWINDOW || nb->GetPage(0)->GetId() == IDM_LOGCONFIGWINDOW)
nb->GetPage(0)->GetId() == IDM_CONSOLEWINDOW)
{ {
// Closing a pane containing the logwindow or a console closes both
SConfig::GetInstance().m_InterfaceConsole = false;
SConfig::GetInstance().m_InterfaceLogWindow = false; SConfig::GetInstance().m_InterfaceLogWindow = false;
SConfig::GetInstance().m_InterfaceLogConfigWindow = false; SConfig::GetInstance().m_InterfaceLogConfigWindow = false;
ToggleConsole(false);
ToggleLogWindow(false); ToggleLogWindow(false);
ToggleLogConfigWindow(false); ToggleLogConfigWindow(false);
} }
@ -132,59 +126,6 @@ void CFrame::ToggleLogConfigWindow(bool bShow)
TogglePane(); TogglePane();
} }
void CFrame::ToggleConsole(bool bShow)
{
#ifdef _WIN32
GetMenuBar()->FindItem(IDM_CONSOLEWINDOW)->Check(bShow);
if (bShow)
{
// If the console doesn't exist, we create it
if (!GetConsoleWindow())
{
ConsoleListener *Console = LogManager::GetInstance()->GetConsoleListener();
Console->Open();
}
else
{
ShowWindow(GetConsoleWindow(), SW_SHOW);
}
// Create the parent window if it doesn't exist
wxPanel *ConsoleParent = (wxPanel*)FindWindowById(IDM_CONSOLEWINDOW);
if (!ConsoleParent) ConsoleParent = new wxPanel(this, IDM_CONSOLEWINDOW,
wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, _("Console"));
wxWindow *ConsoleWin = new wxWindow();
ConsoleWin->SetHWND((WXHWND)GetConsoleWindow());
ConsoleWin->AdoptAttributesFromHWND();
ConsoleWin->Reparent(ConsoleParent);
ConsoleParent->Enable();
const int nbIndex = IDM_CONSOLEWINDOW - IDM_LOGWINDOW;
DoAddPage(ConsoleParent,
g_pCodeWindow ? g_pCodeWindow->iNbAffiliation[nbIndex] : 0,
g_pCodeWindow ? bFloatWindow[nbIndex] : false);
}
else // Hide
{
if(GetConsoleWindow())
ShowWindow(GetConsoleWindow(), SW_HIDE); // WIN32
wxPanel *ConsoleParent = (wxPanel*)FindWindowById(IDM_CONSOLEWINDOW);
if (ConsoleParent)
ConsoleParent->Disable();
// Then close the page
DoRemovePage(ConsoleParent, true);
}
// Hide or Show the pane
if (!g_pCodeWindow)
TogglePane();
#endif
}
void CFrame::OnToggleWindow(wxCommandEvent& event) void CFrame::OnToggleWindow(wxCommandEvent& event)
{ {
bool bShow = GetMenuBar()->IsChecked(event.GetId()); bool bShow = GetMenuBar()->IsChecked(event.GetId());
@ -201,11 +142,6 @@ void CFrame::OnToggleWindow(wxCommandEvent& event)
SConfig::GetInstance().m_InterfaceLogConfigWindow = bShow; SConfig::GetInstance().m_InterfaceLogConfigWindow = bShow;
ToggleLogConfigWindow(bShow); ToggleLogConfigWindow(bShow);
break; break;
case IDM_CONSOLEWINDOW:
if (!g_pCodeWindow)
SConfig::GetInstance().m_InterfaceConsole = bShow;
ToggleConsole(bShow);
break;
case IDM_REGISTERWINDOW: case IDM_REGISTERWINDOW:
g_pCodeWindow->ToggleRegisterWindow(bShow); g_pCodeWindow->ToggleRegisterWindow(bShow);
break; break;
@ -233,7 +169,7 @@ void CFrame::ClosePages()
{ {
ToggleLogWindow(false); ToggleLogWindow(false);
ToggleLogConfigWindow(false); ToggleLogConfigWindow(false);
ToggleConsole(false);
if (g_pCodeWindow) if (g_pCodeWindow)
{ {
g_pCodeWindow->ToggleCodeWindow(false); g_pCodeWindow->ToggleCodeWindow(false);
@ -275,8 +211,6 @@ void CFrame::OnNotebookPageClose(wxAuiNotebookEvent& event)
ToggleLogWindow(false); ToggleLogWindow(false);
if (Ctrl->GetPage(event.GetSelection())->GetId() == IDM_LOGCONFIGWINDOW) if (Ctrl->GetPage(event.GetSelection())->GetId() == IDM_LOGCONFIGWINDOW)
ToggleLogConfigWindow(false); ToggleLogConfigWindow(false);
if (Ctrl->GetPage(event.GetSelection())->GetId() == IDM_CONSOLEWINDOW)
ToggleConsole(false);
if (Ctrl->GetPage(event.GetSelection())->GetId() == IDM_REGISTERWINDOW) if (Ctrl->GetPage(event.GetSelection())->GetId() == IDM_REGISTERWINDOW)
g_pCodeWindow->ToggleRegisterWindow(false); g_pCodeWindow->ToggleRegisterWindow(false);
if (Ctrl->GetPage(event.GetSelection())->GetId() == IDM_BREAKPOINTWINDOW) if (Ctrl->GetPage(event.GetSelection())->GetId() == IDM_BREAKPOINTWINDOW)
@ -299,7 +233,6 @@ void CFrame::OnFloatingPageClosed(wxCloseEvent& event)
void CFrame::OnFloatingPageSize(wxSizeEvent& event) void CFrame::OnFloatingPageSize(wxSizeEvent& event)
{ {
event.Skip(); event.Skip();
ResizeConsole();
} }
void CFrame::OnFloatWindow(wxCommandEvent& event) void CFrame::OnFloatWindow(wxCommandEvent& event)
@ -392,7 +325,6 @@ void CFrame::OnAllowNotebookDnD(wxAuiNotebookEvent& event)
{ {
event.Skip(); event.Skip();
event.Allow(); event.Allow();
ResizeConsole();
} }
void CFrame::ShowResizePane() void CFrame::ShowResizePane()
@ -772,33 +704,6 @@ void CFrame::OnSelectPerspective(wxCommandEvent& event)
DoLoadPerspective(); DoLoadPerspective();
} }
void CFrame::ResizeConsole()
{
#ifdef _WIN32
// Get the console parent window
wxWindow * Win = FindWindowById(IDM_CONSOLEWINDOW);
if (!Win) return;
const int wxBorder = 2, Border = 4,
MenuBar = 30, ScrollBar = 19;
// Get the client size
int X = Win->GetSize().GetX();
int Y = Win->GetSize().GetY();
int InternalWidth = X - wxBorder*2 - ScrollBar;
int InternalHeight = Y - wxBorder*2;
int WindowWidth = InternalWidth + Border*2 +
/*max out the width in the word wrap mode*/ 100;
int WindowHeight = InternalHeight + MenuBar;
// Resize buffer
ConsoleListener* Console = LogManager::GetInstance()->GetConsoleListener();
Console->PixelSpace(0,0, InternalWidth, InternalHeight, false);
// Move the window to hide the border
MoveWindow(GetConsoleWindow(), -Border-wxBorder, -MenuBar-wxBorder,
WindowWidth + 100, WindowHeight, true);
#endif
}
static int Limit(int i, int Low, int High) static int Limit(int i, int Low, int High)
{ {
if (i < Low) return Low; if (i < Low) return Low;
@ -1063,11 +968,6 @@ wxFrame * CFrame::CreateParentFrame(wxWindowID Id, const wxString& Title,
Frame->Bind(wxEVT_CLOSE_WINDOW, &CFrame::OnFloatingPageClosed, this); Frame->Bind(wxEVT_CLOSE_WINDOW, &CFrame::OnFloatingPageClosed, this);
if (Id == IDM_CONSOLEWINDOW_PARENT)
{
Frame->Bind(wxEVT_SIZE, &CFrame::OnFloatingPageSize, this);
}
// Main sizer // Main sizer
Frame->SetSizer(m_MainSizer); Frame->SetSizer(m_MainSizer);
// Minimum frame size // Minimum frame size

View File

@ -218,17 +218,11 @@ void CFrame::CreateMenu()
viewMenu->AppendSeparator(); viewMenu->AppendSeparator();
viewMenu->AppendCheckItem(IDM_LOGWINDOW, _("Show &Log")); viewMenu->AppendCheckItem(IDM_LOGWINDOW, _("Show &Log"));
viewMenu->AppendCheckItem(IDM_LOGCONFIGWINDOW, _("Show Log &Configuration")); viewMenu->AppendCheckItem(IDM_LOGCONFIGWINDOW, _("Show Log &Configuration"));
viewMenu->AppendCheckItem(IDM_CONSOLEWINDOW, _("Show &Console"));
viewMenu->AppendSeparator(); viewMenu->AppendSeparator();
#ifndef _WIN32
viewMenu->Enable(IDM_CONSOLEWINDOW, false);
#endif
if (g_pCodeWindow) if (g_pCodeWindow)
{ {
viewMenu->Check(IDM_LOGWINDOW, g_pCodeWindow->bShowOnStart[0]); viewMenu->Check(IDM_LOGWINDOW, g_pCodeWindow->bShowOnStart[0]);
viewMenu->Check(IDM_CONSOLEWINDOW, g_pCodeWindow->bShowOnStart[1]);
const wxString MenuText[] = { const wxString MenuText[] = {
wxTRANSLATE("&Registers"), wxTRANSLATE("&Registers"),
@ -251,7 +245,6 @@ void CFrame::CreateMenu()
{ {
viewMenu->Check(IDM_LOGWINDOW, SConfig::GetInstance().m_InterfaceLogWindow); viewMenu->Check(IDM_LOGWINDOW, SConfig::GetInstance().m_InterfaceLogWindow);
viewMenu->Check(IDM_LOGCONFIGWINDOW, SConfig::GetInstance().m_InterfaceLogConfigWindow); viewMenu->Check(IDM_LOGCONFIGWINDOW, SConfig::GetInstance().m_InterfaceLogConfigWindow);
viewMenu->Check(IDM_CONSOLEWINDOW, SConfig::GetInstance().m_InterfaceConsole);
} }
wxMenu *platformMenu = new wxMenu; wxMenu *platformMenu = new wxMenu;

View File

@ -129,7 +129,6 @@ enum
// Views // Views
IDM_LOGWINDOW, IDM_LOGWINDOW,
IDM_LOGCONFIGWINDOW, IDM_LOGCONFIGWINDOW,
IDM_CONSOLEWINDOW,
IDM_REGISTERWINDOW, IDM_REGISTERWINDOW,
IDM_BREAKPOINTWINDOW, IDM_BREAKPOINTWINDOW,
IDM_MEMORYWINDOW, IDM_MEMORYWINDOW,
@ -141,7 +140,6 @@ enum
// Float Window IDs // Float Window IDs
IDM_LOGWINDOW_PARENT, IDM_LOGWINDOW_PARENT,
IDM_LOGCONFIGWINDOW_PARENT, IDM_LOGCONFIGWINDOW_PARENT,
IDM_CONSOLEWINDOW_PARENT,
IDM_REGISTERWINDOW_PARENT, IDM_REGISTERWINDOW_PARENT,
IDM_BREAKPOINTWINDOW_PARENT, IDM_BREAKPOINTWINDOW_PARENT,
IDM_MEMORYWINDOW_PARENT, IDM_MEMORYWINDOW_PARENT,

View File

@ -4,7 +4,6 @@
#include "LogConfigWindow.h" #include "LogConfigWindow.h"
#include "LogManager.h" #include "LogManager.h"
#include "ConsoleListener.h"
#include "LogWindow.h" #include "LogWindow.h"
#include "FileUtil.h" #include "FileUtil.h"
#include "WxUtils.h" #include "WxUtils.h"
@ -43,18 +42,8 @@ void LogConfigWindow::CreateGUIControls()
// Options // Options
m_writeFileCB = new wxCheckBox(this, wxID_ANY, _("Write to File")); m_writeFileCB = new wxCheckBox(this, wxID_ANY, _("Write to File"));
m_writeFileCB->Bind(wxEVT_COMMAND_CHECKBOX_CLICKED, &LogConfigWindow::OnWriteFileChecked, this); m_writeFileCB->Bind(wxEVT_COMMAND_CHECKBOX_CLICKED, &LogConfigWindow::OnWriteFileChecked, this);
m_writeConsoleCB = new wxCheckBox(this, wxID_ANY, _("Write to Console"));
m_writeConsoleCB->Bind(wxEVT_COMMAND_CHECKBOX_CLICKED, &LogConfigWindow::OnWriteConsoleChecked, this);
m_writeWindowCB = new wxCheckBox(this, wxID_ANY, _("Write to Window")); m_writeWindowCB = new wxCheckBox(this, wxID_ANY, _("Write to Window"));
m_writeWindowCB->Bind(wxEVT_COMMAND_CHECKBOX_CLICKED, &LogConfigWindow::OnWriteWindowChecked, this); m_writeWindowCB->Bind(wxEVT_COMMAND_CHECKBOX_CLICKED, &LogConfigWindow::OnWriteWindowChecked, this);
m_writeDebuggerCB = NULL;
#ifdef _MSC_VER
if (IsDebuggerPresent())
{
m_writeDebuggerCB = new wxCheckBox(this, wxID_ANY, _("Write to Debugger"));
m_writeDebuggerCB->Bind(wxEVT_COMMAND_CHECKBOX_CLICKED, &LogConfigWindow::OnWriteDebuggerChecked, this);
}
#endif
wxButton *btn_toggle_all = new wxButton(this, wxID_ANY, _("Toggle All Log Types"), wxButton *btn_toggle_all = new wxButton(this, wxID_ANY, _("Toggle All Log Types"),
wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT); wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT);
@ -67,18 +56,7 @@ void LogConfigWindow::CreateGUIControls()
// Sizers // Sizers
wxStaticBoxSizer* sbOutputs = new wxStaticBoxSizer(wxVERTICAL, this, _("Logger Outputs")); wxStaticBoxSizer* sbOutputs = new wxStaticBoxSizer(wxVERTICAL, this, _("Logger Outputs"));
sbOutputs->Add(m_writeFileCB, 0, wxDOWN, 1); sbOutputs->Add(m_writeFileCB, 0, wxDOWN, 1);
sbOutputs->Add(m_writeConsoleCB, 0, wxDOWN, 1);
#ifdef _MSC_VER
if (m_writeDebuggerCB)
{
sbOutputs->Add(m_writeWindowCB, 0, wxDOWN, 1);
sbOutputs->Add(m_writeDebuggerCB, 0);
}
else
#endif
{
sbOutputs->Add(m_writeWindowCB, 0); sbOutputs->Add(m_writeWindowCB, 0);
}
wxStaticBoxSizer* sbLogTypes = new wxStaticBoxSizer(wxVERTICAL, this, _("Log Types")); wxStaticBoxSizer* sbLogTypes = new wxStaticBoxSizer(wxVERTICAL, this, _("Log Types"));
sbLogTypes->Add(m_checks, 1, wxEXPAND); sbLogTypes->Add(m_checks, 1, wxEXPAND);
@ -114,21 +92,8 @@ void LogConfigWindow::LoadSettings()
// Get the logger output settings from the config ini file. // Get the logger output settings from the config ini file.
ini.Get("Options", "WriteToFile", &m_writeFile, false); ini.Get("Options", "WriteToFile", &m_writeFile, false);
m_writeFileCB->SetValue(m_writeFile); m_writeFileCB->SetValue(m_writeFile);
ini.Get("Options", "WriteToConsole", &m_writeConsole, true);
m_writeConsoleCB->SetValue(m_writeConsole);
ini.Get("Options", "WriteToWindow", &m_writeWindow, true); ini.Get("Options", "WriteToWindow", &m_writeWindow, true);
m_writeWindowCB->SetValue(m_writeWindow); m_writeWindowCB->SetValue(m_writeWindow);
#ifdef _MSC_VER
if (IsDebuggerPresent())
{
ini.Get("Options", "WriteToDebugger", &m_writeDebugger, true);
m_writeDebuggerCB->SetValue(m_writeDebugger);
}
else
#endif
{
m_writeDebugger = false;
}
// Run through all of the log types and check each checkbox for each logging type // Run through all of the log types and check each checkbox for each logging type
// depending on its set value within the config ini. // depending on its set value within the config ini.
@ -154,12 +119,7 @@ void LogConfigWindow::SaveSettings()
// Save the enabled/disabled states of the logger outputs to the config ini. // Save the enabled/disabled states of the logger outputs to the config ini.
ini.Set("Options", "WriteToFile", m_writeFile); ini.Set("Options", "WriteToFile", m_writeFile);
ini.Set("Options", "WriteToConsole", m_writeConsole);
ini.Set("Options", "WriteToWindow", m_writeWindow); ini.Set("Options", "WriteToWindow", m_writeWindow);
#ifdef _MSC_VER
if (IsDebuggerPresent())
ini.Set("Options", "WriteToDebugger", m_writeDebugger);
#endif
// Save all enabled/disabled states of the log types to the config ini. // Save all enabled/disabled states of the log types to the config ini.
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i) for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i)
@ -200,21 +160,6 @@ void LogConfigWindow::OnWriteFileChecked(wxCommandEvent& event)
} }
} }
void LogConfigWindow::OnWriteConsoleChecked(wxCommandEvent& event)
{
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i)
{
m_writeConsole = event.IsChecked();
if (m_checks->IsChecked(i))
{
if (m_writeConsole)
m_LogManager->AddListener((LogTypes::LOG_TYPE)i, m_LogManager->GetConsoleListener());
else
m_LogManager->RemoveListener((LogTypes::LOG_TYPE)i, m_LogManager->GetConsoleListener());
}
}
}
void LogConfigWindow::OnWriteWindowChecked(wxCommandEvent& event) void LogConfigWindow::OnWriteWindowChecked(wxCommandEvent& event)
{ {
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i) for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i)
@ -230,21 +175,6 @@ void LogConfigWindow::OnWriteWindowChecked(wxCommandEvent& event)
} }
} }
void LogConfigWindow::OnWriteDebuggerChecked(wxCommandEvent& event)
{
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i)
{
m_writeDebugger = event.IsChecked();
if (m_checks->IsChecked(i))
{
if (m_writeDebugger)
m_LogManager->AddListener((LogTypes::LOG_TYPE)i, (LogListener *)m_LogManager->GetDebuggerListener());
else
m_LogManager->RemoveListener((LogTypes::LOG_TYPE)i, (LogListener *)m_LogManager->GetDebuggerListener());
}
}
}
void LogConfigWindow::OnToggleAll(wxCommandEvent& WXUNUSED(event)) void LogConfigWindow::OnToggleAll(wxCommandEvent& WXUNUSED(event))
{ {
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i) for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i)
@ -265,19 +195,14 @@ void LogConfigWindow::ToggleLog(int _logType, bool enable)
{ {
if (m_writeWindow) if (m_writeWindow)
m_LogManager->AddListener(logType, (LogListener *)m_LogWindow); m_LogManager->AddListener(logType, (LogListener *)m_LogWindow);
if (m_writeFile) if (m_writeFile)
m_LogManager->AddListener(logType, m_LogManager->GetFileListener()); m_LogManager->AddListener(logType, m_LogManager->GetFileListener());
if (m_writeConsole)
m_LogManager->AddListener(logType, m_LogManager->GetConsoleListener());
if (m_writeDebugger)
m_LogManager->AddListener(logType, m_LogManager->GetDebuggerListener());
} }
else else
{ {
m_LogManager->RemoveListener(logType, (LogListener *)m_LogWindow); m_LogManager->RemoveListener(logType, (LogListener *)m_LogWindow);
m_LogManager->RemoveListener(logType, m_LogManager->GetFileListener()); m_LogManager->RemoveListener(logType, m_LogManager->GetFileListener());
m_LogManager->RemoveListener(logType, m_LogManager->GetConsoleListener());
m_LogManager->RemoveListener(logType, m_LogManager->GetDebuggerListener());
} }
} }

View File

@ -23,20 +23,18 @@ public:
private: private:
LogManager *m_LogManager; LogManager *m_LogManager;
CLogWindow *m_LogWindow; CLogWindow *m_LogWindow;
bool m_writeFile, m_writeConsole, m_writeWindow, m_writeDebugger; bool m_writeFile, m_writeWindow;
bool enableAll; bool enableAll;
// Controls // Controls
wxCheckBox *m_writeFileCB, *m_writeConsoleCB, *m_writeWindowCB, *m_writeDebuggerCB; wxCheckBox *m_writeFileCB, *m_writeWindowCB;
wxCheckListBox* m_checks; wxCheckListBox* m_checks;
wxRadioBox *m_verbosity; wxRadioBox *m_verbosity;
void CreateGUIControls(); void CreateGUIControls();
void OnVerbosityChange(wxCommandEvent& event); void OnVerbosityChange(wxCommandEvent& event);
void OnWriteFileChecked(wxCommandEvent& event); void OnWriteFileChecked(wxCommandEvent& event);
void OnWriteConsoleChecked(wxCommandEvent& event);
void OnWriteWindowChecked(wxCommandEvent& event); void OnWriteWindowChecked(wxCommandEvent& event);
void OnWriteDebuggerChecked(wxCommandEvent& event);
void OnToggleAll(wxCommandEvent& event); void OnToggleAll(wxCommandEvent& event);
void ToggleLog(int _logType, bool enable); void ToggleLog(int _logType, bool enable);
void OnLogCheck(wxCommandEvent& event); void OnLogCheck(wxCommandEvent& event);

View File

@ -3,8 +3,6 @@
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include "LogWindow.h" #include "LogWindow.h"
#include "ConsoleListener.h"
#include "Console.h"
#include "IniFile.h" #include "IniFile.h"
#include "FileUtil.h" #include "FileUtil.h"
#include "Debugger/DebuggerUIUtil.h" #include "Debugger/DebuggerUIUtil.h"
@ -17,7 +15,6 @@
BEGIN_EVENT_TABLE(CLogWindow, wxPanel) BEGIN_EVENT_TABLE(CLogWindow, wxPanel)
EVT_CLOSE(CLogWindow::OnClose) EVT_CLOSE(CLogWindow::OnClose)
EVT_TEXT_ENTER(IDM_SUBMITCMD, CLogWindow::OnSubmit)
EVT_BUTTON(IDM_CLEARLOG, CLogWindow::OnClear) EVT_BUTTON(IDM_CLEARLOG, CLogWindow::OnClear)
EVT_CHOICE(IDM_FONT, CLogWindow::OnFontChange) EVT_CHOICE(IDM_FONT, CLogWindow::OnFontChange)
EVT_CHECKBOX(IDM_WRAPLINE, CLogWindow::OnWrapLineCheck) EVT_CHECKBOX(IDM_WRAPLINE, CLogWindow::OnWrapLineCheck)
@ -60,18 +57,7 @@ void CLogWindow::CreateGUIControls()
// Get the logger output settings from the config ini file. // Get the logger output settings from the config ini file.
ini.Get("Options", "WriteToFile", &m_writeFile, false); ini.Get("Options", "WriteToFile", &m_writeFile, false);
ini.Get("Options", "WriteToConsole", &m_writeConsole, true);
ini.Get("Options", "WriteToWindow", &m_writeWindow, true); ini.Get("Options", "WriteToWindow", &m_writeWindow, true);
#ifdef _MSC_VER
if (IsDebuggerPresent())
{
ini.Get("Options", "WriteToDebugger", &m_writeDebugger, true);
}
else
#endif
{
m_writeDebugger = false;
}
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i) for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i)
{ {
@ -88,16 +74,6 @@ void CLogWindow::CreateGUIControls()
else else
m_LogManager->RemoveListener((LogTypes::LOG_TYPE)i, m_LogManager->GetFileListener()); m_LogManager->RemoveListener((LogTypes::LOG_TYPE)i, m_LogManager->GetFileListener());
if (m_writeConsole && enable)
m_LogManager->AddListener((LogTypes::LOG_TYPE)i, m_LogManager->GetConsoleListener());
else
m_LogManager->RemoveListener((LogTypes::LOG_TYPE)i, m_LogManager->GetConsoleListener());
if (m_writeDebugger && enable)
m_LogManager->AddListener((LogTypes::LOG_TYPE)i, m_LogManager->GetDebuggerListener());
else
m_LogManager->RemoveListener((LogTypes::LOG_TYPE)i, m_LogManager->GetDebuggerListener());
m_LogManager->SetLogLevel((LogTypes::LOG_TYPE)i, (LogTypes::LOG_LEVELS)(verbosity)); m_LogManager->SetLogLevel((LogTypes::LOG_TYPE)i, (LogTypes::LOG_LEVELS)(verbosity));
} }
@ -182,25 +158,15 @@ void CLogWindow::SaveSettings()
ini.Save(File::GetUserPath(F_LOGGERCONFIG_IDX)); ini.Save(File::GetUserPath(F_LOGGERCONFIG_IDX));
} }
void CLogWindow::OnSubmit(wxCommandEvent& WXUNUSED (event))
{
if (!m_cmdline) return;
Console_Submit(WxStrToStr(m_cmdline->GetValue()).c_str());
m_cmdline->SetValue(wxEmptyString);
}
void CLogWindow::OnClear(wxCommandEvent& WXUNUSED (event)) void CLogWindow::OnClear(wxCommandEvent& WXUNUSED (event))
{ {
m_Log->Clear(); m_Log->Clear();
{
std::lock_guard<std::mutex> lk(m_LogSection); std::lock_guard<std::mutex> lk(m_LogSection);
int msgQueueSize = (int)msgQueue.size(); int msgQueueSize = (int)msgQueue.size();
for (int i = 0; i < msgQueueSize; i++) for (int i = 0; i < msgQueueSize; i++)
msgQueue.pop(); msgQueue.pop();
}
m_LogManager->GetConsoleListener()->ClearScreen();
} }
void CLogWindow::UnPopulateBottom() void CLogWindow::UnPopulateBottom()

View File

@ -51,7 +51,7 @@ private:
bool m_ignoreLogTimer; bool m_ignoreLogTimer;
LogManager *m_LogManager; LogManager *m_LogManager;
std::queue<std::pair<u8, wxString> > msgQueue; std::queue<std::pair<u8, wxString> > msgQueue;
bool m_writeFile, m_writeConsole, m_writeWindow, m_writeDebugger, m_LogAccess; bool m_writeFile, m_writeWindow, m_LogAccess;
// Controls // Controls
wxBoxSizer *sBottom; wxBoxSizer *sBottom;
@ -68,7 +68,6 @@ private:
void PopulateBottom(); void PopulateBottom();
void UnPopulateBottom(); void UnPopulateBottom();
void OnClose(wxCloseEvent& event); void OnClose(wxCloseEvent& event);
void OnSubmit(wxCommandEvent& event);
void OnFontChange(wxCommandEvent& event); void OnFontChange(wxCommandEvent& event);
void OnWrapLineCheck(wxCommandEvent& event); void OnWrapLineCheck(wxCommandEvent& event);
void OnClear(wxCommandEvent& event); void OnClear(wxCommandEvent& event);