Пример #1
0
/**
 * Write the status line.
 */
void TextMan::write_status() {
	char x[64];

	if (debug_.statusline) {
		print_status("%3d(%03d) %3d,%3d(%3d,%3d)               ",
				getvar(0), getvar(1), game.view_table[0].x_pos,
				game.view_table[0].y_pos, WIN_TO_PIC_X(mouse.x),
				WIN_TO_PIC_Y(mouse.y));
		return;
	}

	if (!game.status_line) {
		int l = game.line_status;
		clear_lines(l, l, 0);
		flush_lines(l, l);
		return;
	}

	sprintf(x, " Score:%i of %-3i", game.vars[V_score], game.vars[V_max_score]);
	print_status("%-17s             Sound:%s ", x, getflag(F_sound_on) ? "on " : "off");
}
Пример #2
0
/**
 * Write the status line.
 */
void AgiEngine::writeStatus() {
	char x[64];

	if (_debug.statusline) {
		printStatus("%3d(%03d) %3d,%3d(%3d,%3d)               ",
				getvar(0), getvar(1), _game.viewTable[0].xPos,
				_game.viewTable[0].yPos, WIN_TO_PIC_X(_mouse.x),
				WIN_TO_PIC_Y(_mouse.y));
		return;
	}

	if (!_game.statusLine) {
		clearLines(_game.lineStatus, _game.lineStatus, 0);
		flushLines(_game.lineStatus, _game.lineStatus);

#if 0
		// FIXME: Breaks wrist watch prompt in SQ2

		// Clear the user input line as well when clearing the status line
		// Fixes bug #1893564 - AGI: Texts messed out in Naturette 1
		clearLines(_game.lineUserInput, _game.lineUserInput, 0);
		flushLines(_game.lineUserInput, _game.lineUserInput);
#endif
		return;
	}

	switch (getLanguage()) {
	case Common::RU_RUS:
		sprintf(x, " \x91\xe7\xa5\xe2: %i \xa8\xa7 %-3i", _game.vars[vScore], _game.vars[vMaxScore]);
		printStatus("%-17s              \x87\xa2\xe3\xaa:%s", x, getflag(fSoundOn) ? "\xa2\xaa\xab " : "\xa2\xeb\xaa\xab");
		break;
	default:
		sprintf(x, " Score:%i of %-3i", _game.vars[vScore], _game.vars[vMaxScore]);
		printStatus("%-17s             Sound:%s ", x, getflag(fSoundOn) ? "on " : "off");
		break;
	}
}
Пример #3
0
int handle_controller (int key)
{
	struct vt_entry *v = &game.view_table[0];
	int i;

	/* The Black Cauldron needs KEY_ESCAPE to use menus */
	if (key == 0 /*|| key == KEY_ESCAPE*/)
		return FALSE;

	_D (_D_WARN "key = %04x", key);

	for (i = 0; i < MAX_DIRS; i++) {
		if (game.ev_keyp[i].data == key) {
			_D ("event %d: key press", i);
			game.ev_keyp[i].occured = TRUE;
			report ("event AC:%i occured\n", i);
			return TRUE;
		}
	}

#ifdef USE_MOUSE
	if (key == BUTTON_LEFT) {
		if (getflag (F_menus_work) && mouse.y <= CHAR_LINES) {
			new_input_mode (INPUT_MENU);
			return TRUE;
		}
	}
#endif

	if (game.player_control) {
		int d = 0;

		if (!KEY_ASCII (key)) {
			switch (key) {
			case KEY_UP:         d = 1; break;
			case KEY_DOWN:       d = 5; break;
			case KEY_LEFT:       d = 7; break;
			case KEY_RIGHT:      d = 3; break;
			case KEY_UP_RIGHT:   d = 2; break;
			case KEY_DOWN_RIGHT: d = 4; break;
			case KEY_UP_LEFT:    d = 8; break;
			case KEY_DOWN_LEFT:  d = 6; break;
			}
		}

#ifdef USE_MOUSE
		if (!opt.agimouse) {
			/* Handle mouse button events */
			if (key == BUTTON_LEFT) {
				v->flags |= ADJ_EGO_XY;
				v->parm1 = WIN_TO_PIC_X(mouse.x);
				v->parm2 = WIN_TO_PIC_Y(mouse.y);
				return TRUE;
			}
		}
#endif

		v->flags &= ~ADJ_EGO_XY;

		if (d || key == KEY_STATIONARY) {
			v->direction = v->direction == d ? 0 : d;
			return TRUE;
		}
	}

	return FALSE;
}
Пример #4
0
void cmdMousePosn(AgiGame *state, uint8 *p) {
	_v[p0] = WIN_TO_PIC_X(state->_vm->_mouse.x);
	_v[p1] = WIN_TO_PIC_Y(state->_vm->_mouse.y);
}
Пример #5
0
int AgiEngine::handleController(int key) {
	VtEntry *v = &_game.viewTable[0];
	int i;

	// AGI 3.149 games, The Black Cauldron and King's Quest 4 need KEY_ESCAPE to use menus
	// Games with the GF_ESCPAUSE flag need KEY_ESCAPE to pause the game
	if (key == 0 ||
		(key == KEY_ESCAPE && getVersion() != 0x3149 && getGameID() != GID_BC && getGameID() != GID_KQ4 && !(getFeatures() & GF_ESCPAUSE)) )
		return false;

	if ((getGameID() == GID_MH1 || getGameID() == GID_MH2) && (key == KEY_ENTER) &&
			(_game.inputMode == INPUT_NONE)) {
		key = 0x20; // Set Enter key to Space in Manhunter when there's no text input
	}

	debugC(3, kDebugLevelInput, "key = %04x", key);

	for (i = 0; i < MAX_CONTROLLERS; i++) {
		if (_game.controllers[i].keycode == key) {
			debugC(3, kDebugLevelInput, "event %d: key press", _game.controllers[i].controller);
			_game.controllerOccured[_game.controllers[i].controller] = true;
			return true;
		}
	}

	if (key == BUTTON_LEFT) {
		if ((getflag(fMenusWork) || (getFeatures() & GF_MENUS)) && _mouse.y <= CHAR_LINES) {
			newInputMode(INPUT_MENU);
			return true;
		}
	}

	// Show predictive dialog if the user clicks on input area
	if (key == BUTTON_LEFT &&
			(int)_mouse.y >= _game.lineUserInput * CHAR_LINES &&
			(int)_mouse.y <= (_game.lineUserInput + 1) * CHAR_LINES) {
		GUI::PredictiveDialog _predictiveDialog;
		_predictiveDialog.runModal();
		strcpy(_predictiveResult, _predictiveDialog.getResult());
		if (strcmp(_predictiveResult, "")) {
			if (_game.inputMode == INPUT_NONE) {
				for (int n = 0; _predictiveResult[n]; n++)
					keyEnqueue(_predictiveResult[n]);
			} else {
				strcpy((char *)_game.inputBuffer, _predictiveResult);
				handleKeys(KEY_ENTER);
			}
		}
		/*
		if (predictiveDialog()) {
			if (_game.inputMode == INPUT_NONE) {
				for (int n = 0; _predictiveResult[n]; n++)
					keyEnqueue(_predictiveResult[n]);
			} else {
				strcpy((char *)_game.inputBuffer, _predictiveResult);
				handleKeys(KEY_ENTER);
			}
		}
		*/
		return true;
	}

	if (_game.playerControl) {
		int d = 0;

		if (!KEY_ASCII(key)) {
			switch (key) {
			case KEY_UP:
				d = 1;
				break;
			case KEY_DOWN:
				d = 5;
				break;
			case KEY_LEFT:
				d = 7;
				break;
			case KEY_RIGHT:
				d = 3;
				break;
			case KEY_UP_RIGHT:
				d = 2;
				break;
			case KEY_DOWN_RIGHT:
				d = 4;
				break;
			case KEY_UP_LEFT:
				d = 8;
				break;
			case KEY_DOWN_LEFT:
				d = 6;
				break;
			}
		}

		if (!(getFeatures() & GF_AGIMOUSE)) {
			// Handle mouse button events
			if (key == BUTTON_LEFT) {
				if (getGameID() == GID_PQ1 && _game.vars[vCurRoom] == 116) {
					// WORKAROUND: Special handling for mouse clicks in the newspaper
					// screen of PQ1. Fixes bug #3018770.
					d = 3;	// fake a right arrow key (next page)
				} else {
					// Click-to-walk mouse interface
					v->flags |= fAdjEgoXY;
					v->parm1 = WIN_TO_PIC_X(_mouse.x);
					v->parm2 = WIN_TO_PIC_Y(_mouse.y);
					return true;
				}
			}
		}

		if (d || key == KEY_STATIONARY) {
			v->flags &= ~fAdjEgoXY;
			v->direction = v->direction == d ? 0 : d;
			return true;
		}
	}

	return false;
}