mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Stub a lua console, add the sol lua wrapper library
This commit is contained in:
parent
a4af129983
commit
cf059ff84c
26 changed files with 30802 additions and 6 deletions
|
@ -1526,6 +1526,8 @@ list(APPEND NativeAppSource
|
|||
UI/ImDebugger/ImDebugger.h
|
||||
UI/ImDebugger/ImGe.cpp
|
||||
UI/ImDebugger/ImGe.h
|
||||
UI/ImDebugger/ImConsole.cpp
|
||||
UI/ImDebugger/ImConsole.h
|
||||
UI/ImDebugger/ImDisasmView.cpp
|
||||
UI/ImDebugger/ImDisasmView.h
|
||||
UI/ImDebugger/ImMemView.cpp
|
||||
|
@ -2048,6 +2050,8 @@ add_library(${CoreLibName} ${CoreLinkType}
|
|||
Core/KeyMap.h
|
||||
Core/KeyMapDefaults.cpp
|
||||
Core/KeyMapDefaults.h
|
||||
Core/LuaContext.cpp
|
||||
Core/LuaContext.h
|
||||
Core/RetroAchievements.h
|
||||
Core/RetroAchievements.cpp
|
||||
Core/ThreadEventQueue.h
|
||||
|
|
|
@ -589,6 +589,7 @@
|
|||
<ClCompile Include="Instance.cpp" />
|
||||
<ClCompile Include="KeyMap.cpp" />
|
||||
<ClCompile Include="KeyMapDefaults.cpp" />
|
||||
<ClCompile Include="LuaContext.cpp" />
|
||||
<ClCompile Include="MemFault.cpp" />
|
||||
<ClCompile Include="MIPS\ARM64\Arm64IRAsm.cpp" />
|
||||
<ClCompile Include="MIPS\ARM64\Arm64IRCompALU.cpp" />
|
||||
|
@ -1210,6 +1211,7 @@
|
|||
<ClInclude Include="Instance.h" />
|
||||
<ClInclude Include="KeyMap.h" />
|
||||
<ClInclude Include="KeyMapDefaults.h" />
|
||||
<ClInclude Include="LuaContext.h" />
|
||||
<ClInclude Include="MemFault.h" />
|
||||
<ClInclude Include="MIPS\ARM64\Arm64IRJit.h" />
|
||||
<ClInclude Include="MIPS\ARM64\Arm64IRRegCache.h" />
|
||||
|
|
|
@ -1345,6 +1345,9 @@
|
|||
<ClCompile Include="Util\RecentFiles.cpp">
|
||||
<Filter>Util</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="LuaContext.cpp">
|
||||
<Filter>Core</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="ELF\ElfReader.h">
|
||||
|
@ -2172,6 +2175,9 @@
|
|||
<ClInclude Include="Util\RecentFiles.h">
|
||||
<Filter>Util</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="LuaContext.h">
|
||||
<Filter>Core</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\LICENSE.TXT" />
|
||||
|
@ -2200,4 +2206,4 @@
|
|||
<Filter>Ext</Filter>
|
||||
</Text>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
|
|
|
@ -54,6 +54,11 @@
|
|||
#include "Core/Instance.h"
|
||||
#include "proAdhoc.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#undef errno
|
||||
#define errno WSAGetLastError()
|
||||
#endif
|
||||
|
||||
#if PPSSPP_PLATFORM(SWITCH) && !defined(INADDR_NONE)
|
||||
// Missing toolchain define
|
||||
#define INADDR_NONE 0xFFFFFFFF
|
||||
|
|
|
@ -41,6 +41,11 @@
|
|||
#include "Core/Core.h"
|
||||
#include "Core/HLE/proAdhocServer.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#undef errno
|
||||
#define errno WSAGetLastError()
|
||||
#endif
|
||||
|
||||
// User Count
|
||||
uint32_t _db_user_count = 0;
|
||||
|
||||
|
|
|
@ -53,6 +53,10 @@
|
|||
#include "Core/HLE/proAdhocServer.h"
|
||||
#include "Core/HLE/KernelWaitHelpers.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#undef errno
|
||||
#define errno WSAGetLastError()
|
||||
#endif
|
||||
|
||||
// shared in sceNetAdhoc.h since it need to be used from sceNet.cpp also
|
||||
// TODO: Make accessor functions instead, and throw all this state in a struct.
|
||||
|
|
76
Core/LuaContext.cpp
Normal file
76
Core/LuaContext.cpp
Normal file
|
@ -0,0 +1,76 @@
|
|||
#include <string>
|
||||
|
||||
#include "Common/Log.h"
|
||||
#include "Common/StringUtils.h"
|
||||
#include "Core/LuaContext.h"
|
||||
|
||||
// lua_writeline
|
||||
|
||||
/*
|
||||
|
||||
#define lua_writestring(s,l) fwrite((s), sizeof(char), (l), stdout)
|
||||
#define lua_writeline() (lua_writestring("\n", 1), fflush(stdout))
|
||||
#define lua_writestringerror(s,p) \
|
||||
(fprintf(stderr, (s), (p)), fflush(stderr))
|
||||
|
||||
*/
|
||||
|
||||
extern "C" {
|
||||
#include "ext/lua/lua.h"
|
||||
#include "ext/lua/lauxlib.h"
|
||||
#include "ext/lua/lualib.h"
|
||||
}
|
||||
|
||||
// Sol is expensive to include so we only do it here.
|
||||
#include "ext/sol/sol.hpp"
|
||||
|
||||
LuaContext g_lua;
|
||||
|
||||
void LuaContext::Init() {
|
||||
_dbg_assert_(L == nullptr);
|
||||
|
||||
L = luaL_newstate();
|
||||
luaopen_base(L);
|
||||
luaopen_table(L);
|
||||
luaopen_string(L);
|
||||
luaopen_math(L);
|
||||
}
|
||||
|
||||
void LuaContext::Shutdown() {
|
||||
lua_close(L);
|
||||
L = nullptr;
|
||||
}
|
||||
|
||||
void LuaContext::Load(const char *code) {
|
||||
/*
|
||||
while (fgets(buff, sizeof(buff), stdin) != NULL) {
|
||||
error = luaL_loadbuffer(L, buff, strlen(buff), "line") ||
|
||||
lua_pcall(L, 0, 0, 0);
|
||||
if (error) {
|
||||
fprintf(stderr, "%s", lua_tostring(L, -1));
|
||||
lua_pop(L, 1); // pop error message from the stack
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
void LuaContext::Execute(std::string_view cmd, std::string *output) {
|
||||
int error = luaL_loadbuffer(L, cmd.data(), cmd.length(), "line");
|
||||
if (error) {
|
||||
ERROR_LOG(Log::System, "%s", lua_tostring(L, -1));
|
||||
*output = lua_tostring(L, -1);
|
||||
lua_pop(L, 1); /* pop error message from the stack */
|
||||
return;
|
||||
}
|
||||
|
||||
lua_pcall(L, 0, 0, 0);
|
||||
|
||||
/* Get the number of values which have been pushed */
|
||||
int res_count = lua_tointeger(L, -1);
|
||||
if (!lua_isnumber(L, -1))
|
||||
*output = "function `f' must return a number";
|
||||
int value = lua_tonumber(L, -1);
|
||||
/* Remove the number of values */
|
||||
lua_pop(L, 1);
|
||||
|
||||
*output = StringFromFormat("%d", value);
|
||||
}
|
22
Core/LuaContext.h
Normal file
22
Core/LuaContext.h
Normal file
|
@ -0,0 +1,22 @@
|
|||
#pragma once
|
||||
|
||||
#include <string_view>
|
||||
#include <string>
|
||||
|
||||
struct lua_State;
|
||||
|
||||
class LuaContext {
|
||||
public:
|
||||
void Init();
|
||||
void Shutdown();
|
||||
void Load(const char *code);
|
||||
|
||||
// For the console.
|
||||
void Execute(std::string_view cmd, std::string *output);
|
||||
|
||||
private:
|
||||
// Naming it L is a common convention.
|
||||
lua_State *L = nullptr;
|
||||
};
|
||||
|
||||
extern LuaContext g_lua;
|
|
@ -58,6 +58,7 @@
|
|||
#include "Core/CoreTiming.h"
|
||||
#include "Core/CoreParameter.h"
|
||||
#include "Core/FileLoaders/RamCachingFileLoader.h"
|
||||
#include "Core/LuaContext.h"
|
||||
#include "Core/FileSystems/MetaFileSystem.h"
|
||||
#include "Core/Loaders.h"
|
||||
#include "Core/PSPLoaders.h"
|
||||
|
@ -217,6 +218,8 @@ bool CPU_Init(std::string *errorString, FileLoader *loadedFile, IdentifiedFileTy
|
|||
|
||||
g_symbolMap = new SymbolMap();
|
||||
|
||||
g_lua.Init();
|
||||
|
||||
// Default memory settings
|
||||
// Seems to be the safest place currently..
|
||||
Memory::g_MemorySize = Memory::RAM_NORMAL_SIZE; // 32 MB of ram by default
|
||||
|
@ -362,6 +365,8 @@ void CPU_Shutdown() {
|
|||
delete g_symbolMap;
|
||||
g_symbolMap = nullptr;
|
||||
|
||||
g_lua.Shutdown();
|
||||
|
||||
g_CoreParameter.mountIsoLoader = nullptr;
|
||||
}
|
||||
|
||||
|
|
314
UI/ImDebugger/ImConsole.cpp
Normal file
314
UI/ImDebugger/ImConsole.cpp
Normal file
|
@ -0,0 +1,314 @@
|
|||
#pragma once
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
#include "ext/imgui/imgui.h"
|
||||
|
||||
#include "UI/ImDebugger/ImDebugger.h"
|
||||
#include "UI/ImDebugger/ImConsole.h"
|
||||
#include "Core/LuaContext.h"
|
||||
|
||||
ImConsole::ImConsole() {
|
||||
ClearLog();
|
||||
memset(InputBuf, 0, sizeof(InputBuf));
|
||||
HistoryPos = -1;
|
||||
|
||||
// "CLASSIFY" is here to provide the test case where "C"+[tab] completes to "CL" and display multiple matches.
|
||||
Commands.push_back("HELP");
|
||||
Commands.push_back("HISTORY");
|
||||
Commands.push_back("CLEAR");
|
||||
Commands.push_back("CLASSIFY");
|
||||
AutoScroll = true;
|
||||
ScrollToBottom = false;
|
||||
AddLog("Welcome to Dear ImGui!");
|
||||
}
|
||||
|
||||
ImConsole::~ImConsole() {
|
||||
ClearLog();
|
||||
for (int i = 0; i < History.Size; i++)
|
||||
ImGui::MemFree(History[i]);
|
||||
}
|
||||
|
||||
// Portable helpers
|
||||
static int Stricmp(const char* s1, const char* s2) { int d; while ((d = toupper(*s2) - toupper(*s1)) == 0 && *s1) { s1++; s2++; } return d; }
|
||||
static int Strnicmp(const char* s1, const char* s2, int n) { int d = 0; while (n > 0 && (d = toupper(*s2) - toupper(*s1)) == 0 && *s1) { s1++; s2++; n--; } return d; }
|
||||
static char* Strdup(const char* s) { IM_ASSERT(s); size_t len = strlen(s) + 1; void* buf = ImGui::MemAlloc(len); IM_ASSERT(buf); return (char*)memcpy(buf, (const void*)s, len); }
|
||||
static void Strtrim(char* s) { char* str_end = s + strlen(s); while (str_end > s && str_end[-1] == ' ') str_end--; *str_end = 0; }
|
||||
|
||||
void ImConsole::ClearLog() {
|
||||
for (int i = 0; i < Items.Size; i++)
|
||||
ImGui::MemFree(Items[i]);
|
||||
Items.clear();
|
||||
}
|
||||
|
||||
void ImConsole::AddLog(const char* fmt, ...) IM_FMTARGS(2) {
|
||||
// FIXME-OPT
|
||||
char buf[1024];
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
vsnprintf(buf, IM_ARRAYSIZE(buf), fmt, args);
|
||||
buf[IM_ARRAYSIZE(buf) - 1] = 0;
|
||||
va_end(args);
|
||||
Items.push_back(Strdup(buf));
|
||||
}
|
||||
|
||||
// In C++11 you'd be better off using lambdas for this sort of forwarding callbacks
|
||||
static int TextEditCallbackStub(ImGuiInputTextCallbackData* data) {
|
||||
ImConsole* console = (ImConsole*)data->UserData;
|
||||
return console->TextEditCallback(data);
|
||||
}
|
||||
|
||||
void ImConsole::Draw(ImConfig &cfg) {
|
||||
ImGui::SetNextWindowSize(ImVec2(520, 600), ImGuiCond_FirstUseEver);
|
||||
if (!ImGui::Begin("Console", &cfg.luaConsoleOpen)) {
|
||||
ImGui::End();
|
||||
return;
|
||||
}
|
||||
|
||||
ImGui::TextWrapped("Lua console. Enter 'HELP' for help.");
|
||||
|
||||
if (ImGui::SmallButton("Add Debug Text")) {
|
||||
AddLog("%d some text", Items.Size);
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if (ImGui::SmallButton("Add Debug Error")) {
|
||||
AddLog("[error] something went wrong");
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if (ImGui::SmallButton("Clear")) {
|
||||
ClearLog();
|
||||
}
|
||||
ImGui::SameLine();
|
||||
bool copy_to_clipboard = ImGui::SmallButton("Copy");
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
// Options menu
|
||||
if (ImGui::BeginPopup("Options")) {
|
||||
ImGui::Checkbox("Auto-scroll", &AutoScroll);
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
|
||||
// Options, Filter
|
||||
ImGui::SetNextItemShortcut(ImGuiMod_Ctrl | ImGuiKey_O, ImGuiInputFlags_Tooltip);
|
||||
if (ImGui::Button("Options"))
|
||||
ImGui::OpenPopup("Options");
|
||||
ImGui::SameLine();
|
||||
Filter.Draw("Filter (\"incl,-excl\") (\"error\")", 180);
|
||||
ImGui::Separator();
|
||||
|
||||
// Reserve enough left-over height for 1 separator + 1 input text
|
||||
const float footer_height_to_reserve = ImGui::GetStyle().ItemSpacing.y + ImGui::GetFrameHeightWithSpacing();
|
||||
if (ImGui::BeginChild("ScrollingRegion", ImVec2(0, -footer_height_to_reserve), ImGuiChildFlags_None, ImGuiWindowFlags_HorizontalScrollbar | ImGuiWindowFlags_NavFlattened)) {
|
||||
if (ImGui::BeginPopupContextWindow()) {
|
||||
if (ImGui::Selectable("Clear"))
|
||||
ClearLog();
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
|
||||
// Display every line as a separate entry so we can change their color or add custom widgets.
|
||||
// If you only want raw text you can use ImGui::TextUnformatted(log.begin(), log.end());
|
||||
// NB- if you have thousands of entries this approach may be too inefficient and may require user-side clipping
|
||||
// to only process visible items. The clipper will automatically measure the height of your first item and then
|
||||
// "seek" to display only items in the visible area.
|
||||
// To use the clipper we can replace your standard loop:
|
||||
// for (int i = 0; i < Items.Size; i++)
|
||||
// With:
|
||||
// ImGuiListClipper clipper;
|
||||
// clipper.Begin(Items.Size);
|
||||
// while (clipper.Step())
|
||||
// for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; i++)
|
||||
// - That your items are evenly spaced (same height)
|
||||
// - That you have cheap random access to your elements (you can access them given their index,
|
||||
// without processing all the ones before)
|
||||
// You cannot this code as-is if a filter is active because it breaks the 'cheap random-access' property.
|
||||
// We would need random-access on the post-filtered list.
|
||||
// A typical application wanting coarse clipping and filtering may want to pre-compute an array of indices
|
||||
// or offsets of items that passed the filtering test, recomputing this array when user changes the filter,
|
||||
// and appending newly elements as they are inserted. This is left as a task to the user until we can manage
|
||||
// to improve this example code!
|
||||
// If your items are of variable height:
|
||||
// - Split them into same height items would be simpler and facilitate random-seeking into your list.
|
||||
// - Consider using manual call to IsRectVisible() and skipping extraneous decoration from your items.
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(4, 1)); // Tighten spacing
|
||||
if (copy_to_clipboard)
|
||||
ImGui::LogToClipboard();
|
||||
for (const char* item : Items) {
|
||||
if (!Filter.PassFilter(item))
|
||||
continue;
|
||||
|
||||
// Normally you would store more information in your item than just a string.
|
||||
// (e.g. make Items[] an array of structure, store color/type etc.)
|
||||
ImVec4 color;
|
||||
bool has_color = false;
|
||||
if (strstr(item, "[error]")) {
|
||||
color = ImVec4(1.0f, 0.4f, 0.4f, 1.0f); has_color = true;
|
||||
} else if (strncmp(item, "# ", 2) == 0) {
|
||||
color = ImVec4(1.0f, 0.8f, 0.6f, 1.0f); has_color = true;
|
||||
}
|
||||
if (has_color)
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, color);
|
||||
ImGui::TextUnformatted(item);
|
||||
if (has_color)
|
||||
ImGui::PopStyleColor();
|
||||
}
|
||||
if (copy_to_clipboard)
|
||||
ImGui::LogFinish();
|
||||
|
||||
// Keep up at the bottom of the scroll region if we were already at the bottom at the beginning of the frame.
|
||||
// Using a scrollbar or mouse-wheel will take away from the bottom edge.
|
||||
if (ScrollToBottom || (AutoScroll && ImGui::GetScrollY() >= ImGui::GetScrollMaxY()))
|
||||
ImGui::SetScrollHereY(1.0f);
|
||||
ScrollToBottom = false;
|
||||
|
||||
ImGui::PopStyleVar();
|
||||
}
|
||||
ImGui::EndChild();
|
||||
ImGui::Separator();
|
||||
|
||||
// Command-line
|
||||
bool reclaim_focus = false;
|
||||
ImGuiInputTextFlags input_text_flags = ImGuiInputTextFlags_EnterReturnsTrue | ImGuiInputTextFlags_EscapeClearsAll | ImGuiInputTextFlags_CallbackCompletion | ImGuiInputTextFlags_CallbackHistory;
|
||||
if (ImGui::InputText("Input", InputBuf, IM_ARRAYSIZE(InputBuf), input_text_flags, &TextEditCallbackStub, (void*)this)) {
|
||||
char* s = InputBuf;
|
||||
Strtrim(s);
|
||||
if (s[0])
|
||||
ExecCommand(s);
|
||||
strcpy(s, "");
|
||||
reclaim_focus = true;
|
||||
}
|
||||
|
||||
// Auto-focus on window apparition
|
||||
ImGui::SetItemDefaultFocus();
|
||||
if (reclaim_focus)
|
||||
ImGui::SetKeyboardFocusHere(-1); // Auto focus previous widget
|
||||
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
void ImConsole::ExecCommand(const char* command_line) {
|
||||
AddLog("# %s\n", command_line);
|
||||
|
||||
// Insert into history. First find match and delete it so it can be pushed to the back.
|
||||
// This isn't trying to be smart or optimal.
|
||||
HistoryPos = -1;
|
||||
for (int i = History.Size - 1; i >= 0; i--)
|
||||
if (Stricmp(History[i], command_line) == 0)
|
||||
{
|
||||
ImGui::MemFree(History[i]);
|
||||
History.erase(History.begin() + i);
|
||||
break;
|
||||
}
|
||||
History.push_back(Strdup(command_line));
|
||||
|
||||
// Process command
|
||||
if (Stricmp(command_line, "CLEAR") == 0) {
|
||||
ClearLog();
|
||||
} else if (Stricmp(command_line, "HELP") == 0) {
|
||||
AddLog("Commands:");
|
||||
for (int i = 0; i < Commands.Size; i++)
|
||||
AddLog("- %s", Commands[i]);
|
||||
} else if (Stricmp(command_line, "HISTORY") == 0) {
|
||||
int first = History.Size - 10;
|
||||
for (int i = first > 0 ? first : 0; i < History.Size; i++)
|
||||
AddLog("%3d: %s\n", i, History[i]);
|
||||
} else {
|
||||
// TODO: Anything else, forward to Lua.
|
||||
// AddLog("Unknown command: '%s'\n", command_line);
|
||||
std::string response;
|
||||
g_lua.Execute(command_line, &response);
|
||||
AddLog("%s", response.c_str());
|
||||
}
|
||||
|
||||
// On command input, we scroll to bottom even if AutoScroll==false
|
||||
ScrollToBottom = true;
|
||||
}
|
||||
|
||||
int ImConsole::TextEditCallback(ImGuiInputTextCallbackData* data) {
|
||||
//AddLog("cursor: %d, selection: %d-%d", data->CursorPos, data->SelectionStart, data->SelectionEnd);
|
||||
switch (data->EventFlag) {
|
||||
case ImGuiInputTextFlags_CallbackCompletion:
|
||||
{
|
||||
// Example of TEXT COMPLETION
|
||||
|
||||
// Locate beginning of current word
|
||||
const char* word_end = data->Buf + data->CursorPos;
|
||||
const char* word_start = word_end;
|
||||
while (word_start > data->Buf)
|
||||
{
|
||||
const char c = word_start[-1];
|
||||
if (c == ' ' || c == '\t' || c == ',' || c == ';')
|
||||
break;
|
||||
word_start--;
|
||||
}
|
||||
|
||||
// Build a list of candidates
|
||||
ImVector<const char*> candidates;
|
||||
for (int i = 0; i < Commands.Size; i++)
|
||||
if (Strnicmp(Commands[i], word_start, (int)(word_end - word_start)) == 0)
|
||||
candidates.push_back(Commands[i]);
|
||||
|
||||
if (candidates.Size == 0) {
|
||||
// No match
|
||||
AddLog("No match for \"%.*s\"!\n", (int)(word_end - word_start), word_start);
|
||||
} else if (candidates.Size == 1) {
|
||||
// Single match. Delete the beginning of the word and replace it entirely so we've got nice casing.
|
||||
data->DeleteChars((int)(word_start - data->Buf), (int)(word_end - word_start));
|
||||
data->InsertChars(data->CursorPos, candidates[0]);
|
||||
data->InsertChars(data->CursorPos, " ");
|
||||
} else {
|
||||
// Multiple matches. Complete as much as we can..
|
||||
// So inputing "C"+Tab will complete to "CL" then display "CLEAR" and "CLASSIFY" as matches.
|
||||
int match_len = (int)(word_end - word_start);
|
||||
for (;;) {
|
||||
int c = 0;
|
||||
bool all_candidates_matches = true;
|
||||
for (int i = 0; i < candidates.Size && all_candidates_matches; i++)
|
||||
if (i == 0)
|
||||
c = toupper(candidates[i][match_len]);
|
||||
else if (c == 0 || c != toupper(candidates[i][match_len]))
|
||||
all_candidates_matches = false;
|
||||
if (!all_candidates_matches)
|
||||
break;
|
||||
match_len++;
|
||||
}
|
||||
|
||||
if (match_len > 0) {
|
||||
data->DeleteChars((int)(word_start - data->Buf), (int)(word_end - word_start));
|
||||
data->InsertChars(data->CursorPos, candidates[0], candidates[0] + match_len);
|
||||
}
|
||||
|
||||
// List matches
|
||||
AddLog("Possible matches:\n");
|
||||
for (int i = 0; i < candidates.Size; i++) {
|
||||
AddLog("- %s\n", candidates[i]);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case ImGuiInputTextFlags_CallbackHistory:
|
||||
{
|
||||
// Example of HISTORY
|
||||
const int prev_history_pos = HistoryPos;
|
||||
if (data->EventKey == ImGuiKey_UpArrow) {
|
||||
if (HistoryPos == -1)
|
||||
HistoryPos = History.Size - 1;
|
||||
else if (HistoryPos > 0)
|
||||
HistoryPos--;
|
||||
} else if (data->EventKey == ImGuiKey_DownArrow) {
|
||||
if (HistoryPos != -1)
|
||||
if (++HistoryPos >= History.Size)
|
||||
HistoryPos = -1;
|
||||
}
|
||||
|
||||
// A better implementation would preserve the data on the current input line along with cursor position.
|
||||
if (prev_history_pos != HistoryPos) {
|
||||
const char* history_str = (HistoryPos >= 0) ? History[HistoryPos] : "";
|
||||
data->DeleteChars(0, data->BufTextLen);
|
||||
data->InsertChars(0, history_str);
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
30
UI/ImDebugger/ImConsole.h
Normal file
30
UI/ImDebugger/ImConsole.h
Normal file
|
@ -0,0 +1,30 @@
|
|||
#pragma once
|
||||
|
||||
#include <cstdlib>
|
||||
#include <locale>
|
||||
|
||||
#include "ext/imgui/imgui.h"
|
||||
|
||||
// Adapted from the ImGui demo.
|
||||
struct ImConsole {
|
||||
char InputBuf[256];
|
||||
ImVector<char*> Items;
|
||||
ImVector<const char*> Commands;
|
||||
ImVector<char*> History;
|
||||
int HistoryPos; // -1: new line, 0..History.Size-1 browsing history.
|
||||
ImGuiTextFilter Filter;
|
||||
bool AutoScroll;
|
||||
bool ScrollToBottom;
|
||||
|
||||
ImConsole();
|
||||
~ImConsole();
|
||||
|
||||
void ClearLog();
|
||||
|
||||
void AddLog(const char* fmt, ...) IM_FMTARGS(2);
|
||||
|
||||
void Draw(ImConfig &cfg);
|
||||
void ExecCommand(const char* command_line);
|
||||
|
||||
int TextEditCallback(ImGuiInputTextCallbackData* data);
|
||||
};
|
|
@ -1958,6 +1958,9 @@ void ImDebugger::Frame(MIPSDebugInterface *mipsDebug, GPUDebugInterface *gpuDebu
|
|||
case ImCmd::SHOW_IN_PIXEL_VIEWER:
|
||||
break;
|
||||
}
|
||||
if (cfg_.luaConsoleOpen) {
|
||||
luaConsole_.Draw(cfg_);
|
||||
}
|
||||
}
|
||||
|
||||
void ImDebugger::Snapshot(MIPSState *mips) {
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "UI/ImDebugger/ImMemView.h"
|
||||
#include "UI/ImDebugger/ImStructViewer.h"
|
||||
#include "UI/ImDebugger/ImGe.h"
|
||||
#include "UI/ImDebugger/ImConsole.h"
|
||||
|
||||
// This is the main state container of the whole Dear ImGUI-based in-game cross-platform debugger.
|
||||
//
|
||||
|
@ -115,7 +116,6 @@ class IniFile;
|
|||
|
||||
struct ImConfig {
|
||||
// Defaults for saved settings are set in SyncConfig.
|
||||
|
||||
bool disasmOpen;
|
||||
bool demoOpen;
|
||||
bool gprOpen;
|
||||
|
@ -152,6 +152,7 @@ struct ImConfig {
|
|||
bool utilityModulesOpen;
|
||||
bool atracToolOpen;
|
||||
bool memViewOpen[4];
|
||||
bool luaConsoleOpen;
|
||||
|
||||
// HLE explorer settings
|
||||
// bool filterByUsed = true;
|
||||
|
@ -246,6 +247,7 @@ private:
|
|||
ImGePixelViewerWindow pixelViewer_;
|
||||
ImMemDumpWindow memDumpWindow_;
|
||||
ImAtracToolWindow atracToolWindow_;
|
||||
ImConsole luaConsole_;
|
||||
|
||||
ImSnapshotState newSnapshot_;
|
||||
ImSnapshotState snapshot_;
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
|
||||
// Background worker threads should be spawned in NativeInit and joined
|
||||
// in NativeShutdown.
|
||||
#include <errno.h>
|
||||
|
||||
#include <clocale>
|
||||
#include <algorithm>
|
||||
|
|
|
@ -51,6 +51,7 @@
|
|||
<ClCompile Include="GameScreen.cpp" />
|
||||
<ClCompile Include="GameSettingsScreen.cpp" />
|
||||
<ClCompile Include="GPUDriverTestScreen.cpp" />
|
||||
<ClCompile Include="ImDebugger\ImConsole.cpp" />
|
||||
<ClCompile Include="ImDebugger\ImDebugger.cpp" />
|
||||
<ClCompile Include="ImDebugger\ImDisasmView.cpp" />
|
||||
<ClCompile Include="ImDebugger\ImGe.cpp" />
|
||||
|
@ -96,6 +97,7 @@
|
|||
<ClInclude Include="GameSettingsScreen.h" />
|
||||
<ClInclude Include="CwCheatScreen.h" />
|
||||
<ClInclude Include="GPUDriverTestScreen.h" />
|
||||
<ClInclude Include="ImDebugger\ImConsole.h" />
|
||||
<ClInclude Include="ImDebugger\ImDebugger.h" />
|
||||
<ClInclude Include="ImDebugger\ImDisasmView.h" />
|
||||
<ClInclude Include="ImDebugger\ImGe.h" />
|
||||
|
|
|
@ -113,6 +113,9 @@
|
|||
<ClCompile Include="ImDebugger\ImMemView.cpp">
|
||||
<Filter>ImDebugger</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ImDebugger\ImConsole.cpp">
|
||||
<Filter>ImDebugger</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="GameInfoCache.h" />
|
||||
|
@ -226,6 +229,9 @@
|
|||
<ClInclude Include="ImDebugger\ImMemView.h">
|
||||
<Filter>ImDebugger</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ImDebugger\ImConsole.h">
|
||||
<Filter>ImDebugger</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Filter Include="Screens">
|
||||
|
@ -238,4 +244,4 @@
|
|||
<UniqueIdentifier>{fda6bc55-1386-4650-a274-44fac9605ea3}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
|
|
|
@ -278,6 +278,7 @@
|
|||
<ClInclude Include="..\..\Core\KeyMap.h" />
|
||||
<ClInclude Include="..\..\Core\KeyMapDefaults.h" />
|
||||
<ClInclude Include="..\..\Core\Loaders.h" />
|
||||
<ClInclude Include="..\..\Core\LuaContext.h" />
|
||||
<ClInclude Include="..\..\Core\MemFault.h" />
|
||||
<ClInclude Include="..\..\Core\MemMap.h" />
|
||||
<ClInclude Include="..\..\Core\MemMapHelpers.h" />
|
||||
|
@ -539,6 +540,7 @@
|
|||
<ClCompile Include="..\..\Core\KeyMap.cpp" />
|
||||
<ClCompile Include="..\..\Core\KeyMapDefaults.cpp" />
|
||||
<ClCompile Include="..\..\Core\Loaders.cpp" />
|
||||
<ClCompile Include="..\..\Core\LuaContext.cpp" />
|
||||
<ClCompile Include="..\..\Core\MemFault.cpp" />
|
||||
<ClCompile Include="..\..\Core\MemMap.cpp" />
|
||||
<ClCompile Include="..\..\Core\MemMapFunctions.cpp" />
|
||||
|
@ -1032,6 +1034,9 @@
|
|||
<ProjectReference Include="..\libchdr_UWP\libchdr_UWP.vcxproj">
|
||||
<Project>{191b6f52-ad66-4172-bd20-733eeeceef8c}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\lua\lua.vcxproj">
|
||||
<Project>{3cea9e74-a31d-4044-a378-ed2e485931f2}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\miniupnpc_UWP\miniupnpc_UWP.vcxproj">
|
||||
<Project>{d31fd4f0-53eb-477c-9dc7-149796f628e2}</Project>
|
||||
</ProjectReference>
|
||||
|
|
|
@ -1233,6 +1233,9 @@
|
|||
</ClCompile>
|
||||
<ClCompile Include="..\..\Core\HLE\SocketManager.cpp">
|
||||
<Filter>HLE</Filter>
|
||||
<ClCompile Include="..\..\Core\LuaContext.cpp" />
|
||||
<Filter>Dialog</Filter>
|
||||
</ClCompile>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\Core\Util\AtracTrack.cpp">
|
||||
<Filter>Util</Filter>
|
||||
|
@ -1964,10 +1967,13 @@
|
|||
<ClInclude Include="..\..\Core\Util\RecentFiles.h">
|
||||
<Filter>Util</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\Core\LuaContext.h" />
|
||||
<Filter>Dialog</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\..\ext\gason\LICENSE">
|
||||
<Filter>Ext\gason</Filter>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
|
|
|
@ -126,6 +126,7 @@
|
|||
<ClInclude Include="..\..\UI\GameScreen.h" />
|
||||
<ClInclude Include="..\..\UI\GameSettingsScreen.h" />
|
||||
<ClInclude Include="..\..\UI\GPUDriverTestScreen.h" />
|
||||
<ClInclude Include="..\..\UI\ImDebugger\ImConsole.h" />
|
||||
<ClInclude Include="..\..\UI\ImDebugger\ImDebugger.h" />
|
||||
<ClInclude Include="..\..\UI\ImDebugger\ImDisasmView.h" />
|
||||
<ClInclude Include="..\..\UI\ImDebugger\ImGe.h" />
|
||||
|
@ -171,6 +172,7 @@
|
|||
<ClCompile Include="..\..\UI\GameScreen.cpp" />
|
||||
<ClCompile Include="..\..\UI\GameSettingsScreen.cpp" />
|
||||
<ClCompile Include="..\..\UI\GPUDriverTestScreen.cpp" />
|
||||
<ClCompile Include="..\..\UI\ImDebugger\ImConsole.cpp" />
|
||||
<ClCompile Include="..\..\UI\ImDebugger\ImDebugger.cpp" />
|
||||
<ClCompile Include="..\..\UI\ImDebugger\ImDisasmView.cpp" />
|
||||
<ClCompile Include="..\..\UI\ImDebugger\ImGe.cpp" />
|
||||
|
@ -204,6 +206,9 @@
|
|||
<ProjectReference Include="..\CommonUWP\CommonUWP.vcxproj">
|
||||
<Project>{acb316ca-3ecb-48e5-be0a-91e72d5b0f12}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\lua\lua.vcxproj">
|
||||
<Project>{3cea9e74-a31d-4044-a378-ed2e485931f2}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\rcheevos_UWP\rcheevos_UWP.vcxproj">
|
||||
<Project>{4c9d52d0-310a-4347-8991-e3788cb22169}</Project>
|
||||
</ProjectReference>
|
||||
|
|
|
@ -54,6 +54,9 @@
|
|||
<ClCompile Include="..\..\UI\ImDebugger\ImMemView.cpp">
|
||||
<Filter>ImDebugger</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\UI\ImDebugger\ImConsole.cpp">
|
||||
<Filter>ImDebugger</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="pch.h" />
|
||||
|
@ -109,10 +112,13 @@
|
|||
<ClInclude Include="..\..\UI\ImDebugger\ImMemView.h">
|
||||
<Filter>ImDebugger</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\UI\ImDebugger\ImConsole.h">
|
||||
<Filter>ImDebugger</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Filter Include="ImDebugger">
|
||||
<UniqueIdentifier>{4013cb89-6145-451c-9cb1-d63d01f66bd5}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
|
|
|
@ -497,6 +497,9 @@
|
|||
<ProjectReference Include="libzstd_UWP\libzstd_UWP.vcxproj">
|
||||
<Project>{75286959-e7a2-4cbe-8b95-bf05c9c540fe}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="lua\lua.vcxproj">
|
||||
<Project>{3cea9e74-a31d-4044-a378-ed2e485931f2}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="SPIRVCross_UWP\SPIRVCross_UWP.vcxproj">
|
||||
<Project>{2b2d16bd-1d37-46af-a3f8-552900951b26}</Project>
|
||||
</ProjectReference>
|
||||
|
@ -528,4 +531,4 @@
|
|||
<Import Project="$(VSINSTALLDIR)\Common7\IDE\Extensions\Microsoft\VsGraphics\MeshContentTask.targets" />
|
||||
<Import Project="$(VSINSTALLDIR)\Common7\IDE\Extensions\Microsoft\VsGraphics\ShaderGraphContentTask.targets" />
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
</Project>
|
|
@ -601,6 +601,7 @@ EXEC_AND_LIB_FILES := \
|
|||
$(SRC)/Core/Instance.cpp \
|
||||
$(SRC)/Core/KeyMap.cpp \
|
||||
$(SRC)/Core/KeyMapDefaults.cpp \
|
||||
$(SRC)/Core/LuaContext.cpp \
|
||||
$(SRC)/Core/Loaders.cpp \
|
||||
$(SRC)/Core/PSPLoaders.cpp \
|
||||
$(SRC)/Core/FileLoaders/CachingFileLoader.cpp \
|
||||
|
@ -889,6 +890,7 @@ LOCAL_SRC_FILES := \
|
|||
$(SRC)/android/jni/OpenSLContext.cpp \
|
||||
$(SRC)/UI/ImDebugger/ImDebugger.cpp \
|
||||
$(SRC)/UI/ImDebugger/ImGe.cpp \
|
||||
$(SRC)/UI/ImDebugger/ImConsole.cpp \
|
||||
$(SRC)/UI/ImDebugger/ImDisasmView.cpp \
|
||||
$(SRC)/UI/ImDebugger/ImMemView.cpp \
|
||||
$(SRC)/UI/ImDebugger/ImStructViewer.cpp \
|
||||
|
|
53
ext/sol/config.hpp
Normal file
53
ext/sol/config.hpp
Normal file
|
@ -0,0 +1,53 @@
|
|||
// The MIT License (MIT)
|
||||
|
||||
// Copyright (c) 2013-2020 Rapptz, ThePhD and contributors
|
||||
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
// this software and associated documentation files (the "Software"), to deal in
|
||||
// the Software without restriction, including without limitation the rights to
|
||||
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
// the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
// subject to the following conditions:
|
||||
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
// This file was generated with a script.
|
||||
// Generated 2022-06-25 08:14:19.336233 UTC
|
||||
// This header was generated with sol v3.3.0 (revision eba86625)
|
||||
// https://github.com/ThePhD/sol2
|
||||
|
||||
#ifndef SOL_SINGLE_CONFIG_HPP
|
||||
#define SOL_SINGLE_CONFIG_HPP
|
||||
|
||||
// beginning of sol/config.hpp
|
||||
|
||||
/* Base, empty configuration file!
|
||||
|
||||
To override, place a file in your include paths of the form:
|
||||
|
||||
. (your include path here)
|
||||
| sol (directory, or equivalent)
|
||||
| config.hpp (your config.hpp file)
|
||||
|
||||
So that when sol2 includes the file
|
||||
|
||||
#include <sol/config.hpp>
|
||||
|
||||
it gives you the configuration values you desire. Configuration values can be
|
||||
seen in the safety.rst of the doc/src, or at
|
||||
https://sol2.readthedocs.io/en/latest/safety.html ! You can also pass them through
|
||||
the build system, or the command line options of your compiler.
|
||||
|
||||
*/
|
||||
|
||||
// end of sol/config.hpp
|
||||
|
||||
#endif // SOL_SINGLE_CONFIG_HPP
|
1321
ext/sol/forward.hpp
Normal file
1321
ext/sol/forward.hpp
Normal file
File diff suppressed because it is too large
Load diff
28907
ext/sol/sol.hpp
Normal file
28907
ext/sol/sol.hpp
Normal file
File diff suppressed because it is too large
Load diff
|
@ -652,6 +652,7 @@ SOURCES_CXX += \
|
|||
$(COREDIR)/WaveFile.cpp \
|
||||
$(COREDIR)/KeyMap.cpp \
|
||||
$(COREDIR)/KeyMapDefaults.cpp \
|
||||
$(COREDIR)/LuaContext.cpp \
|
||||
$(COREDIR)/FileLoaders/HTTPFileLoader.cpp \
|
||||
$(COREDIR)/FileLoaders/CachingFileLoader.cpp \
|
||||
$(COREDIR)/FileLoaders/DiskCachingFileLoader.cpp \
|
||||
|
|
Loading…
Add table
Reference in a new issue