Hg:
enable newline normalization get revision number via `hg svn info` for svnrev.h ignore incremental/generated binary files (windows/VS at least) leave a comment if some files need native eol set in svnprops git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5637 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
@@ -1,235 +1,235 @@
|
||||
// Copyright (C) 2003 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/
|
||||
|
||||
#include "LuaWindow.h"
|
||||
#include "LuaInterface.h"
|
||||
#include "../../Core/Src/CoreTiming.h"
|
||||
|
||||
#include <map>
|
||||
|
||||
|
||||
int wxLuaWindow::luaCount = 0;
|
||||
|
||||
// Constant Colors
|
||||
const unsigned long COLOR_GRAY = 0xDCDCDC;
|
||||
|
||||
BEGIN_EVENT_TABLE(wxLuaWindow, wxWindow)
|
||||
EVT_SIZE( wxLuaWindow::OnEvent_Window_Resize)
|
||||
EVT_CLOSE( wxLuaWindow::OnEvent_Window_Close)
|
||||
EVT_BUTTON(ID_BUTTON_CLOSE, wxLuaWindow::OnEvent_ButtonClose_Press)
|
||||
EVT_BUTTON(ID_BUTTON_LOAD, wxLuaWindow::OnEvent_ScriptLoad_Press)
|
||||
EVT_BUTTON(ID_BUTTON_RUN, wxLuaWindow::OnEvent_ScriptRun_Press)
|
||||
EVT_BUTTON(ID_BUTTON_STOP, wxLuaWindow::OnEvent_ScriptStop_Press)
|
||||
EVT_BUTTON(ID_BUTTON_CLEAR, wxLuaWindow::OnEvent_ButtonClear_Press)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
std::map<int, wxLuaWindow *> g_contextMap;
|
||||
|
||||
static int ev_LuaOpen, ev_LuaClose, ev_LuaStart, ev_LuaStop;
|
||||
|
||||
|
||||
void LuaPrint(int uid, const char *msg)
|
||||
{
|
||||
g_contextMap[uid]->PrintMessage(msg);
|
||||
}
|
||||
|
||||
void LuaStop(int uid, bool ok)
|
||||
{
|
||||
if(ok)
|
||||
g_contextMap[uid]->PrintMessage("Script completed successfully!\n");
|
||||
//else // disabled because this message makes no sense in certain contexts, and there's always an earlier error message anyway.
|
||||
// g_contextMap[uid]->PrintMessage("Script failed.\n");
|
||||
|
||||
g_contextMap[uid]->OnStop();
|
||||
}
|
||||
|
||||
wxLuaWindow::wxLuaWindow(wxFrame* parent, const wxPoint& pos, const wxSize& size) :
|
||||
wxFrame(parent, wxID_ANY, _T("Lua Script Console"), pos, size, wxDEFAULT_FRAME_STYLE | wxNO_FULL_REPAINT_ON_RESIZE)
|
||||
{
|
||||
LuaWindow_InitFirstTime();
|
||||
|
||||
// Create Lua context
|
||||
luaID = luaCount;
|
||||
luaCount++;
|
||||
CoreTiming::ScheduleEvent_Threadsafe_Immediate(ev_LuaOpen, luaID);
|
||||
g_contextMap[luaID] = this;
|
||||
bScriptRunning = false;
|
||||
|
||||
// Create the GUI controls
|
||||
InitGUIControls();
|
||||
|
||||
// Setup Window
|
||||
SetBackgroundColour(wxColour(COLOR_GRAY));
|
||||
SetSize(size);
|
||||
SetPosition(pos);
|
||||
Layout();
|
||||
Show();
|
||||
}
|
||||
|
||||
wxLuaWindow::~wxLuaWindow()
|
||||
{
|
||||
// On Disposal
|
||||
CoreTiming::ScheduleEvent_Threadsafe_Immediate(ev_LuaClose, luaID);
|
||||
g_contextMap.erase(luaID);
|
||||
}
|
||||
|
||||
void wxLuaWindow::PrintMessage(const char *text)
|
||||
{
|
||||
m_TextCtrl_Log->AppendText(wxString::FromAscii(text));
|
||||
}
|
||||
|
||||
void wxLuaWindow::InitGUIControls()
|
||||
{
|
||||
// $ Log Console
|
||||
m_Tab_Log = new wxPanel(this, ID_TAB_LOG, wxDefaultPosition, wxDefaultSize);
|
||||
m_TextCtrl_Log = new wxTextCtrl(m_Tab_Log, ID_TEXTCTRL_LOG, wxT(""), wxDefaultPosition, wxSize(100, 600),
|
||||
wxTE_MULTILINE | wxTE_READONLY | wxTE_DONTWRAP);
|
||||
wxBoxSizer *HStrip1 = new wxBoxSizer(wxHORIZONTAL);
|
||||
wxBoxSizer *sTabLog = new wxBoxSizer(wxVERTICAL);
|
||||
sTabLog->Add(HStrip1, 0, wxALL, 5);
|
||||
sTabLog->Add(m_TextCtrl_Log, 1, wxALL|wxEXPAND, 5);
|
||||
|
||||
m_Tab_Log->SetSizer(sTabLog);
|
||||
m_Tab_Log->Layout();
|
||||
|
||||
// Button Strip
|
||||
m_Button_Close = new wxButton(this, ID_BUTTON_CLOSE, _T("Close"), wxDefaultPosition, wxDefaultSize);
|
||||
m_Button_LoadScript = new wxButton(this, ID_BUTTON_LOAD, _T("Load Script..."), wxDefaultPosition, wxDefaultSize);
|
||||
m_Button_Run = new wxButton(this, ID_BUTTON_RUN, _T("Run"), wxDefaultPosition, wxDefaultSize);
|
||||
m_Button_Stop = new wxButton(this, ID_BUTTON_STOP, _T("Stop"), wxDefaultPosition, wxDefaultSize);
|
||||
m_Button_Clear = new wxButton(this, ID_BUTTON_CLEAR, _T("Clear"), wxDefaultPosition, wxDefaultSize);
|
||||
wxBoxSizer* sButtons = new wxBoxSizer(wxHORIZONTAL);
|
||||
|
||||
m_Button_Run->Disable();
|
||||
m_Button_Stop->Disable();
|
||||
|
||||
sButtons->Add(m_Button_Close, 0, wxALL, 5);
|
||||
sButtons->Add(m_Button_LoadScript, 0, wxALL, 5);
|
||||
sButtons->Add(m_Button_Run, 0, wxALL, 5);
|
||||
sButtons->Add(m_Button_Stop, 0, wxALL, 5);
|
||||
sButtons->Add(m_Button_Clear, 0, wxALL, 5);
|
||||
|
||||
wxBoxSizer* sMain = new wxBoxSizer(wxVERTICAL);
|
||||
sMain->Add(m_Tab_Log, 1, wxEXPAND|wxALL, 5);
|
||||
sMain->Add(sButtons, 0, wxALL, 5);
|
||||
SetSizer(sMain);
|
||||
Layout();
|
||||
|
||||
Fit();
|
||||
}
|
||||
|
||||
void wxLuaWindow::OnEvent_ScriptLoad_Press(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
wxString path = wxFileSelector(
|
||||
_T("Select the script to load"),
|
||||
wxEmptyString, wxEmptyString, wxEmptyString,
|
||||
wxString::Format
|
||||
(
|
||||
_T("Lua Scripts (lua)|*.lua|All files (%s)|%s"),
|
||||
wxFileSelectorDefaultWildcardStr,
|
||||
wxFileSelectorDefaultWildcardStr
|
||||
),
|
||||
wxFD_OPEN | wxFD_PREVIEW | wxFD_FILE_MUST_EXIST,
|
||||
this);
|
||||
|
||||
if(!path.IsEmpty())
|
||||
currentScript = path;
|
||||
else
|
||||
return;
|
||||
|
||||
m_TextCtrl_Log->Clear();
|
||||
m_TextCtrl_Log->AppendText(wxString::FromAscii(
|
||||
StringFromFormat("Script %s loaded successfully.\n",
|
||||
(const char *)path.mb_str()).c_str()));
|
||||
m_Button_Run->Enable();
|
||||
}
|
||||
|
||||
void wxLuaWindow::OnEvent_ScriptRun_Press(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
m_TextCtrl_Log->AppendText(wxT("Running script...\n"));
|
||||
bScriptRunning = true;
|
||||
m_Button_LoadScript->Disable();
|
||||
m_Button_Run->Disable();
|
||||
m_Button_Stop->Enable();
|
||||
|
||||
CoreTiming::ScheduleEvent_Threadsafe_Immediate(ev_LuaStart, luaID);
|
||||
}
|
||||
|
||||
void wxLuaWindow::OnEvent_ScriptStop_Press(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
CoreTiming::ScheduleEvent_Threadsafe_Immediate(ev_LuaStop, luaID);
|
||||
OnStop();
|
||||
PrintMessage("Stopping script...\n");
|
||||
}
|
||||
|
||||
void wxLuaWindow::OnStop()
|
||||
{
|
||||
bScriptRunning = false;
|
||||
m_Button_LoadScript->Enable();
|
||||
m_Button_Run->Enable();
|
||||
m_Button_Stop->Disable();
|
||||
}
|
||||
|
||||
void wxLuaWindow::OnEvent_ButtonClear_Press(wxCommandEvent& WXUNUSED (event))
|
||||
{
|
||||
m_TextCtrl_Log->Clear();
|
||||
}
|
||||
|
||||
void wxLuaWindow::OnEvent_Window_Resize(wxSizeEvent& WXUNUSED (event))
|
||||
{
|
||||
Layout();
|
||||
}
|
||||
void wxLuaWindow::OnEvent_ButtonClose_Press(wxCommandEvent& WXUNUSED (event))
|
||||
{
|
||||
Destroy();
|
||||
}
|
||||
void wxLuaWindow::OnEvent_Window_Close(wxCloseEvent& WXUNUSED (event))
|
||||
{
|
||||
Destroy();
|
||||
}
|
||||
|
||||
|
||||
// this layer of event stuff is because Lua needs to run on the CPU thread
|
||||
void wxLuaWindow::LuaOpenCallback(u64 userdata, int)
|
||||
{
|
||||
Lua::OpenLuaContext((int)userdata, LuaPrint, NULL, LuaStop);
|
||||
}
|
||||
void wxLuaWindow::LuaCloseCallback(u64 userdata, int)
|
||||
{
|
||||
Lua::CloseLuaContext((int)userdata);
|
||||
}
|
||||
void wxLuaWindow::LuaStartCallback(u64 userdata, int)
|
||||
{
|
||||
int luaID = (int)userdata;
|
||||
Lua::RunLuaScriptFile(luaID, (const char *)g_contextMap[luaID]->currentScript.mb_str());
|
||||
}
|
||||
void wxLuaWindow::LuaStopCallback(u64 userdata, int)
|
||||
{
|
||||
Lua::StopLuaScript((int)userdata);
|
||||
}
|
||||
void wxLuaWindow::LuaWindow_InitFirstTime()
|
||||
{
|
||||
static bool initialized = false;
|
||||
if(!initialized)
|
||||
{
|
||||
ev_LuaOpen = CoreTiming::RegisterEvent("LuaOpen", &wxLuaWindow::LuaOpenCallback);
|
||||
ev_LuaClose = CoreTiming::RegisterEvent("LuaClose", &wxLuaWindow::LuaCloseCallback);
|
||||
ev_LuaStart = CoreTiming::RegisterEvent("LuaStart", &wxLuaWindow::LuaStartCallback);
|
||||
ev_LuaStop = CoreTiming::RegisterEvent("LuaStop", &wxLuaWindow::LuaStopCallback);
|
||||
initialized = true;
|
||||
}
|
||||
}
|
||||
// Copyright (C) 2003 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/
|
||||
|
||||
#include "LuaWindow.h"
|
||||
#include "LuaInterface.h"
|
||||
#include "../../Core/Src/CoreTiming.h"
|
||||
|
||||
#include <map>
|
||||
|
||||
|
||||
int wxLuaWindow::luaCount = 0;
|
||||
|
||||
// Constant Colors
|
||||
const unsigned long COLOR_GRAY = 0xDCDCDC;
|
||||
|
||||
BEGIN_EVENT_TABLE(wxLuaWindow, wxWindow)
|
||||
EVT_SIZE( wxLuaWindow::OnEvent_Window_Resize)
|
||||
EVT_CLOSE( wxLuaWindow::OnEvent_Window_Close)
|
||||
EVT_BUTTON(ID_BUTTON_CLOSE, wxLuaWindow::OnEvent_ButtonClose_Press)
|
||||
EVT_BUTTON(ID_BUTTON_LOAD, wxLuaWindow::OnEvent_ScriptLoad_Press)
|
||||
EVT_BUTTON(ID_BUTTON_RUN, wxLuaWindow::OnEvent_ScriptRun_Press)
|
||||
EVT_BUTTON(ID_BUTTON_STOP, wxLuaWindow::OnEvent_ScriptStop_Press)
|
||||
EVT_BUTTON(ID_BUTTON_CLEAR, wxLuaWindow::OnEvent_ButtonClear_Press)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
std::map<int, wxLuaWindow *> g_contextMap;
|
||||
|
||||
static int ev_LuaOpen, ev_LuaClose, ev_LuaStart, ev_LuaStop;
|
||||
|
||||
|
||||
void LuaPrint(int uid, const char *msg)
|
||||
{
|
||||
g_contextMap[uid]->PrintMessage(msg);
|
||||
}
|
||||
|
||||
void LuaStop(int uid, bool ok)
|
||||
{
|
||||
if(ok)
|
||||
g_contextMap[uid]->PrintMessage("Script completed successfully!\n");
|
||||
//else // disabled because this message makes no sense in certain contexts, and there's always an earlier error message anyway.
|
||||
// g_contextMap[uid]->PrintMessage("Script failed.\n");
|
||||
|
||||
g_contextMap[uid]->OnStop();
|
||||
}
|
||||
|
||||
wxLuaWindow::wxLuaWindow(wxFrame* parent, const wxPoint& pos, const wxSize& size) :
|
||||
wxFrame(parent, wxID_ANY, _T("Lua Script Console"), pos, size, wxDEFAULT_FRAME_STYLE | wxNO_FULL_REPAINT_ON_RESIZE)
|
||||
{
|
||||
LuaWindow_InitFirstTime();
|
||||
|
||||
// Create Lua context
|
||||
luaID = luaCount;
|
||||
luaCount++;
|
||||
CoreTiming::ScheduleEvent_Threadsafe_Immediate(ev_LuaOpen, luaID);
|
||||
g_contextMap[luaID] = this;
|
||||
bScriptRunning = false;
|
||||
|
||||
// Create the GUI controls
|
||||
InitGUIControls();
|
||||
|
||||
// Setup Window
|
||||
SetBackgroundColour(wxColour(COLOR_GRAY));
|
||||
SetSize(size);
|
||||
SetPosition(pos);
|
||||
Layout();
|
||||
Show();
|
||||
}
|
||||
|
||||
wxLuaWindow::~wxLuaWindow()
|
||||
{
|
||||
// On Disposal
|
||||
CoreTiming::ScheduleEvent_Threadsafe_Immediate(ev_LuaClose, luaID);
|
||||
g_contextMap.erase(luaID);
|
||||
}
|
||||
|
||||
void wxLuaWindow::PrintMessage(const char *text)
|
||||
{
|
||||
m_TextCtrl_Log->AppendText(wxString::FromAscii(text));
|
||||
}
|
||||
|
||||
void wxLuaWindow::InitGUIControls()
|
||||
{
|
||||
// $ Log Console
|
||||
m_Tab_Log = new wxPanel(this, ID_TAB_LOG, wxDefaultPosition, wxDefaultSize);
|
||||
m_TextCtrl_Log = new wxTextCtrl(m_Tab_Log, ID_TEXTCTRL_LOG, wxT(""), wxDefaultPosition, wxSize(100, 600),
|
||||
wxTE_MULTILINE | wxTE_READONLY | wxTE_DONTWRAP);
|
||||
wxBoxSizer *HStrip1 = new wxBoxSizer(wxHORIZONTAL);
|
||||
wxBoxSizer *sTabLog = new wxBoxSizer(wxVERTICAL);
|
||||
sTabLog->Add(HStrip1, 0, wxALL, 5);
|
||||
sTabLog->Add(m_TextCtrl_Log, 1, wxALL|wxEXPAND, 5);
|
||||
|
||||
m_Tab_Log->SetSizer(sTabLog);
|
||||
m_Tab_Log->Layout();
|
||||
|
||||
// Button Strip
|
||||
m_Button_Close = new wxButton(this, ID_BUTTON_CLOSE, _T("Close"), wxDefaultPosition, wxDefaultSize);
|
||||
m_Button_LoadScript = new wxButton(this, ID_BUTTON_LOAD, _T("Load Script..."), wxDefaultPosition, wxDefaultSize);
|
||||
m_Button_Run = new wxButton(this, ID_BUTTON_RUN, _T("Run"), wxDefaultPosition, wxDefaultSize);
|
||||
m_Button_Stop = new wxButton(this, ID_BUTTON_STOP, _T("Stop"), wxDefaultPosition, wxDefaultSize);
|
||||
m_Button_Clear = new wxButton(this, ID_BUTTON_CLEAR, _T("Clear"), wxDefaultPosition, wxDefaultSize);
|
||||
wxBoxSizer* sButtons = new wxBoxSizer(wxHORIZONTAL);
|
||||
|
||||
m_Button_Run->Disable();
|
||||
m_Button_Stop->Disable();
|
||||
|
||||
sButtons->Add(m_Button_Close, 0, wxALL, 5);
|
||||
sButtons->Add(m_Button_LoadScript, 0, wxALL, 5);
|
||||
sButtons->Add(m_Button_Run, 0, wxALL, 5);
|
||||
sButtons->Add(m_Button_Stop, 0, wxALL, 5);
|
||||
sButtons->Add(m_Button_Clear, 0, wxALL, 5);
|
||||
|
||||
wxBoxSizer* sMain = new wxBoxSizer(wxVERTICAL);
|
||||
sMain->Add(m_Tab_Log, 1, wxEXPAND|wxALL, 5);
|
||||
sMain->Add(sButtons, 0, wxALL, 5);
|
||||
SetSizer(sMain);
|
||||
Layout();
|
||||
|
||||
Fit();
|
||||
}
|
||||
|
||||
void wxLuaWindow::OnEvent_ScriptLoad_Press(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
wxString path = wxFileSelector(
|
||||
_T("Select the script to load"),
|
||||
wxEmptyString, wxEmptyString, wxEmptyString,
|
||||
wxString::Format
|
||||
(
|
||||
_T("Lua Scripts (lua)|*.lua|All files (%s)|%s"),
|
||||
wxFileSelectorDefaultWildcardStr,
|
||||
wxFileSelectorDefaultWildcardStr
|
||||
),
|
||||
wxFD_OPEN | wxFD_PREVIEW | wxFD_FILE_MUST_EXIST,
|
||||
this);
|
||||
|
||||
if(!path.IsEmpty())
|
||||
currentScript = path;
|
||||
else
|
||||
return;
|
||||
|
||||
m_TextCtrl_Log->Clear();
|
||||
m_TextCtrl_Log->AppendText(wxString::FromAscii(
|
||||
StringFromFormat("Script %s loaded successfully.\n",
|
||||
(const char *)path.mb_str()).c_str()));
|
||||
m_Button_Run->Enable();
|
||||
}
|
||||
|
||||
void wxLuaWindow::OnEvent_ScriptRun_Press(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
m_TextCtrl_Log->AppendText(wxT("Running script...\n"));
|
||||
bScriptRunning = true;
|
||||
m_Button_LoadScript->Disable();
|
||||
m_Button_Run->Disable();
|
||||
m_Button_Stop->Enable();
|
||||
|
||||
CoreTiming::ScheduleEvent_Threadsafe_Immediate(ev_LuaStart, luaID);
|
||||
}
|
||||
|
||||
void wxLuaWindow::OnEvent_ScriptStop_Press(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
CoreTiming::ScheduleEvent_Threadsafe_Immediate(ev_LuaStop, luaID);
|
||||
OnStop();
|
||||
PrintMessage("Stopping script...\n");
|
||||
}
|
||||
|
||||
void wxLuaWindow::OnStop()
|
||||
{
|
||||
bScriptRunning = false;
|
||||
m_Button_LoadScript->Enable();
|
||||
m_Button_Run->Enable();
|
||||
m_Button_Stop->Disable();
|
||||
}
|
||||
|
||||
void wxLuaWindow::OnEvent_ButtonClear_Press(wxCommandEvent& WXUNUSED (event))
|
||||
{
|
||||
m_TextCtrl_Log->Clear();
|
||||
}
|
||||
|
||||
void wxLuaWindow::OnEvent_Window_Resize(wxSizeEvent& WXUNUSED (event))
|
||||
{
|
||||
Layout();
|
||||
}
|
||||
void wxLuaWindow::OnEvent_ButtonClose_Press(wxCommandEvent& WXUNUSED (event))
|
||||
{
|
||||
Destroy();
|
||||
}
|
||||
void wxLuaWindow::OnEvent_Window_Close(wxCloseEvent& WXUNUSED (event))
|
||||
{
|
||||
Destroy();
|
||||
}
|
||||
|
||||
|
||||
// this layer of event stuff is because Lua needs to run on the CPU thread
|
||||
void wxLuaWindow::LuaOpenCallback(u64 userdata, int)
|
||||
{
|
||||
Lua::OpenLuaContext((int)userdata, LuaPrint, NULL, LuaStop);
|
||||
}
|
||||
void wxLuaWindow::LuaCloseCallback(u64 userdata, int)
|
||||
{
|
||||
Lua::CloseLuaContext((int)userdata);
|
||||
}
|
||||
void wxLuaWindow::LuaStartCallback(u64 userdata, int)
|
||||
{
|
||||
int luaID = (int)userdata;
|
||||
Lua::RunLuaScriptFile(luaID, (const char *)g_contextMap[luaID]->currentScript.mb_str());
|
||||
}
|
||||
void wxLuaWindow::LuaStopCallback(u64 userdata, int)
|
||||
{
|
||||
Lua::StopLuaScript((int)userdata);
|
||||
}
|
||||
void wxLuaWindow::LuaWindow_InitFirstTime()
|
||||
{
|
||||
static bool initialized = false;
|
||||
if(!initialized)
|
||||
{
|
||||
ev_LuaOpen = CoreTiming::RegisterEvent("LuaOpen", &wxLuaWindow::LuaOpenCallback);
|
||||
ev_LuaClose = CoreTiming::RegisterEvent("LuaClose", &wxLuaWindow::LuaCloseCallback);
|
||||
ev_LuaStart = CoreTiming::RegisterEvent("LuaStart", &wxLuaWindow::LuaStartCallback);
|
||||
ev_LuaStop = CoreTiming::RegisterEvent("LuaStop", &wxLuaWindow::LuaStopCallback);
|
||||
initialized = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,105 +1,105 @@
|
||||
// Copyright (C) 2003 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/
|
||||
|
||||
#ifndef __LUAWINDOW_H__
|
||||
#define __LUAWINDOW_H__
|
||||
|
||||
#include <wx/wx.h>
|
||||
#include <wx/sizer.h>
|
||||
#include <wx/filepicker.h>
|
||||
#include <wx/statbmp.h>
|
||||
#include <wx/imaglist.h>
|
||||
#include <wx/treectrl.h>
|
||||
#include <wx/gbsizer.h>
|
||||
#include <wx/notebook.h>
|
||||
#include <wx/mimetype.h>
|
||||
#include <wx/colour.h>
|
||||
#include <wx/listbox.h>
|
||||
#include <string>
|
||||
|
||||
#include "Filesystem.h"
|
||||
#include "IniFile.h"
|
||||
|
||||
class wxLuaWindow : public wxFrame
|
||||
{
|
||||
public:
|
||||
|
||||
wxLuaWindow(wxFrame* parent, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize);
|
||||
|
||||
void PrintMessage(const char *text);
|
||||
|
||||
void OnStop();
|
||||
|
||||
virtual ~wxLuaWindow();
|
||||
|
||||
protected:
|
||||
static int luaCount;
|
||||
int luaID;
|
||||
bool bScriptRunning;
|
||||
wxString currentScript;
|
||||
|
||||
// Event Table
|
||||
DECLARE_EVENT_TABLE();
|
||||
|
||||
// --- GUI Controls ---
|
||||
|
||||
wxPanel *m_Tab_Log;
|
||||
|
||||
wxButton *m_Button_Close, *m_Button_LoadScript, *m_Button_Run,
|
||||
*m_Button_Stop, *m_Button_Clear;
|
||||
|
||||
wxTextCtrl *m_TextCtrl_Log;
|
||||
|
||||
// GUI IDs
|
||||
enum
|
||||
{
|
||||
ID_TAB_LOG,
|
||||
ID_BUTTON_CLOSE,
|
||||
ID_BUTTON_LOAD,
|
||||
ID_BUTTON_RUN,
|
||||
ID_BUTTON_STOP,
|
||||
ID_BUTTON_CLEAR,
|
||||
ID_TEXTCTRL_LOG
|
||||
};
|
||||
|
||||
void InitGUIControls();
|
||||
|
||||
|
||||
// --- Wx Events Handlers ---
|
||||
// $ Window
|
||||
void OnEvent_Window_Resize(wxSizeEvent& event);
|
||||
void OnEvent_Window_Close(wxCloseEvent& event);
|
||||
|
||||
// $ Buttons
|
||||
void OnEvent_ButtonClose_Press(wxCommandEvent& event);
|
||||
void OnEvent_ScriptLoad_Press(wxCommandEvent& event);
|
||||
void OnEvent_ScriptRun_Press(wxCommandEvent& event);
|
||||
void OnEvent_ScriptStop_Press(wxCommandEvent& event);
|
||||
void OnEvent_ButtonClear_Press(wxCommandEvent& event);
|
||||
|
||||
// -- CoreTiming-style event handlers --
|
||||
static void LuaOpenCallback(u64 userdata, int cyclesLate);
|
||||
static void LuaCloseCallback(u64 userdata, int cyclesLate);
|
||||
static void LuaStartCallback(u64 userdata, int cyclesLate);
|
||||
static void LuaStopCallback(u64 userdata, int cyclesLate);
|
||||
|
||||
static void LuaWindow_InitFirstTime();
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
// Copyright (C) 2003 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/
|
||||
|
||||
#ifndef __LUAWINDOW_H__
|
||||
#define __LUAWINDOW_H__
|
||||
|
||||
#include <wx/wx.h>
|
||||
#include <wx/sizer.h>
|
||||
#include <wx/filepicker.h>
|
||||
#include <wx/statbmp.h>
|
||||
#include <wx/imaglist.h>
|
||||
#include <wx/treectrl.h>
|
||||
#include <wx/gbsizer.h>
|
||||
#include <wx/notebook.h>
|
||||
#include <wx/mimetype.h>
|
||||
#include <wx/colour.h>
|
||||
#include <wx/listbox.h>
|
||||
#include <string>
|
||||
|
||||
#include "Filesystem.h"
|
||||
#include "IniFile.h"
|
||||
|
||||
class wxLuaWindow : public wxFrame
|
||||
{
|
||||
public:
|
||||
|
||||
wxLuaWindow(wxFrame* parent, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize);
|
||||
|
||||
void PrintMessage(const char *text);
|
||||
|
||||
void OnStop();
|
||||
|
||||
virtual ~wxLuaWindow();
|
||||
|
||||
protected:
|
||||
static int luaCount;
|
||||
int luaID;
|
||||
bool bScriptRunning;
|
||||
wxString currentScript;
|
||||
|
||||
// Event Table
|
||||
DECLARE_EVENT_TABLE();
|
||||
|
||||
// --- GUI Controls ---
|
||||
|
||||
wxPanel *m_Tab_Log;
|
||||
|
||||
wxButton *m_Button_Close, *m_Button_LoadScript, *m_Button_Run,
|
||||
*m_Button_Stop, *m_Button_Clear;
|
||||
|
||||
wxTextCtrl *m_TextCtrl_Log;
|
||||
|
||||
// GUI IDs
|
||||
enum
|
||||
{
|
||||
ID_TAB_LOG,
|
||||
ID_BUTTON_CLOSE,
|
||||
ID_BUTTON_LOAD,
|
||||
ID_BUTTON_RUN,
|
||||
ID_BUTTON_STOP,
|
||||
ID_BUTTON_CLEAR,
|
||||
ID_TEXTCTRL_LOG
|
||||
};
|
||||
|
||||
void InitGUIControls();
|
||||
|
||||
|
||||
// --- Wx Events Handlers ---
|
||||
// $ Window
|
||||
void OnEvent_Window_Resize(wxSizeEvent& event);
|
||||
void OnEvent_Window_Close(wxCloseEvent& event);
|
||||
|
||||
// $ Buttons
|
||||
void OnEvent_ButtonClose_Press(wxCommandEvent& event);
|
||||
void OnEvent_ScriptLoad_Press(wxCommandEvent& event);
|
||||
void OnEvent_ScriptRun_Press(wxCommandEvent& event);
|
||||
void OnEvent_ScriptStop_Press(wxCommandEvent& event);
|
||||
void OnEvent_ButtonClear_Press(wxCommandEvent& event);
|
||||
|
||||
// -- CoreTiming-style event handlers --
|
||||
static void LuaOpenCallback(u64 userdata, int cyclesLate);
|
||||
static void LuaCloseCallback(u64 userdata, int cyclesLate);
|
||||
static void LuaStartCallback(u64 userdata, int cyclesLate);
|
||||
static void LuaStopCallback(u64 userdata, int cyclesLate);
|
||||
|
||||
static void LuaWindow_InitFirstTime();
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,154 +1,154 @@
|
||||
// Copyright (C) 2003 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/
|
||||
|
||||
#ifndef _WII_SAVE_CRYPTED
|
||||
#define _WII_SAVE_CRYPTED
|
||||
|
||||
#include "AES/aes.h"
|
||||
#include "StringUtil.h"
|
||||
#include "Crypto/tools.h"
|
||||
#include "Crypto/md5.h"
|
||||
|
||||
// --- this is used for encrypted Wii save files
|
||||
|
||||
|
||||
|
||||
class CWiiSaveCrypted
|
||||
{
|
||||
public:
|
||||
CWiiSaveCrypted(const char* FileName, u64 title = 0);
|
||||
~CWiiSaveCrypted();
|
||||
void ReadHDR();
|
||||
void ReadBKHDR();
|
||||
void WriteHDR();
|
||||
void WriteBKHDR();
|
||||
void Extract(){;}
|
||||
void ImportWiiSaveFiles();
|
||||
void ExportWiiSaveFiles(); // To data.bin
|
||||
void do_sig();
|
||||
void make_ec_cert(u8 *cert, u8 *sig, char *signer, char *name, u8 *priv,
|
||||
u32 key_id);
|
||||
bool getPaths(bool _export = false);
|
||||
void ScanForFiles(std::string savDir, std::vector<std::string>&FilesList, u32 *_numFiles, u32 *_sizeFiles);
|
||||
|
||||
private:
|
||||
AES_KEY m_AES_KEY;
|
||||
u8 SD_IV[0x10];
|
||||
std::vector<std::string> FilesList;
|
||||
|
||||
FILE *fpData_bin,
|
||||
*fpBanner_bin,
|
||||
*fpRawSaveFile;
|
||||
|
||||
char pathData_bin[2048],
|
||||
pathSavedir[2048],
|
||||
pathBanner_bin[2048], //should always be FULL_WII_USER_DIR "title/%08x/%08x/data/"
|
||||
pathRawSave[2048],
|
||||
_saveGameString[5];
|
||||
|
||||
u8 IV[0x10],
|
||||
*_encryptedData,
|
||||
*_data,
|
||||
md5_file[16],
|
||||
md5_calc[16];
|
||||
|
||||
u32 _bannerSize,
|
||||
_numberOfFiles,
|
||||
_sizeOfFiles,
|
||||
_totalSize,
|
||||
_fileSize,
|
||||
_roundedfileSize;
|
||||
|
||||
u64 _saveGameTitle;
|
||||
|
||||
bool b_valid,
|
||||
b_tryAgain;
|
||||
|
||||
enum
|
||||
{
|
||||
BLOCK_SZ = 0x40,
|
||||
HDR_SZ = 0x20,
|
||||
ICON_SZ = 0x1200,
|
||||
BNR_SZ = 0x60a0,
|
||||
FULL_BNR_MIN = 0x72a0, // BNR_SZ + 1*ICON_SZ
|
||||
FULL_BNR_MAX = 0xF0A0, // BNR_SZ + 8*ICON_SZ
|
||||
HEADER_SZ = 0xF0C0, // HDR_SZ + FULL_BNR_MAX
|
||||
BK_LISTED_SZ = 0x70, // Size before rounding to nearest block
|
||||
BK_SZ = 0x80,
|
||||
FILE_HDR_SZ = 0x80,
|
||||
|
||||
SIG_SZ = 0x40,
|
||||
NG_CERT_SZ = 0x180,
|
||||
AP_CERT_SZ = 0x180,
|
||||
FULL_CERT_SZ = 0x3C0, // SIG_SZ + NG_CERT_SZ + AP_CERT_SZ + 0x80?
|
||||
|
||||
|
||||
BK_HDR_MAGIC = 0x426B0001,
|
||||
FILE_HDR_MAGIC = 0x03adf17e
|
||||
};
|
||||
|
||||
#pragma pack(push,1)
|
||||
|
||||
struct Data_Bin_HDR // encrypted
|
||||
{
|
||||
u64 SaveGameTitle;
|
||||
u32 BannerSize; // (0x72A0 or 0xF0A0, also seen 0xBAA0)
|
||||
u8 Permissions;
|
||||
u8 unk1; // maybe permissions is a be16
|
||||
u8 Md5[0x10]; // md5 of plaintext header with md5 blanker applied
|
||||
u16 unk2;
|
||||
};
|
||||
|
||||
struct HEADER
|
||||
{
|
||||
Data_Bin_HDR hdr;
|
||||
u8 BNR[FULL_BNR_MAX];
|
||||
}_header, _encryptedHeader;
|
||||
|
||||
struct BK_Header // Not encrypted
|
||||
{
|
||||
u32 size; // 0x00000070
|
||||
// u16 magic; // 'Bk'
|
||||
// u16 magic2; // or version (0x0001)
|
||||
u32 magic; // 0x426B0001
|
||||
u32 NGid;
|
||||
u32 numberOfFiles;
|
||||
u32 sizeOfFiles;
|
||||
u32 unk1;
|
||||
u32 unk2;
|
||||
u32 totalSize;
|
||||
u8 unk3[64];
|
||||
u64 SaveGameTitle;
|
||||
u8 MACaddress[6];
|
||||
u8 padding[0x12];
|
||||
}bkhdr;
|
||||
|
||||
struct FileHDR // encrypted
|
||||
{
|
||||
u32 magic; //0x03adf17e
|
||||
u32 size;
|
||||
u8 Permissions;
|
||||
u8 attrib;
|
||||
u8 type; // (1=file, 2=directory)
|
||||
u8 name[0x45];
|
||||
u8 IV[0x10];
|
||||
u8 unk[0x20];
|
||||
};
|
||||
#pragma pack(pop)
|
||||
};
|
||||
|
||||
#endif
|
||||
// Copyright (C) 2003 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/
|
||||
|
||||
#ifndef _WII_SAVE_CRYPTED
|
||||
#define _WII_SAVE_CRYPTED
|
||||
|
||||
#include "AES/aes.h"
|
||||
#include "StringUtil.h"
|
||||
#include "Crypto/tools.h"
|
||||
#include "Crypto/md5.h"
|
||||
|
||||
// --- this is used for encrypted Wii save files
|
||||
|
||||
|
||||
|
||||
class CWiiSaveCrypted
|
||||
{
|
||||
public:
|
||||
CWiiSaveCrypted(const char* FileName, u64 title = 0);
|
||||
~CWiiSaveCrypted();
|
||||
void ReadHDR();
|
||||
void ReadBKHDR();
|
||||
void WriteHDR();
|
||||
void WriteBKHDR();
|
||||
void Extract(){;}
|
||||
void ImportWiiSaveFiles();
|
||||
void ExportWiiSaveFiles(); // To data.bin
|
||||
void do_sig();
|
||||
void make_ec_cert(u8 *cert, u8 *sig, char *signer, char *name, u8 *priv,
|
||||
u32 key_id);
|
||||
bool getPaths(bool _export = false);
|
||||
void ScanForFiles(std::string savDir, std::vector<std::string>&FilesList, u32 *_numFiles, u32 *_sizeFiles);
|
||||
|
||||
private:
|
||||
AES_KEY m_AES_KEY;
|
||||
u8 SD_IV[0x10];
|
||||
std::vector<std::string> FilesList;
|
||||
|
||||
FILE *fpData_bin,
|
||||
*fpBanner_bin,
|
||||
*fpRawSaveFile;
|
||||
|
||||
char pathData_bin[2048],
|
||||
pathSavedir[2048],
|
||||
pathBanner_bin[2048], //should always be FULL_WII_USER_DIR "title/%08x/%08x/data/"
|
||||
pathRawSave[2048],
|
||||
_saveGameString[5];
|
||||
|
||||
u8 IV[0x10],
|
||||
*_encryptedData,
|
||||
*_data,
|
||||
md5_file[16],
|
||||
md5_calc[16];
|
||||
|
||||
u32 _bannerSize,
|
||||
_numberOfFiles,
|
||||
_sizeOfFiles,
|
||||
_totalSize,
|
||||
_fileSize,
|
||||
_roundedfileSize;
|
||||
|
||||
u64 _saveGameTitle;
|
||||
|
||||
bool b_valid,
|
||||
b_tryAgain;
|
||||
|
||||
enum
|
||||
{
|
||||
BLOCK_SZ = 0x40,
|
||||
HDR_SZ = 0x20,
|
||||
ICON_SZ = 0x1200,
|
||||
BNR_SZ = 0x60a0,
|
||||
FULL_BNR_MIN = 0x72a0, // BNR_SZ + 1*ICON_SZ
|
||||
FULL_BNR_MAX = 0xF0A0, // BNR_SZ + 8*ICON_SZ
|
||||
HEADER_SZ = 0xF0C0, // HDR_SZ + FULL_BNR_MAX
|
||||
BK_LISTED_SZ = 0x70, // Size before rounding to nearest block
|
||||
BK_SZ = 0x80,
|
||||
FILE_HDR_SZ = 0x80,
|
||||
|
||||
SIG_SZ = 0x40,
|
||||
NG_CERT_SZ = 0x180,
|
||||
AP_CERT_SZ = 0x180,
|
||||
FULL_CERT_SZ = 0x3C0, // SIG_SZ + NG_CERT_SZ + AP_CERT_SZ + 0x80?
|
||||
|
||||
|
||||
BK_HDR_MAGIC = 0x426B0001,
|
||||
FILE_HDR_MAGIC = 0x03adf17e
|
||||
};
|
||||
|
||||
#pragma pack(push,1)
|
||||
|
||||
struct Data_Bin_HDR // encrypted
|
||||
{
|
||||
u64 SaveGameTitle;
|
||||
u32 BannerSize; // (0x72A0 or 0xF0A0, also seen 0xBAA0)
|
||||
u8 Permissions;
|
||||
u8 unk1; // maybe permissions is a be16
|
||||
u8 Md5[0x10]; // md5 of plaintext header with md5 blanker applied
|
||||
u16 unk2;
|
||||
};
|
||||
|
||||
struct HEADER
|
||||
{
|
||||
Data_Bin_HDR hdr;
|
||||
u8 BNR[FULL_BNR_MAX];
|
||||
}_header, _encryptedHeader;
|
||||
|
||||
struct BK_Header // Not encrypted
|
||||
{
|
||||
u32 size; // 0x00000070
|
||||
// u16 magic; // 'Bk'
|
||||
// u16 magic2; // or version (0x0001)
|
||||
u32 magic; // 0x426B0001
|
||||
u32 NGid;
|
||||
u32 numberOfFiles;
|
||||
u32 sizeOfFiles;
|
||||
u32 unk1;
|
||||
u32 unk2;
|
||||
u32 totalSize;
|
||||
u8 unk3[64];
|
||||
u64 SaveGameTitle;
|
||||
u8 MACaddress[6];
|
||||
u8 padding[0x12];
|
||||
}bkhdr;
|
||||
|
||||
struct FileHDR // encrypted
|
||||
{
|
||||
u32 magic; //0x03adf17e
|
||||
u32 size;
|
||||
u8 Permissions;
|
||||
u8 attrib;
|
||||
u8 type; // (1=file, 2=directory)
|
||||
u8 name[0x45];
|
||||
u8 IV[0x10];
|
||||
u8 unk[0x20];
|
||||
};
|
||||
#pragma pack(pop)
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user