bool Inventory::getItems(const Common::Array<Item> *&items) {
	bool changed = updateItems();

	items = &_items;

	return changed;
}
Example #2
0
int
rdDelItem(rdWin *w, int item)
{
	rdItem **pi;
	rdItem *i;
	int len;

	assert(w);
	if (w->wintype != rdList || item < 0) {
		DPRINT("Invalid window or item for delete");
		return 1;
	}
	for (pi = &w->items; *pi && item; pi = &((*pi)->next))
		item--;
	if (item) {
		DPRINT("Could not find item to delete it");
		return 1;		/* not found */
	}
	i = *pi;
	len = i->p1 - i->p0;
	if (rpc_delete(wilyq, w->id, i->p0, i->p1) < 0) {
		DPRINT("Could not delete item from list");
		return 1;
	}
	*pi =  i->next;
	free(i);
	updateItems(w, *pi, -len);
	return 0;
}
Example #3
0
SchedScene::SchedScene(task_t *task, perm_t *perm, sched_t *sched, QObject *parent)
    : QGraphicsScene(parent)
    , task_(task)
    , perm_(perm)
    , sched_(sched)
    , items_(task->size())
    , marker(new Marker)
    , tRect_(NULL)

{
    for (size_t i = 0; i < task->size(); ++i)
    {
        items_[i] = new SchedItem(this, i);
        items_[i]->setPos(sched->operator[](i), 0);

        addItem(items_[i]);
        items_[i]->updateData(getItemWidth(i));
    }

    marker->setPos(0, 0);
    addItem(marker);

    tRect_ = addRect(0, 0, 0, 0);
    tRect_->setPen(QPen(Qt::red, 1));
    tRect_->setBrush(QBrush(Qt::red, Qt::Dense5Pattern));


    updateItems();
}
Example #4
0
File: app.cpp Project: KDE/kshisen
void App::newGame()
{
    setCheatModeEnabled(false);
    setPauseEnabled(false);
    updateItems();
    updateTileDisplay();
}
void GraphicsScene::move( QPointF offset )
{ 
	qreal minLen = shorterSceneRectSide();
	QPointF normOffset(offset.x()/(minLen*mRatio), -offset.y()/(minLen*mRatio));
	mOffset += normOffset;
	updateItems();
}
Example #6
0
int
rdChangeItem(rdWin *w, int item, char *text)
{
	rdItem **pi;
	rdItem *i;
	int len, oldlen, newlen;
	char *sep = "\n";

	assert(w);
	assert(text);
	newlen = strlen(text);
	if (w->wintype != rdList || !text || !*text) {
		DPRINT("changeItem() called for non-list window");
		return 1;
	}
	for (pi = &w->items; *pi && item; pi = &((*pi)->next))
		item--;
	if (item) {
		DPRINT("item not found");
		return 1;
	}
	i = *pi;
	oldlen = i->p1 - i->p0;
	if (rpc_delete(wilyq, w->id, i->p0, i->p1) ||
		rpc_insert(wilyq, w->id, i->p0, text) ||
		rpc_insert(wilyq, w->id, i->p0 + newlen, sep)) {
		DPRINT("Updates to wily window failed");
		return 1;
	}
	newlen += strlen(sep);
	i->p1 = i->p0 + newlen;
	len = newlen - oldlen;
	updateItems(w, i->next, len);
	return 0;
}
Example #7
0
void SchedScene::invalidateItems()
{
    /*vector<cost_t> tards(jobs_.size());

    for (size_t i = 0; i < jobs_.size(); ++i)
    {
        const size_t job_i = (*perm_)[i];

        tards[i] = std::max<cost_t>((*sched_)[job_i] - (*task_)[job_i].due, 0) * (*task_)[job_i].tweight;
        
        qreal width = 5; // FIXME

        if (i < jobs_.size() - 1)
        {
            const size_t next_job = (*perm_)[i + 1];
            width = time2coord((*task_)[job_i].spans[next_job]);
        }
        
        jobs_[i]->updateData(width, weight2coord((*task_)[job_i].tweight));
    }
    const cost_t max_tard = *std::max_element(tards.begin(), tards.end());

    for (size_t i = 0; i < tards.size(); ++i)
    {
        if (true || tards[i] < 0 || std::fabs(max_tard) < 0.00001)
            jobs_[i]->setColor(QColor(0, 255, 255));
        else
        {
            float ratio = tards[i] / max_tard;
            int green = std::min(static_cast<int>(255.0 * 2.0 * (1.0 - ratio)), 255);
            int red = std::min(static_cast<int>(255.0 * 2.0 * ratio), 255);
            jobs_[i]->setColor(QColor(red, green, 0));
        }
    }*/

    for (size_t i = 0; i < task_->size(); ++i)
    {
        const size_t job_i = (*perm_)[i];
        qreal width = time2coord(get_processing_time(*task_, *perm_, i));

        jobs_[i]->updateData(width, weight2coord((*task_)[job_i].tweight()));
        jobs_[i]->setColor(Qt::cyan);
    }

    for (size_t i = task_->size(); i < jobs_.size(); ++i)
        jobs_[i]->setColor(Qt::red);

    for (size_t i = subtask_begin_; i < subtask_end_; ++i)
    {
        jobs_[i]->setColor(Qt::blue);           
        jobs_[i]->setColor(Qt::blue);
    }

    if (current.is_initialized())
        jobs_[*current]->setColor(QColor(255, 0, 0));


    updateItems();
}
Example #8
0
void SelectCollection::purchaseUpdateFullGame()
{
    if(_last_scene)
    {
        updateItems();
        _last_scene->_pop_up_manager.backAction();
    }
}
Example #9
0
File: app.cpp Project: KDE/kshisen
void App::redo()
{
    if (!m_board->canRedo()) {
        return;
    }
    m_board->redo();
    updateItems();
    updateTileDisplay();
}
Example #10
0
//Sells an Item, returns true if successful
bool itemSell(Player *p, Item *i){
    if(listSearch(&p->inventory, i)){
        listRemoveByValue(&p->inventory, i);
        p->money += i->prize*2/3;
        updateItems(p);
        return true;
    }
    return false;
}
Example #11
0
void DynamicPlaylist::checkUpdateItems()
{
    if(!m_dirty)
        return;

    updateItems();

    m_dirty = false;
}
Example #12
0
void UserMgmtWidget::resizeEvent(QResizeEvent *event)
{
    if(event->oldSize() == event->size())
    {
	event->ignore();
	return;
    }
    updateItems();
    event->accept();
}
Example #13
0
File: app.cpp Project: KDE/kshisen
void App::hint()
{
#ifdef DEBUGGING
    m_board->makeHintMove();
#else
    m_board->showHint();
    setCheatModeEnabled(true);
#endif
    updateItems();
}
Example #14
0
void PsFilesListView::deleteFile()
{
    QAction *act = qobject_cast<QAction*>(sender());
    if (act)
    {
        int index = act->data().toInt();
        mProject->removeFile(index);
    }
    updateItems();
}
Example #15
0
//Sells a mineral, returns true if successful
bool mineralSell(Player *p, MineralTypes m, int amount){
    //Mineral is of Type Earth. We ignore
    if(m == 0) return true;
    if(p->minerals[m] >= amount){
        p->minerals[m] -= amount;
        p->money += amount * mineralInfo[m].value;
        updateItems(p);
        return true;
    }
    return false;
}
void MeshWidgetChart::init()
{
    setFont(QFont("Sans Serif", 11, QFont::Bold));
    m_action = new QAction(m_title, this);
    m_action->setCheckable(true);
    m_action->setChecked(true);
    m_spacing = 7;

    connect(m_action, SIGNAL(toggled(bool)), this, SLOT(setVisible(bool)));
    connect(&m_topItem, SIGNAL(updateRequired()), this, SLOT(updateItems()));
}
Example #17
0
void SchedScene::swapItems(size_t i, size_t j)
{
    std::swap((*perm_)[i], (*perm_)[j]);

    items_[i]->updateData(getItemWidth(i));
    items_[j]->updateData(getItemWidth(j));

    updateItems();

    qDebug() << "Cost: " << get_cost(*task_, *sched_);
}
Example #18
0
//Buys an Item, returns true if successful
bool itemBuy(Player *p, Item *i){
    //Check if Item is already owned
    if(listCount(&p->inventory, i) >= 1 ) return false;
    int newmoney = p->money - i->prize;
    int newspace = getFreeInvSpace(p) - i->inventorySizeTaken;
    if( newmoney >= 0 && newspace >= 0){
        p->money = newmoney;
        listInsert(&p->inventory, i);
        updateItems(p);
        return true;
    }
    return false;
}
Example #19
0
void ScoresDialog::editingFinished() {
	// Hide lineedit
	m_username->hide();
	m_scores_layout->removeWidget(m_username);
	m_scores[m_row].name = m_username->text();
	m_score_labels[m_row][1]->show();
	updateItems();

	// Save scores
	QStringList values;
	foreach (const Score& s, m_scores) {
		values += QString("%1:%2:%3:%4") .arg(s.name) .arg(s.score) .arg(s.date.toString("yyyy.MM.dd-hh.mm.ss")) .arg(s.timer);
	}
Example #20
0
void UatDialog::on_deleteToolButton_clicked()
{
    QTreeWidgetItem *item = ui->uatTreeWidget->currentItem();
    if (!uat_ || !item) return;

    guint row = item->data(0, Qt::UserRole).toUInt();

    uat_remove_record_idx(uat_, row);
    updateItems();

    on_uatTreeWidget_itemSelectionChanged();
    uat_->changed = TRUE;
}
Example #21
0
File: app.cpp Project: KDE/kshisen
void App::restartGame()
{
    m_board->setUpdatesEnabled(false);
    while (m_board->canUndo()) {
        m_board->undo();
    }
    m_board->resetRedo();
    m_board->resetTimer();
    setCheatModeEnabled(false);
    m_board->setGameOverEnabled(false);
    m_board->setGameStuckEnabled(false);
    m_board->setUpdatesEnabled(true);
    updateItems();
}
Example #22
0
File: app.cpp Project: KDE/kshisen
void App::undo()
{
    if (!m_board->canUndo()) {
        return;
    }
    m_board->undo();
    setCheatModeEnabled(true);

    // If the game is stuck (no matching tiles anymore), the player can decide
    // to undo some steps and try a different approach.
    m_board->setGameStuckEnabled(false);

    updateItems();
    updateTileDisplay();
}
Example #23
0
void GraphicsScene::zoom( int step, QPointF hoverPos )
{
	if(mRatio==0.9 && step<=0)
		return;
	QPointF normPoint = sceneCoorToNormCoor(hoverPos);
	qreal minLen = shorterSceneRectSide();
	mRatio += 0.1 * step;
	if(mRatio<0.9)
		mRatio = 0.9;
	QPointF newScenePoint = 
		QPointF( normPoint.x() * minLen * mRatio, - normPoint.y()*minLen*mRatio);
	QPointF tmp = (hoverPos - newScenePoint)/(minLen*mRatio);
	mOffset = QPointF(tmp.x(), -tmp.y());
	updateItems();
	doSomething();
}
Example #24
0
bool ListUsers::v_caseMessage( af::Msg * msg)
{
#ifdef AFOUTPUT
	msg->stdOut();
#endif
	switch( msg->type())
	{
	case af::Msg::TUsersList:
	{
		updateItems( msg);
		calcTitle();
		subscribe();
		break;
	}
	default:
		return false;
	}
	return true;
}
Example #25
0
File: app.cpp Project: KDE/kshisen
void App::slotEndOfGame()
{
    if (m_board->tilesLeft() > 0) {
        m_board->setGameStuckEnabled(true);
    } else {
        m_board->setGameOverEnabled(true);
        auto const timeString = i18nc("time string: hh:mm:ss", "%1:%2:%3",
                                      QString().sprintf("%02d", m_board->currentTime() / 3600),
                                      QString().sprintf("%02d", (m_board->currentTime() / 60) % 60),
                                      QString().sprintf("%02d", m_board->currentTime() % 60));
        KScoreDialog::FieldInfo scoreInfo;
        scoreInfo[KScoreDialog::Score].setNum(score(m_board->xTiles(), m_board->yTiles(), m_board->currentTime(), m_board->gravityFlag()));
        scoreInfo[KScoreDialog::Time] = timeString;

        QPointer<KScoreDialog> scoreDialog = new KScoreDialog(KScoreDialog::Name | KScoreDialog::Time | KScoreDialog::Score, this);
        scoreDialog->addField(KScoreDialog::Custom1, i18n("Gravity"), QStringLiteral("gravity"));
        // FIXME: This is bad, because the translated words are stored in the highscores and thus switching the language makes ugly things (schwarzer)
        if (m_board->gravityFlag()) {
            scoreInfo[KScoreDialog::Custom1] = i18n("Yes");
        } else {
            scoreInfo[KScoreDialog::Custom1] = i18n("No");
        }
        auto const configGroup = QStringLiteral("%1x%2").arg(m_board->xTiles()).arg(m_board->yTiles());
        scoreDialog->setConfigGroup(qMakePair(QByteArray(configGroup.toUtf8()), configGroup));

        if (m_board->hasCheated()) {
            auto const message = i18n("\nYou could have been in the highscores\nif you did not use Undo or Hint.\nTry without them next time.");
            KMessageBox::information(this, message, i18n("End of Game"));
        } else {
            if (scoreDialog->addScore(scoreInfo) > 0) {
                auto const message = i18n("Congratulations!\nYou made it into the hall of fame.");
                scoreDialog->setComment(message);
                scoreDialog->exec();
            } else {
                auto const message = i18nc("%1 - time string like hh:mm:ss", "You made it in %1", timeString);
                KMessageBox::information(this, message, i18n("End of Game"));
            }
        }
        delete scoreDialog;
    }
    updateItems();
}
Example #26
0
File: app.cpp Project: KDE/kshisen
App::App(QWidget * parent)
    : KXmlGuiWindow(parent)
    , m_gameTipLabel(nullptr)
    , m_gameTimerLabel(nullptr)
    , m_gameTilesLabel(nullptr)
    , m_gameCheatLabel(nullptr)
    , m_board(nullptr)
{
    m_board = new Board(this);
    m_board->setObjectName(QStringLiteral("board"));

    setCentralWidget(m_board);

    setupStatusBar();
    setupActions();
    setupGUI();

    updateItems();
    updateTileDisplay();
}
Example #27
0
int Select::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = KTToolPlugin::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0:
            syncNodes();
            break;
        case 1:
            updateItems((*reinterpret_cast< KTGraphicsScene*(*)>(_a[1])));
            break;
        default:
            ;
        }
        _id -= 2;
    }
    return _id;
}
Example #28
0
bool ScoresDialog::addScore(int score) {
	// Add score
	m_row = addScore(m_default_name, score, QDateTime::currentDateTime(), QSettings().value("Board/TimerMode", Clock::Tanglet).toInt());
	if (m_row == -1) {
		return false;
	}
	for (int c = 0; c < 5; ++c) {
		QFont f = m_score_labels[m_row][c]->font();
		f.setWeight(QFont::Bold);
		m_score_labels[m_row][c]->setFont(f);
	}
	updateItems();

	// Show lineedit
	m_scores_layout->addWidget(m_username, m_row + 1, 1);
	m_score_labels[m_row][1]->hide();
	m_username->setText(m_default_name);
	m_username->show();

	return true;
}
Example #29
0
void UatDialog::addRecord(bool copy_from_current)
{
    if (!uat_) return;

    void *rec = g_malloc0(uat_->record_size);

    if (copy_from_current && uat_->copy_cb) {
        QTreeWidgetItem *item = ui->uatTreeWidget->currentItem();
        if (!item) return;
        guint row = item->data(0, Qt::UserRole).toUInt();
        uat_->copy_cb(rec, UAT_INDEX_PTR(uat_, row), uat_->record_size);
    } else {
        for (guint col = 0; col < uat_->ncols; col++) {
            uat_field_t *field = &uat_->fields[col];
            switch (field->mode) {
            case PT_TXTMOD_ENUM:
                guint length;
                char *str;
                field->cb.tostr(rec, &str, &length, field->cbdata.tostr, field->fld_data);
                field->cb.set(rec, str, length, field->cbdata.set, field->fld_data);
                g_free(str);
                break;
            case PT_TXTMOD_NONE:
                break;
            default:
                field->cb.set(rec, "", 0, field->cbdata.set, field->fld_data);
                break;
            }
        }
    }

    uat_add_record(uat_, rec, TRUE);
    if (uat_->free_cb) {
        uat_->free_cb(rec);
    }
    g_free(rec);
    uat_->changed = TRUE;
    updateItems();
    activateLastItem();
}
Example #30
0
void UatDialog::setUat(epan_uat *uat)
{
    QString title(tr("Unknown User Accessible Table"));

    uat_ = uat;

    ui->uatTreeWidget->clear();
    ui->uatTreeWidget->setColumnCount(0);
    ui->pathLabel->clear();
    ui->pathLabel->setEnabled(false);
    help_button_->setEnabled(false);

    if (uat_) {
        if (uat_->name) {
            title = uat_->name;
        }

        QString abs_path = gchar_free_to_qstring(uat_get_actual_filename(uat_, FALSE));
        ui->pathLabel->setText(abs_path);
        ui->pathLabel->setUrl(QUrl::fromLocalFile(abs_path).toString());
        ui->pathLabel->setToolTip(tr("Open ") + uat->filename);
        ui->pathLabel->setEnabled(true);

        ui->uatTreeWidget->setColumnCount(uat_->ncols);

        for (guint col = 0; col < uat->ncols; col++) {
            ui->uatTreeWidget->headerItem()->setText(col, uat_->fields[col].title);
        }

        updateItems();

        if (uat_->help && strlen(uat_->help) > 0) {
            help_button_->setEnabled(true);
        }
    }

    setWindowTitle(title);
}