示例#1
0
文件: ggob.cpp 项目: argarak/tw-light
void GobStation::upgrade_menu(GobStation *station, GobPlayer *gs)
{
	STACKTRACE;
	int i;
	upgrade_list_for = gs;
	clear_to_color(screen, palette_color[8]);
	while (true) {
		sprintf(dialog_string[0], "%03d Starbucks  %03d Buckazoids", gs->starbucks, gs->buckazoids);
		int j = 0;
		for (i = 0; gs->upgrade_list[i]; i += 1) {
			if (gs->upgrade_list[i]->update(gs->ship, station, gs)) {
				upgrade_index[j] = i;
				j += 1;
			}
		}
		num_upgrade_indexes = j;
		int m = 0;
		if (game->is_local(gs->channel))
			m = tw_do_dialog(game->window, upgrade_dialog, UPGRADE_DIALOG_EXIT);
		game->log_int(gs->channel, m);
		if (m == UPGRADE_DIALOG_EXIT) return;
		if (m == UPGRADE_DIALOG_LIST) {
			int i = 0;
			if (game->is_local(gs->channel))
				i = upgrade_dialog[UPGRADE_DIALOG_LIST].d1;
			game->log_int(gs->channel, i);
			i = upgrade_index[i];
			Upgrade *u = gs->upgrade_list[i];
			if (gs->charge(u->name, u->starbucks, u->buckazoids)) {
				u->execute(gs->ship, station, gs);
				u->charge(gs);
			}
		}
	}
	return;
}