Exemple #1
0
void SearchStateOnAction(deque<ItemState>& state, ItemState current, ActionEffect action)
{
	if(current.CanTakeAction(action))
	{
		ItemState next;
		bool rst = current.TakeAction(action,next);
		if(rst && !IsProcessedState(state,next))
		{
			state.push_back(next);
			SearchState(state);
			state.pop_back();
		}
	}
}
Exemple #2
0
void SearchState(deque<ItemState>& state)
{
	ItemState current = state.back();
	if(current.IsFinalState())
	{
		PrintResult(state);
		return;
	}
	else
	{
		for(int i=0; i< sizeof(acteffect)/sizeof(acteffect[0]); i++)
		{
			SearchStateOnAction(state, current, acteffect[i]);
		}
	}
}
Exemple #3
0
void NodePalette::ResetContour()
{
	if (doc != 0)
	{
		PageItem *currItem = doc->m_Selection->itemAt(0);
		if (UndoManager::undoEnabled())
		{
			ItemState<FPointArray> *is = new ItemState<FPointArray>(Um::ResetContourLine, "",Um::IBorder);
			is->set("RESET_CONTOUR", "reset_contour");
			is->setItem(doc->m_Selection->itemAt(0)->ContourLine);
			UndoManager::instance()->action(currItem, is);
		}
		//FIXME make an internal item copy poline to contourline member
		currItem->ContourLine = currItem->PoLine.copy();
		currItem->ClipEdited = true;
		view->DrawNew();
	}
}
Exemple #4
0
bool ItemState::TakeAction(ActionEffect action, ItemState &next)
{
	next.local_monster = local_monster + action.move_monster;
	next.local_monk = local_monk + action.move_monk;
	next.remote_monster = remote_monster - action.move_monster;
	next.remote_monk = remote_monk - action.move_monk;
	
	next.boat = action.boat_to;
	
	next.SetAction(action);
	if(next.local_monster > next.local_monk && next.local_monk > 0)
		return false;
	if(next.remote_monster > next.remote_monk && next.remote_monk >0)
		return false;
	return true;
}
Exemple #5
0
bool IsSameState(ItemState state1, ItemState state2)
{
	return state1.IsSameState(state2);
}
void PageItem_ImageFrame::clearContents()
{
	if (UndoManager::undoEnabled())
	{
		ItemState<ScImageEffectList> *is = new ItemState<ScImageEffectList>(Um::ClearImage + "\n" + Pfile, "");
		is->set("CLEAR_IMAGE", "clear_image");
		is->set("CI_PFILE", Pfile);
		is->set("CI_FLIPPH",imageFlippedH());
		is->set("CI_FLIPPV",imageFlippedV());
		is->set("CI_SCALING",ScaleType);
		is->set("CI_ASPECT",AspectRatio);
		is->set("CI_XOFF",imageXOffset());
		is->set("CI_XSCALE",imageXScale());
		is->set("CI_YOFF",imageYOffset());
		is->set("CI_YSCALE",imageYScale());
		is->set("CI_FILLT", fillTransparency());
		is->set("CI_LINET", lineTransparency());
		is->setItem(effectsInUse);
		undoManager->action(this, is);
	}
	effectsInUse.clear();
	PictureIsAvailable = false;
	Pfile = "";
	pixm = ScImage();

	LocalScX = 1;
	LocalScY = 1;
	OrigW = 0;
	OrigH = 0;
	LocalX = 0;
	LocalY = 0;
	setImageFlippedH(false);
	setImageFlippedV(false);
	EmProfile = "";
	ScaleType = true;
	AspectRatio = true;
	setFillTransparency(0.0);
	setLineTransparency(0.0);
	imageClip.resize(0);
	if (tempImageFile != NULL)
		delete tempImageFile;
	tempImageFile = NULL;
	isInlineImage = false;
	//				emit UpdtObj(Doc->currentPage->pageNr(), ItemNr);
}
Exemple #7
0
uint32
PackageInstall::_Install()
{
	PackageInfo *info = fParent->GetPackageInfo();
	pkg_profile *type = static_cast<pkg_profile *>(info->GetProfile(
		fParent->GetCurrentType()));
	uint32 n = type->items.CountItems(), m = info->GetScriptCount();

	PackageStatus *progress = fParent->GetStatusWindow();
	progress->Reset(n + m + 5);

	progress->StageStep(1, B_TRANSLATE("Preparing package"));

	InstalledPackageInfo packageInfo(info->GetName(), info->GetVersion());

	status_t err = packageInfo.InitCheck();
	if (err == B_OK) {
		// The package is already installed, inform the user
		BAlert *reinstall = new BAlert("reinstall",
			B_TRANSLATE("The given package seems to be already installed on "
				"your system. Would you like to uninstall the existing one "
				"and continue the installation?"),
			B_TRANSLATE("Continue"),
			B_TRANSLATE("Abort"));

		if (reinstall->Go() == 0) {
			// Uninstall the package
			err = packageInfo.Uninstall();
			if (err != B_OK) {
				fprintf(stderr, B_TRANSLATE("Error on uninstall\n"));
				return P_MSG_I_ERROR;
			}

			err = packageInfo.SetTo(info->GetName(), info->GetVersion(), true);
			if (err != B_OK) {
				fprintf(stderr, B_TRANSLATE("Error on SetTo\n"));
				return P_MSG_I_ERROR;
			}
		} else {
			// Abort the installation
			return P_MSG_I_ABORT;
		}
	} else if (err == B_ENTRY_NOT_FOUND) {
		err = packageInfo.SetTo(info->GetName(), info->GetVersion(), true);
		if (err != B_OK) {
			fprintf(stderr, B_TRANSLATE("Error on SetTo\n"));
			return P_MSG_I_ERROR;
		}
	} else if (progress->Stopped()) {
		return P_MSG_I_ABORT;
	} else {
		fprintf(stderr, B_TRANSLATE("returning on error\n"));
		return P_MSG_I_ERROR;
	}

	progress->StageStep(1, B_TRANSLATE("Installing files and folders"));

	// Install files and directories
	PackageItem *iter;
	ItemState state;
	uint32 i;
	int32 choice;
	BString label;

	packageInfo.SetName(info->GetName());
	// TODO: Here's a small problem, since right now it's not quite sure
	//		which description is really used as such. The one displayed on
	//		the installer is mostly package installation description, but
	//		most people use it for describing the application in more detail
	//		then in the short description.
	//		For now, we'll use the short description if possible.
	BString description = info->GetShortDescription();
	if (description.Length() <= 0)
		description = info->GetDescription();
	packageInfo.SetDescription(description.String());
	packageInfo.SetSpaceNeeded(type->space_needed);

	fItemExistsPolicy = P_EXISTS_NONE;

	const char *installPath = fParent->GetCurrentPath()->Path();
	for (i = 0; i < n; i++) {
		state.Reset(fItemExistsPolicy); // Reset the current item state
		iter = static_cast<PackageItem *>(type->items.ItemAt(i));

		err = iter->DoInstall(installPath, &state);
		if (err == B_FILE_EXISTS) {
			// Writing to path failed because path already exists - ask the user
			// what to do and retry the writing process
			choice = fParent->ItemExists(*iter, state.destination,
				fItemExistsPolicy);
			if (choice != P_EXISTS_ABORT) {
				state.policy = choice;
				err = iter->DoInstall(installPath, &state);
			}
		}

		if (err != B_OK) {
			fprintf(stderr, B_TRANSLATE("Error while writing path\n"));
			return P_MSG_I_ERROR;
		}

		if (progress->Stopped())
			return P_MSG_I_ABORT;
		label = "";
		label << (uint32)(i + 1) << " of " << (uint32)n;
		progress->StageStep(1, NULL, label.String());

		packageInfo.AddItem(state.destination.Path());
	}

	progress->StageStep(1, B_TRANSLATE("Running post-installation scripts"),
		 "");

	PackageScript *scr;
	status_t status;
	// Run all scripts
	for (i = 0; i < m; i++) {
		scr = info->GetScript(i);

		fCurrentScriptLocker.Lock();
		fCurrentScript = scr;

		if (scr->DoInstall() != B_OK) {
			fprintf(stderr, B_TRANSLATE("Error while running script\n"));
			return P_MSG_I_ERROR;
		}
		fCurrentScriptLocker.Unlock();

		wait_for_thread(scr->GetThreadId(), &status);
		fCurrentScriptLocker.Lock();
		scr->SetThreadId(-1);
		fCurrentScript = NULL;
		fCurrentScriptLocker.Unlock();

		if (progress->Stopped())
			return P_MSG_I_ABORT;
		label = "";
		label << (uint32)(i + 1) << " of " << (uint32)m;
		progress->StageStep(1, NULL, label.String());
	}

	progress->StageStep(1, B_TRANSLATE("Finishing installation"), "");

	err = packageInfo.Save();
	if (err != B_OK)
		return P_MSG_I_ERROR;

	progress->StageStep(1, B_TRANSLATE("Done"));

	// Inform our parent that we finished
	return P_MSG_I_FINISHED;
}