Exemplo n.º 1
0
MarginWidget::MarginWidget(SourceViewerWidget *parent) : QWidget(parent),
	m_sourceViewer(parent),
	m_lastClickedLine(-1)
{
	setAmount(m_sourceViewer->blockCount());
	setContextMenuPolicy(Qt::NoContextMenu);

	connect(m_sourceViewer, SIGNAL(blockCountChanged(int)), this, SLOT(setAmount(int)));
	connect(m_sourceViewer, SIGNAL(textChanged()), this, SLOT(setAmount()));
	connect(m_sourceViewer, SIGNAL(updateRequest(QRect,int)), this, SLOT(updateNumbers(QRect,int)));
}
            void Opcode8116::_run() {
                Logger::debug("SCRIPT")
                        << "[8116] [+] void add_mult_objs_to_inven(GameObject* who, GameItemObject* item, int amount)"
                        << std::endl;
                auto amount = _script->dataStack()->popInteger();
                auto item = dynamic_cast<Game::ItemObject *>(_script->dataStack()->popObject());
                auto invenObj = _script->dataStack()->popObject();

                if (!item) {
                    _error("add_mult_objs_to_inven - item not instanceof GameItemObject");
                    return;
                }

                item->setAmount(amount);
                // who can be critter or container
                std::vector<Game::ItemObject *> *inven;
                if (auto critterObj = dynamic_cast<Game::CritterObject *>(invenObj)) {
                    inven = critterObj->inventory();
                } else if (auto contObj = dynamic_cast<Game::ContainerItemObject *>(invenObj)) {
                    inven = contObj->inventory();
                } else {
                    _error("add_mult_objs_to_inven - wrong WHO parameter");
                    return;
                }

                inven->push_back(item);

                if (item->hexagon()) {
                    auto location = Game::Game::getInstance()->locationState();
                    if (location) {
                        location->removeObjectFromMap(item);
                    }
                }
            }
Exemplo n.º 3
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    QObject::connect(ui->SFMLWidget, SIGNAL(rotationChanged(int)), this, SLOT(setRotation(int)));
    QObject::connect(ui->SFMLWidget, SIGNAL(rangeChanged(int)), this, SLOT(setRange(int)));
    QObject::connect(ui->SFMLWidget, SIGNAL(colorChanged(uint8_t,uint8_t,uint8_t)), this, SLOT(setColor(uint8_t,uint8_t,uint8_t)));
    QObject::connect(ui->SFMLWidget, SIGNAL(amountChanged(int)), this, SLOT(setAmount(int)));
    QObject::connect(ui->SFMLWidget, SIGNAL(speedChanged(int)), this, SLOT(setSpeed(int)));
    QObject::connect(ui->SFMLWidget, SIGNAL(lifeChanged(int)), this, SLOT(setLife(int)));

    // validators
    CODE_VALIDATOR_LINE_SLIDER(lineEditRange, sliderRange);
    CODE_VALIDATOR_LINE_SLIDER(lineEditRotation, sliderRotation);
    CODE_VALIDATOR_LINE_SLIDER(lineEditAmount, sliderAmount);
    CODE_VALIDATOR_LINE_SLIDER(lineEditSpeed, sliderSpeed);
    CODE_VALIDATOR_LINE_SLIDER(lineEditLife, sliderLife);

    // standard values
    setRange(360);
    setRotation(0);
    setAmount(200);
    setSpeed(100);
    setLife(3);
    setColor(255, 0, 0);
}
Exemplo n.º 4
0
bool MarginWidget::event(QEvent *event)
{
	const bool result(QWidget::event(event));

	if (event->type() == QEvent::FontChange)
	{
		setAmount();
	}

	return result;
}
Exemplo n.º 5
0
Resource::Resource(float pos_x, float pos_y, int type, float amount) :
  Entity(pos_x, pos_y)
{
  setSprite( new Sprite(pos_x, pos_y, RES_CLICK_WIDTH, RES_CLICK_HEIGHT, RES_CLICK_OFFSET_X, RES_CLICK_OFFSET_Y) );
  //  setPosX(pos_x);
  //setPosY(pos_y);
  setDead(false);

  setType(type);
  setAmount(amount);
}
bool MarginWidget::event(QEvent *event)
{
	const bool value = QWidget::event(event);

	if (event->type() == QEvent::FontChange)
	{
		setAmount();
	}

	return value;
}
Exemplo n.º 7
0
Health::Health()
{
	if ( multiplayerManager.checkFlag( MP_FLAG_NO_HEALTH ) )
	{
		PostEvent( EV_Remove, EV_REMOVE );
		return;
	}
	
	setAmount( 20 );
	
	item_name = "health";
}
void
TestRecurrentTransaction::testSetAmountNoSignal() {
    auto amount = .45;
    auto account = std::make_shared<PublicAccount>("Test account", .0, "");
    auto category = std::make_shared<com::chancho::Category>("Test category", com::chancho::Category::Type::EXPENSE);
    auto transactionPtr = std::make_shared<com::chancho::Transaction>(account, amount, category);
    auto recurrentPtr = std::make_shared<com::chancho::RecurrentTransaction>(transactionPtr,
                                                                             std::make_shared<com::chancho::RecurrentTransaction::Recurrence>());

    auto qmlTransaction = std::make_shared<com::chancho::tests::PublicRecurrentTransaction>(recurrentPtr);

    QSignalSpy spy(qmlTransaction.get(), SIGNAL(amountChanged(double)));
    qmlTransaction->setAmount(amount);
    QCOMPARE(spy.count(), 0);
}
Exemplo n.º 9
0
void ProducerAction(void* info)
{
  struct thInfo* thinfo = (struct thInfo*) info;
  //Produce
  delay(100,10);
  thinfo->persist->itemCount = thinfo->persist->itemCount + 1;
  fprintf(stderr,"+");
  fflush(stderr);

  setAmount(&thinfo->flags, getAmount(&thinfo->flags) - 1);

  if(getAmount(&thinfo->flags) == 0) {
    fprintf(stderr,"$(%d)", pCount);
    fflush(stderr);
  }
}
Exemplo n.º 10
0
void ConsumerAction(void* info)
{
  struct thInfo* thinfo = (struct thInfo*) info;
  //Consume
  delay(100,10);
  thinfo->persist->itemCount = thinfo->persist->itemCount - 1;
  fprintf(stderr,"-");
  fflush(stderr);
  
  setAmount(&thinfo->flags, getAmount(&thinfo->flags) - 1);

  if(getAmount(&thinfo->flags) == 0) {
    fprintf(stderr,"&(%d)", cCount);
    fflush(stderr);
  }
}
Exemplo n.º 11
0
bool TranlogEntry::fromString(QString strNotation) {
	QStringList parts = strNotation.split("\t");
	Q_ASSERT_X(parts.size()==4, "TranlogEntry::fromString(Qstring)", "Invalid file format!");


	QString dtstring = parts.at(0);
	QString amountstring = parts.at(1);
	QString messagestring = parts.at(2);
	QString tagslist = parts.at(3);

	HisaabDateTime date;
	bool ok = date.fromString(dtstring);
	if( !ok ) return false;
	setDateTime(date);

	if( !isFloat(amountstring) ) return false;
	setAmount( amountstring.toFloat() );

	setMessage(messagestring);

	QStringList tags = tagslist.split(" ");
	foreach(QString tag, tags) {
		addTag(tag);
	}
void OOOperatorDescriptorList::initializeWithDefaultOperators()
{
	using OD = OOOperatorDescriptor;
	// Unary operators
	add(new OD("preincrement", "++ expr", 1, 2, OD::RightAssociative,	OD::unary<UnaryOperation::PREINCREMENT>));
	add(new OD("predecrement", "-- expr", 1, 2, OD::RightAssociative,	OD::unary<UnaryOperation::PREDECREMENT>));
	add(new OD("postincrement", "expr ++", 1, 2, OD::LeftAssociative, OD::unary<UnaryOperation::POSTINCREMENT>));
	add(new OD("postdecrement", "expr --", 1, 2, OD::LeftAssociative, OD::unary<UnaryOperation::POSTDECREMENT>));
	add(new OD("unary plus", "+ expr", 1, 2, OD::RightAssociative,	OD::unary<UnaryOperation::PLUS>));
	add(new OD("unary minus", "- expr", 1, 2, OD::RightAssociative, OD::unary<UnaryOperation::MINUS>));
	add(new OD("not", "! expr", 1, 2, OD::RightAssociative, OD::unary<UnaryOperation::NOT>));
	add(new OD("complement", "~ expr", 1, 2, OD::RightAssociative, OD::unary<UnaryOperation::COMPLEMENT>));
	add(new OD("parenthesis", "( expr )", 1, 1, OD::NotAssociative, OD::unary<UnaryOperation::PARENTHESIS>));
	add(new OD("dereference", "* expr", 1, 2, OD::RightAssociative, OD::unary<UnaryOperation::DEREFERENCE>));
	add(new OD("addressof", "& expr", 1, 2, OD::RightAssociative, OD::unary<UnaryOperation::ADDRESSOF>));

	// Binary operators
	add(new OD("times", "expr * expr", 2, 3, OD::LeftAssociative, OD::binary<BinaryOperation::TIMES>));
	add(new OD("divide", "expr / expr", 2, 3, OD::LeftAssociative, OD::binary<BinaryOperation::DIVIDE>));
	add(new OD("remainder", "expr % expr", 2, 3, OD::LeftAssociative, OD::binary<BinaryOperation::REMAINDER>));
	add(new OD("plus", "expr + expr", 2, 4, OD::LeftAssociative, OD::binary<BinaryOperation::PLUS>));
	add(new OD("minus", "expr - expr", 2, 4, OD::LeftAssociative, OD::binary<BinaryOperation::MINUS>));
	add(new OD("left shift", "expr << expr", 2, 5, OD::LeftAssociative, OD::binary<BinaryOperation::LEFT_SHIFT>));
	add(new OD("right shift signed", "expr >> expr", 2, 5, OD::LeftAssociative,
			OD::binary<BinaryOperation::RIGHT_SHIFT_SIGNED>));
	add(new OD("righ shift unsigned", "expr >>> expr", 2, 5, OD::LeftAssociative,
			OD::binary<BinaryOperation::RIGHT_SHIFT_UNSIGNED>));
	add(new OD("less", "expr < expr", 2, 6, OD::LeftAssociative, OD::binary<BinaryOperation::LESS>));
	add(new OD("greater", "expr > expr", 2, 6, OD::LeftAssociative, OD::binary<BinaryOperation::GREATER>));
	add(new OD("less equals", "expr <= expr", 2, 6, OD::LeftAssociative, OD::binary<BinaryOperation::LESS_EQUALS>));
	add(new OD("greater equals", "expr >= expr", 2, 6, OD::LeftAssociative,
			OD::binary<BinaryOperation::GREATER_EQUALS>));
	add(new OD("equals", "expr == expr", 2, 7, OD::LeftAssociative, OD::binary<BinaryOperation::EQUALS>));
	add(new OD("not equals", "expr != expr", 2, 7, OD::LeftAssociative, OD::binary<BinaryOperation::NOT_EQUALS>));
	add(new OD("bitwise xor", "expr ^ expr", 2, 9, OD::LeftAssociative, OD::binary<BinaryOperation::XOR>));
	add(new OD("bitwise and", "expr & expr", 2, 8, OD::LeftAssociative, OD::binary<BinaryOperation::AND>));
	add(new OD("bitwise or", "expr | expr", 2, 10, OD::LeftAssociative, OD::binary<BinaryOperation::OR>));
	add(new OD("conditional and", "expr && expr", 2, 11, OD::LeftAssociative,
			OD::binary<BinaryOperation::CONDITIONAL_AND>));
	add(new OD("conditional or", "expr || expr", 2, 12, OD::LeftAssociative,
			OD::binary<BinaryOperation::CONDITIONAL_OR>));
	add(new OD("array index", "expr [ expr ]", 2, 1, OD::LeftAssociative, OD::binary<BinaryOperation::ARRAY_INDEX>));

	// Ternary operator
	add(new OD("conditional expression", "expr ? expr : expr", 3, 13, OD::RightAssociative,
			[](const QList<Expression*>& operands) -> Expression* {
		auto opr = new ConditionalExpression();
		opr->setCondition(operands.first());
		opr->setTrueExpression(operands.at(1));
		opr->setFalseExpression(operands.last());
		return opr;
	}));

	// Assignment
	add(new OD("assign", "expr = expr", 2, 14, OD::RightAssociative,
			OD::assignment<AssignmentExpression::ASSIGN>));
	add(new OD("assign", "expr += expr", 2, 14, OD::RightAssociative,
			OD::assignment<AssignmentExpression::PLUS_ASSIGN>));
	add(new OD("assign", "expr -= expr", 2, 14, OD::RightAssociative,
			OD::assignment<AssignmentExpression::MINUS_ASSIGN>));
	add(new OD("assign", "expr *= expr", 2, 14, OD::RightAssociative,
			OD::assignment<AssignmentExpression::TIMES_ASSIGN>));
	add(new OD("assign", "expr /= expr", 2, 14, OD::RightAssociative,
			OD::assignment<AssignmentExpression::DIVIDE_ASSIGN>));
	add(new OD("assign", "expr &= expr", 2, 14, OD::RightAssociative,
			OD::assignment<AssignmentExpression::BIT_AND_ASSIGN>));
	add(new OD("assign", "expr |= expr", 2, 14, OD::RightAssociative,
			OD::assignment<AssignmentExpression::BIT_OR_ASSIGN>));
	add(new OD("assign", "expr ^= expr", 2, 14, OD::RightAssociative,
			OD::assignment<AssignmentExpression::BIT_XOR_ASSIGN>));
	add(new OD("assign", "expr %= expr", 2, 14, OD::RightAssociative,
			OD::assignment<AssignmentExpression::REMAINDER_ASSIGN>));
	add(new OD("assign", "expr <<= expr", 2, 14, OD::RightAssociative,
			OD::assignment<AssignmentExpression::LEFT_SHIFT_ASSIGN>));
	add(new OD("assign", "expr >>= expr", 2, 14, OD::RightAssociative,
			OD::assignment<AssignmentExpression::RIGHT_SHIFT_SIGNED_ASSIGN>));
	add(new OD("assign", "expr >>>= expr", 2, 14, OD::RightAssociative,
			OD::assignment<AssignmentExpression::RIGHT_SHIFT_UNSIGNED_ASSIGN>));

	// Others
	add(new OD( "cast", "( expr ) expr", 2, 2, OD::RightAssociative,
			[](const QList<Expression*>& operands) -> Expression* {
		auto opr = new OOModel::CastExpression();
		opr->setType(operands.first());
		opr->setExpr(operands.last());
		return opr;
	}));

	add(new OD( "comma", "expr , expr", 2, 50, OD::LeftAssociative,
			[](const QList<Expression*>& operands) -> Expression* {
		auto opr = new OOModel::CommaExpression();
		opr->setLeft(operands.first());
		opr->setRight(operands.last());
		return opr;
	}));

	add(new OD( "initializer", "{ expr }", 1, 0, OD::NotAssociative,
			[](const QList<Expression*>& operands) -> Expression* {
		auto opr = new OOModel::ArrayInitializer();

		for(auto e: operands)
		{
			if (auto comma = dynamic_cast<OOModel::CommaExpression*>(e))
			{
				for(auto ee : comma->allSubOperands(true))
					opr->values()->append(ee);

				SAFE_DELETE(comma);
			}
			else
				opr->values()->append(e);
		}

		return opr;
	}));

	add(new OD( "new object", "new SPACE expr", 1, 2, OD::RightAssociative,
			[](const QList<Expression*>& operands) -> Expression* {
		auto opr = new OOModel::NewExpression();
		opr->setNewType( operands.first());
		return opr;
	}));

	add(new OD( "new array", "new SPACE expr [ expr ]", 2, 2, OD::RightAssociative,
			[](const QList<Expression*>& operands) -> Expression* {
		auto opr = new OOModel::NewExpression();
		opr->setNewType( operands.first());
		opr->setAmount(operands.last());
		return opr;
	}));

	add(new OD( "delete object", "delete SPACE expr", 1, 2, OD::RightAssociative,
			[](const QList<Expression*>& operands) -> Expression* {
		auto expr = new OOModel::DeleteExpression();
		expr->setExpr( operands.first());
		return expr;
	}));

	add(new OD( "delete array", "delete [] SPACE expr", 1, 2, OD::RightAssociative,
			[](const QList<Expression*>& operands) -> Expression* {
		auto expr = new OOModel::DeleteExpression();
		expr->setIsArray(true);
		expr->setExpr( operands.first());
		return expr;
	}));

	add(new OD( "member", "expr . id", 2, 1, OD::LeftAssociative,
			[](const QList<Expression*>& operands) -> Expression* {
		Q_ASSERT(operands.size() == 2);
		auto ref = dynamic_cast<OOModel::ReferenceExpression*>( operands[1]);
		Q_ASSERT(ref);

		auto r = new OOModel::ReferenceExpression( ref->name(), operands.first() );
		SAFE_DELETE(ref);
		return r;
	}));

	add(new OD( "member", "expr . id < expr >", 3, 1, OD::LeftAssociative,
			[](const QList<Expression*>& operands) -> Expression* {
		Q_ASSERT(operands.size() == 3 );
		auto ref = dynamic_cast<OOModel::ReferenceExpression*>( operands[1]);
		Q_ASSERT(ref);

		auto r = new OOModel::ReferenceExpression( ref->name(), operands.first() );
		SAFE_DELETE(ref);

		if (auto comma = dynamic_cast<OOModel::CommaExpression*>(operands.last()))
		{
			for(auto arg : comma->allSubOperands(true))
				r->typeArguments()->append(arg);

			SAFE_DELETE(comma);
		}
		else
			if (!dynamic_cast<OOModel::EmptyExpression*>(operands.last()) )
				r->typeArguments()->append(operands.last());

		return r;
	}));

	add(new OD( "call", "expr ( expr )", 2, 1, OD::LeftAssociative,
			[](const QList<Expression*>& operands) -> Expression* {
		Q_ASSERT(operands.size() == 2);
		auto ref = dynamic_cast<OOModel::ReferenceExpression*>( operands.first());
		Q_ASSERT(ref);

		auto opr = new OOModel::MethodCallExpression();
		opr->setRef(ref);

		if (auto comma = dynamic_cast<OOModel::CommaExpression*>(operands.last()))
		{
			for(auto arg : comma->allSubOperands(true))
				opr->arguments()->append(arg);

			SAFE_DELETE(comma);
		}
		else
			if (!dynamic_cast<OOModel::EmptyExpression*>(operands.last()) )
					opr->arguments()->append(operands.last());

		return opr;
	}));

	add(new OD( "type arguments", "id < expr >", 2, 0, OD::LeftAssociative,
			[](const QList<Expression*>& operands) -> Expression* {
		Q_ASSERT(operands.size() == 2);
		auto ref = dynamic_cast<OOModel::ReferenceExpression*>( operands.first());
		Q_ASSERT(ref);

		if (auto comma = dynamic_cast<OOModel::CommaExpression*>(operands.last()))
		{
			for(auto arg : comma->allSubOperands(true))
				ref->typeArguments()->append(arg);

			SAFE_DELETE(comma);
		}
		else
			if (!dynamic_cast<OOModel::EmptyExpression*>(operands.last()) )
					ref->typeArguments()->append(operands.last());

		return ref;
	}));

	add(new OD( "array type", "expr []", 1, 1, OD::LeftAssociative,
			[](const QList<Expression*>& operands) -> Expression* {
		auto at = new OOModel::ArrayTypeExpression();
		at->setTypeExpression(operands.first());
		return at;
	}));

	add(new OD( "pointer type", "expr *", 1, 1, OD::LeftAssociative,
			[](const QList<Expression*>& operands) -> Expression* {
		auto at = new OOModel::PointerTypeExpression();
		at->setTypeExpression(operands.first());
		return at;
	}));

	add(new OD( "reference type", "expr &", 1, 1, OD::LeftAssociative,
			[](const QList<Expression*>& operands) -> Expression* {
		auto at = new OOModel::ReferenceTypeExpression();
		at->setTypeExpression(operands.first());
		return at;
	}));

	add(new OD( "const qualifier", "const SPACE expr", 1, 1, OD::RightAssociative,
			[](const QList<Expression*>& operands) -> Expression* {
		auto at = new OOModel::TypeQualifierExpression();
		at->setQualifier(OOModel::Type::CONST);
		at->setTypeExpression(operands.first());
		return at;
	}));

	add(new OD( "volatile qualifier", "volatile SPACE expr", 1, 1, OD::RightAssociative,
			[](const QList<Expression*>& operands) -> Expression* {
		auto at = new OOModel::TypeQualifierExpression();
		at->setQualifier(OOModel::Type::VOLATILE);
		at->setTypeExpression(operands.first());
		return at;
	}));

	// Variable declaration
	auto varDeclFunction = [](const QList<Expression*>& operands) -> Expression*
	{
		auto vd = new OOModel::VariableDeclarationExpression();

		vd->decl()->setTypeExpression( operands.first() );
		auto ref = dynamic_cast<OOModel::ReferenceExpression*>(operands[1]);
		vd->decl()->setName( ref->name());
		SAFE_DELETE(ref);

		if (operands.size() > 2) vd->decl()->setInitialValue(operands[2]);
		return vd;
	};
	add(new OD( "variable decl", "expr SPACE id", 2, 40, OD::RightAssociative, varDeclFunction));
	add(new OD( "variable decl and initialization", "expr SPACE id = expr", 3, 40,
			OD::RightAssociative, varDeclFunction));

	add(new OD( "throw", "throw SPACE expr", 1, 30, OD::RightAssociative,
			[](const QList<Expression*>& operands) -> Expression* {
		auto expr = new OOModel::ThrowExpression();
		expr->setExpr( operands.first());
		return expr;
	}));

	// Command descriptors
	add(new CommandDescriptor( "command without params", "\\ id SPACE", 1, 0, OD::NotAssociative));
	add(new CommandDescriptor( "command with params", "\\ id ( expr )", 2, 0, OD::NotAssociative));

	add(new CompoundObjectDescriptor( "compound object",
			CompoundObjectDescriptor::compoundSignature(), 1, 0, OD::NotAssociative));
}
StubChainAdaptor::StubChainAdaptor(QObject* parent)
    : QObject(parent)
{
    auto orphanage = message.getOrphanage();
    auto coinOrphan = orphanage.newOrphan<Coin>();
    auto coin = coinOrphan.get();
    coin.setName("BTS");
    coin.setId(0);
    coin.setPrecision(5);
    coins.emplace_back(kj::mv(coinOrphan));

    coinOrphan = orphanage.newOrphan<Coin>();
    coin = coinOrphan.get();
    coin.setName("FMV");
    coin.setId(1);
    coin.setPrecision(0);
    coins.emplace_back(kj::mv(coinOrphan));

    coinOrphan = orphanage.newOrphan<Coin>();
    coin = coinOrphan.get();
    coin.setName("USD");
    coin.setId(2);
    coin.setPrecision(2);
    coins.emplace_back(kj::mv(coinOrphan));

    std::reference_wrapper<std::vector<capnp::Orphan<Balance>>> bals = balances["nathan"];
    auto balanceOrphan = orphanage.newOrphan<Balance>();
    auto balance = balanceOrphan.get();
    balance.setAmount(50000000);
    balance.initId(1)[0] = 0;
    balance.setType(0);
    bals.get().emplace_back(kj::mv(balanceOrphan));

    balanceOrphan = orphanage.newOrphan<Balance>();
    balance = balanceOrphan.get();
    balance.setAmount(10);
    balance.initId(1)[0] = 1;
    balance.setType(1);
    bals.get().emplace_back(kj::mv(balanceOrphan));

    balanceOrphan = orphanage.newOrphan<Balance>();
    balance = balanceOrphan.get();
    balance.setAmount(5000);
    balance.initId(1)[0] = 2;
    balance.setType(2);
    bals.get().emplace_back(kj::mv(balanceOrphan));

    bals = balances["dev.nathanhourt.com"];

    balanceOrphan = orphanage.newOrphan<Balance>();
    balance = balanceOrphan.get();
    balance.setAmount(10000000);
    balance.initId(1)[0] = 3;
    balance.setType(0);
    bals.get().emplace_back(kj::mv(balanceOrphan));

    bals = balances["adam"];

    balanceOrphan = orphanage.newOrphan<Balance>();
    balance = balanceOrphan.get();
    balance.setAmount(88);
    balance.initId(1)[0] = 4;
    balance.setType(1);
    bals.get().emplace_back(kj::mv(balanceOrphan));

    auto contestOrphan = orphanage.newOrphan<Contest>();
    auto contest = contestOrphan.get();
    auto ucontest = contest.getContest();
    contest.initSignature(0);
    ucontest.initId(1)[0] = 0;
    ucontest.setCoin(1);
    ucontest.setName("Lunch poll");
    ucontest.setDescription("Where should we go for lunch?");
    ucontest.setStartTime(static_cast<uint64_t>(QDateTime::fromString("2015-09-20T12:00:00",
                                                                      Qt::ISODate).toMSecsSinceEpoch()));
    auto tags = ucontest.initTags(1);
    tags[0].setKey("category");
    tags[0].setValue("food");
    auto contestants = ucontest.initContestants(3);
    contestants[0].setName("Wikiteria");
    contestants[0].setDescription("Cafeteria on the CRC campus");
    contestants[1].setName("Wicked Taco");
    contestants[1].setDescription("Restaurant on Prices Fork");
    contestants[2].setName("Firehouse");
    contestants[2].setDescription("Sub Shop on University City Blvd");
    contests.emplace_back(kj::mv(contestOrphan));

    contestOrphan = orphanage.newOrphan<Contest>();
    contest = contestOrphan.get();
    ucontest = contest.getContest();
    contest.initSignature(0);
    ucontest.initId(1)[0] = 1;
    ucontest.setCoin(0);
    ucontest.setName("Upgrade Authorization");
    ucontest.setDescription("Do the BitShares stakeholders accept the upgrade to version 2.0, "
                            "using the Graphene Toolkit?");
    ucontest.setStartTime(static_cast<uint64_t>(QDateTime::fromString("2015-09-11T12:00:00",
                                                                      Qt::ISODate).toMSecsSinceEpoch()));
    tags = ucontest.initTags(1);
    tags[0].setKey("category");
    tags[0].setValue("hard-forks");
    contestants = ucontest.initContestants(2);
    contestants[0].setName("Yes");
    contestants[0].setDescription("Accept the upgrade, and hard-fork to BitShares 2.0");
    contestants[1].setName("No");
    contestants[1].setDescription("Reject the upgrade, and continue using BitShares 0.9.x");
    contests.emplace_back(kj::mv(contestOrphan));
}
Exemplo n.º 14
0
void Item::SetAmountEvent( Event *ev )
{
	setAmount( ev->GetInteger( 1 ) );
}
Exemplo n.º 15
0
/**
 * @brief eine Transition wird anhand der Eingabe durchgefuehrt
 * Die IDs der Zustaende idle(IDLE), selected(SELECTED), amountset(AMOUNTSET) und finished(FINISHED) werden gesetzt.
 * 
 * Anhand der ID des aktuellen Zustandes wird entschieden:
 * -IDLE: Anhand der Eingabe wird entschieden:
 *		 *SELECT: Der neue Zustand ist selected. Die Produkt ID wird (Aufruf getDetectedPid()) bestimmt.
 *		 *sonst: Fehlermeldung
 * -SELECTED: Anhand der Eingabe wird entschieden:
 *		 *ONE: Der neue Zustand ist amountset. Die Produktmenge ist 1.
 *		 *TWO: Der neue Zustand ist amountset. Die Produktmenge ist 2.
 *		 *BACK: Der neue Zustand ist idle.
 *		 *CANCEL: Der neue Zustand ist idle.
 *		 *sonst: Fehlermeldung
 * -AMOUNTSET: Anhand der Eingabe wird entschieden:
 *		 *PUTINCART: der neue Zustand ist finished. Das Produkt wird in den Warenkorb abgelegt.
 *		 *BACK: der neue Zustand ist selected. Die Produkt Menge wird zurueckgesetzt.
 *		 *CANCEL: der neue Zustand ist idle. Die Produkt Menge wird zurueckgesetzt.
 *		 *sonst: Fehlermeldung
 * -FINISHED: Anhand der Eingabe wird entschieden:
 *		 *MORE: der neue Zustand ist idle. Die Produkt Menge wird zurueckgesetzt.
 *		 *sonst: Fehlermeldung
 * @param input Eine Zahl, von der abhaengig ist, welche Aktion als naechstes ausgefuehrt wird.
 * @return void
 * @see IDLE 0
 * @see SELECTED 1
 * @see AMOUNTSET 2
 * @see FINISHED 3
 * @see ONE 1
 * @see TWO 2
 * @see SELECT 100
 * @see PUTINCART 101
 * @see BACK 102
 * @see CANCEL 103
 * @see MORE 104
 */
void automaton::transitions(int input){

    idle.setId(IDLE);
    selected.setId(SELECTED);
    amountset.setId(AMOUNTSET);
    finished.setId(FINISHED);

    QMessageBox msgBox;
    msgBox.setText("Die StateId ist: "+QString::number(currentState.getId())+"\nDer Input ist: "+QString::number(input));
    msgBox.exec();

    switch (currentState.getId()){

    case IDLE:
        switch (input) {
        case SELECT:
            // neue pid hier setzen
            setState(selected);
            this->setPid(connectedKinect->getDetectedPid());
            break;
        default:
            qDebug() << "FEHLER: case IDLE";
            break;
        }
    break;

    case SELECTED:
        switch (input) {
        case ONE:
            setState(amountset);
            setAmount(1);
            break;
        case TWO:
            setState(amountset);
            setAmount(2);
            break;
        case BACK:
            setState(idle);
            break;
        case CANCEL:
            setState(idle);
            break;
        default:
            qDebug() << "FEHLER: case SELECTED";
            break;
        }
    break;

    case AMOUNTSET:
        switch (input) {
        case PUTINCART:
        {
            setState(finished);
            QSqlQuery query;
            query.prepare("SELECT price, title FROM products WHERE id = :pid");
            query.bindValue(":pid", pid);
            query.exec();
            query.next();
            double price = query.value(0).toDouble();
            QString title = query.value(1).toString();
            connectedObj->addToCart(pid,amount,price,title);
            break;
        }
        case BACK:
            setState(selected);
            setAmount(0);
            break;
        case CANCEL:
            setState(idle);
            setAmount(0);
            break;
        default:
            qDebug() << "FEHLER: case AMOUNTSET";
            break;
        }
    break;

    case FINISHED:
        switch (input) {
        case MORE:
            setState(idle);
            setAmount(0);
            break;
        default:
            qDebug() << "FEHLER: case FINISHED";
            break;
        }
    break;

    default:
        qDebug() << "FEHLER: switch";
        break;
    }
}
Exemplo n.º 16
0
CSlider::CSlider(Point position, int totalw, std::function<void(int)> Moved, int Capacity, int Amount, int Value, bool Horizontal, CSlider::EStyle style):
    capacity(Capacity),
    horizontal(Horizontal),
    amount(Amount),
    value(Value),
    scrollStep(1),
    moved(Moved)
{
	OBJ_CONSTRUCTION_CAPTURING_ALL;
	setAmount(amount);
	vstd::amax(value, 0);
	vstd::amin(value, positions);

	addUsedEvents(LCLICK | KEYBOARD | WHEEL);
	strongInterest = true;

	pos.x += position.x;
	pos.y += position.y;

	if(style == BROWN)
	{
		std::string name = horizontal?"IGPCRDIV.DEF":"OVBUTN2.DEF";
		//NOTE: this images do not have "blocked" frames. They should be implemented somehow (e.g. palette transform or something...)

		left =   new CButton(Point(), name, CButton::tooltip());
		right =  new CButton(Point(), name, CButton::tooltip());
		slider = new CButton(Point(), name, CButton::tooltip());

		left->setImageOrder(0, 1, 1, 1);
		right->setImageOrder(2, 3, 3, 3);
		slider->setImageOrder(4, 4, 4, 4);
	}
	else
	{
		left = new CButton(Point(), horizontal ? "SCNRBLF.DEF" : "SCNRBUP.DEF", CButton::tooltip());
		right = new CButton(Point(), horizontal ? "SCNRBRT.DEF" : "SCNRBDN.DEF", CButton::tooltip());
		slider = new CButton(Point(), "SCNRBSL.DEF", CButton::tooltip());
	}
	slider->actOnDown = true;
	slider->soundDisabled = true;
	left->soundDisabled = true;
	right->soundDisabled = true;

	if (horizontal)
		right->moveBy(Point(totalw - right->pos.w, 0));
	else
		right->moveBy(Point(0, totalw - right->pos.h));

	left->addCallback(std::bind(&CSlider::moveLeft,this));
	right->addCallback(std::bind(&CSlider::moveRight,this));
	slider->addCallback(std::bind(&CSlider::sliderClicked,this));

	if(horizontal)
	{
		pos.h = slider->pos.h;
		pos.w = totalw;
	}
	else
	{
		pos.w = slider->pos.w;
		pos.h = totalw;
	}

	updateSliderPos();
}
Exemplo n.º 17
0
CSlider::CSlider(int x, int y, int totalw, boost::function<void(int)> Moved, int Capacity, int Amount, int Value, bool Horizontal, int style)
:capacity(Capacity),amount(Amount),horizontal(Horizontal), moved(Moved)
{
	OBJ_CONSTRUCTION_CAPTURING_ALL;
	setAmount(amount);

	addUsedEvents(LCLICK | KEYBOARD | WHEEL);
	strongInterest = true;


	left = new CAdventureMapButton();
	right = new CAdventureMapButton();
	slider = new CAdventureMapButton();

	pos.x += x;
	pos.y += y;

	if(horizontal)
	{
		left->pos.y = slider->pos.y = right->pos.y = pos.y;
		left->pos.x = pos.x;
		right->pos.x = pos.x + totalw - 16;
	}
	else
	{
		left->pos.x = slider->pos.x = right->pos.x = pos.x;
		left->pos.y = pos.y;
		right->pos.y = pos.y + totalw - 16;
	}

	left->callback = boost::bind(&CSlider::moveLeft,this);
	right->callback = boost::bind(&CSlider::moveRight,this);
	slider->callback = boost::bind(&CSlider::sliderClicked,this);
	left->pos.w = left->pos.h = right->pos.w = right->pos.h = slider->pos.w = slider->pos.h = 16;
	if(horizontal)
	{
		pos.h = 16;
		pos.w = totalw;
	}
	else
	{
		pos.w = 16;
		pos.h = totalw;
	}

	if(style == 0)
	{
		std::string name = horizontal?"IGPCRDIV.DEF":"OVBUTN2.DEF";
		//NOTE: this images do not have "blocked" frames. They should be implemented somehow (e.g. palette transform or something...)

		//use source def to create custom animations. Format "name.def:123" will load this frame from def file
		CAnimation *animLeft = new CAnimation();
		animLeft->setCustom(name + ":0", 0);
		animLeft->setCustom(name + ":1", 1);
		left->setImage(animLeft);

		CAnimation *animRight = new CAnimation();
		animRight->setCustom(name + ":2", 0);
		animRight->setCustom(name + ":3", 1);
		right->setImage(animRight);

		CAnimation *animSlider = new CAnimation();
		animSlider->setCustom(name + ":4", 0);
		slider->setImage(animSlider);
	}
	else
	{
		left->setImage(new CAnimation(horizontal ? "SCNRBLF.DEF" : "SCNRBUP.DEF"));
		right->setImage(new CAnimation(horizontal ? "SCNRBRT.DEF" : "SCNRBDN.DEF"));
		slider->setImage(new CAnimation("SCNRBSL.DEF"));
	}
	slider->actOnDown = true;
	slider->soundDisabled = true;
	left->soundDisabled = true;
	right->soundDisabled = true;

	value = -1;
	moveTo(Value);
}
Exemplo n.º 18
0
int main(int argc, char* const argv[])
{
  srand(time(NULL));
  int n=10, m=255 & AmountMask, p=GRAIN, c = n*m/4; 
  int gopt;
  while((gopt = getopt(argc,argv,"n:m:p:c:")) != -1) {
    switch(gopt) {
      case 'n':
        n = atoi(optarg);
        break;
      case 'm':
        m = atoi(optarg);
        break;
      case 'p':
        p = atoi(optarg);
        break;
      case 'c':
        c = atoi(optarg);
        break;
    }
  }
  if(m > (255 & AmountMask)) {
    printf("Max m is %d\n", (255 & AmountMask));
  }
  printf("n: %d (thread total nr)  m: %d (max production/consumption) p: %d (chance) c: %d (maxItems)\n", n,m,p,c);
  pthread_t threads[n];
  memset(threads, 0, sizeof(threads));
  pthread_attr_t pattr;
  CERRS(pthread_attr_init(&pattr), "pthread attr init failed");
  CERRS(pthread_attr_setdetachstate(&pattr, PTHREAD_CREATE_JOINABLE), "pthread attr setds failed");
  struct thInfo* thinfo;
  thinfo = (struct thInfo*) malloc(sizeof(struct thInfo)*n);
  memset(thinfo, 0, n*sizeof(struct thInfo));
  struct thInfoPersist* pr = (struct thInfoPersist*)malloc(sizeof(struct thInfoPersist));
  CERRS(pthread_mutex_init(&pr->buffer,NULL) != 0, "sem init failed");
  CERRS(pthread_cond_init(&pr->notEmpty,NULL) != 0, "cond init failed");
  CERRS(pthread_cond_init(&pr->notFull,NULL) != 0, "cond init failed");
  CERRS(pthread_mutex_init(&pCountLock,NULL) != 0, "mutex init failed");
  CERRS(pthread_mutex_init(&cCountLock,NULL) != 0, "mutex init failed");
  pr->maxItems = c;
  pr->itemCount = 0;
  int balance = pr->itemCount;
  cCount=0;
  pCount=0;
  for(int i=0; i < n; i++) {
    setThInfo(&thinfo[i], pr);
    setAmount(&thinfo[i].flags, rand() % m);
    if(rand() % (p+GRAIN) > GRAIN ) {
      printf("Made consumer: ");
      setConsumer(&thinfo[i].flags, 1);
      balance = balance - getAmount(&thinfo[i].flags);
    } else {
      printf("Made producer: ");
      setProducer(&thinfo[i].flags, 1);
      balance = balance + getAmount(&thinfo[i].flags);
    }
    printf("am : %u bal: %d IC: %d\n", getAmount(&thinfo[i].flags), balance, pr->itemCount);
    CERRS(pthread_create(&threads[i], &pattr, &routine, (void*) &thinfo[i]), "pthread creation failed");
  }
  for (int j=0; j < n; j++) {
//    printf("\n  joining. %d p(%d) c(%d)\n", j, pCount, cCount);
    CERRS(pthread_join(threads[j], NULL), "pthread join failed");
    printf("\nnr %d (%s) done\n", j, (isConsumer(&(thinfo[j].flags))) ? "Consumer" : "Producer");
  }
  free(thinfo);
  free(pr);
}
    bool CCPurchaseWithVirtualItem::init(cocos2d::CCString *itemId, cocos2d::CCInteger *amount) {
        setItemId(itemId);
        setAmount(amount);

        return true;
    }
Exemplo n.º 20
0
TranlogEntry::TranlogEntry(float amount, QString message, QDateTime dt) {
	setAmount(amount);
	setMessage(message);
	setDateTime(HisaabDateTime(dt));
}