Пример #1
0
int Control::choose_ship(VideoWindow *window, char * prompt, Fleet *fleet)
{
    STACKTRACE;
    int ret = -1, slot = 0;
    if (fleet->getSize() == 0) {
        tw_error ("Empty fleet! (prompt:%s)", prompt);
    }
    selectDialog[SELECT_DIALOG_LIST].dp3 = fleet;

    strcpy(selectShipPrompt,prompt);

    slot = -1;
    while (!always_random) {
        while (key[KEY_ENTER] || key[KEY_SPACE]) poll_keyboard();

        ret = tw_do_dialog(window, selectDialog, SELECT_DIALOG_LIST);
        if (ret == SELECT_DIALOG_INFO) {
            ship_view_dialog(
                selectDialog[SELECT_DIALOG_LIST].d1,
                fleet
            );
            continue;
        }
        break;
    }
    if ((ret == SELECT_DIALOG_SHIP) || (ret == SELECT_DIALOG_LIST))
        slot = selectDialog[SELECT_DIALOG_LIST].d1;
    if ((ret == SELECT_DIALOG_ARANDOM) || (ret == -1)) always_random = 1;
    return(slot);
}
Пример #2
0
int _tw_alert (
bool popup,
char *message,
const char *b1,
const char *b2 = NULL,
const char *b3 = NULL,
const char *b4 = NULL,
const char *b5 = NULL
)
{
	int l = 0;
	if (b2)
		l = 1;
	if (b3)
		l = 2;
	if (b4)
		l = 3;
	if (b5)
		l = 4;
	DIALOG *dialog = tw_alert_dialogs[l];
	dialog[1].dp = (void*)message;
	if (b1) {
		dialog[2].dp = (void*)b1;
		dialog[2].key = find_shortcut_key(b1);
	}
	if (b2) {
		dialog[3].dp = (void*)b2;
		dialog[3].key = find_shortcut_key(b2);
	}
	if (b3) {
		dialog[4].dp = (void*)b3;
		dialog[4].key = find_shortcut_key(b3);
	}
	if (b4) {
		dialog[5].dp = (void*)b4;
		dialog[5].key = find_shortcut_key(b4);
	}
	if (b5) {
		dialog[6].dp = (void*)b5;
		dialog[6].key = find_shortcut_key(b5);
	}

	int i;

	if (popup)
		i = tw_popup_dialog(&videosystem.window, dialog, 2) - 2;
	else
		i = tw_do_dialog   (&videosystem.window, dialog, 2) - 2;
	return i + 1;
}
Пример #3
0
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;
}
Пример #4
0
void GobStation::station_screen(GobPlayer *s)
{
	STACKTRACE;

	BITMAP *background = load_bitmap(data_full_path(background_pic).c_str(), NULL);
	if (!background) {
		message.print(1000, 15, "%s", background_pic);
		tw_error ("couldn't load station background");
	}
	game->window->lock();
	aa_set_mode(AA_DITHER);
	aa_stretch_blit(background, game->window->surface,
		0,0,background->w,background->h,
		game->window->x,game->window->y,game->window->w, game->window->h);
	game->window->unlock();
	while (true) {
		sprintf(dialog_string[0], "%03d Starbucks  %03d Buckazoids", s->starbucks, s->buckazoids);
		int r = 0;
		if (game->is_local(s->channel))
			r = tw_do_dialog(game->window, station_dialog, STATION_DIALOG_DEPART);
		game->log_int(s->channel, r);
		switch (r) {
			case STATION_DIALOG_UPGRADE:
			{
				upgrade_menu(this, s);
				aa_set_mode(AA_DITHER);
				aa_stretch_blit(background, game->window->surface,
					0,0,background->w,background->h,
					game->window->x,game->window->y,
					game->window->w, game->window->h);
			}
			break;
			case STATION_DIALOG_NEWSHIP:
			{
				buy_new_ship_menu(s);
			}
			break;
			case STATION_DIALOG_REPAIR:
			{
				if (s->ship->crew == s->ship->crew_max) {
					if (game->is_local(s->channel))
						alert("You don't need repairs", "", "", "Oh, okay", "I knew that", 0, 0);

					break;
				}
				int p = 0;
				if (game->is_local(s->channel))
					p = alert3("Which would you prefer", "to pay for your repairs", "", "1 &Starbuck", "1 &Buckazoid", "&Nothing!", 's', 'b', 'n');
				game->log_int(s->channel, p);
				switch (p) {
					case 1:
					{
						if (s->starbucks) {
							s->starbucks -= 1;
							s->ship->crew = s->ship->crew_max;
						}
						else {
							if (game->is_local(s->channel))
								alert("You don't have enough!", NULL, NULL, "&Shit", NULL, 's', 0);
						}
					}
					break;
					case 2:
					{
						if (s->buckazoids) {
							s->buckazoids -= 1;
							s->ship->crew = s->ship->crew_max;
						}
						else {
							if (game->is_local(s->channel))
								alert("You don't have enough!", NULL, NULL, "&Shit", NULL, 's', 0);
						}
					}
					break;
					case 3:
					{
						r = STATION_DIALOG_DEPART;
					}
					break;
				}
			}
			break;
		}
		if (r == STATION_DIALOG_DEPART || r == -1) break;
	}
	return;
}