예제 #1
0
bool spend_xp(short pc_num, short mode, short parent)
//short mode; // 0 - create  1 - train
// returns 1 if cancelled
{
	Str255 get_text,text2;
	short item_hit;

	store_train_pc = pc_num;

	make_cursor_sword();

	cd_create_dialog_parent_num(1010,parent);
	sprintf((char *) get_text,"Health (%d/%d)",1,10);
	cd_add_label(1010,52,(char *) get_text,1075);
	sprintf((char *) get_text,"Spell Pts. (%d/%d)",1,15);
	//cd_add_label(1010,5,get_text,1040);
	cd_add_label(1010,53,(char *) get_text,1075);
	for (i = 54; i < 73; i++) {
		get_str(text2,9,1 + 2 * (i - 54));
		sprintf((char *) get_text,"%s (%d/%d)",text2,skill_cost[i - 54],skill_g_cost[i - 54]);
		cd_add_label(1010,i,(char *) get_text,(i < 63) ? 1075 : 1069);
		}
	do_xp_draw();
	
	dialog_answer = 0;
	
	item_hit = cd_run_dialog();	

	cd_kill_dialog(1010);

	return dialog_answer;
}
예제 #2
0
void display_alchemy()
{
	short i,item_hit;
	char *alch_names[] = {"Weak Curing Potion (1)","Weak Healing Potion (1)","Weak Poison (1)",
	"Weak Speed Potion (3)","Medium Poison (3)",
		"Medium Heal Potion (4)","Strong Curing (5)","Medium Speed Potion (5)",
		"Graymold Salve (7)","Weak Power Potion (9)",
		"Potion of Clarity (9)","Strong Poison (10)","Strong Heal Potion (12)","Killer Poison (12)",
		"Resurrection Balm (9)","Medium Power Potion (14)","Knowledge Brew (19)",
		"Strong Strength (10)","Bliss (18)","Strong Power (20)"	
		};

	make_cursor_sword();

	cd_create_dialog_parent_num(996,0);


	for (i = 0; i < 20; i++) {
		cd_add_label(996,i + 4,alch_names[i],1083);
		if (univ.party.alchemy[i] > 0)
			cd_set_led(996,i + 4,1);
			else cd_set_led(996,i + 4,0);
	}
	
	item_hit = cd_run_dialog();
	cd_kill_dialog(996);
	untoast_dialog();

}
예제 #3
0
void talk_notes()
{

	short i,item_hit;
	
	store_num_i = 0;
	for (i = 0; i < 120; i++)
		if (univ.party.talk_save[i].personality != -1)
			store_num_i = i + 1;
	store_page_on = 0;
	if (store_num_i == 0) {
		ASB("Nothing in your talk journal.");
		print_buf();
		return;
		}
	
	make_cursor_sword();

	cd_create_dialog_parent_num(960,0);

	put_talk();
	if (store_num_i == 1) {
		cd_activate_item(960,10,0);
		cd_activate_item(960,11,0);
	}
	
	item_hit = cd_run_dialog();
	cd_kill_dialog(960);

}
예제 #4
0
void journal()
{

	unsigned short i;
	short item_hit;
	Str255 place_str;
	
	store_num_i = 0;
	//for (i = 0; i < 120; i++)
		//if (univ.party.journal[i].str_num > 0)
			store_num_i = univ.party.journal.size();//i + 1;
	store_page_on = 0;
	
	make_cursor_sword();

	cd_create_dialog_parent_num(962,0);

	for (i = 0; i < 3; i++) {
		if (univ.party.journal.size() > i) {
			////get_str(place_str,17,univ.party.journal_str[i]);
			csit(962,3 + i,scenario.scen_strs(univ.party.journal[i].str_num + 10));
			sprintf((char *)place_str,"Day: %d",univ.party.journal[i].day);
			csit(962,9 + i,(char *)place_str);
			}
		}
	if (store_num_i <= 3) {
		cd_activate_item(962,7,0);
		cd_activate_item(962,8,0);
	}
	
	item_hit = cd_run_dialog();	
	cd_kill_dialog(962);

}
예제 #5
0
void display_help(short mode,short parent)
{
	Str255 get_text;
   long get_val;
   short item_hit;
	
	store_help_mode = mode;
	cur_entry = 3;

	make_cursor_sword();

	cd_create_dialog_parent_num(997,parent);

		get_str (get_text, 25 + mode, 1);
		csit( 997,6,(char *) get_text);
		GetIndString (get_text, 25 + mode, 2);
		StringToNum(get_text,&get_val);
		num_entries = (short) get_val;
		get_str (get_text, 25 + mode, cur_entry);
		csit( 997,7,(char *) get_text);
	
	
	item_hit = cd_run_dialog();	
	cd_kill_dialog(997);

}
예제 #6
0
void edit_xp(cPlayer *pc)
{

	short item_hit;
	Str255 sign_text;
	location view_loc;

	store_xp_pc = pc;

	make_cursor_sword();
	
	cd_create_dialog(1024,mainPtr);
		
	sprintf((char *) sign_text,"%d",(short)pc->experience);
	cd_set_text_edit_str(1024,2,(char *) sign_text);
	item_hit = store_xp_pc->get_tnl();
	cdsin(1024,8,item_hit);
	
	item_hit = cd_run_dialog();
	
	cd_kill_dialog(1024);
	
	if (dialog_answer < 0)
		dialog_answer = dialog_answer * -1;
	dialog_answer = minmax(0,10000,dialog_answer);
	
	pc->experience = dialog_answer;
}
예제 #7
0
void display_pc(short pc_num,short mode,short parent)
{
	short i,item_hit;
	Str255 label_str;
	
	if (univ.party[pc_num].main_status == 0) {
		for (pc_num = 0; pc_num < 6; pc_num++)
			if (univ.party[pc_num].main_status == 1)
				break;
		}
	which_pc_displayed = pc_num;
	store_trait_mode = mode;

	make_cursor_sword();

	cd_create_dialog_parent_num(991,parent);

	for (i = 3; i < 65; i++) {
		get_str(label_str,(mode == 0) ? 7 : 8,(i - 3) * 2 + 1);
		cd_add_label(991,i,(char *)label_str,46);
		}
	put_pc_graphics();

	cd_set_pict(991,2,14 + mode,PICT_DLG);
	
	item_hit = cd_run_dialog();	
	cd_kill_dialog(991);
}
예제 #8
0
void display_spells(short mode,short force_spell,short parent_num)
//short mode; // 0 - mage  1 - priest
//short force_spell; // if 100, ignore
{
	short item_hit;

	store_display_mode = mode;
	if (force_spell < 100) {
		if (mode == 0)
			mage_spell_pos = force_spell;
			else priest_spell_pos = force_spell;
		}

	make_cursor_sword();

	cd_create_dialog_parent_num(1096,parent_num);

      cd_set_pict(1096,18,14 + mode,PICT_DLG);
		put_spell_info();
	if (mode == 0)
		csit(1096,3,"Mage Spells");
	else csit(1096,3,"Priest Spells");
	
	item_hit = cd_run_dialog();		
	cd_kill_dialog(1096);

}
예제 #9
0
void display_monst(short array_pos,cCreature *which_m,short mode)
//creature_data_type *which_m; // if NULL, show full roster
//short mode; // if 1, full roster, else use monster from storwhich_me_m
{
	
	short item_hit;
	
	position = array_pos;
	full_roster = false;
	if (mode == 1) {
		full_roster = true;
		store_m = &hold_m;
		store_m->number = on_monst_menu[array_pos];
		*store_m = *store_m; // yes, this DOES do something
		}
		else {
			hold_m = *which_m;
			store_m = which_m;
			}

	make_cursor_sword();

	cd_create_dialog(999,mainPtr);

	if (full_roster == false) {
		cd_activate_item(999,28,0);
		cd_activate_item(999,29,0);
		}
	cd_add_label(999,5,"Name",1026);
	cd_add_label(999,6,"Level",1021);
	cd_add_label(999,7,"Health",1024);
	cd_add_label(999,8,"Magic Pts.",1032);
	cd_add_label(999,9,"Armor",1023);
	cd_add_label(999,10,"Skill",1018);
	cd_add_label(999,11,"Morale",1023);
	cd_add_label(999,12,"Speed",1019);
	cd_add_label(999,13,"Att #1",1026);
	cd_add_label(999,14,"Att #2",1023);
	cd_add_label(999,15,"Att #3",1022);
	cd_add_label(999,16,"Mage L.",1034);
	cd_add_label(999,17,"Priest L.",1030);
	cd_add_label(999,18,"Poison",1023);
	cd_add_label(999,19,"Ability 1",1029);
	cd_add_label(999,31,"Ability 2",1029);
	cd_add_label(999,20,"Magic Resistant",45);
	cd_add_label(999,21,"Immune To Magic",45);
	cd_add_label(999,22,"Fire Resistant",45);
	cd_add_label(999,23,"Immune To Fire",45);
	cd_add_label(999,24,"Cold Resistant",45);
	cd_add_label(999,25,"Immune To Cold",45);
	cd_add_label(999,26,"Poison Resistant",45);
	cd_add_label(999,27,"Immune To Poison",45);
	put_monst_info();
	
	item_hit = cd_run_dialog();
	cd_kill_dialog(999);
}
예제 #10
0
void give_reg_info()
{
	short item_hit;

	make_cursor_sword();

	cd_create_dialog_parent_num(1073,0);
	
	item_hit = cd_run_dialog();
	cd_kill_dialog(1073);

}
예제 #11
0
void adventure_notes()
{

	unsigned short i;
	short item_hit;
	Str255 place_str;
	
	store_num_i = 0;
	//for (i = 0; i < 140; i++)
		//if (univ.party.special_notes_str[i][0] > 0)
			store_num_i = univ.party.special_notes.size(); //i + 1;
	store_page_on = 0;
	if (store_num_i == 0) {
		ASB("Nothing in your journal.");
		print_buf();
		return;
		}
	
	make_cursor_sword();

	cd_create_dialog_parent_num(961,0);

	for (i = 0; i < 3; i++) {
		if (univ.party.special_notes.size() > i) {
			switch (univ.party.special_notes[i].str_num / 1000) {
				case 0:
					strcpy((char *) place_str,scenario.scen_strs(univ.party.special_notes[i].str_num % 1000)); break;
				case 1:
					 load_outdoor_str(loc(univ.party.special_notes[i].where % scenario.out_width,
					 	univ.party.special_notes[i].where / scenario.out_width), univ.party.special_notes[i].str_num % 1000,(char *)place_str);
					break;
				case 2:
					load_town_str(univ.party.special_notes[i].where,univ.party.special_notes[i].str_num % 1000,(char *)place_str); break;
				}

			csit(961,3 + i,(char *) place_str);
			cd_activate_item(961,9 + i,1);
			}
			else cd_activate_item(961,9 + i,0);
		}
	if (store_num_i <= 3) {
		cd_activate_item(961,7,0);
		cd_activate_item(961,8,0);
	}
	
	item_hit = cd_run_dialog();
	cd_kill_dialog(961);

}
예제 #12
0
void edit_xp(cPlayer *pc) {
	location view_loc;
	
	make_cursor_sword();
	
	cDialog dlog("edit-xp");
	dlog["okay"].attachClickHandler(get_num_event_filter);
	
	dlog["number"].setTextToNum(pc->experience);
	dlog["perlevel"].setTextToNum(pc->get_tnl());
	
	dlog.run();
	
	int dialog_answer = minmax(0,10000,abs(dlog.getResult<long long>()));
	
	pc->experience = dialog_answer;
}
예제 #13
0
void edit_day() {
	
	location view_loc;
	
	
	make_cursor_sword();
	
	cDialog dlog("edit-day");
	dlog["okay"].attachClickHandler(get_num_event_filter);
	
	dlog["number"].setTextToNum(((univ.party.age) / 3700) + 1);
	
	dlog.run();
	
	long long dialog_answer = minmax(0,500,dlog.getResult<long long>());
	
	univ.party.age = (long long) (3700) * (long long) (dialog_answer);
}
예제 #14
0
void give_pc_info(short pc_num)
{
	short item_hit ,i;
	Str255 str;
	
	store_pc_num = pc_num;
	make_cursor_sword();

	cd_create_dialog_parent_num(1019,0);

	for (i = 0; i < 19; i++) {
		get_str(str,9,1 + i * 2);
		csit(1019,17 + i * 2,(char *) str);
		}
	display_pc_info(); 
	
	item_hit = cd_run_dialog();	
	cd_kill_dialog(1019);
}
예제 #15
0
void display_skills(short force_skill,short parent)
{

	short item_hit;

	if (force_skill < 100)
		skill_pos = force_skill;
	if (skill_pos < 0)
		skill_pos = 0;

	make_cursor_sword();

	cd_create_dialog_parent_num(1097,parent);

	put_skill_info();
	
	item_hit = cd_run_dialog();	
	cd_kill_dialog(1097);

}
예제 #16
0
void display_pc_item(short pc_num,short item,cItemRec si,short parent)
{
	short item_hit;

		store_item_pc = pc_num;
		if (pc_num == 6)
			store_i = si;
			else store_i = univ.party[pc_num].items[item];
	store_displayed_item = item;
	make_cursor_sword();

	if (cd_create_dialog_parent_num(998,parent) < 0)
		return;

		if (store_item_pc >= 6) {
			cd_activate_item(998,14,0);
			cd_activate_item(998,15,0);
			}
	cd_add_label(998,3,"Name:",1026);
	cd_add_label(998,4,"Type:",1026);
	cd_add_label(998,5,"Value:",1020);
	cd_add_label(998,6,"Damage:",1026);
	cd_add_label(998,7,"Bonus:",1024);
	cd_add_label(998,8,"Defend:",1025);
	cd_add_label(998,9,"Encumb.:",1029);
	cd_add_label(998,10,"Uses:",1019);
	cd_add_label(998,11,"Item Level:",1037);
	cd_add_label(998,12,"Ability:",1026);
	cd_add_label(998,16,"ID?",1013);
	cd_add_label(998,17,"Magic?",1022);
	cd_add_label(998,20 ,"Weight",1027);

	cd_activate_item(998,18,0);
	cd_activate_item(998,19,0);

	put_item_info(pc_num,item);
	
	item_hit = cd_run_dialog();
	cd_kill_dialog(998);

}
예제 #17
0
//0 - gold 1 - food
void edit_gold_or_food(short which_to_edit) {
	
	location view_loc;
	
	store_which_to_edit = which_to_edit;
	
	make_cursor_sword();
	cDialog dlog("get-num");
	dlog["okay"].attachClickHandler(get_num_event_filter);
	if(which_to_edit == 0)
		dlog["prompt"].setText("How much gold do you want?");
	else dlog["prompt"].setText("How much food do you want?");
	dlog["number"].setTextToNum((which_to_edit == 0) ? univ.party.gold : univ.party.food);
	
	dlog.run();
	int dialog_answer = minmax(0,25000,dlog.getResult<long long>());
	if(which_to_edit == 0)
		univ.party.gold = dialog_answer;
	else
		univ.party.food = dialog_answer;
}
예제 #18
0
void pick_race_abil(cPlayer *pc,short mode,short parent_num)
//mode; // 0 - edit  1 - just display  2 - can't change race
{
	char *start_str1 = "Click on button by name for description.";
	char *start_str2 = "Click on advantage button to add/remove.";
	short item_hit;
	
	store_trait_mode = mode;
	store_pc = pc;
	make_cursor_sword();

	cd_create_dialog_parent_num(1013,parent_num);

	display_traits_graphics();
	if (mode == 1)
		csit(1013,19,start_str1);
		else csit(1013,19,start_str2);
	
	item_hit = cd_run_dialog();
	cd_kill_dialog(1013);
	untoast_dialog();
}
예제 #19
0
void display_alchemy()
{
	short i,item_hit;


	make_cursor_sword();

	cd_create_dialog_parent_num(996,1019);


	for (i = 0; i < 20; i++) {
		cd_add_label(996,i + 4,alch_names[i],1083);
		if (univ.party.alchemy[i] > 0)
			cd_set_led(996,i + 4,1);
			else cd_set_led(996,i + 4,0);
		}
	
	item_hit = cd_run_dialog();		
	cd_kill_dialog(996);
	untoast_dialog();

}
예제 #20
0
void edit_day()
{

	short item_hit;
	Str255 sign_text;
	location view_loc;


	make_cursor_sword();
	
	cd_create_dialog(917,mainPtr);
		
	sprintf((char *) sign_text,"%d",(short) ( ((univ.party.age) / 3700) + 1));
	cd_set_text_edit_str(917,2,(char *) sign_text);
	
	item_hit = cd_run_dialog();
	
	cd_kill_dialog(917);
	
	dialog_answer = minmax(0,500,dialog_answer);
	
	univ.party.age = (long long) (3700) * (long long) (dialog_answer);
}
예제 #21
0
void edit_gold_or_food(short which_to_edit)
//0 - gold 1 - food
{

	short item_hit;
	Str255 sign_text;
	location view_loc;

	store_which_to_edit = which_to_edit;

	make_cursor_sword();
	cd_create_dialog((which_to_edit == 0) ? 1012 : 947, mainPtr);
	sprintf((char *) sign_text,"%d",(short) ((which_to_edit == 0) ? univ.party.gold : univ.party.food));
	cd_set_text_edit_str((which_to_edit == 0) ? 1012 : 947,2,(char *) sign_text);
	
	item_hit = cd_run_dialog();
	cd_kill_dialog((which_to_edit == 0) ? 1012 : 947);
	dialog_answer = minmax(0,25000,dialog_answer);
	if (which_to_edit == 0)
		univ.party.gold = dialog_answer;
	else
		univ.party.food = dialog_answer;
}
예제 #22
0
void handle_menu_choice(eMenu item_hit) {
	std::string dialogToShow;
	sf::Event dummyEvent = {sf::Event::KeyPressed};
	short i, choice;
	
	switch(item_hit) {
		case eMenu::NONE: break;
		case eMenu::FILE_OPEN:
			do_load();
			break;
		case eMenu::FILE_SAVE:
			do_save(0);
			break;
		case eMenu::FILE_SAVE_AS:
			do_save(1);
			break;
		case eMenu::FILE_NEW:
			if(overall_mode != MODE_STARTUP) {
				std::string choice = cChoiceDlog("restart-game",{"okay","cancel"}).show();
				if(choice == "cancel")
					return;
				for(i = 0; i < 6; i++)
					univ.party[i].main_status = eMainStatus::ABSENT;
				party_in_memory = false;
				reload_startup();
				overall_mode = MODE_STARTUP;
				draw_startup(0);
			}
			start_new_game();
			draw_startup(0);
			menu_activate();
			break;
		case eMenu::FILE_ABORT:
			if(overall_mode != MODE_STARTUP) {
				std::string choice = cChoiceDlog("abort-game",{"okay","cancel"}).show();
				if (choice=="cancel") return;
				reload_startup();
				overall_mode = MODE_STARTUP;
			}
			party_in_memory = false;
			draw_startup(0);
			menu_activate();
			break;
		case eMenu::PREFS:
			pick_preferences();
			break;
		case eMenu::QUIT:
			if(overall_mode == MODE_STARTUP) {
				if(party_in_memory) {
					std::string choice = cChoiceDlog("quit-confirm-save", {"save","quit","cancel"}).show();
					if(choice == "cancel") break;
					if(choice == "save") {
						fs::path file = nav_put_party();
						if(!file.empty()) break;
						save_party(file, univ);
					}
				}
				All_Done = true;
				break;
			}
			if(overall_mode > MODE_TOWN) {
				std::string choice = cChoiceDlog("quit-confirm-nosave",{"quit","cancel"}).show();
				if(choice == "cancel")
					return;
			}
			else {
				std::string choice = cChoiceDlog("quit-confirm-save",{"quit","save","cancel"}).show();
				if(choice == "cancel")
					break;
				if(choice == "save") {
					if(univ.file.empty()) {
						univ.file = nav_put_party();
						if(univ.file.empty()) break;
					}
					save_party(univ.file, univ);
				}
			}
			All_Done = true;
			break;
		case eMenu::OPTIONS_PC_GRAPHIC:
			choice = char_select_pc(1,"New graphic for who?");
			if(choice < 6)
				pick_pc_graphic(choice,1,nullptr);
			draw_terrain();
			break;
			
		case eMenu::OPTIONS_DELETE_PC:
			if(!prime_time()) {
				ASB("Finish what you're doing first.");
				print_buf();
			}
			else {
				choice = char_select_pc(1,"Delete who?");
				if(choice < 6) {
					std::string confirm = cChoiceDlog("delete-pc-confirm",{"yes","no"}).show();
					if(confirm == "yes")
						kill_pc(univ.party[choice],eMainStatus::ABSENT);
				}
				draw_terrain();
			}
			break;
			
			
		case eMenu::OPTIONS_RENAME_PC:
			choice = char_select_pc(1,"Rename who?");
			if(choice < 6)
				pick_pc_name(choice,nullptr);
			put_pc_screen();
			put_item_screen(stat_window);
			break;
			
			
		case eMenu::OPTIONS_NEW_PC:
			if(!(is_town())) {
				add_string_to_buf("Add PC: Town mode only.");
				print_buf();
				break;
			}
			for(i = 0; i < 6; i++)
				if(univ.party[i].main_status == eMainStatus::ABSENT)
					i = 20;
			if(i == 6) {
				ASB("Add PC: You already have 6 PCs.");
				print_buf();
				break;
			}
			if(univ.town->has_tavern) {
				give_help(56,0);
				create_pc(6,nullptr);
			} else {
				add_string_to_buf("Add PC: You cannot add new characters in this town. Try in the town you started in.", 2);
			}
			print_buf();
			put_pc_screen();
			put_item_screen(stat_window);
			break;
			
		case eMenu::OPTIONS_JOURNAL:
			journal();
			break;
		case eMenu::OPTIONS_TALK_NOTES:
			if(overall_mode == MODE_TALKING) {
				ASB("Talking notes: Can't read while talking.");
				print_buf();
				return;
			}
			talk_notes();
			break;
		case eMenu::OPTIONS_ENCOUNTER_NOTES:
			adventure_notes();
			break;
		case eMenu::OPTIONS_STATS:
			if(overall_mode != MODE_STARTUP)
				print_party_stats();
			break;
		case eMenu::HELP_OUT:
			dialogToShow = "help-outdoor";
			break;
		case eMenu::HELP_TOWN:
			dialogToShow = "help-town";
			break;
		case eMenu::HELP_COMBAT:
			dialogToShow = "help-combat";
			break;
		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
			display_alchemy();
			break;
		case eMenu::LIBRARY_TIPS:
			tip_of_day();
			break;
		case eMenu::LIBRARY_INTRO:
			dialogToShow = "welcome";
			break;
		case eMenu::ACTIONS_ALCHEMY:
			dummyEvent.key.code = sf::Keyboard::A;
			dummyEvent.key.shift = true;
			handle_keystroke(dummyEvent);
			break;
		case eMenu::ACTIONS_WAIT:
			dummyEvent.key.code = sf::Keyboard::W;
			handle_keystroke(dummyEvent);
			break;
		case eMenu::ACTIONS_AUTOMAP:
			if(!prime_time()) {
				ASB("Finish what you're doing first.");
				print_buf();
			}
			else {
				give_help(62,0);
				display_map();
			}
			make_cursor_sword();
			break;
		case eMenu::HELP_TOC:
			if(fs::is_directory(progDir/"doc"))
				launchURL("file://" + (progDir/"doc/game/Contents.html").string());
			else launchURL("https://blades.calref.net/doc/game/Contents.html");
			break;
		case eMenu::ABOUT_MAGE:
		case eMenu::ABOUT_PRIEST:
			give_help(209,0);
			break;
		case eMenu::ABOUT_MONSTERS:
			give_help(212,0);
			break;
	}
	if(!dialogToShow.empty()) {
		cChoiceDlog dlog(dialogToShow);
		dlog.show();
	}
}
예제 #23
0
void Handle_One_Event() {
	static const long twentyTicks = time_in_ticks(20).asMilliseconds();
	static const long fortyTicks = time_in_ticks(40).asMilliseconds();
	
	through_sending();
	Handle_Update();
	
	//(cur_time - last_anim_time > 42)
	if((animTimer.getElapsedTime().asMilliseconds() >= fortyTicks) && (overall_mode != MODE_STARTUP) && (anim_onscreen) && get_bool_pref("DrawTerrainAnimation", true)
	   && (!gInBackground)) {
		animTimer.restart();
		draw_terrain();
	}
	if((animTimer.getElapsedTime().asMilliseconds() > twentyTicks) && (overall_mode == MODE_STARTUP)) {
		animTimer.restart();
		draw_startup_anim(true);
	}
	
	clear_sound_memory();
	
	if(map_visible && mini_map.pollEvent(event)){
		if(event.type == sf::Event::Closed) {
			mini_map.setVisible(false);
			map_visible = false;
		} else if(event.type == sf::Event::GainedFocus)
			makeFrontWindow(mainPtr);
	}
	if(!mainPtr.pollEvent(event)) {
		if(changed_display_mode) {
			changed_display_mode = false;
			adjust_window_mode();
		}
		flushingInput = false;
		redraw_screen(REFRESH_NONE);
		return;
	}
	switch(event.type) {
		case sf::Event::KeyPressed:
			if(flushingInput) return;
			if(!(event.key.*systemKey))
				handle_keystroke(event);
			
			break;
			
		case sf::Event::MouseButtonPressed:
			if(flushingInput) return;
			Mouse_Pressed();
			break;
			
		case sf::Event::MouseLeft:
			// Make sure we don't have an arrow cursor when it's outside the window
			make_cursor_sword();
			break;
			
		case sf::Event::GainedFocus:
			Handle_Update();
			makeFrontWindow(mainPtr);
		case sf::Event::MouseMoved:
			if(!gInBackground) {
				location where(event.mouseMove.x, event.mouseMove.y);
				change_cursor(where);
			}
			break;
			
		case sf::Event::MouseWheelMoved:
			if(flushingInput) return;
			handle_scroll(event);
			break;
			
		case sf::Event::Closed:
			if(overall_mode == MODE_STARTUP) {
				if(party_in_memory) {
					std::string choice = cChoiceDlog("quit-confirm-save", {"save","quit","cancel"}).show();
					if(choice == "cancel") break;
					if(choice == "save") {
						fs::path file = nav_put_party();
						if(!file.empty()) break;
						save_party(file, univ);
					}
				}
				All_Done = true;
				break;
			}
			if(overall_mode > MODE_TOWN){
				std::string choice = cChoiceDlog("quit-confirm-nosave", {"quit", "cancel"}).show();
				if(choice == "cancel")
					break;
			}
			else {
				std::string choice = cChoiceDlog("quit-confirm-save", {"save", "quit", "cancel"}).show();
				if(choice == "cancel")
					break;
				if(choice == "save")
					save_party(univ.file, univ);
			}
			All_Done = true;
		default:
			break; // There's several events we don't need to handle at all
	}
	flushingInput = false; // TODO: Could there be a case when the key and mouse input that needs to be flushed has other events interspersed?
}