Exemplo n.º 1
0
bool
GUI::Load(const res_ref& name)
{
	std::cout << "GUI::Load(" << name.CString() << ")" << std::endl;
	try {
		if (fCursors[0] == NULL)
			_InitCursors();

		gResManager->ReleaseResource(fResource);
		Clear();

		fResource = gResManager->GetCHUI(name);

		/*for (uint16 c = 0; c < fResource->CountWindows(); c++) {
			Window* window = fResource->GetWindow(c);
			if (window != NULL)
				fWindows.push_back(window);
		}*/
	} catch (...) {
		std::cout << "GUI::Load(): ERROR" << std::endl;
		return false;
	}
	std::cout << "GUI::Load(): OK!" << std::endl;
	return true;
}
Exemplo n.º 2
0
bool
RoomContainer::LoadArea(const res_ref& areaName, const char* longName,
					const char* entranceName)
{
	// Save the entrance name, it will be unloaded in UnloadArea
	std::string savedEntranceName = entranceName ? entranceName : "";

	_Unload();

	SetName(areaName.CString());

	GraphicsEngine::Get()->SetWindowCaption(Name());

	std::cout << "Room::Load(" << areaName.CString() << ")" << std::endl;

	fArea = gResManager->GetARA(Name());
	if (fArea == NULL)
		return false;

	_InitWed(fArea->WedName().CString());

	fBcs = gResManager->GetBCS(fArea->ScriptName());
	Script* roomScript = NULL;
	if (fBcs != NULL)
		roomScript = fBcs->GetScript();

	SetScript(roomScript);

	GUI* gui = GUI::Get();
	gui->Clear();

	if (!gui->Load("GUIW")) {
		// TODO: Delete other loaded stuff
		gResManager->ReleaseResource(fArea);
		fArea = NULL;
		gResManager->ReleaseResource(fBcs);
		fBcs = NULL;
		SetScript(NULL);
		delete roomScript;
		return false;
	}

	gui->ShowWindow(uint16(-1));
	Window* window = gui->GetWindow(uint16(-1));

	gui->ShowWindow(0);
	gui->ShowWindow(1);
	/*gui->ShowWindow(2);
	gui->ShowWindow(4);
	if (Window* tmp = gui->GetWindow(4)) {
		TextArea *textArea = dynamic_cast<TextArea*>(tmp->GetControlByID(3));
		if (textArea != NULL)
			textArea->SetText("This is a test");
	}*/
	//gui->GetWindow(15);


	if (window != NULL) {
		Control* control = window->GetControlByID(uint32(-1));
		if (control != NULL)
			control->AssociateRoom(this);
		Label* label = dynamic_cast<Label*>(window->GetControlByID(268435459));
		if (label != NULL)
			label->SetText(longName);
	}

	_InitVariables();
	_InitAnimations();
	_InitRegions();
	_LoadActors();
	_InitDoors();
	_InitContainers();
	_InitBlitMask();

	Core::Get()->EnteredArea(this, roomScript);

	delete roomScript;

	IE::point point = { 0, 0 };
	if (!savedEntranceName.empty()) {
		for (uint32 e = 0; e < fArea->CountEntrances(); e++) {
			IE::entrance entrance = fArea->EntranceAt(e);
			//std::cout << "current: " << entrance.name;
			//std::cout << ", looking for " << entranceName << std::endl;

			if (savedEntranceName == entrance.name) {
				point.x = entrance.x;
				point.y = entrance.y;
				CenterArea(point);
				break;
			}
		}
	} else {
		try {
			IE::entrance entrance = fArea->EntranceAt(0);
			point.x = entrance.x;
			point.y = entrance.y;
		} catch (std::out_of_range& ex) {

		}
		CenterArea(point);
	}

	Actor* player = Game::Get()->Party()->ActorAt(0);
	if (player != NULL) {
		player->SetPosition(point);
		if (!player->IsSelected())
			player->Select(true);
		fSelectedActor = player;
	}


	//GUI::Get()->DrawTooltip("THIS IS A TEXT", 50, 40, 3000);

	return true;
}