mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 06:09:50 -06:00
Lua now has GUI and is fully functional! But it doesn't link if I don't ignore libcmt.lib so commented all the LuaInterface calls until someone fixes it...
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4510 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
@ -17,7 +17,6 @@
|
|||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <algorithm>
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include "zlib.h"
|
#include "zlib.h"
|
||||||
|
|
||||||
@ -78,12 +77,12 @@ namespace Lua {
|
|||||||
//extern void UpdateLagCount();
|
//extern void UpdateLagCount();
|
||||||
//extern bool Step_emulua_MainLoop(bool allowSleep, bool allowEmulate);
|
//extern bool Step_emulua_MainLoop(bool allowSleep, bool allowEmulate);
|
||||||
|
|
||||||
extern int disableSound2, disableRamSearchUpdate;
|
int disableSound2, disableRamSearchUpdate;
|
||||||
extern bool BackgroundInput;
|
bool BackgroundInput;
|
||||||
extern bool g_disableStatestateWarnings;
|
bool g_disableStatestateWarnings;
|
||||||
extern bool g_onlyCallSavestateCallbacks;
|
bool g_onlyCallSavestateCallbacks;
|
||||||
extern bool frameadvSkipLagForceDisable;
|
bool frameadvSkipLagForceDisable;
|
||||||
extern bool SkipNextRerecordIncrement;
|
bool SkipNextRerecordIncrement;
|
||||||
|
|
||||||
enum SpeedMode
|
enum SpeedMode
|
||||||
{
|
{
|
||||||
@ -1338,7 +1337,7 @@ DEFINE_LUA_FUNCTION(emulua_speedmode, "mode")
|
|||||||
info.speedMode = newSpeedMode;
|
info.speedMode = newSpeedMode;
|
||||||
RefreshScriptSpeedStatus();
|
RefreshScriptSpeedStatus();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
// tells emulua to wait while the script is doing calculations
|
// tells emulua to wait while the script is doing calculations
|
||||||
// can call this periodically instead of emulua.frameadvance
|
// can call this periodically instead of emulua.frameadvance
|
||||||
@ -1346,7 +1345,7 @@ DEFINE_LUA_FUNCTION(emulua_speedmode, "mode")
|
|||||||
// (e.g. a savestate could possibly get loaded before emulua.wait() returns)
|
// (e.g. a savestate could possibly get loaded before emulua.wait() returns)
|
||||||
DEFINE_LUA_FUNCTION(emulua_wait, "")
|
DEFINE_LUA_FUNCTION(emulua_wait, "")
|
||||||
{
|
{
|
||||||
LuaContextInfo& info = GetCurrentInfo();
|
/*LuaContextInfo& info = GetCurrentInfo();
|
||||||
|
|
||||||
switch(info.speedMode)
|
switch(info.speedMode)
|
||||||
{
|
{
|
||||||
@ -1359,11 +1358,11 @@ DEFINE_LUA_FUNCTION(emulua_wait, "")
|
|||||||
case SPEEDMODE_MAXIMUM:
|
case SPEEDMODE_MAXIMUM:
|
||||||
Step_emulua_MainLoop(Core::GetState() == Core::CORE_PAUSE, false);
|
Step_emulua_MainLoop(Core::GetState() == Core::CORE_PAUSE, false);
|
||||||
break;
|
break;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
DEFINE_LUA_FUNCTION(emulua_frameadvance, "")
|
DEFINE_LUA_FUNCTION(emulua_frameadvance, "")
|
||||||
{
|
{
|
||||||
@ -1373,9 +1372,13 @@ DEFINE_LUA_FUNCTION(emulua_frameadvance, "")
|
|||||||
int uid = luaStateToUIDMap[L];
|
int uid = luaStateToUIDMap[L];
|
||||||
LuaContextInfo& info = GetCurrentInfo();
|
LuaContextInfo& info = GetCurrentInfo();
|
||||||
|
|
||||||
info.ranFrameAdvance = !info.ranFrameAdvance;
|
if(!info.ranFrameAdvance) {
|
||||||
|
info.ranFrameAdvance = true;
|
||||||
|
Frame::SetFrameStepping(info.ranFrameAdvance);
|
||||||
|
}
|
||||||
|
|
||||||
Frame::SetFrameStepping(info.ranFrameAdvance);
|
// Should step exactly one frame
|
||||||
|
Core::SetState(Core::CORE_RUN);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -2707,13 +2710,14 @@ static void GetCurrentScriptDir(char* buffer, int bufLen)
|
|||||||
|
|
||||||
DEFINE_LUA_FUNCTION(emu_openscript, "filename")
|
DEFINE_LUA_FUNCTION(emu_openscript, "filename")
|
||||||
{
|
{
|
||||||
char curScriptDir[1024]; GetCurrentScriptDir(curScriptDir, 1024); // make sure we can always find scripts that are in the same directory as the current script
|
/*char curScriptDir[1024]; GetCurrentScriptDir(curScriptDir, 1024); // make sure we can always find scripts that are in the same directory as the current script
|
||||||
const char* filename = lua_isstring(L,1) ? lua_tostring(L,1) : NULL;
|
const char* filename = lua_isstring(L,1) ? lua_tostring(L,1) : NULL;
|
||||||
extern const char* OpenLuaScript(const char* filename, const char* extraDirToCheck, bool makeSubservient);
|
extern const char* OpenLuaScript(const char* filename, const char* extraDirToCheck, bool makeSubservient);
|
||||||
const char* errorMsg = OpenLuaScript(filename, curScriptDir, true);
|
const char* errorMsg = OpenLuaScript(filename, curScriptDir, true);
|
||||||
if(errorMsg)
|
if(errorMsg)
|
||||||
luaL_error(L, errorMsg);
|
luaL_error(L, errorMsg);*/
|
||||||
return 0;
|
luaL_error(L, "ERROR: emu_openscript not implemented");
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEFINE_LUA_FUNCTION(emulua_loadrom, "filename")
|
DEFINE_LUA_FUNCTION(emulua_loadrom, "filename")
|
||||||
@ -3563,9 +3567,7 @@ void StopScriptIfFinished(int uid, bool justReturned)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(info.print)
|
if(!info.print)
|
||||||
info.print(uid, "script finished running\r\n");
|
|
||||||
else
|
|
||||||
fprintf(stderr, "%s\n", "script finished running");
|
fprintf(stderr, "%s\n", "script finished running");
|
||||||
|
|
||||||
StopLuaScript(uid);
|
StopLuaScript(uid);
|
||||||
|
@ -97,7 +97,7 @@ private:
|
|||||||
// disallowed, it's dangerous to call this
|
// disallowed, it's dangerous to call this
|
||||||
// (because the memory the destructor deletes isn't refcounted and shouldn't need to be copied)
|
// (because the memory the destructor deletes isn't refcounted and shouldn't need to be copied)
|
||||||
// so pass LuaSaveDatas by reference and this should never get called
|
// so pass LuaSaveDatas by reference and this should never get called
|
||||||
LuaSaveData(const LuaSaveData& copy) {}
|
LuaSaveData(const LuaSaveData& ) {}
|
||||||
};
|
};
|
||||||
void CallRegisteredLuaSaveFunctions(int savestateNumber, LuaSaveData& saveData);
|
void CallRegisteredLuaSaveFunctions(int savestateNumber, LuaSaveData& saveData);
|
||||||
void CallRegisteredLuaLoadFunctions(int savestateNumber, const LuaSaveData& saveData);
|
void CallRegisteredLuaLoadFunctions(int savestateNumber, const LuaSaveData& saveData);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="Windows-1252"?>
|
<?xml version="1.0" encoding="Windows-1252"?>
|
||||||
<VisualStudioProject
|
<VisualStudioProject
|
||||||
ProjectType="Visual C++"
|
ProjectType="Visual C++"
|
||||||
Version="9,00"
|
Version="9.00"
|
||||||
Name="Dolphin"
|
Name="Dolphin"
|
||||||
ProjectGUID="{A72606EF-C5C1-4954-90AD-F0F93A8D97D9}"
|
ProjectGUID="{A72606EF-C5C1-4954-90AD-F0F93A8D97D9}"
|
||||||
RootNamespace="DolphinWX"
|
RootNamespace="DolphinWX"
|
||||||
@ -212,6 +212,8 @@
|
|||||||
LinkIncremental="1"
|
LinkIncremental="1"
|
||||||
SuppressStartupBanner="true"
|
SuppressStartupBanner="true"
|
||||||
AdditionalLibraryDirectories="$(SolutionDir)\$(ConfigurationName)\$(PlatformName);..\..\..\Externals\wxWidgets\lib\vc_lib\$(PlatformName)"
|
AdditionalLibraryDirectories="$(SolutionDir)\$(ConfigurationName)\$(PlatformName);..\..\..\Externals\wxWidgets\lib\vc_lib\$(PlatformName)"
|
||||||
|
IgnoreAllDefaultLibraries="false"
|
||||||
|
IgnoreDefaultLibraryNames=""
|
||||||
GenerateDebugInformation="true"
|
GenerateDebugInformation="true"
|
||||||
ProgramDatabaseFile="$(PlatformName)\$(ConfigurationName)\$(TargetName).pdb"
|
ProgramDatabaseFile="$(PlatformName)\$(ConfigurationName)\$(TargetName).pdb"
|
||||||
SubSystem="2"
|
SubSystem="2"
|
||||||
@ -548,6 +550,7 @@
|
|||||||
LinkIncremental="1"
|
LinkIncremental="1"
|
||||||
SuppressStartupBanner="true"
|
SuppressStartupBanner="true"
|
||||||
AdditionalLibraryDirectories=""$(SolutionDir)\Release\$(PlatformName)";"..\..\..\Externals\wxWidgets\lib\vc_lib\$(PlatformName)""
|
AdditionalLibraryDirectories=""$(SolutionDir)\Release\$(PlatformName)";"..\..\..\Externals\wxWidgets\lib\vc_lib\$(PlatformName)""
|
||||||
|
IgnoreDefaultLibraryNames=""
|
||||||
GenerateDebugInformation="true"
|
GenerateDebugInformation="true"
|
||||||
ProgramDatabaseFile="$(PlatformName)\$(ConfigurationName)\$(TargetName).pdb"
|
ProgramDatabaseFile="$(PlatformName)\$(ConfigurationName)\$(TargetName).pdb"
|
||||||
SubSystem="2"
|
SubSystem="2"
|
||||||
@ -660,6 +663,7 @@
|
|||||||
LinkIncremental="1"
|
LinkIncremental="1"
|
||||||
SuppressStartupBanner="true"
|
SuppressStartupBanner="true"
|
||||||
AdditionalLibraryDirectories=""$(SolutionDir)\Release\$(PlatformName)";"..\..\..\Externals\wxWidgets\lib\vc_lib\$(PlatformName)""
|
AdditionalLibraryDirectories=""$(SolutionDir)\Release\$(PlatformName)";"..\..\..\Externals\wxWidgets\lib\vc_lib\$(PlatformName)""
|
||||||
|
IgnoreDefaultLibraryNames=""
|
||||||
GenerateDebugInformation="true"
|
GenerateDebugInformation="true"
|
||||||
ProgramDatabaseFile="$(PlatformName)\$(ConfigurationName)\$(TargetName).pdb"
|
ProgramDatabaseFile="$(PlatformName)\$(ConfigurationName)\$(TargetName).pdb"
|
||||||
GenerateMapFile="false"
|
GenerateMapFile="false"
|
||||||
@ -774,7 +778,7 @@
|
|||||||
SuppressStartupBanner="true"
|
SuppressStartupBanner="true"
|
||||||
AdditionalLibraryDirectories=""$(SolutionDir)\Release\$(PlatformName)";"..\..\..\Externals\wxWidgets\lib\vc_lib\$(PlatformName)""
|
AdditionalLibraryDirectories=""$(SolutionDir)\Release\$(PlatformName)";"..\..\..\Externals\wxWidgets\lib\vc_lib\$(PlatformName)""
|
||||||
IgnoreAllDefaultLibraries="false"
|
IgnoreAllDefaultLibraries="false"
|
||||||
IgnoreDefaultLibraryNames="msvcrt"
|
IgnoreDefaultLibraryNames=""
|
||||||
GenerateDebugInformation="true"
|
GenerateDebugInformation="true"
|
||||||
ProgramDatabaseFile="$(PlatformName)\$(ConfigurationName)\$(TargetName).pdb"
|
ProgramDatabaseFile="$(PlatformName)\$(ConfigurationName)\$(TargetName).pdb"
|
||||||
GenerateMapFile="false"
|
GenerateMapFile="false"
|
||||||
@ -889,6 +893,7 @@
|
|||||||
LinkIncremental="1"
|
LinkIncremental="1"
|
||||||
SuppressStartupBanner="true"
|
SuppressStartupBanner="true"
|
||||||
AdditionalLibraryDirectories=""$(SolutionDir)\Release\$(PlatformName)";"..\..\..\Externals\wxWidgets\lib\vc_lib\$(PlatformName)""
|
AdditionalLibraryDirectories=""$(SolutionDir)\Release\$(PlatformName)";"..\..\..\Externals\wxWidgets\lib\vc_lib\$(PlatformName)""
|
||||||
|
IgnoreDefaultLibraryNames=""
|
||||||
GenerateDebugInformation="true"
|
GenerateDebugInformation="true"
|
||||||
ProgramDatabaseFile="$(PlatformName)\$(ConfigurationName)\$(TargetName).pdb"
|
ProgramDatabaseFile="$(PlatformName)\$(ConfigurationName)\$(TargetName).pdb"
|
||||||
SubSystem="2"
|
SubSystem="2"
|
||||||
@ -1164,6 +1169,14 @@
|
|||||||
RelativePath=".\src\LogWindow.h"
|
RelativePath=".\src\LogWindow.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\Src\LuaWindow.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\Src\LuaWindow.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\src\MemcardManager.cpp"
|
RelativePath=".\src\MemcardManager.cpp"
|
||||||
>
|
>
|
||||||
|
@ -194,6 +194,7 @@ EVT_MENU(IDM_RESET, CFrame::OnReset)
|
|||||||
EVT_MENU(IDM_RECORD, CFrame::OnRecord)
|
EVT_MENU(IDM_RECORD, CFrame::OnRecord)
|
||||||
EVT_MENU(IDM_PLAYRECORD, CFrame::OnPlayRecording)
|
EVT_MENU(IDM_PLAYRECORD, CFrame::OnPlayRecording)
|
||||||
EVT_MENU(IDM_FRAMESTEP, CFrame::OnFrameStep)
|
EVT_MENU(IDM_FRAMESTEP, CFrame::OnFrameStep)
|
||||||
|
EVT_MENU(IDM_LUA, CFrame::OnOpenLuaWindow)
|
||||||
EVT_MENU(IDM_SCREENSHOT, CFrame::OnScreenshot)
|
EVT_MENU(IDM_SCREENSHOT, CFrame::OnScreenshot)
|
||||||
EVT_MENU(IDM_CONFIG_MAIN, CFrame::OnConfigMain)
|
EVT_MENU(IDM_CONFIG_MAIN, CFrame::OnConfigMain)
|
||||||
EVT_MENU(IDM_CONFIG_GFX_PLUGIN, CFrame::OnPluginGFX)
|
EVT_MENU(IDM_CONFIG_GFX_PLUGIN, CFrame::OnPluginGFX)
|
||||||
|
@ -305,6 +305,7 @@ class CFrame : public wxFrame
|
|||||||
void OnHostMessage(wxCommandEvent& event);
|
void OnHostMessage(wxCommandEvent& event);
|
||||||
|
|
||||||
void OnMemcard(wxCommandEvent& event); // Misc
|
void OnMemcard(wxCommandEvent& event); // Misc
|
||||||
|
void OnOpenLuaWindow(wxCommandEvent& event);
|
||||||
|
|
||||||
void OnNetPlay(wxCommandEvent& event);
|
void OnNetPlay(wxCommandEvent& event);
|
||||||
|
|
||||||
|
@ -51,6 +51,7 @@ Core::GetWindowHandle().
|
|||||||
#include "MemcardManager.h"
|
#include "MemcardManager.h"
|
||||||
#include "CheatsWindow.h"
|
#include "CheatsWindow.h"
|
||||||
#include "InfoWindow.h"
|
#include "InfoWindow.h"
|
||||||
|
#include "LuaWindow.h"
|
||||||
#include "AboutDolphin.h"
|
#include "AboutDolphin.h"
|
||||||
#include "GameListCtrl.h"
|
#include "GameListCtrl.h"
|
||||||
#include "BootManager.h"
|
#include "BootManager.h"
|
||||||
@ -183,6 +184,7 @@ void CFrame::CreateMenu()
|
|||||||
|
|
||||||
// Tools menu
|
// Tools menu
|
||||||
wxMenu* toolsMenu = new wxMenu;
|
wxMenu* toolsMenu = new wxMenu;
|
||||||
|
toolsMenu->Append(IDM_LUA, _T("New &Lua Console"));
|
||||||
toolsMenu->Append(IDM_MEMCARD, _T("&Memcard Manager"));
|
toolsMenu->Append(IDM_MEMCARD, _T("&Memcard Manager"));
|
||||||
toolsMenu->Append(IDM_CHEATS, _T("Action &Replay Manager"));
|
toolsMenu->Append(IDM_CHEATS, _T("Action &Replay Manager"));
|
||||||
toolsMenu->Append(IDM_INFO, _T("System Information"));
|
toolsMenu->Append(IDM_INFO, _T("System Information"));
|
||||||
@ -766,6 +768,11 @@ m_bModalDialogOpen = true;
|
|||||||
m_bModalDialogOpen = false;
|
m_bModalDialogOpen = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CFrame::OnOpenLuaWindow(wxCommandEvent& WXUNUSED (event))
|
||||||
|
{
|
||||||
|
new wxLuaWindow(this, wxDefaultPosition, wxSize(600, 390));
|
||||||
|
}
|
||||||
|
|
||||||
void CFrame::OnShow_CheatsWindow(wxCommandEvent& WXUNUSED (event))
|
void CFrame::OnShow_CheatsWindow(wxCommandEvent& WXUNUSED (event))
|
||||||
{
|
{
|
||||||
CheatsWindow = new wxCheatsWindow(this, wxDefaultPosition, wxSize(600, 390));
|
CheatsWindow = new wxCheatsWindow(this, wxDefaultPosition, wxSize(600, 390));
|
||||||
|
@ -95,6 +95,7 @@ enum
|
|||||||
IDM_CHANGEDISC,
|
IDM_CHANGEDISC,
|
||||||
IDM_PROPERTIES,
|
IDM_PROPERTIES,
|
||||||
IDM_LOAD_WII_MENU,
|
IDM_LOAD_WII_MENU,
|
||||||
|
IDM_LUA,
|
||||||
|
|
||||||
IDM_LISTWAD,
|
IDM_LISTWAD,
|
||||||
IDM_LISTWII,
|
IDM_LISTWII,
|
||||||
|
190
Source/Core/DolphinWX/Src/LuaWindow.cpp
Normal file
190
Source/Core/DolphinWX/Src/LuaWindow.cpp
Normal file
@ -0,0 +1,190 @@
|
|||||||
|
// 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 <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)
|
||||||
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
|
std::map<int, wxLuaWindow *> g_contextMap;
|
||||||
|
|
||||||
|
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
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
// Create Lua context
|
||||||
|
luaID = luaCount;
|
||||||
|
///Lua::OpenLuaContext(luaID, LuaPrint, NULL, LuaStop);
|
||||||
|
g_contextMap[luaID] = this;
|
||||||
|
luaCount++;
|
||||||
|
bScriptRunning = false;
|
||||||
|
|
||||||
|
// Create the GUI controls
|
||||||
|
InitGUIControls();
|
||||||
|
|
||||||
|
// Setup Window
|
||||||
|
SetBackgroundColour(wxColour(COLOR_GRAY));
|
||||||
|
SetSize(size);
|
||||||
|
SetPosition(pos);
|
||||||
|
Layout();
|
||||||
|
Show();
|
||||||
|
}
|
||||||
|
|
||||||
|
wxLuaWindow::~wxLuaWindow()
|
||||||
|
{
|
||||||
|
// On Disposal
|
||||||
|
///Lua::CloseLuaContext(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);
|
||||||
|
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);
|
||||||
|
|
||||||
|
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",
|
||||||
|
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();
|
||||||
|
|
||||||
|
///Lua::RunLuaScriptFile(luaID, (const char *)currentScript.mb_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxLuaWindow::OnEvent_ScriptStop_Press(wxCommandEvent& WXUNUSED(event))
|
||||||
|
{
|
||||||
|
///Lua::StopLuaScript(luaID);
|
||||||
|
OnStop();
|
||||||
|
PrintMessage("Script stopped!\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxLuaWindow::OnStop()
|
||||||
|
{
|
||||||
|
bScriptRunning = false;
|
||||||
|
m_Button_LoadScript->Enable();
|
||||||
|
m_Button_Run->Enable();
|
||||||
|
m_Button_Stop->Disable();
|
||||||
|
}
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
|
96
Source/Core/DolphinWX/Src/LuaWindow.h
Normal file
96
Source/Core/DolphinWX/Src/LuaWindow.h
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
// 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;
|
||||||
|
|
||||||
|
wxTextCtrl *m_TextCtrl_Log;
|
||||||
|
|
||||||
|
// GUI IDs
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
ID_TAB_LOG,
|
||||||
|
ID_BUTTON_CLOSE,
|
||||||
|
ID_BUTTON_LOAD,
|
||||||
|
ID_BUTTON_RUN,
|
||||||
|
ID_BUTTON_STOP,
|
||||||
|
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);
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
Reference in New Issue
Block a user