From 76ccb66786208c2e03542082612c58103e09a870 Mon Sep 17 00:00:00 2001 From: Celtic Minstrel Date: Wed, 10 Dec 2014 19:36:24 -0500 Subject: [PATCH] Beep beep --- osx/boe.dlgutil.cpp | 15 +++++++++++---- osx/boe.items.cpp | 4 ++-- osx/boe.party.cpp | 5 +++-- osx/boe.town.cpp | 2 +- osx/boe.townspec.cpp | 3 ++- osx/pcedit/pc.editors.cpp | 13 ++++++++----- osx/scenedit/scen.main.cpp | 3 ++- osx/tools/winutil.h | 2 ++ osx/tools/winutil.mac.mm | 4 ++++ 9 files changed, 35 insertions(+), 16 deletions(-) diff --git a/osx/boe.dlgutil.cpp b/osx/boe.dlgutil.cpp index 0bdb34d5..b401104d 100644 --- a/osx/boe.dlgutil.cpp +++ b/osx/boe.dlgutil.cpp @@ -26,6 +26,7 @@ #include "graphtool.h" #include "mathutil.h" #include "dlogutil.h" +#include "winutil.h" #include "fileio.h" #include "restypes.hpp" #include "scrollbar.h" @@ -306,7 +307,10 @@ void handle_sale(short what_chosen,short cost) case 8: base_item = store_mage_spells(what_chosen - 800 - 30); if ((base_item.item_level < 0) || (base_item.item_level > 61)) { - ASB("Error 102: Report this!"); break;} // TODO: Play an error sound here + beep(); + giveError("Error: The scenario tried to sell you an invalid mage spell!"); + break; + } if (univ.party[current_pc].mage_spells[base_item.item_level] == true) ASB("You already have this spell."); else if (take_gold(cost,false) == false) @@ -321,7 +325,10 @@ void handle_sale(short what_chosen,short cost) case 9: base_item = store_priest_spells(what_chosen - 900 - 30); if ((base_item.item_level < 0) || (base_item.item_level > 61)) { - ASB("Error 101: Report this!"); break;} // TODO: Play an error sound here + beep(); + giveError("Error: The scenario tried to sell you an invalid priest spell!"); + break; + } if (univ.party[current_pc].priest_spells[base_item.item_level] == true) ASB("You already have this spell."); else if (take_gold(cost,false) == false) @@ -351,7 +358,7 @@ void handle_sale(short what_chosen,short cost) set_up_shop_array(); if (overall_mode != MODE_SHOPPING) { - // TODO: Play an error sound here + beep(); ASB("Shop error 1. Report This!"); } draw_shop_graphics(0,dummy_rect); @@ -649,7 +656,7 @@ void handle_talk_event(location p) break; case TALK_RECORD: if (strnum1 <= 0) { - // TODO: Play an error sound here + beep(); return; } if(univ.party.has_talk_save(store_personality, univ.town.num, strnum1, strnum2)){ diff --git a/osx/boe.items.cpp b/osx/boe.items.cpp index 798a7f89..d079bb57 100644 --- a/osx/boe.items.cpp +++ b/osx/boe.items.cpp @@ -138,7 +138,7 @@ bool give_to_pc(short pc_num,cItemRec item,short print_result,bool allow_overl if(!allow_overload && item.item_weight() > amount_pc_can_carry(pc_num) - pc_carry_weight(pc_num)) { if (print_result == true) { - // TODO: Play an error sound here + beep(); // TODO: This is a game event, so it should have a game sound, not a system alert. ASB("Item too heavy to carry."); } return false; @@ -1028,7 +1028,7 @@ static bool display_item_event_filter(cDialog& me, std::string id, size_t& first play_sound(62); // formerly force_play_sound } else { if(!allow_overload && item.item_weight() > amount_pc_can_carry(current_getting_pc) - pc_carry_weight(current_getting_pc)) { - // TODO: Play an error sound here + beep(); // TODO: This is a game event, so it should have a game sound, not a system alert. me["prompt"].setText("It's too heavy to carry."); give_help(38,0,me); return true; diff --git a/osx/boe.party.cpp b/osx/boe.party.cpp index 8c025598..40e077af 100644 --- a/osx/boe.party.cpp +++ b/osx/boe.party.cpp @@ -27,6 +27,7 @@ #include "graphtool.h" #include "mathutil.h" #include "dlogutil.h" +#include "winutil.h" #include "fileio.h" #include "boe.menus.h" #include "restypes.hpp" @@ -875,13 +876,13 @@ void award_xp(short pc_num,short amt) return; } if (amt > 200) { // debug - // TODO: Play an error sound here + beep(); ASB("Oops! Too much xp!"); ASB("Report this!"); return; } if (amt < 0) { // debug - // TODO: Play an error sound here + beep(); ASB("Oops! Negative xp!"); ASB("Report this!"); return; diff --git a/osx/boe.town.cpp b/osx/boe.town.cpp index 138b6d01..c552913b 100644 --- a/osx/boe.town.cpp +++ b/osx/boe.town.cpp @@ -1208,7 +1208,7 @@ void erase_specials()//// where = univ.town->special_locs[k]; if ((where.x != 100) && ((where.x > univ.town->max_dim()) || (where.y > univ.town->max_dim()) || (where.x < 0) || (where.y < 0))) { - // TODO: Play an error sound here + beep(); add_string_to_buf("Town corrupt. Problem fixed."); print_nums(where.x,where.y,k); univ.town->special_locs[k].x = 0; diff --git a/osx/boe.townspec.cpp b/osx/boe.townspec.cpp index 4bf697e5..96c6d299 100644 --- a/osx/boe.townspec.cpp +++ b/osx/boe.townspec.cpp @@ -18,6 +18,7 @@ #include "soundtool.h" #include "mathutil.h" #include "dlogutil.h" +#include "winutil.h" extern eGameMode overall_mode; //extern party_record_type univ.party; @@ -81,7 +82,7 @@ bool run_trap(short pc_num,eTrapType trap_type,short trap_level,short diff) 78,80,82,84,86, 88,90,92,94,96,98,99,99,99,99,99,99,99,99,99}; if (pc_num > 7) { // Debug - // TODO: Play an error sound here + beep(); ASB("TRAP ERROR! REPORT!"); return true; } diff --git a/osx/pcedit/pc.editors.cpp b/osx/pcedit/pc.editors.cpp index a48c1a7e..7977a920 100644 --- a/osx/pcedit/pc.editors.cpp +++ b/osx/pcedit/pc.editors.cpp @@ -8,6 +8,7 @@ #include "control.h" #include "button.h" #include "dlogutil.h" +#include "winutil.h" #include /* @@ -432,7 +433,8 @@ static bool spend_xp_navigate_filter(cDialog& me, std::string item_hit, eKeyMod) } while (univ.party[pc_num].main_status != eMainStatus::ALIVE); store_train_pc = pc_num; do_xp_draw(me); - } // else TODO: Play an error sound here + } else + beep(); // TODO: This is a game event, so it should have a game sound, not a system alert. } else if(item_hit == "right") { // TODO: If they don't work in mode 0, why are they visible? if (mode != 0) { @@ -442,7 +444,8 @@ static bool spend_xp_navigate_filter(cDialog& me, std::string item_hit, eKeyMod) } while (univ.party[pc_num].main_status != eMainStatus::ALIVE); store_train_pc = pc_num; do_xp_draw(me); - } // else TODO: Play an error sound here + } else + beep(); // TODO: This is a game event, so it should have a game sound, not a system alert. } store_train_pc = pc_num; if (talk_done == true) { @@ -461,7 +464,7 @@ static bool spend_xp_event_filter(cDialog& me, std::string item_hit, eKeyMod mod } else if (((store_h >= 250) && (item_hit[3] == 'p')) || ((store_h == univ.party[pc_num].max_health) && (item_hit[3] == 'm') && (mode == 1)) || ((store_h == 6) && (item_hit[3] == 'm') && (mode == 0))) - ; // TODO: Play an error sound here + beep(); // TODO: This is a game event, so it should have a game sound, not a system alert. else if(item_hit == "hp-m") { store_g += 10; store_h -= 2; @@ -492,7 +495,7 @@ static bool spend_xp_event_filter(cDialog& me, std::string item_hit, eKeyMod mod } else if (((store_sp >= 150) && (item_hit[3] == 'p')) || ((store_sp == univ.party[pc_num].max_sp) && (item_hit[3] == 'm') && (mode == 1)) || ((store_sp == 0) && (item_hit[3] == 'm') && (mode == 0))) - ; // TODO: Play an error sound here + beep(); // TODO: This is a game event, so it should have a game sound, not a system alert. else if(item_hit == "sp-m") { store_g += 15; store_sp -= 1; @@ -531,7 +534,7 @@ static bool spend_xp_event_filter(cDialog& me, std::string item_hit, eKeyMod mod ((store_skills[which_skill] == univ.party[pc_num].skills[which_skill]) && (dir == 'm') && (mode == 1)) || ((store_skills[which_skill] == 0) && (dir == 'm') && (mode == 0) && (which_skill > 2)) || ((store_skills[which_skill] == 1) && (dir == 'm') && (mode == 0) && (which_skill <= 2))) - ; // TODO: Play an error sound here + beep(); // TODO: This is a game event, so it should have a game sound, not a system alert. else { if(dir == 'm') { store_g += skill_g_cost[which_skill]; diff --git a/osx/scenedit/scen.main.cpp b/osx/scenedit/scen.main.cpp index d2586f4f..a5191a24 100644 --- a/osx/scenedit/scen.main.cpp +++ b/osx/scenedit/scen.main.cpp @@ -525,6 +525,7 @@ void close_program() { if(town != NULL) delete town; } +// TODO: Remove this function and replace it with beep() or play_sound() everywhere. void ding() { - // TODO: Play an error sound here + beep(); } diff --git a/osx/tools/winutil.h b/osx/tools/winutil.h index 49d9b3d4..8468debb 100644 --- a/osx/tools/winutil.h +++ b/osx/tools/winutil.h @@ -26,6 +26,8 @@ fs::path nav_put_party(); fs::path nav_get_scenario(); fs::path nav_put_scenario(); +void beep(); + class ModalSession { void* session; public: diff --git a/osx/tools/winutil.mac.mm b/osx/tools/winutil.mac.mm index afef549b..54ddcc0d 100644 --- a/osx/tools/winutil.mac.mm +++ b/osx/tools/winutil.mac.mm @@ -106,6 +106,10 @@ void ModalSession::pumpEvents() { [[NSApplication sharedApplication] runModalSession: nsHandle]; } +void beep() { + NSBeep(); +} + NSOpenPanel* dlg_get_scen; NSOpenPanel* dlg_get_game; NSSavePanel* dlg_put_scen;