Ejemplo n.º 1
0
void
RoomContainer::SetAreaOffset(IE::point point)
{
	GFX::rect areaRect = AreaRect();
	fAreaOffset = point;
	if (fAreaOffset.x < 0)
		fAreaOffset.x = 0;
	else if (fAreaOffset.x + fViewPort.w > areaRect.w)
		fAreaOffset.x = std::max(areaRect.w - fViewPort.w, 0);
	if (fAreaOffset.y < 0)
		fAreaOffset.y = 0;
	else if (fAreaOffset.y + fViewPort.h > areaRect.h)
		fAreaOffset.y = std::max(areaRect.h - fViewPort.h, 0);

	fMapArea = offset_rect_to(fViewPort,
			fAreaOffset.x, fAreaOffset.y);
}
Ejemplo n.º 2
0
void
RoomBase::SetAreaOffset(const IE::point& point)
{
	GFX::rect areaRect = AreaRect();
	fAreaOffset = point;
	if (fAreaOffset.x < 0)
		fAreaOffset.x = 0;
	else if (fAreaOffset.x + fViewPort.w > areaRect.w)
		fAreaOffset.x = std::max(areaRect.w - fViewPort.w, 0);
	if (fAreaOffset.y < 0)
		fAreaOffset.y = 0;
	else if (fAreaOffset.y + fViewPort.h > areaRect.h)
		fAreaOffset.y = std::max(areaRect.h - fViewPort.h, 0);

	fMapArea = gfx_rect_to_rect(offset_rect_to(fViewPort,
			fAreaOffset.x, fAreaOffset.y));
}
Ejemplo n.º 3
0
void
RoomContainer::Draw(Bitmap *surface)
{
	GraphicsEngine* gfx = GraphicsEngine::Get();

	if (fWorldMap != NULL) {
		GFX::rect sourceRect = offset_rect(fViewPort,
				-fViewPort.x, -fViewPort.y);
		sourceRect = offset_rect(sourceRect, fAreaOffset.x, fAreaOffset.y);
		if (sourceRect.w < gfx->ScreenFrame().w || sourceRect.h < gfx->ScreenFrame().h) {
			GFX::rect clippingRect = fViewPort;
			clippingRect.w = gfx->ScreenFrame().w;
			clippingRect.h = gfx->ScreenFrame().h;
			gfx->SetClipping(&clippingRect);
			gfx->ScreenBitmap()->Clear(0);
			gfx->SetClipping(NULL);
		}
		gfx->BlitToScreen(fWorldMapBitmap, &sourceRect, &fViewPort);
	} else {
		if (sSelectedActorRadius > 22) {
			sSelectedActorRadiusStep = -1;
		} else if (sSelectedActorRadius < 18) {
			sSelectedActorRadiusStep = 1;
		}
		sSelectedActorRadius += sSelectedActorRadiusStep;

		GFX::rect mapRect = offset_rect_to(fViewPort,
				fAreaOffset.x, fAreaOffset.y);

		bool paused = Core::Get()->IsPaused();
		if (!paused) {
			assert(fBackMap != NULL);
			fBackMap->Update(mapRect);
		}

		if (fDrawAnimations) {
			Timer* timer = Timer::Get("ANIMATIONS");
			bool advance = timer != NULL && timer->Expired() && !paused;
			_DrawAnimations(advance);
		}
		_DrawActors();

		if (fDrawPolygons) {
			fBackMap->Image()->Lock();
			for (uint32 p = 0; p < fWed->CountPolygons(); p++) {
				const Polygon* poly = fWed->PolygonAt(p);
				if (poly != NULL && poly->CountPoints() > 0) {
					if (rects_intersect(poly->Frame(), mapRect)) {
						uint32 color = 0;
						if (poly->Flags() & IE::POLY_SHADE_WALL)
							color = 200;
						else if (poly->Flags() & IE::POLY_HOVERING)
							color = 500;
						else if (poly->Flags() & IE::POLY_COVER_ANIMATIONS)
							color = 1000;

						fBackMap->Image()->FillPolygon(*poly, color,
											-fAreaOffset.x, -fAreaOffset.y);
						fBackMap->Image()->StrokePolygon(*poly, color,
											-fAreaOffset.x, -fAreaOffset.y);
					}
				}
			}
			fBackMap->Image()->Unlock();
		}

		// TODO: handle this better
		if (Door* door = dynamic_cast<Door*>(fMouseOverObject.Target())) {
			GFX::rect rect = rect_to_gfx_rect(door->Frame());
			rect = offset_rect(rect, -mapRect.x, -mapRect.y);
			fBackMap->Image()->Lock();
			fBackMap->Image()->StrokeRect(rect, 70);
			fBackMap->Image()->Unlock();
		} else if (Actor* actor = dynamic_cast<Actor*>(fMouseOverObject.Target())) {
			try {
				GFX::rect rect = rect_to_gfx_rect(actor->Frame());
				rect = offset_rect(rect, -mapRect.x, -mapRect.y);
				fBackMap->Image()->Lock();
				IE::point position = offset_point(actor->Position(), -mapRect.x, -mapRect.y);
				uint32 color = fBackMap->Image()->MapColor(255, 255, 255);
				fBackMap->Image()->StrokeCircle(position.x, position.y, 20, color);
				fBackMap->Image()->Unlock();
			} catch (const char* string) {
				std::cerr << string << std::endl;
			} catch (...) {

			}
		} else if (Region* region = dynamic_cast<Region*>(fMouseOverObject.Target())) {
			GFX::rect rect = rect_to_gfx_rect(region->Frame());
			rect = offset_rect(rect, -mapRect.x, -mapRect.y);

			uint32 color = 0;
			switch (region->Type()) {
				case IE::REGION_TYPE_TRAVEL:
					color = fBackMap->Image()->MapColor(0, 125, 0);
					break;
				case IE::REGION_TYPE_TRIGGER:
					color = fBackMap->Image()->MapColor(125, 0, 0);
					break;
				default:
					color = fBackMap->Image()->MapColor(255, 255, 255);
					break;
			}

			fBackMap->Image()->Lock();

			if (region->Polygon().CountPoints() > 2) {
				fBackMap->Image()->StrokePolygon(region->Polygon(), color,
									-mapRect.x, -mapRect.y);
			} else
				fBackMap->Image()->StrokeRect(rect, color);
			fBackMap->Image()->Unlock();
		} else if (Container* container = dynamic_cast<Container*>(fMouseOverObject.Target())) {
			uint32 color = 0;
			color = fBackMap->Image()->MapColor(0, 125, 0);
			// TODO: Different colors for trapped/nontrapped
			fBackMap->Image()->Lock();

			if (container->Polygon().CountPoints() > 2) {
				fBackMap->Image()->StrokePolygon(container->Polygon(), color,
											-mapRect.x, -mapRect.y);
			}
			fBackMap->Image()->Unlock();
		}

		gfx->BlitToScreen(fBackMap->Image(), NULL, &fViewPort);
		_DrawSearchMap(mapRect);
	}
}