mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 06:09:50 -06:00
Common: Moved Windows console functions to common
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1887 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
@ -19,7 +19,10 @@
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// includes
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Includes
|
||||
// -------------
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
@ -28,13 +31,16 @@
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#include "ConsoleWindow.h" // Open and close console
|
||||
|
||||
#include "Debugger.h"
|
||||
#include "PBView.h"
|
||||
#include "IniFile.h"
|
||||
#include "FileUtil.h"
|
||||
#include "StringUtil.h"
|
||||
#include "FileSearch.h"
|
||||
#include "../Logging/Console.h" // open and close console
|
||||
//#include "../Logging/File.h" // Write to file
|
||||
///////////////////////////////
|
||||
|
||||
|
||||
// Make the wxTextCtrls scroll with each other
|
||||
@ -55,7 +61,7 @@ void CDebugger::DoScrollBlocks()
|
||||
else if(GetAsyncKeyState(VK_NUMPAD2))
|
||||
A += 0.11;
|
||||
|
||||
wprintf("GetScrollPos:%i GetScrollRange:%i GetPosition:%i GetLastPosition:%i GetMaxWidth:%i \
|
||||
Console::Print("GetScrollPos:%i GetScrollRange:%i GetPosition:%i GetLastPosition:%i GetMaxWidth:%i \
|
||||
GetLineLength:%i XYToPosition:%i\n \
|
||||
GetScrollPos * GetLineLength + GetScrollRange:%i A:%f\n",
|
||||
m_bl95->GetScrollPos(wxVERTICAL), m_bl95->GetScrollRange(wxVERTICAL),
|
||||
|
@ -19,26 +19,31 @@
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Includes
|
||||
// -------------
|
||||
// includes
|
||||
#include <iostream>
|
||||
#include <iostream> // System
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
|
||||
#ifndef _WIN32
|
||||
#include <stdlib.h>
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#include "ConsoleWindow.h" // Open and close console
|
||||
|
||||
#include "Debugger.h"
|
||||
#include "PBView.h"
|
||||
#include "IniFile.h"
|
||||
#include "FileUtil.h"
|
||||
#include "StringUtil.h"
|
||||
#include "FileSearch.h"
|
||||
#include "../Logging/Console.h" // open and close console
|
||||
|
||||
#include "../Debugger/File.h" // Write to file
|
||||
//////////////////////////////
|
||||
|
||||
// =======================================================================================
|
||||
// Declare events
|
||||
// Event table and class
|
||||
BEGIN_EVENT_TABLE(CDebugger,wxDialog)
|
||||
EVT_CLOSE(CDebugger::OnClose) // on close event
|
||||
|
||||
@ -69,8 +74,6 @@ BEGIN_EVENT_TABLE(CDebugger,wxDialog)
|
||||
//EVT_SCROLL(CDebugger::ScrollBlocks)
|
||||
//EVT_SCROLLWIN(CDebugger::ScrollBlocks)
|
||||
END_EVENT_TABLE()
|
||||
// =======================================================================================
|
||||
|
||||
|
||||
CDebugger::CDebugger(wxWindow *parent, wxWindowID id, const wxString &title,
|
||||
const wxPoint &position, const wxSize& size, long style)
|
||||
@ -147,7 +150,50 @@ CDebugger::~CDebugger()
|
||||
this->Save(file);
|
||||
file.Save(DEBUGGER_CONFIG_FILE);
|
||||
}
|
||||
// ====================
|
||||
|
||||
|
||||
// ========================================================================
|
||||
// System functions
|
||||
// --------------
|
||||
void CDebugger::OnClose(wxCloseEvent& /*event*/)
|
||||
{
|
||||
// Save the window position when we hide the window to
|
||||
IniFile file;
|
||||
file.Load(DEBUGGER_CONFIG_FILE);
|
||||
this->Save(file);
|
||||
file.Save(DEBUGGER_CONFIG_FILE);
|
||||
|
||||
EndModal(0);
|
||||
#ifdef _WIN32
|
||||
Console::Close(); // Take the console window with it
|
||||
#endif
|
||||
}
|
||||
|
||||
void CDebugger::DoHide()
|
||||
{
|
||||
Hide();
|
||||
#ifdef _WIN32
|
||||
Console::Close(); // The console goes with the wx window
|
||||
#endif
|
||||
}
|
||||
|
||||
void CDebugger::DoShow()
|
||||
{
|
||||
Show();
|
||||
DoShowHideConsole(); // The console goes with the wx window
|
||||
}
|
||||
|
||||
void CDebugger::OnUpdate(wxCommandEvent& /*event*/)
|
||||
{
|
||||
this->NotifyUpdate();
|
||||
}
|
||||
// ===============
|
||||
|
||||
|
||||
// ==========================================================================
|
||||
// Save and load settings
|
||||
// --------------
|
||||
void CDebugger::Save(IniFile& _IniFile) const
|
||||
{
|
||||
// TODO2: get the screen resolution and make limits from that
|
||||
@ -197,7 +243,12 @@ void CDebugger::Load(IniFile& _IniFile)
|
||||
_IniFile.Get("SoundWindow", "StoreMails", &StoreMails, m_gcwiiset->IsChecked(1));
|
||||
m_gcwiiset->Check(1, StoreMails);
|
||||
}
|
||||
// ===================
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Create GUI controls
|
||||
// -------------
|
||||
void CDebugger::CreateGUIControls()
|
||||
{
|
||||
SetTitle(wxT("Sound Debugging"));
|
||||
@ -517,39 +568,7 @@ SetTitle(wxT("Sound Debugging"));
|
||||
NotifyUpdate();
|
||||
// --------------------------------------------------------------------
|
||||
}
|
||||
|
||||
// ========================================================================
|
||||
// System functions
|
||||
// --------------
|
||||
void CDebugger::OnClose(wxCloseEvent& /*event*/)
|
||||
{
|
||||
// save the window position when we hide the window to
|
||||
IniFile file;
|
||||
file.Load(DEBUGGER_CONFIG_FILE);
|
||||
this->Save(file);
|
||||
file.Save(DEBUGGER_CONFIG_FILE);
|
||||
|
||||
EndModal(0);
|
||||
CloseConsole(); // Take the console window with it
|
||||
}
|
||||
|
||||
void CDebugger::DoHide()
|
||||
{
|
||||
Hide();
|
||||
CloseConsole(); // The console goes with the wx window
|
||||
}
|
||||
|
||||
void CDebugger::DoShow()
|
||||
{
|
||||
Show();
|
||||
DoShowHideConsole(); // The console goes with the wx window
|
||||
}
|
||||
|
||||
void CDebugger::OnUpdate(wxCommandEvent& /*event*/)
|
||||
{
|
||||
this->NotifyUpdate();
|
||||
}
|
||||
// ===============
|
||||
/////////////////////////////
|
||||
|
||||
|
||||
// =======================================================================================
|
||||
@ -663,11 +682,13 @@ void CDebugger::ShowHideConsole(wxCommandEvent& event)
|
||||
}
|
||||
|
||||
void CDebugger::DoShowHideConsole()
|
||||
{
|
||||
{
|
||||
#ifdef _WIN32
|
||||
if(m_options->IsChecked(3))
|
||||
OpenConsole();
|
||||
else
|
||||
CloseConsole();
|
||||
#endif
|
||||
}
|
||||
// ==============
|
||||
|
||||
|
117
Source/Plugins/Plugin_DSP_HLE/Src/Debugger/File.cpp
Normal file
117
Source/Plugins/Plugin_DSP_HLE/Src/Debugger/File.cpp
Normal file
@ -0,0 +1,117 @@
|
||||
// Copyright (C) 2003-2008 Dolphin Project.
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, version 2.0.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License 2.0 for more details.
|
||||
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
|
||||
// Official SVN repository and contact information can be found at
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
|
||||
// --------------------
|
||||
// Includes
|
||||
#include <string>
|
||||
#include <stdio.h>
|
||||
#include "Common.h"
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_WX) && HAVE_WX
|
||||
#include "../Debugger/Debugger.h"
|
||||
#include "../Debugger/File.h"
|
||||
extern CDebugger* m_frame;
|
||||
#endif
|
||||
|
||||
// --------------------
|
||||
// On and off
|
||||
bool g_consoleEnable = true;
|
||||
//int gSaveFile = 0;
|
||||
#define DEBUG_HLE
|
||||
|
||||
// --------------------
|
||||
// Create file handles
|
||||
#ifdef DEBUG_HLE
|
||||
FILE* __fStdOut[nFiles];
|
||||
#endif
|
||||
|
||||
|
||||
// =======================================================================================
|
||||
/* Open file handles */
|
||||
// -------------
|
||||
void StartFile(int width, int height, char* fname)
|
||||
{
|
||||
#if defined(DEBUG_HLE) && defined(_WIN32)
|
||||
if(fname)
|
||||
{
|
||||
for(int i = 0; i < nFiles; i++)
|
||||
{
|
||||
// Edit the log file name
|
||||
std::string FileEnding = ".log";
|
||||
std::string FileName = fname;
|
||||
char buffer[33]; _itoa(i, buffer, 10); // convert number to string
|
||||
std::string FullFilename = (FileName + buffer + FileEnding);
|
||||
__fStdOut[i] = fopen(FullFilename.c_str(), "w");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
// ======================
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
/* Close the file handles */
|
||||
// -------------
|
||||
void CloseFile()
|
||||
{
|
||||
// Close the file handles
|
||||
for(int i = 0; i < nFiles; i++)
|
||||
{
|
||||
if(__fStdOut[i]) fclose(__fStdOut[i]);
|
||||
}
|
||||
}
|
||||
//////////////////////////////
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------------------
|
||||
// File printf function
|
||||
// -------------
|
||||
int PrintFile(int a, char *fmt, ...)
|
||||
{
|
||||
#if defined(DEBUG_HLE) && defined(_WIN32)
|
||||
|
||||
if(m_frame->gSaveFile)
|
||||
{
|
||||
char s[StringSize];
|
||||
va_list argptr;
|
||||
int cnt;
|
||||
|
||||
va_start(argptr, fmt);
|
||||
cnt = vsnprintf(s, StringSize, fmt, argptr);
|
||||
va_end(argptr);
|
||||
|
||||
// ---------------------------------------------------------------------------------------
|
||||
if(__fStdOut[a]) // TODO: make this work, we have to set all default values to NULL
|
||||
// to make it work
|
||||
fprintf(__fStdOut[a], s);
|
||||
// -------------
|
||||
|
||||
return(cnt);
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
@ -19,7 +19,10 @@
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// includes
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Includes
|
||||
// -------------
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
@ -28,23 +31,31 @@
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
//#include "ConsoleWindow.h" // Open and close console
|
||||
|
||||
#include "Debugger.h"
|
||||
#include "PBView.h"
|
||||
#include "IniFile.h"
|
||||
#include "FileUtil.h"
|
||||
#include "StringUtil.h"
|
||||
#include "FileSearch.h"
|
||||
#include "../Logging/Console.h" // open and close console
|
||||
///////////////////////////////
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Declarations and definitions
|
||||
// -------------
|
||||
extern std::vector<std::string> sMailLog, sMailTime;
|
||||
extern CDebugger* m_frame;
|
||||
///////////////////////////////
|
||||
|
||||
|
||||
// =======================================================================================
|
||||
// Update mail window
|
||||
// --------------
|
||||
void CDebugger::DoUpdateMail()
|
||||
{
|
||||
//wprintf("i %i %i\n", sFullMail.size(), sMailLog.size());
|
||||
//Console::Print("i %i %i\n", sFullMail.size(), sMailLog.size());
|
||||
|
||||
if(sFullMail.size() > 0 && sMailLog.size() > 0)
|
||||
{
|
||||
@ -69,7 +80,7 @@ void CDebugger::UpdateMail(wxNotebookEvent& event)
|
||||
// Change mail from radio button change
|
||||
void CDebugger::ChangeMail(wxCommandEvent& event)
|
||||
{
|
||||
//wprintf("abc");
|
||||
//Console::Print("abc");
|
||||
DoUpdateMail();
|
||||
//if(StoreMails) ReadDir();
|
||||
}
|
||||
@ -120,7 +131,7 @@ void CDebugger::ReadDir()
|
||||
else
|
||||
cut = pieces[0];
|
||||
|
||||
//wprintf("%s %s %s\n", pieces[0].c_str(), pieces[1].c_str(),
|
||||
//Console::Print("%s %s %s\n", pieces[0].c_str(), pieces[1].c_str(),
|
||||
// pieces[2].c_str(), pieces[3].c_str());
|
||||
|
||||
if (NoDuplicate(pieces[0]) && pieces.size() >= 3)
|
||||
@ -163,11 +174,11 @@ u32 CDebugger::CountFiles(std::string FileName)
|
||||
|
||||
for (u32 i = 0; i < all_all_files.size(); i++)
|
||||
{
|
||||
//wprintf("CountFiles %i %s\n", i, all_all_files[i].c_str());
|
||||
//Console::Print("CountFiles %i %s\n", i, all_all_files[i].c_str());
|
||||
if(all_all_files[i] == FileName)
|
||||
match++;
|
||||
}
|
||||
//wprintf("We found %i files for this game\n", match);
|
||||
//Console::Print("We found %i files for this game\n", match);
|
||||
return match;
|
||||
}
|
||||
// ==============
|
||||
@ -219,13 +230,13 @@ void CDebugger::Readfile(std::string FileName, bool GC)
|
||||
if(m_RadioBox[3]->IsItemEnabled(i)) curr_n++;
|
||||
m_RadioBox[3]->Enable(i, false); // disable all
|
||||
}
|
||||
//wprintf("Disabled all: n %i\n", n);
|
||||
//Console::Print("Disabled all: n %i\n", n);
|
||||
|
||||
|
||||
for (u32 i = 0; i < n; i++)
|
||||
{
|
||||
m_RadioBox[3]->Enable(i, true); // then anble the right ones
|
||||
//wprintf("m_RadioBox[3] enabled: %i\n", i);
|
||||
//Console::Print("m_RadioBox[3] enabled: %i\n", i);
|
||||
|
||||
std::string sz = "";
|
||||
std::ostringstream ci;
|
||||
@ -233,7 +244,7 @@ void CDebugger::Readfile(std::string FileName, bool GC)
|
||||
std::string f0 = FULL_MAIL_LOGS_DIR + FileName + "_sep" + ci.str() + "_sep" + "0_sep" + (GC ? "GC" : "Wii") + "_sep.log";
|
||||
std::string f1 = FULL_MAIL_LOGS_DIR + FileName + "_sep" + ci.str() + "_sep" + "1_sep" + (GC ? "GC" : "Wii") + "_sep.log";
|
||||
|
||||
//wprintf("ifstream %s %s\n", f0.c_str(), f1.c_str());
|
||||
//Console::Print("ifstream %s %s\n", f0.c_str(), f1.c_str());
|
||||
|
||||
if(sFullMail.size() <= i) sFullMail.resize(sFullMail.size() + 1);
|
||||
if(sMailLog.size() <= i) sMailLog.resize(sMailLog.size() + 1);
|
||||
@ -244,7 +255,7 @@ void CDebugger::Readfile(std::string FileName, bool GC)
|
||||
else sMailLog.at(i) = "";
|
||||
}
|
||||
if(n < curr_n) m_RadioBox[3]->Select(n - 1);
|
||||
//wprintf("Select: %i | n %i curr_n %i\n", n - 1, n, curr_n);
|
||||
//Console::Print("Select: %i | n %i curr_n %i\n", n - 1, n, curr_n);
|
||||
DoUpdateMail();
|
||||
}
|
||||
// ==============
|
||||
@ -278,7 +289,7 @@ void CDebugger::OnGameChange(wxCommandEvent& event)
|
||||
void CDebugger::MailSettings(wxCommandEvent& event)
|
||||
{
|
||||
//for (int i = 0; i < all_all_files.size(); ++i)
|
||||
//wprintf("s: %s \n", all_all_files.at(i).c_str());
|
||||
//Console::Print("s: %s \n", all_all_files.at(i).c_str());
|
||||
|
||||
ScanMails = m_gcwiiset->IsChecked(0);
|
||||
StoreMails = m_gcwiiset->IsChecked(1);
|
||||
|
Reference in New Issue
Block a user