Пример #1
0
void ItemsList::update()
{
    while(!inventoryItems()->empty())
    {
        delete inventoryItems()->back();
        inventoryItems()->pop_back();
    }

    for (unsigned int i = _slotOffset; i < items()->size() && i != _slotOffset + _slotsNumber; i++)
    {
        auto inventoryItem = new InventoryItem(items()->at(i));
        inventoryItems()->push_back(inventoryItem);
    }
}
Пример #2
0
void ItemsList::onMouseDragStart(Event::Mouse* event)
{
    unsigned int index = (event->position().y() - y())/_slotHeight;
    _draggedItem = inventoryItems()->at(index);
    _draggedItem->setType(InventoryItem::Type::DRAG);
    _draggedItem->setPosition(event->position());
    Logger::critical() << "mousedragstart at " << index << " (" << _draggedItem->item()->name() << ")" << std::endl;
}
Пример #3
0
unsigned int ItemsList::pixel(const Point& pos)
{
    unsigned int i = 0;
    for (auto item : *inventoryItems())
    {
        unsigned int pixel = item->pixel(pos - Point(0, _slotHeight*i));
        if (pixel) return pixel;
        i++;
    }
    return 0;
}
Пример #4
0
void ItemsList::render(bool eggTransparency)
{
    //ActiveUI::render();
    unsigned int i = 0;
    for (auto item : *inventoryItems())
    {
        item->setPosition(position() + Point(0, _slotHeight*i));
        item->render();
        i++;
    }
}
Пример #5
0
/**
 * @brief Write the Human data back to a file.
 */
void Human::writeToFile( QFile &unitFile )
{
    QTextStream unitStream(&unitFile);

    unitStream << profession() << "/"
               << QString("%1").arg(posX(),0,'g',8) << "/"
               << QString("%1").arg(posY(),0,'g',8) << "/"
               << QString("%1").arg(posZ(),0,'g',8) << "/"
               << name() << "/";
    unitStream.flush();

    unitFile.write(Utils::toBinary(archerLevel()));
    unitFile.write(Utils::toBinary(blacksmithLevel()));
    unitFile.write(Utils::toBinary(builderLevel()));
    unitFile.write(Utils::toBinary(carpenterLevel()).constData());
    unitFile.write(Utils::toBinary(engineerLevel()).constData());
    unitFile.write(Utils::toBinary(farmerLevel()).constData());
    unitFile.write(Utils::toBinary(fishermanLevel()).constData());
    unitFile.write(Utils::toBinary(foragerLevel()).constData());
    unitFile.write(Utils::toBinary(infantryLevel()).constData());
    unitFile.write(Utils::toBinary(minerLevel()).constData());
    unitFile.write(Utils::toBinary(stoneMasonLevel()).constData());
    unitFile.write(Utils::toBinary(woodChopperLevel()).constData());
    unitFile.write(Utils::toBinary(tailorLevel()).constData());
    unitFile.write(Utils::toBinary(traderLevel()).constData());
    unitFile.write(Utils::toBinary(herderLevel()).constData());
    unitFile.write(Utils::toBinary(adventurerLevel()).constData());
    unitFile.write(Utils::toBinary(unknown1Level()).constData());
    unitFile.write(Utils::toBinary(unknown2Level()).constData());
    unitFile.write(Utils::toBinary(unknown3Level()).constData());
    unitFile.write(Utils::toBinary(unknown4Level()).constData());
    unitStream << "/"; unitStream.flush();

    unitFile.write(Utils::toBinary(experience()).constData());
    unitStream << "/"; unitStream.flush();

    unitStream << QString(autoChop()?"True":"False") << "/"
               << QString(gatherBerries()?"True":"False") << "/"
               << QString(huntChicken()?"True":"False") << "/"
               << QString(huntBoar()?"True":"False") << "/"
               << QString(showBowRange()?"True":"False") << "/";

    unitStream << QString(trainNearTarget()?"True":"False") << "/";

    unitStream << QString("%1").arg(rotation(),0,'g',8) << "/";
    unitStream.flush();

    unitFile.write(Utils::toBinary(equipHand()).constData());
    unitStream << "/"; unitStream.flush();
    unitFile.write(Utils::toBinary(equipOffhand()).constData());
    unitStream << "/"; unitStream.flush();
    unitFile.write(Utils::toBinary(equipHead()).constData());
    unitStream << "/"; unitStream.flush();
    unitFile.write(Utils::toBinary(equipBody()).constData());
    unitStream << "/"; unitStream.flush();
    unitFile.write(Utils::toBinary(equipFeet()).constData());
    unitStream << "/"; unitStream.flush();
    unitFile.write(Utils::toBinary(health()).constData());
    unitStream << "/"; unitStream.flush();

    // Dump some of the options in the file.
    for (unsigned int i = 0; i<52; i++) {
        unitStream << QString(option(i)?"True":"False") << "/";
    }
    unitStream << timeToEat() << "/"
               << morale() << "/"
               << fatigue() << "/"
               << hunger() << "/";

    // Dump more options in the file.
    for (unsigned int i = 52; i<52+12; i++) {
        unitStream << QString(option(i)?"True":"False") << "/";
    }

    // Inventory Preferences
    for (int i = 0; i<inventoryPreferences()->length(); i++) {
        unitStream << inventoryPreferences()->at(i) << "/";
    }

    // Inventory Items
    unitStream << inventoryItems()->length() << "/";
    for (int i = 0; i<inventoryItems()->length(); i++) {
        unitStream << inventoryItems()->at(i) << "/";
    }

    // Spare Inventory
    unitStream << spareInventory()->length() << "/";
    for (int i = 0; i<spareInventory()->length(); i++) {
        unitStream << spareInventory()->at(i) << "/";
    }

    // Patrol
    unitStream << patrolSetpoints()->length() << "/";
    for (int i = 0; i<patrolSetpoints()->length(); i++) {
        unitStream << patrolSetpoints()->at(i) << "/";
    }
    unitStream << patrolIndex() << "/";

    unitStream << guardedUnit() << "/";

    // Profession Experience
    for (int i = 0; i<professionEXP()->length(); i++) {
        unitStream << professionEXP()->at(i) << "/";
    }

    unitStream << maxWeight() << "/";

    unitStream << endl;
    unitStream.flush();

}