Add button to open scenario folder & refresh list
This commit is contained in:
@@ -46,7 +46,9 @@
|
||||
<text outline='double' name='start3' top='205' left='59' width='342' height='84'/>
|
||||
</page>
|
||||
</stack>
|
||||
<button name='prev' type='left' def-key='left' top='294' left='62'/>
|
||||
<button name='next' type='right' def-key='right' top='294' left='125'/>
|
||||
<button name='cancel' type='regular' top='294' left='337'>Cancel</button>
|
||||
<button name='cancel' type='regular' top='294' left='5'>Cancel</button>
|
||||
<button name='prev' type='left' def-key='left' relative='pos pos-in' rel-anchor='prev' top='0' left='14'/>
|
||||
<button name='next' type='right' def-key='right' relative='pos pos-in' rel-anchor='prev' top='0' left='0'/>
|
||||
<button name='folder' type='large' relative='pos pos-in' rel-anchor='prev' top='0' left='14'>Show Folder</button>
|
||||
<button name='refresh' type='regular' relative='pos pos-in' rel-anchor='prev' top='0' left='7'>Refresh</button>
|
||||
</dialog>
|
||||
|
@@ -1810,11 +1810,28 @@ class cChooseScenario {
|
||||
me.toast(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Show the custom scenario folder
|
||||
bool showFolder() {
|
||||
extern fs::path scenDir;
|
||||
launchURL("file://" + scenDir.string());
|
||||
return true;
|
||||
}
|
||||
|
||||
// Refresh the scenario list (check if custom scenarios added/removed)
|
||||
bool refreshList() {
|
||||
scen_headers = build_scen_headers();
|
||||
auto& stk = dynamic_cast<cStack&>(me["list"]);
|
||||
short page = stk.getPage();
|
||||
// Redo the stack
|
||||
put_scen_info();
|
||||
// Put the viewer to the same page it was (clamped in case the list got shorter)
|
||||
stk.setPage(min(page, stk.getPageCount() - 1));
|
||||
return true;
|
||||
}
|
||||
public:
|
||||
cChooseScenario() {
|
||||
// TODO: Add a button to jump to the scenarios folder
|
||||
// Note: if the player jumps to the scenarios folder and adds scenarios, build_scen_headers() must be called again
|
||||
scen_headers = build_scen_headers(); // TODO: Either make this local to this class, or make it take scen_headers by reference
|
||||
scen_headers = build_scen_headers();
|
||||
}
|
||||
scen_header_type run() {
|
||||
using namespace std::placeholders;
|
||||
@@ -1831,6 +1848,8 @@ public:
|
||||
me["scen1"].attachClickHandler(std::bind(&cChooseScenario::doSelectScenario, this, 0));
|
||||
me["scen2"].attachClickHandler(std::bind(&cChooseScenario::doSelectScenario, this, 1));
|
||||
me["scen3"].attachClickHandler(std::bind(&cChooseScenario::doSelectScenario, this, 2));
|
||||
me["folder"].attachClickHandler(std::bind(&cChooseScenario::showFolder, this));
|
||||
me["refresh"].attachClickHandler(std::bind(&cChooseScenario::refreshList, this));
|
||||
|
||||
put_scen_info();
|
||||
|
||||
|
Reference in New Issue
Block a user