Reform game menu -> command mapping so that the non-platform-dependent code doesn't need to know where the menuitem is
- Also fix some issues with the notes dialogs - Journal is now available; has a different icon now
This commit is contained in:
@@ -3,10 +3,10 @@
|
|||||||
<!--<!DOCTYPE dialog SYSTEM "dialog.dtd">-->
|
<!--<!DOCTYPE dialog SYSTEM "dialog.dtd">-->
|
||||||
<dialog skin='dark' defbtn='done'>
|
<dialog skin='dark' defbtn='done'>
|
||||||
<button name='done' type='done' top='341' left='319'/>
|
<button name='done' type='done' top='341' left='319'/>
|
||||||
<pict type='dlog' num='8' top='9' left='9'/>
|
<pict type='dlog' num='24' top='9' left='9'/>
|
||||||
<text name='str1' framed='true' top='37' left='121' width='257' height='92'/>
|
<text name='str1' framed='true' top='37' left='121' width='257' height='92'/>
|
||||||
<text name='str2' framed='true' top='136' left='121' width='257' height='92'/>
|
<text name='str2' framed='true' top='136' left='121' width='257' height='92'/>
|
||||||
<text name='str2' framed='true' top='235' left='121' width='257' height='92'/>
|
<text name='str3' framed='true' top='235' left='121' width='257' height='92'/>
|
||||||
<text size='large' top='9' left='53' width='257' height='19'>Journal of your Travels:</text>
|
<text size='large' top='9' left='53' width='257' height='19'>Journal of your Travels:</text>
|
||||||
<button name='left' type='left' def-key='left' top='340' left='48'/>
|
<button name='left' type='left' def-key='left' top='340' left='48'/>
|
||||||
<button name='right' type='right' def-key='right' top='340' left='111'/>
|
<button name='right' type='right' def-key='right' top='340' left='111'/>
|
||||||
|
@@ -801,11 +801,8 @@ static bool talk_notes_event_filter(cDialog& me, std::string item_hit, eKeyMod)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void talk_notes() {
|
void talk_notes() {
|
||||||
|
|
||||||
short i;
|
|
||||||
|
|
||||||
store_num_i = 0;
|
store_num_i = 0;
|
||||||
for(i = 0; i < 120; i++)
|
for(size_t i = 0; i < univ.party.talk_save.size(); i++)
|
||||||
if(univ.party.talk_save[i].filled)
|
if(univ.party.talk_save[i].filled)
|
||||||
store_num_i = i + 1;
|
store_num_i = i + 1;
|
||||||
store_page_on = 0;
|
store_page_on = 0;
|
||||||
@@ -859,6 +856,11 @@ static bool journal_event_filter(cDialog& me, std::string item_hit, eKeyMod) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void journal() {
|
void journal() {
|
||||||
|
if(univ.party.journal.empty()) {
|
||||||
|
ASB("Nothing in your events journal.");
|
||||||
|
print_buf();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
unsigned short i;
|
unsigned short i;
|
||||||
char place_str[256];
|
char place_str[256];
|
||||||
@@ -906,7 +908,7 @@ static void give_help(short help1,short help2,cDialog* parent) {
|
|||||||
}
|
}
|
||||||
if((PSD[SDF_NO_INSTANT_HELP] > 0) && !help_forced)
|
if((PSD[SDF_NO_INSTANT_HELP] > 0) && !help_forced)
|
||||||
return;
|
return;
|
||||||
if(univ.party.help_received[help1] > 0)
|
if(univ.party.help_received[help1] > 0 && !help_forced)
|
||||||
return;
|
return;
|
||||||
//if(help1 >= 20)
|
//if(help1 >= 20)
|
||||||
univ.party.help_received[help1] = 1;
|
univ.party.help_received[help1] = 1;
|
||||||
|
135
src/boe.main.cpp
135
src/boe.main.cpp
@@ -434,23 +434,25 @@ void close_program() {
|
|||||||
sync_prefs();
|
sync_prefs();
|
||||||
}
|
}
|
||||||
|
|
||||||
void handle_file_menu(int item_hit) {
|
void handle_menu_choice(eMenu item_hit) {
|
||||||
std::string choice;
|
std::string dialogToShow;
|
||||||
short i;
|
sf::Event dummyEvent = {sf::Event::KeyPressed};
|
||||||
|
short i, choice;
|
||||||
|
|
||||||
switch(item_hit) {
|
switch(item_hit) {
|
||||||
case 1:
|
case eMenu::NONE: break;
|
||||||
|
case eMenu::FILE_OPEN:
|
||||||
do_load();
|
do_load();
|
||||||
break;
|
break;
|
||||||
case 2:
|
case eMenu::FILE_SAVE:
|
||||||
do_save(0);
|
do_save(0);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case eMenu::FILE_SAVE_AS:
|
||||||
do_save(1);
|
do_save(1);
|
||||||
break;
|
break;
|
||||||
case 4:
|
case eMenu::FILE_NEW:
|
||||||
if(overall_mode != MODE_STARTUP) {
|
if(overall_mode != MODE_STARTUP) {
|
||||||
choice = cChoiceDlog("restart-game",{"okay","cancel"}).show();
|
std::string choice = cChoiceDlog("restart-game",{"okay","cancel"}).show();
|
||||||
if(choice == "cancel")
|
if(choice == "cancel")
|
||||||
return;
|
return;
|
||||||
for(i = 0; i < 6; i++)
|
for(i = 0; i < 6; i++)
|
||||||
@@ -464,10 +466,10 @@ void handle_file_menu(int item_hit) {
|
|||||||
draw_startup(0);
|
draw_startup(0);
|
||||||
menu_activate();
|
menu_activate();
|
||||||
break;
|
break;
|
||||||
case 6:
|
case eMenu::PREFS:
|
||||||
pick_preferences();
|
pick_preferences();
|
||||||
break;
|
break;
|
||||||
case 8:
|
case eMenu::QUIT:
|
||||||
|
|
||||||
if(overall_mode == MODE_STARTUP) {
|
if(overall_mode == MODE_STARTUP) {
|
||||||
if(party_in_memory) {
|
if(party_in_memory) {
|
||||||
@@ -483,12 +485,12 @@ void handle_file_menu(int item_hit) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(overall_mode > MODE_TOWN) {
|
if(overall_mode > MODE_TOWN) {
|
||||||
choice = cChoiceDlog("quit-confirm-nosave",{"quit","cancel"}).show();
|
std::string choice = cChoiceDlog("quit-confirm-nosave",{"quit","cancel"}).show();
|
||||||
if(choice == "cancel")
|
if(choice == "cancel")
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
choice = cChoiceDlog("quit-confirm-save",{"quit","save","cancel"}).show();
|
std::string choice = cChoiceDlog("quit-confirm-save",{"quit","save","cancel"}).show();
|
||||||
if(choice == "cancel")
|
if(choice == "cancel")
|
||||||
break;
|
break;
|
||||||
if(choice == "save")
|
if(choice == "save")
|
||||||
@@ -496,21 +498,14 @@ void handle_file_menu(int item_hit) {
|
|||||||
}
|
}
|
||||||
All_Done = true;
|
All_Done = true;
|
||||||
break;
|
break;
|
||||||
}
|
case eMenu::OPTIONS_PC_GRAPHIC:
|
||||||
}
|
|
||||||
|
|
||||||
void handle_options_menu(int item_hit) {
|
|
||||||
short choice,i;
|
|
||||||
|
|
||||||
switch(item_hit) {
|
|
||||||
case 1:
|
|
||||||
choice = char_select_pc(0,0,"New graphic for who?");
|
choice = char_select_pc(0,0,"New graphic for who?");
|
||||||
if(choice < 6)
|
if(choice < 6)
|
||||||
pick_pc_graphic(choice,1,NULL);
|
pick_pc_graphic(choice,1,NULL);
|
||||||
draw_terrain();
|
draw_terrain();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 4:
|
case eMenu::OPTIONS_DELETE_PC:
|
||||||
if(!prime_time()) {
|
if(!prime_time()) {
|
||||||
ASB("Finish what you're doing first.");
|
ASB("Finish what you're doing first.");
|
||||||
print_buf();
|
print_buf();
|
||||||
@@ -527,7 +522,7 @@ void handle_options_menu(int item_hit) {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
case 2:
|
case eMenu::OPTIONS_RENAME_PC:
|
||||||
choice = select_pc(0,0);
|
choice = select_pc(0,0);
|
||||||
if(choice < 6)
|
if(choice < 6)
|
||||||
pick_pc_name(choice,NULL);
|
pick_pc_name(choice,NULL);
|
||||||
@@ -536,7 +531,7 @@ void handle_options_menu(int item_hit) {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
case 3:
|
case eMenu::OPTIONS_NEW_PC:
|
||||||
if(!(is_town())) {
|
if(!(is_town())) {
|
||||||
add_string_to_buf("Add PC: Town mode only.");
|
add_string_to_buf("Add PC: Town mode only.");
|
||||||
print_buf();
|
print_buf();
|
||||||
@@ -565,10 +560,10 @@ void handle_options_menu(int item_hit) {
|
|||||||
put_item_screen(stat_window,0);
|
put_item_screen(stat_window,0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
//case 6:
|
case eMenu::OPTIONS_JOURNAL:
|
||||||
// journal();
|
journal();
|
||||||
// break;////
|
break;
|
||||||
case 6:
|
case eMenu::OPTIONS_TALK_NOTES:
|
||||||
if(overall_mode == MODE_TALKING) {
|
if(overall_mode == MODE_TALKING) {
|
||||||
ASB("Talking notes: Can't read while talking.");
|
ASB("Talking notes: Can't read while talking.");
|
||||||
print_buf();
|
print_buf();
|
||||||
@@ -576,64 +571,63 @@ void handle_options_menu(int item_hit) {
|
|||||||
}
|
}
|
||||||
talk_notes();
|
talk_notes();
|
||||||
break;
|
break;
|
||||||
case 7:
|
case eMenu::OPTIONS_ENCOUNTER_NOTES:
|
||||||
adventure_notes();
|
adventure_notes();
|
||||||
break;
|
break;
|
||||||
case 8:
|
case eMenu::OPTIONS_STATS:
|
||||||
if(overall_mode != MODE_STARTUP)
|
if(overall_mode != MODE_STARTUP)
|
||||||
print_party_stats();
|
print_party_stats();
|
||||||
break;
|
break;
|
||||||
}
|
case eMenu::HELP_OUT:
|
||||||
}
|
dialogToShow = "help-outdoor";
|
||||||
|
|
||||||
void handle_help_menu(int item_hit) {
|
|
||||||
std::string dialogToShow;
|
|
||||||
switch(item_hit) {
|
|
||||||
case 1: dialogToShow = "help-outdoor"; break;
|
|
||||||
case 2: dialogToShow = "help-town"; break;
|
|
||||||
case 3: dialogToShow = "help-combat"; break;
|
|
||||||
case 4: dialogToShow = "help-fields"; break;
|
|
||||||
case 6: dialogToShow = "help-hints"; break;
|
|
||||||
case 7: dialogToShow = "help-magic"; break;
|
|
||||||
case 10: dialogToShow = "about-boe"; break;
|
|
||||||
}
|
|
||||||
if(!dialogToShow.empty())
|
|
||||||
cChoiceDlog(dialogToShow).show();
|
|
||||||
// TODO: Windows version has an option to bring up Windows help for the game; should we have something equivalent for Mac?
|
|
||||||
}
|
|
||||||
void handle_library_menu(int item_hit) {
|
|
||||||
switch(item_hit) {
|
|
||||||
case 1: display_spells(eSkill::MAGE_SPELLS,100,0);
|
|
||||||
break;
|
break;
|
||||||
case 2: display_spells(eSkill::PRIEST_SPELLS,100,0);
|
case eMenu::HELP_TOWN:
|
||||||
|
dialogToShow = "help-town";
|
||||||
break;
|
break;
|
||||||
case 3: display_skills(eSkill::INVALID,0);
|
case eMenu::HELP_COMBAT:
|
||||||
|
dialogToShow = "help-combat";
|
||||||
break;
|
break;
|
||||||
case 4:
|
case eMenu::HELP_BARRIER:
|
||||||
|
dialogToShow = "help-fields";
|
||||||
|
break;
|
||||||
|
case eMenu::HELP_HINTS:
|
||||||
|
dialogToShow = "help-hints";
|
||||||
|
break;
|
||||||
|
case eMenu::HELP_SPELLS:
|
||||||
|
dialogToShow = "help-magic";
|
||||||
|
break;
|
||||||
|
case eMenu::ABOUT:
|
||||||
|
dialogToShow = "about-boe";
|
||||||
|
break;
|
||||||
|
case eMenu::LIBRARY_MAGE:
|
||||||
|
display_spells(eSkill::MAGE_SPELLS,100,0);
|
||||||
|
break;
|
||||||
|
case eMenu::LIBRARY_PRIEST:
|
||||||
|
display_spells(eSkill::PRIEST_SPELLS,100,0);
|
||||||
|
break;
|
||||||
|
case eMenu::LIBRARY_SKILLS:
|
||||||
|
display_skills(eSkill::INVALID,0);
|
||||||
|
break;
|
||||||
|
case eMenu::LIBRARY_ALCHEMY:
|
||||||
// TODO: Create a dedicated dialog for alchemy info
|
// TODO: Create a dedicated dialog for alchemy info
|
||||||
display_alchemy();
|
display_alchemy();
|
||||||
break;
|
break;
|
||||||
case 5:
|
case eMenu::LIBRARY_TIPS:
|
||||||
tip_of_day(); break;
|
tip_of_day();
|
||||||
case 7:
|
|
||||||
cChoiceDlog("welcome").show();
|
|
||||||
break;
|
break;
|
||||||
}
|
case eMenu::LIBRARY_INTRO:
|
||||||
}
|
dialogToShow = "welcome";
|
||||||
|
break;
|
||||||
void handle_actions_menu(int item_hit) {
|
case eMenu::ACTIONS_ALCHEMY:
|
||||||
sf::Event dummyEvent = {sf::Event::KeyPressed};
|
|
||||||
switch(item_hit) {
|
|
||||||
case 1:
|
|
||||||
dummyEvent.key.code = sf::Keyboard::A;
|
dummyEvent.key.code = sf::Keyboard::A;
|
||||||
dummyEvent.key.shift = true;
|
dummyEvent.key.shift = true;
|
||||||
handle_keystroke(dummyEvent);
|
handle_keystroke(dummyEvent);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case eMenu::ACTIONS_WAIT:
|
||||||
dummyEvent.key.code = sf::Keyboard::W;
|
dummyEvent.key.code = sf::Keyboard::W;
|
||||||
handle_keystroke(dummyEvent);
|
handle_keystroke(dummyEvent);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case eMenu::ACTIONS_AUTOMAP:
|
||||||
if(!prime_time()) {
|
if(!prime_time()) {
|
||||||
ASB("Finish what you're doing first.");
|
ASB("Finish what you're doing first.");
|
||||||
print_buf();
|
print_buf();
|
||||||
@@ -644,7 +638,16 @@ void handle_actions_menu(int item_hit) {
|
|||||||
}
|
}
|
||||||
make_cursor_sword();
|
make_cursor_sword();
|
||||||
break;
|
break;
|
||||||
|
case eMenu::HELP_INDEX:
|
||||||
|
launchURL("https://calref.net/~sylae/boe-doc/game/Contents.html");
|
||||||
|
break;
|
||||||
|
case eMenu::ABOUT_MAGE:
|
||||||
|
case eMenu::ABOUT_PRIEST:
|
||||||
|
give_help(209,0);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
if(!dialogToShow.empty())
|
||||||
|
cChoiceDlog(dialogToShow).show();
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Let this function take a cMonster* instead of the item_hit
|
// TODO: Let this function take a cMonster* instead of the item_hit
|
||||||
|
@@ -7,15 +7,6 @@ void Handle_One_Event();
|
|||||||
void Handle_Update();
|
void Handle_Update();
|
||||||
void Mouse_Pressed();
|
void Mouse_Pressed();
|
||||||
void close_program();
|
void close_program();
|
||||||
void handle_file_menu(int item_hit);
|
|
||||||
void handle_options_menu(int item_hit);
|
|
||||||
void handle_help_menu(int item_hit);
|
|
||||||
void handle_library_menu(int item_hit);
|
|
||||||
void handle_actions_menu(int item_hit);
|
|
||||||
void handle_mage_spells_menu(int item_hit);
|
|
||||||
void handle_priest_spells_menu(int item_hit);
|
|
||||||
void handle_monster_info_menu(int item_hit);
|
|
||||||
void handle_music_menu(int item_hit);
|
|
||||||
void change_cursor(location where_curs);
|
void change_cursor(location where_curs);
|
||||||
void set_up_apple_events();
|
void set_up_apple_events();
|
||||||
void move_sound(ter_num_t ter,short step);
|
void move_sound(ter_num_t ter,short step);
|
||||||
|
@@ -17,4 +17,22 @@ void menu_activate();
|
|||||||
void hideMenuBar();
|
void hideMenuBar();
|
||||||
void showMenuBar();
|
void showMenuBar();
|
||||||
|
|
||||||
|
enum class eMenu {
|
||||||
|
NONE, ABOUT, PREFS, QUIT,
|
||||||
|
FILE_NEW, FILE_OPEN, FILE_ABORT, FILE_SAVE, FILE_SAVE_AS,
|
||||||
|
OPTIONS_PC_GRAPHIC, OPTIONS_RENAME_PC, OPTIONS_NEW_PC, OPTIONS_DELETE_PC,
|
||||||
|
OPTIONS_TALK_NOTES, OPTIONS_ENCOUNTER_NOTES, OPTIONS_STATS, OPTIONS_JOURNAL,
|
||||||
|
ACTIONS_ALCHEMY, ACTIONS_WAIT, ACTIONS_AUTOMAP,
|
||||||
|
LIBRARY_MAGE, LIBRARY_PRIEST, LIBRARY_SKILLS, LIBRARY_ALCHEMY, LIBRARY_TIPS, LIBRARY_INTRO,
|
||||||
|
HELP_INDEX, HELP_OUT, HELP_TOWN, HELP_COMBAT, HELP_BARRIER, HELP_HINTS, HELP_SPELLS,
|
||||||
|
// The "About This Menu" options
|
||||||
|
ABOUT_MONSTERS, ABOUT_MAGE, ABOUT_PRIEST,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class eSpell;
|
||||||
|
|
||||||
|
void handle_menu_choice(eMenu item_hit);
|
||||||
|
void handle_menu_spell(eSpell spell_picked);
|
||||||
|
void handle_monster_info_menu(int item_hit);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -34,15 +34,9 @@ MenuHandle apple_menu,file_menu,extra_menu,help_menu,monster_info_menu,library_m
|
|||||||
MenuHandle actions_menu,music_menu,mage_spells_menu,priest_spells_menu;
|
MenuHandle actions_menu,music_menu,mage_spells_menu,priest_spells_menu;
|
||||||
|
|
||||||
@interface MenuHandler : NSObject
|
@interface MenuHandler : NSObject
|
||||||
-(void) fileMenu:(id) sender;
|
-(void) menuChoice:(id) sender;
|
||||||
-(void) optMenu:(id) sender;
|
|
||||||
-(void) actMenu:(id) sender;
|
|
||||||
-(void) monstMenu:(id) sender;
|
-(void) monstMenu:(id) sender;
|
||||||
-(void) spellMenu:(id) sender;
|
-(void) spellMenu:(id) sender;
|
||||||
-(void) libMenu:(id) sender;
|
|
||||||
-(void) helpMenu:(id) sender;
|
|
||||||
-(void) onlineHelp:(id) sender;
|
|
||||||
-(void) menuHelp:(id) sender; // The "About This Menu" options
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@interface MonsterWrapper : NSObject
|
@interface MonsterWrapper : NSObject
|
||||||
@@ -120,32 +114,50 @@ void init_menubar() {
|
|||||||
priest_spells_menu = [[menu_bar_handle itemWithTitle: @"Cast Priest"] submenu];
|
priest_spells_menu = [[menu_bar_handle itemWithTitle: @"Cast Priest"] submenu];
|
||||||
monster_info_menu = [[menu_bar_handle itemWithTitle: @"Monsters"] submenu];
|
monster_info_menu = [[menu_bar_handle itemWithTitle: @"Monsters"] submenu];
|
||||||
|
|
||||||
MenuHandler* handler = [[[MenuHandler alloc] init] retain];
|
static const eMenu file_choices[] = {
|
||||||
setMenuCallback([help_menu itemAtIndex: 0], handler, @selector(onlineHelp:), 0);
|
eMenu::FILE_NEW, eMenu::FILE_OPEN, eMenu::NONE, eMenu::FILE_ABORT, eMenu::FILE_SAVE, eMenu::FILE_SAVE_AS,
|
||||||
setMenuCallback([apple_menu itemWithTitle: @"About Blades of Exile"], handler, @selector(helpMenu:), 10);
|
};
|
||||||
setMenuCallback([apple_menu itemWithTitle: @"Preferences…"], handler, @selector(fileMenu:), 6);
|
static const eMenu opt_choices[] = {
|
||||||
setMenuCallback([apple_menu itemWithTitle: @"Quit Blades of Exile"], handler, @selector(fileMenu:), 8);
|
eMenu::OPTIONS_PC_GRAPHIC, eMenu::OPTIONS_RENAME_PC, eMenu::OPTIONS_NEW_PC, eMenu::OPTIONS_DELETE_PC, eMenu::NONE,
|
||||||
// TODO: Check to make sure that Cocoa 0-indexes its menus
|
eMenu::OPTIONS_TALK_NOTES, eMenu::OPTIONS_ENCOUNTER_NOTES, eMenu::OPTIONS_STATS, eMenu::OPTIONS_JOURNAL,
|
||||||
// TODO: Need to verify arrangement of the File menu
|
};
|
||||||
setMenuCallback([file_menu itemWithTitle: @"New Game…"], handler, @selector(fileMenu:), 4);
|
static const eMenu act_choices[] = {
|
||||||
setMenuCallback([file_menu itemWithTitle: @"Save"], handler, @selector(fileMenu:), 2);
|
eMenu::ACTIONS_ALCHEMY, eMenu::ACTIONS_WAIT, eMenu::ACTIONS_AUTOMAP,
|
||||||
setMenuCallback([file_menu itemWithTitle: @"Save As…"], handler, @selector(fileMenu:), 3);
|
};
|
||||||
setMenuCallback([file_menu itemWithTitle: @"Open…"], handler, @selector(fileMenu:), 1);
|
static const eMenu lib_choices[] = {
|
||||||
setMenuCallback([file_menu itemWithTitle: @"Abort"], handler, @selector(fileMenu:), 0);
|
eMenu::LIBRARY_MAGE, eMenu::LIBRARY_PRIEST, eMenu::LIBRARY_SKILLS, eMenu::LIBRARY_ALCHEMY, eMenu::LIBRARY_TIPS,
|
||||||
// for(int i = 0; i < [file_menu numberOfItems]; i++)
|
eMenu::NONE, eMenu::LIBRARY_INTRO,
|
||||||
// setMenuCallback([file_menu itemAtIndex: i], handler, @selector(fileMenu:), i + 1);
|
};
|
||||||
for(int i = 0; i < [extra_menu numberOfItems]; i++)
|
static const eMenu help_choices[] = {
|
||||||
setMenuCallback([extra_menu itemAtIndex: i], handler, @selector(optMenu:), i + 1);
|
eMenu::HELP_INDEX, eMenu::NONE, eMenu::HELP_OUT, eMenu::HELP_TOWN, eMenu::HELP_COMBAT, eMenu::HELP_BARRIER,
|
||||||
for(int i = 1; i < [help_menu numberOfItems]; i++)
|
eMenu::NONE, eMenu::HELP_HINTS, eMenu::HELP_SPELLS,
|
||||||
setMenuCallback([help_menu itemAtIndex: i], handler, @selector(helpMenu:), i - 1);
|
};
|
||||||
for(int i = 0; i < [library_menu numberOfItems]; i++)
|
|
||||||
setMenuCallback([library_menu itemAtIndex: i], handler, @selector(libMenu:), i + 1);
|
|
||||||
for(int i = 0; i < [actions_menu numberOfItems]; i++)
|
|
||||||
setMenuCallback([actions_menu itemAtIndex: i], handler, @selector(actMenu:), i + 1);
|
|
||||||
|
|
||||||
setMenuCallback([mage_spells_menu itemAtIndex: 0], handler, @selector(menuHelp:), 0);
|
MenuHandler* handler = [[[MenuHandler alloc] init] retain];
|
||||||
setMenuCallback([priest_spells_menu itemAtIndex: 0], handler, @selector(menuHelp:), 1);
|
setMenuCallback([apple_menu itemWithTitle: @"About Blades of Exile"], handler, @selector(menuChoice:), int(eMenu::ABOUT));
|
||||||
setMenuCallback([monster_info_menu itemAtIndex: 0], handler, @selector(menuHelp:), 2);
|
setMenuCallback([apple_menu itemWithTitle: @"Preferences…"], handler, @selector(menuChoice:), int(eMenu::PREFS));
|
||||||
|
setMenuCallback([apple_menu itemWithTitle: @"Quit Blades of Exile"], handler, @selector(menuChoice:), int(eMenu::QUIT));
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
for(eMenu opt : file_choices)
|
||||||
|
setMenuCallback([file_menu itemAtIndex: i++], handler, @selector(menuChoice:), int(opt));
|
||||||
|
i = 0;
|
||||||
|
for(eMenu opt : opt_choices)
|
||||||
|
setMenuCallback([extra_menu itemAtIndex: i++], handler, @selector(menuChoice:), int(opt));
|
||||||
|
i = 0;
|
||||||
|
for(eMenu opt : act_choices)
|
||||||
|
setMenuCallback([actions_menu itemAtIndex: i++], handler, @selector(menuChoice:), int(opt));
|
||||||
|
i = 0;
|
||||||
|
for(eMenu opt : lib_choices)
|
||||||
|
setMenuCallback([library_menu itemAtIndex: i++], handler, @selector(menuChoice:), int(opt));
|
||||||
|
i = 0;
|
||||||
|
for(eMenu opt : help_choices)
|
||||||
|
setMenuCallback([help_menu itemAtIndex: i++], handler, @selector(menuChoice:), int(opt));
|
||||||
|
i = 0;
|
||||||
|
|
||||||
|
setMenuCallback([mage_spells_menu itemAtIndex: 0], handler, @selector(menuChoice:), int(eMenu::ABOUT_MAGE));
|
||||||
|
setMenuCallback([priest_spells_menu itemAtIndex: 0], handler, @selector(menuChoice:), int(eMenu::ABOUT_PRIEST));
|
||||||
|
setMenuCallback([monster_info_menu itemAtIndex: 0], handler, @selector(menuChoice:), int(eMenu::ABOUT_MONSTERS));
|
||||||
|
|
||||||
menu_activate();
|
menu_activate();
|
||||||
}
|
}
|
||||||
@@ -272,27 +284,7 @@ void menu_activate() {
|
|||||||
[[file_menu itemWithTitle: @"Save As…"] setEnabled: YES];
|
[[file_menu itemWithTitle: @"Save As…"] setEnabled: YES];
|
||||||
}
|
}
|
||||||
|
|
||||||
void handle_file_menu(int item_hit);
|
|
||||||
void handle_options_menu(int item_hit);
|
|
||||||
void handle_help_menu(int item_hit);
|
|
||||||
void handle_library_menu(int item_hit);
|
|
||||||
void handle_actions_menu(int item_hit);
|
|
||||||
void handle_monster_info_menu(int item_hit);
|
|
||||||
void handle_menu_spell(eSpell spell_picked);
|
|
||||||
|
|
||||||
@implementation MenuHandler
|
@implementation MenuHandler
|
||||||
-(void) fileMenu:(id) sender {
|
|
||||||
handle_file_menu([[sender representedObject] intValue]);
|
|
||||||
}
|
|
||||||
|
|
||||||
-(void) optMenu:(id) sender {
|
|
||||||
handle_options_menu([[sender representedObject] intValue]);
|
|
||||||
}
|
|
||||||
|
|
||||||
-(void) actMenu:(id) sender {
|
|
||||||
handle_actions_menu([[sender representedObject] intValue]);
|
|
||||||
}
|
|
||||||
|
|
||||||
-(void) monstMenu:(id) sender {
|
-(void) monstMenu:(id) sender {
|
||||||
cMonster* monst = [[sender representedObject] monst];
|
cMonster* monst = [[sender representedObject] monst];
|
||||||
handle_monster_info_menu([monster_info_menu indexOfItem: sender] - 1);
|
handle_monster_info_menu([monster_info_menu indexOfItem: sender] - 1);
|
||||||
@@ -303,23 +295,8 @@ void handle_menu_spell(eSpell spell_picked);
|
|||||||
handle_menu_spell(cSpell::fromNum([spell type], [spell num]));
|
handle_menu_spell(cSpell::fromNum([spell type], [spell num]));
|
||||||
}
|
}
|
||||||
|
|
||||||
-(void) libMenu:(id) sender {
|
-(void) menuChoice:(id) sender {
|
||||||
handle_library_menu([[sender representedObject] intValue]);
|
handle_menu_choice(eMenu([[sender representedObject] intValue]));
|
||||||
}
|
|
||||||
|
|
||||||
-(void) helpMenu:(id) sender {
|
|
||||||
handle_help_menu([[sender representedObject] intValue]);
|
|
||||||
}
|
|
||||||
|
|
||||||
-(void) onlineHelp:(id) sender {
|
|
||||||
(void) sender; // Suppress "unused parameter" warning
|
|
||||||
[[NSWorkspace sharedWorkspace] openURL: [NSURL URLWithString: @"https://calref.net/~sylae/boe-doc/game/Contents.html"]];
|
|
||||||
}
|
|
||||||
|
|
||||||
-(void) menuHelp:(id) sender {
|
|
||||||
// TODO: Do something for monster menu as well
|
|
||||||
if([[sender representedObject] intValue] < 2)
|
|
||||||
give_help(209,0);
|
|
||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
|
|
||||||
#include "boe.menus.h"
|
#include "boe.menus.h"
|
||||||
|
#include <map>
|
||||||
#include <SFML/Graphics/RenderWindow.hpp>
|
#include <SFML/Graphics/RenderWindow.hpp>
|
||||||
#include "Resource.h"
|
#include "Resource.h"
|
||||||
#include "universe.h"
|
#include "universe.h"
|
||||||
@@ -35,9 +36,19 @@ extern eGameMode overall_mode;
|
|||||||
extern sf::RenderWindow mainPtr;
|
extern sf::RenderWindow mainPtr;
|
||||||
LONG_PTR mainProc;
|
LONG_PTR mainProc;
|
||||||
HMENU menuHandle = NULL;
|
HMENU menuHandle = NULL;
|
||||||
|
std::map<int,eMenu> menuChoices;
|
||||||
|
|
||||||
LRESULT CALLBACK menuProc(HWND handle, UINT message, WPARAM wParam, LPARAM lParam);
|
LRESULT CALLBACK menuProc(HWND handle, UINT message, WPARAM wParam, LPARAM lParam);
|
||||||
|
|
||||||
|
void setMenuCommand(HMENU& menu, int i, eMenu cmd) {
|
||||||
|
MENUITEMINFOA item;
|
||||||
|
item.cbSize = sizeof(MENUITEMINFOA);
|
||||||
|
item.fMask = MIIM_ID | MIIM_FTYPE;
|
||||||
|
GetMenuItemInfoA(menu, i++, true, &item);
|
||||||
|
if(item.fType == MFT_SEPARATOR) return;
|
||||||
|
menuChoices[item.wID] = cmd;
|
||||||
|
}
|
||||||
|
|
||||||
void init_menubar() {
|
void init_menubar() {
|
||||||
HWND winHandle = mainPtr.getSystemHandle();
|
HWND winHandle = mainPtr.getSystemHandle();
|
||||||
if(winHandle == NULL) return;
|
if(winHandle == NULL) return;
|
||||||
@@ -54,6 +65,52 @@ void init_menubar() {
|
|||||||
double usableHeight = sz.y - menubarHeight;
|
double usableHeight = sz.y - menubarHeight;
|
||||||
sf::View view(sf::FloatRect(0, 0, sz.x, usableHeight));
|
sf::View view(sf::FloatRect(0, 0, sz.x, usableHeight));
|
||||||
mainPtr.setView(view);
|
mainPtr.setView(view);
|
||||||
|
|
||||||
|
// And now initialize the mapping from Windows menu commands to eMenu constants
|
||||||
|
static bool inited = false;
|
||||||
|
if(inited) return;
|
||||||
|
inited = true;
|
||||||
|
|
||||||
|
static const eMenu file_choices[] = {
|
||||||
|
eMenu::FILE_NEW, eMenu::FILE_OPEN, eMenu::NONE, eMenu::FILE_ABORT, eMenu::FILE_SAVE, eMenu::FILE_SAVE_AS, eMenu::NONE, eMenu::PREFS, eMenu::NONE, eMenu::QUIT,
|
||||||
|
};
|
||||||
|
static const eMenu opt_choices[] = {
|
||||||
|
eMenu::OPTIONS_PC_GRAPHIC, eMenu::OPTIONS_RENAME_PC, eMenu::OPTIONS_NEW_PC, eMenu::OPTIONS_DELETE_PC, eMenu::NONE,
|
||||||
|
eMenu::OPTIONS_TALK_NOTES, eMenu::OPTIONS_ENCOUNTER_NOTES, eMenu::OPTIONS_STATS, eMenu::OPTIONS_JOURNAL,
|
||||||
|
};
|
||||||
|
static const eMenu act_choices[] = {
|
||||||
|
eMenu::ACTIONS_ALCHEMY, eMenu::ACTIONS_WAIT, eMenu::ACTIONS_AUTOMAP,
|
||||||
|
};
|
||||||
|
static const eMenu lib_choices[] = {
|
||||||
|
eMenu::LIBRARY_MAGE, eMenu::LIBRARY_PRIEST, eMenu::LIBRARY_SKILLS, eMenu::LIBRARY_ALCHEMY, eMenu::LIBRARY_TIPS,
|
||||||
|
eMenu::NONE, eMenu::LIBRARY_INTRO,
|
||||||
|
};
|
||||||
|
static const eMenu help_choices[] = {
|
||||||
|
eMenu::HELP_INDEX, eMenu::ABOUT, eMenu::NONE, eMenu::HELP_OUT, eMenu::HELP_TOWN, eMenu::HELP_COMBAT, eMenu::HELP_BARRIER,
|
||||||
|
eMenu::NONE, eMenu::HELP_HINTS, eMenu::HELP_SPELLS,
|
||||||
|
};
|
||||||
|
|
||||||
|
HMENU file_menu = GetSubMenu(menuHandle, FILE_MENU_POS);
|
||||||
|
HMENU opt_menu = GetSubMenu(menuHandle, OPT_MENU_POS);
|
||||||
|
HMENU act_menu = GetSubMenu(menuHandle, ACT_MENU_POS);
|
||||||
|
HMENU lib_menu = GetSubMenu(menuHandle, LIB_MENU_POS);
|
||||||
|
HMENU help_menu = GetSubMenu(menuHandle, HELP_MENU_POS);
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
for(eMenu opt : file_choices)
|
||||||
|
setMenuCommand(file_menu, i++, opt);
|
||||||
|
i = 0;
|
||||||
|
for(eMenu opt : opt_choices)
|
||||||
|
setMenuCommand(opt_menu, i++, opt);
|
||||||
|
i = 0;
|
||||||
|
for(eMenu opt : act_choices)
|
||||||
|
setMenuCommand(act_menu, i++, opt);
|
||||||
|
i = 0;
|
||||||
|
for(eMenu opt : lib_choices)
|
||||||
|
setMenuCommand(lib_menu, i++, opt);
|
||||||
|
i = 0;
|
||||||
|
for(eMenu opt : help_choices)
|
||||||
|
setMenuCommand(help_menu, i++, opt);
|
||||||
}
|
}
|
||||||
|
|
||||||
void adjust_monst_menu() {
|
void adjust_monst_menu() {
|
||||||
@@ -212,14 +269,6 @@ void showMenuBar() {
|
|||||||
DrawMenuBar(mainPtr.getSystemHandle());
|
DrawMenuBar(mainPtr.getSystemHandle());
|
||||||
}
|
}
|
||||||
|
|
||||||
void handle_file_menu(int item_hit);
|
|
||||||
void handle_options_menu(int item_hit);
|
|
||||||
void handle_help_menu(int item_hit);
|
|
||||||
void handle_library_menu(int item_hit);
|
|
||||||
void handle_actions_menu(int item_hit);
|
|
||||||
void handle_monster_info_menu(int item_hit);
|
|
||||||
void handle_menu_spell(eSpell spell_picked);
|
|
||||||
|
|
||||||
#include "cursors.h"
|
#include "cursors.h"
|
||||||
|
|
||||||
LRESULT CALLBACK menuProc(HWND handle, UINT message, WPARAM wParam, LPARAM lParam) {
|
LRESULT CALLBACK menuProc(HWND handle, UINT message, WPARAM wParam, LPARAM lParam) {
|
||||||
@@ -231,48 +280,7 @@ LRESULT CALLBACK menuProc(HWND handle, UINT message, WPARAM wParam, LPARAM lPara
|
|||||||
handle_menu_spell(cSpell::fromNum(eSkill::MAGE_SPELLS, cmd - 2000));
|
handle_menu_spell(cSpell::fromNum(eSkill::MAGE_SPELLS, cmd - 2000));
|
||||||
} else if(cmd >= 3000 && cmd < 4000) {
|
} else if(cmd >= 3000 && cmd < 4000) {
|
||||||
handle_menu_spell(cSpell::fromNum(eSkill::PRIEST_SPELLS, cmd - 3000));
|
handle_menu_spell(cSpell::fromNum(eSkill::PRIEST_SPELLS, cmd - 3000));
|
||||||
} else switch(cmd) {
|
} else handle_menu_choice(menuChoices[cmd]);
|
||||||
// File menu
|
|
||||||
case IDM_FILE_NEW: handle_file_menu(4); break;
|
|
||||||
case IDM_FILE_OPEN: handle_file_menu(1); break;
|
|
||||||
case IDM_FILE_ABORT: handle_file_menu(0); break;
|
|
||||||
case IDM_FILE_SAVE: handle_file_menu(2); break;
|
|
||||||
case IDM_FILE_SAVE_AS: handle_file_menu(3); break;
|
|
||||||
case IDM_FILE_PREFS: handle_file_menu(6); break;
|
|
||||||
case IDM_FILE_QUIT: handle_file_menu(8); break;
|
|
||||||
// Options menu
|
|
||||||
case IDM_OPTIONS_GRAPHIC: handle_options_menu(1); break;
|
|
||||||
case IDM_OPTIONS_NAME: handle_options_menu(2); break;
|
|
||||||
case IDM_OPTIONS_NEW: handle_options_menu(3); break;
|
|
||||||
case IDM_OPTIONS_DELETE: handle_options_menu(4); break;
|
|
||||||
case IDM_OPTIONS_TALKING: handle_options_menu(6); break;
|
|
||||||
case IDM_OPTIONS_ENCOUNTER: handle_options_menu(7); break;
|
|
||||||
case IDM_OPTIONS_STATS: handle_options_menu(8); break;
|
|
||||||
// Actions menu
|
|
||||||
case IDM_ACTIONS_ALCHEMY: handle_actions_menu(1); break;
|
|
||||||
case IDM_ACTIONS_WAIT: handle_actions_menu(2); break;
|
|
||||||
case IDM_ACTIONS_MAP: handle_actions_menu(3); break;
|
|
||||||
// Monster/Spell menu About items
|
|
||||||
case IDM_MONSTERS_ABOUT: break;
|
|
||||||
case IDM_MAGE_ABOUT: give_help(209, 0); break;
|
|
||||||
case IDM_PRIEST_ABOUT: give_help(209, 0); break;
|
|
||||||
// Library menu
|
|
||||||
case IDM_LIBRARY_MAGE: handle_library_menu(1); break;
|
|
||||||
case IDM_LIBRARY_PRIEST: handle_library_menu(2); break;
|
|
||||||
case IDM_LIBRARY_ALCHEMY: handle_library_menu(3); break;
|
|
||||||
case IDM_LIBRARY_SKILLS: handle_library_menu(4); break;
|
|
||||||
case IDM_LIBRARY_TIPS: handle_library_menu(5); break;
|
|
||||||
case IDM_LIBRARY_INTRO: handle_library_menu(7); break;
|
|
||||||
// Help menu
|
|
||||||
case IDM_HELP_INDEX: ShellExecuteA(NULL, "open", "https://calref.net/~sylae/boe-doc/game/Contents.html", NULL, NULL, SW_SHOWNORMAL); break;
|
|
||||||
case IDM_HELP_ABOUT: handle_help_menu(10); break;
|
|
||||||
case IDM_HELP_OUTDOOR: handle_help_menu(1); break;
|
|
||||||
case IDM_HELP_TOWN: handle_help_menu(2); break;
|
|
||||||
case IDM_HELP_COMBAT: handle_help_menu(3); break;
|
|
||||||
case IDM_HELP_BARRIER: handle_help_menu(4); break;
|
|
||||||
case IDM_HELP_HINTS: handle_help_menu(6); break;
|
|
||||||
case IDM_HELP_SPELLS: handle_help_menu(7); break;
|
|
||||||
}
|
|
||||||
} else if(message == WM_SETCURSOR) {
|
} else if(message == WM_SETCURSOR) {
|
||||||
// Windows resets the cursor to an arrow whenever the mouse moves, unless we do this.
|
// Windows resets the cursor to an arrow whenever the mouse moves, unless we do this.
|
||||||
// Note: By handling this message, sf::Window::setMouseCursorVisible() will NOT work.
|
// Note: By handling this message, sf::Window::setMouseCursorVisible() will NOT work.
|
||||||
|
@@ -379,7 +379,6 @@
|
|||||||
<array class="NSMutableArray" key="NSMenuItems">
|
<array class="NSMutableArray" key="NSMenuItems">
|
||||||
<object class="NSMenuItem" id="89118923">
|
<object class="NSMenuItem" id="89118923">
|
||||||
<reference key="NSMenu" ref="974783340"/>
|
<reference key="NSMenu" ref="974783340"/>
|
||||||
<bool key="NSIsDisabled">YES</bool>
|
|
||||||
<string key="NSTitle">About this menu</string>
|
<string key="NSTitle">About this menu</string>
|
||||||
<string key="NSKeyEquiv"/>
|
<string key="NSKeyEquiv"/>
|
||||||
<int key="NSMnemonicLoc">2147483647</int>
|
<int key="NSMnemonicLoc">2147483647</int>
|
||||||
|
Reference in New Issue
Block a user