commit 1295678c5dd0a36c2a99150d253804bfabd38dd3
Author: jtothebell <j.to.the.bell@gmail.com>
AuthorDate: Mon Aug 23 20:35:41 2021 -0600
Commit: jtothebell <j.to.the.bell@gmail.com>
CommitDate: Mon Aug 23 20:35:41 2021 -0600
add cart load breadcrumb support
---
source/p8GlobalLuaFunctions.h | 14 ++++++++++----
source/vm.cpp | 8 +++++++-
2 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/source/p8GlobalLuaFunctions.h b/source/p8GlobalLuaFunctions.h
index 1a8e4a5..3ee50b3 100644
--- a/source/p8GlobalLuaFunctions.h
+++ b/source/p8GlobalLuaFunctions.h
@@ -151,6 +151,12 @@ function menuitem(index, label, callback)
__f08_menu_items[index + 1][2] = callback
end
+function __addbreadcrumb(label, carttoload)
+ __f08_menu_items[8] = {nil, nil}
+ __f08_menu_items[8][1] = label
+ __f08_menu_items[8][2] = function() load(carttoload) end
+end
+
__f08_menu_items = {
[0] = {"continue", __togglepausemenu},
@@ -194,9 +200,9 @@ end
function __f08_menu_draw()
local menuwidth = 82
local itemcount = 0
- for i=0, 7, 1 do
+ for i=0, 8, 1 do
item = __f08_menu_items[i]
- if item[1] and item[2] then
+ if item and item[1] and item[2] then
itemcount = itemcount + 1
end
end
@@ -210,9 +216,9 @@ function __f08_menu_draw()
local itemy = menuy + 6
local itemidx = 0
- for i=0, 7, 1 do
+ for i=0, 8, 1 do
item = __f08_menu_items[i]
- if item[1] and item[2] then
+ if item and item[1] and item[2] then
print(item[1], itemx, itemy, 7)
--draw selection indicator
diff --git a/source/vm.cpp b/source/vm.cpp
index 5581276..84f50b7 100644
--- a/source/vm.cpp
+++ b/source/vm.cpp
@@ -325,6 +325,10 @@ bool Vm::loadCart(Cart* cart) {
}
}
+ if (_cartBreadcrumb.length() > 0) {
+ ExecuteLua("__addbreadcrumb(\"" + _cartBreadcrumb +"\", \"" + _prevCartKey +"\")", "");
+ }
+
_cartLoadError = "";
return true;
@@ -902,7 +906,9 @@ void Vm::vm_extcmd(std::string cmd){
void Vm::vm_load(std::string filename, std::string breadcrumb, std::string param){
_cartBreadcrumb = breadcrumb;
- _cartParam = param;
+ if (param.length() > 0) {
+ _cartParam = param;
+ }
QueueCartChange(filename);
}