Implement the close and revert menu choices, as well as PC editor help

- Fix storing directions in save file as control characters
This commit is contained in:
2015-02-14 13:19:52 -05:00
parent 4fbc6cfa77
commit 0aaa299642
13 changed files with 96 additions and 31 deletions

View File

@@ -7,8 +7,9 @@
//
#include <Cocoa/Cocoa.h>
#include <string>
extern bool verify_restore_quit(bool mode);
extern bool verify_restore_quit(std::string dlog);
extern bool All_Done;
typedef NSAppleEventDescriptor AEDescr;
@@ -37,7 +38,7 @@ void set_up_apple_events() {
-(void)handleQuit:(AEDescr*)theAppleEvent withReply: (AEDescr*)reply {
(void) theAppleEvent; // Suppress "unused parameter" warning
(void) reply;
All_Done = verify_restore_quit(0);
All_Done = verify_restore_quit("save-quit");
}
@end

View File

@@ -53,7 +53,7 @@ void Handle_One_Event();
void Handle_Activate();
void Handle_Update();
void Mouse_Pressed();
bool verify_restore_quit(bool mode);
bool verify_restore_quit(std::string dlog);
void set_up_apple_events();
extern bool cur_scen_is_mac;
extern fs::path progDir;
@@ -132,7 +132,7 @@ void Handle_One_Event() {
break;
case sf::Event::Closed:
All_Done = verify_restore_quit(false);
All_Done = verify_restore_quit("save-quit");
break;
default:
@@ -145,7 +145,7 @@ void Mouse_Pressed() {
try_to_end = handle_action(event);
if(try_to_end)
All_Done = verify_restore_quit(false);
All_Done = verify_restore_quit("save-quit");
}
static void display_strings(short nstr, pic_num_t pic) {
@@ -170,8 +170,12 @@ void handle_menu_choice(eMenu item_hit) {
if(!file.empty()) save_party(file, univ);
break;
case eMenu::FILE_OPEN:
if(verify_restore_quit(true)){
file = nav_get_party();
i = verify_restore_quit("save-open");
if(false)
case eMenu::FILE_REVERT:
i = cChoiceDlog("save-revert", {"okay", "cancel"}).show() == "okay";
if(i) {
file = item_hit == eMenu::FILE_OPEN ? nav_get_party() : file_in_mem;
if(!file.empty()) {
if(load_party(file, univ)) {
file_in_mem = file;
@@ -184,8 +188,12 @@ void handle_menu_choice(eMenu item_hit) {
menu_activate();
}
break;
case eMenu::FILE_CLOSE:
if(verify_restore_quit("save-close"))
file_in_mem = "";
break;
case eMenu::QUIT:
All_Done = verify_restore_quit(false);
All_Done = verify_restore_quit("save-quit");
break;
case eMenu::EDIT_GOLD:
edit_gold_or_food(0);
@@ -310,6 +318,9 @@ void handle_menu_choice(eMenu item_hit) {
case eMenu::SET_SDF:
edit_stuff_done();
break;
case eMenu::HELP_TOC:
launchURL("https://calref.net/~sylae/boe-doc/game/Editor.html");
break;
}
}
@@ -321,13 +332,12 @@ void handle_item_menu(int item_hit) {
univ.party[current_active_pc].give_item(store_i,false);
}
//short mode; // 0 - quit 1- restore
bool verify_restore_quit(bool mode) {
bool verify_restore_quit(std::string dlog) {
std::string choice;
if(file_in_mem.empty())
return true;
cChoiceDlog verify(mode ? "save-open" : "save-quit", {"save", "quit", "cancel"});
cChoiceDlog verify(dlog, {"save", "quit", "cancel"});
choice = verify.show();
if(choice == "cancel")
return false;

View File

@@ -568,14 +568,6 @@
</array>
<object class="IBObjectContainer" key="IBDocument.Objects">
<array class="NSMutableArray" key="connectionRecords">
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">showHelp:</string>
<reference key="source" ref="1014"/>
<reference key="destination" ref="238773614"/>
</object>
<int key="connectionID">360</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">hide:</string>

View File

@@ -75,6 +75,7 @@ void init_menubar() {
MenuHandler* handler = [[[MenuHandler alloc] init] retain];
setMenuCallback([apple_menu itemWithTitle: @"About BoE Character Editor"], handler, @selector(menuChoice:), int(eMenu::ABOUT));
setMenuCallback([apple_menu itemWithTitle: @"Quit BoE Character Editor"], handler, @selector(menuChoice:), int(eMenu::QUIT));
setMenuCallback([[[menu_bar_handle itemWithTitle: @"Help"] submenu] itemAtIndex: 0], handler, @selector(menuChoice:), int(eMenu::HELP_TOC));
int i = 0;
for(eMenu opt : file_choices)

View File

@@ -73,7 +73,7 @@ void init_menubar() {
eMenu::NONE, eMenu::LEAVE_SCENARIO, eMenu::SET_SDF,
};
static const eMenu help_choices[] = {
eMenu::ABOUT,
eMenu::ABOUT, eMenu::HELP_TOC
};
HMENU file_menu = GetSubMenu(menuHandle, FILE_MENU_POS);