示例#1
0
文件: Camera.cpp 项目: Pured/CSCI356
void DemoApp::frameRenderingCamera()
{
	Ogre::Vector3 camPos;

	if(mousePressedVar == true && boxTimeout >= 6 && selectionMode!=2)
	{
		mSelecting = true;
		selectionBox();
	}
	else if(mousePressedVar == true )
	{
		boxTimeout++;
	}
	
	Ogre::Vector3 height=camNode->getPosition();
	camNode->translate((camNode->getOrientation()*Ogre::Vector3::UNIT_X)  * camX);
	camNode->translate((camNode->getOrientation()*Ogre::Vector3::UNIT_Z)  * camY);
	camNode->translate((camNode->getOrientation()*Ogre::Vector3::NEGATIVE_UNIT_Z)  * -camZ);
	camPos=camNode->getPosition();
		
	camNode->setPosition(camPos.x, height.y, camPos.z);

	camZ=0;
	mRotationX=0;
	mRotationY=0;
}
示例#2
0
int AgiEngine::saveGameDialog() {
	char *desc;
	const char *buttons[] = { "Do as I say!", "I regret", NULL };
	char dstr[200];
	int rc, slot = 0;
	int hm, vm, hp, vp;
	int w;

	hm = 1;
	vm = 3;
	hp = hm * CHAR_COLS;
	vp = vm * CHAR_LINES;
	w = (40 - 2 * hm) - 1;

	do {
		drawWindow(hp, vp, GFX_WIDTH - hp, GFX_HEIGHT - vp);
		printText("Select a slot in which you wish to\nsave the game:",
				0, hm + 1, vm + 1, w, MSG_BOX_TEXT, MSG_BOX_COLOR);
		slot = selectSlot();
		if (slot + _firstSlot == 0)
			messageBox("That slot is for Autosave only.");
		else if (slot < 0)
			return errOK;
	} while (slot + _firstSlot == 0);

	drawWindow(hp, vp + 5 * CHAR_LINES, GFX_WIDTH - hp,
			GFX_HEIGHT - vp - 9 * CHAR_LINES);
	printText("Enter a description for this game:",
			0, hm + 1, vm + 6, w, MSG_BOX_TEXT, MSG_BOX_COLOR);
	_gfx->drawRectangle(3 * CHAR_COLS, 11 * CHAR_LINES - 1,
			37 * CHAR_COLS, 12 * CHAR_LINES, MSG_BOX_TEXT);
	_gfx->flushBlock(3 * CHAR_COLS, 11 * CHAR_LINES - 1,
			37 * CHAR_COLS, 12 * CHAR_LINES);

	// The description field of the save/restore dialog holds 32 characters
	// but we use four of them for the slot number. The input field is a
	// bit wider than that, so we don't have to worry about leaving space
	// for the cursor.

	getString(2, 11, 28, MAX_STRINGS);

	// If we're saving over an old slot, show the old description. We can't
	// access that buffer directly, so we have to feed the characters to
	// the input handler one at a time.

	char name[40];
	int numChars;

	getSavegameDescription(_firstSlot + slot, name, false);

	for (numChars = 0; numChars < 28 && name[numChars]; numChars++)
		handleGetstring(name[numChars]);

	_gfx->printCharacter(numChars + 3, 11, _game.cursorChar, MSG_BOX_COLOR, MSG_BOX_TEXT);
	do {
		mainCycle();
	} while (_game.inputMode == INPUT_GETSTRING);
	closeWindow();

	desc = _game.strings[MAX_STRINGS];
	sprintf(dstr, "Are you sure you want to save the game "
			"described as:\n\n%s\n\nin slot %d?\n\n\n", desc, _firstSlot + slot);

	rc = selectionBox(dstr, buttons);

	if (rc != 0) {
		messageBox("Game NOT saved.");
		return errOK;
	}

	Common::String fileName = getSavegameFilename(_firstSlot + slot);
	debugC(8, kDebugLevelMain | kDebugLevelResources, "file is [%s]", fileName.c_str());

	// Make sure all graphics was blitted to screen. This fixes bug
	// #2960567: "AGI: Ego partly erased in Load/Save thumbnails"
	_gfx->doUpdate();

	int result = saveGame(fileName, desc);

	if (result == errOK)
		messageBox("Game saved.");
	else
		messageBox("Error saving game.");

	return result;
}