Skip to content

Commit dbe144e

Browse files
authored
Merge branch 'grumpycoders:main' into Breakpoints-improvements
2 parents 0c33f1d + 06fdac5 commit dbe144e

File tree

28 files changed

+3173
-51
lines changed

28 files changed

+3173
-51
lines changed

.github/filter-mips/filter.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,6 @@ git filter-branch -f --tree-filter "find . -name Makefile -exec sed 's|\.\./\.\.
3232
git filter-branch -f --tree-filter "find . -name Makefile -exec sed 's|\.\./\.\./\.\./third_party/EASTL/|../third_party/EASTL/|' -i {} \;" --tag-name-filter cat --prune-empty
3333
git filter-branch -f --tree-filter "find . -name '*.mk' -exec sed 's|\.\./\.\./\.\./third_party/EABase/|../third_party/EABase/|' -i {} \;" --tag-name-filter cat --prune-empty
3434
git filter-branch -f --tree-filter "find . -name '*.mk' -exec sed 's|\.\./\.\./\.\./third_party/EASTL/|../third_party/EASTL/|' -i {} \;" --tag-name-filter cat --prune-empty
35+
36+
# Delete unwanted files
37+
git filter-branch -f --tree-filter 'find . -name compile_flags.txt -or -name Doxyfile -delete || true' --tag-name-filter cat --prune-empty

.github/workflows/chores.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,14 @@ jobs:
7474
- uses: n1hility/cancel-previous-runs@v2
7575
with:
7676
token: ${{ secrets.GITHUB_TOKEN }}
77+
- name: Install doxygen
78+
run: sudo apt-get install -y doxygen graphviz
7779
- name: Filter repository
7880
env:
7981
FILTER_BRANCH_SQUELCH_WARNING: 1
8082
run: |
8183
cp -rv .github/filter-mips /tmp
84+
cp src/mips/Doxyfile /tmp
8285
/tmp/filter-mips/filter.sh
8386
- name: Pushing result
8487
env:
@@ -87,6 +90,23 @@ jobs:
8790
git config -l | grep 'http\..*\.extraheader' | cut -d= -f1 | xargs -L1 git config --unset-all
8891
git remote add nugget https://nicolasnoble:$PAT@github.com/pcsx-redux/nugget.git
8992
git push --force https://nicolasnoble:$PAT@github.com/pcsx-redux/nugget.git main
93+
- name: Creating documentation
94+
run: |
95+
doxygen /tmp/Doxyfile
96+
mv html /tmp
97+
rm -rf latex
98+
git checkout --orphan gh_pages
99+
git rm -rf .
100+
mv /tmp/html/* .
101+
git add .
102+
git config --global user.email "pixel@nobis-crew.org."
103+
git config --global user.name 'Nicolas "Pixel" Noble'
104+
git commit -m "Documentation."
105+
- name: Pushing documentation
106+
env:
107+
PAT: ${{ secrets.PAT }}
108+
run: |
109+
git push --force https://nicolasnoble:$PAT@github.com/pcsx-redux/nugget.git gh_pages
90110
91111
export-support:
92112
runs-on: ubuntu-latest

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,3 +94,6 @@
9494
[submodule "third_party/uriparser"]
9595
path = third_party/uriparser
9696
url = https://github.com/uriparser/uriparser.git
97+
[submodule "third_party/PEGTL"]
98+
path = third_party/PEGTL
99+
url = https://github.com/taocpp/PEGTL.git

src/core/logger.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
#pragma once
2121

22-
#include <stdarg.h>
22+
#include <utility>
2323

2424
#include "core/system.h"
2525
#include "fmt/printf.h"
@@ -54,9 +54,9 @@ enum class LogClass : unsigned {
5454
template <LogClass logClass, bool enabled>
5555
struct Logger {
5656
template <typename... Args>
57-
static void Log(const char *format, const Args &...args) {
57+
static void Log(const char *format, Args &&...args) {
5858
if (!enabled) return;
59-
std::string s = fmt::sprintf(format, args...);
59+
std::string s = fmt::sprintf(format, std::forward<Args>(args)...);
6060
g_system->log(logClass, std::move(s));
6161
}
6262
static void Log(std::string &&s) {

src/core/pcsxlua.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,9 @@ void PCSX::LuaFFI::open_pcsx(Lua L) {
178178
registerAllSymbols(L);
179179
L.load(pcsxFFI, "src:core/pcsxffi.lua");
180180
L.getfieldtable("PCSX", LUA_GLOBALSINDEX);
181+
L.push("execSlots");
182+
L.newtable();
183+
L.settable();
181184
L.declareFunc(
182185
"getSaveStateProtoSchema",
183186
[](lua_State* L_) -> int {

src/core/psxhw.cc

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -437,10 +437,7 @@ void PCSX::HW::write8(uint32_t add, uint32_t rawvalue) {
437437
try {
438438
L.pcall();
439439
} catch (...) {
440-
g_system->pause();
441440
}
442-
} else {
443-
g_system->pause();
444441
}
445442
while (top != L.gettop()) L.pop();
446443
}

src/gui/luaimguiextra.cc

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
1818
***************************************************************************/
1919

20+
#include <string_view>
21+
2022
#include "gui/luaimguiextra.h"
2123

2224
#include "gui/gui.h"
@@ -70,6 +72,35 @@ void registerAllSymbols(PCSX::Lua L) {
7072
L.pop();
7173
}
7274

75+
bool validateColorArgs(PCSX::Lua L, std::string_view funcName) {
76+
int n = L.gettop();
77+
if (n < 2) return L.error("%s: not enough arguments", funcName);
78+
if (n > 4) return L.error("%s: too many arguments", funcName);
79+
if (!L.isstring(1)) return L.error("%s: argument 1 must be a string", funcName);
80+
if (!L.istable(2)) return L.error("%s: argument 2 must be a table", funcName);
81+
if (n == 3 && !L.isnumber(3)) return L.error("%s: argument 3 must be a number", funcName);
82+
return true;
83+
}
84+
85+
void extractColorComponents(PCSX::Lua L, float* col, int components) {
86+
static const char* const fields[] = {"r", "g", "b", "a"};
87+
for (int i = 0; i < components; i++) {
88+
L.getfield(fields[i], 2);
89+
col[i] = L.tonumber(-1);
90+
L.pop();
91+
}
92+
}
93+
94+
void createColorTable(PCSX::Lua L, const float* col, int components) {
95+
static const char* const fields[] = {"r", "g", "b", "a"};
96+
L.newtable();
97+
for (int i = 0; i < components; i++) {
98+
L.push(fields[i]);
99+
L.push(col[i]);
100+
L.settable();
101+
}
102+
}
103+
73104
} // namespace
74105

75106
void PCSX::LuaFFI::open_imguiextra(GUI* gui, Lua L) {
@@ -155,6 +186,62 @@ void PCSX::LuaFFI::open_imguiextra(GUI* gui, Lua L) {
155186
return 2;
156187
},
157188
-1);
189+
L.declareFunc(
190+
"ColorEdit3",
191+
[](lua_State* L_) -> int {
192+
Lua L(L_);
193+
if (!validateColorArgs(L, "ColorEdit3")) return 0;
194+
std::string label = L.tostring(1);
195+
float col[3];
196+
extractColorComponents(L, col, 3);
197+
ImGuiColorEditFlags flags = L.gettop() == 3 ? L.tonumber(3) : 0;
198+
L.push(ImGui::ColorEdit3(label.c_str(), col, flags));
199+
createColorTable(L, col, 3);
200+
return 2;
201+
},
202+
-1);
203+
L.declareFunc(
204+
"ColorEdit4",
205+
[](lua_State* L_) -> int {
206+
Lua L(L_);
207+
if (!validateColorArgs(L, "ColorEdit4")) return 0;
208+
std::string label = L.tostring(1);
209+
float col[4];
210+
extractColorComponents(L, col, 4);
211+
ImGuiColorEditFlags flags = L.gettop() == 3 ? L.tonumber(3) : 0;
212+
L.push(ImGui::ColorEdit4(label.c_str(), col, flags));
213+
createColorTable(L, col, 4);
214+
return 2;
215+
},
216+
-1);
217+
L.declareFunc(
218+
"ColorPicker3",
219+
[](lua_State* L_) -> int {
220+
Lua L(L_);
221+
if (!validateColorArgs(L, "ColorPicker3")) return 0;
222+
std::string label = L.tostring(1);
223+
float col[3];
224+
extractColorComponents(L, col, 3);
225+
ImGuiColorEditFlags flags = L.gettop() == 3 ? L.tonumber(3) : 0;
226+
L.push(ImGui::ColorPicker3(label.c_str(), col, flags));
227+
createColorTable(L, col, 3);
228+
return 2;
229+
},
230+
-1);
231+
L.declareFunc(
232+
"ColorPicker4",
233+
[](lua_State* L_) -> int {
234+
Lua L(L_);
235+
if (!validateColorArgs(L, "ColorPicker4")) return 0;
236+
std::string label = L.tostring(1);
237+
float col[4];
238+
extractColorComponents(L, col, 4);
239+
ImGuiColorEditFlags flags = L.gettop() == 3 ? L.tonumber(3) : 0;
240+
L.push(ImGui::ColorPicker4(label.c_str(), col, flags));
241+
createColorTable(L, col, 4);
242+
return 2;
243+
},
244+
-1);
158245
L.pop(2);
159246
assert(L.gettop() == 0);
160247
}

src/lua/luawrapper.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ static int callwrap(lua_State* raw, lua_CFunction func) {
2727
try {
2828
return func(raw);
2929
} catch (std::exception& e) {
30-
return L.error(std::string("LuaException: ") + e.what());
30+
return L.error("LuaException: %s", e.what());
3131
}
3232
}
3333

src/lua/luawrapper.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@
2424
#include <optional>
2525
#include <string>
2626
#include <string_view>
27+
#include <utility>
2728

29+
#include "fmt/printf.h"
2830
#include "json.hpp"
2931
#include "lua.hpp"
3032
#include "support/ssize_t.h"
@@ -177,6 +179,10 @@ class Lua {
177179
int gettop() { return lua_gettop(L); }
178180
void pushLuaContext(bool inTable = false);
179181
int error(std::string_view msg);
182+
template <typename... Args>
183+
int error(const char* format, Args&&... args) {
184+
return error(fmt::sprintf(format, std::forward<Args>(args)...));
185+
}
180186

181187
int type(int i = -1) { return lua_type(L, i); }
182188
const char* typestring(int i = -1) { return lua_typename(L, lua_type(L, i)); }

0 commit comments

Comments
 (0)