Example #1
0
void GMap::draw(Rect drawRect_, bool generate_)
{
    // Draw

    // Generate
    if(generate_)
        generate(drawRect_.getWidth(), drawRect_.getHeight());

    // Draw

    // Map
    for(int mX = 0; mX < alignX(drawRect_.getWidth()); mX++)
    {
        // X
        int x = cameraX(alignX(drawRect_.getWidth())) + mX;

        for(int mY = 0; mY < alignY(drawRect_.getHeight()); mY++)
        {
            // Y
            int y = cameraY(alignY(drawRect_.getHeight())) + mY;

            // Draw
            move(alignY(drawRect_.coord.getY()) + mY, alignX(drawRect_.coord.getY()) + mX);
            if(slot[x][y]->getDynamicType() == ' ')
            {
                addch(slot[x][y]->getStaticType());
            }
            else
            {
                addch(slot[x][y]->getDynamicType());
            }
        }
    }

    // Player
    move(toScrY(playerY, alignY(drawRect_.getHeight()), alignY(drawRect_.coord.getY())),
         toScrX(playerX, alignX(drawRect_.getWidth()), alignX(drawRect_.coord.getX())));
    printw("T");
}
Example #2
0
void GMap::generate(int dW, int dH)
{
    // Generate slots

    for(int mX = 0; mX < alignX(dW); mX++)
    {
        // X
        int gX = cameraX(alignX(dW)) + mX;

        for(int mY = 0; mY < alignY(dH); mY++)
        {
            // Y
            int gY = cameraY(alignY(dH)) + mY;

            // Generate
            if( slot.find(gX) == slot.end() ||
                    slot[gX].find(gY) == slot[gX].end() )
            {
                slot[gX][gY] = generateSlot();
            }
        }
    }
}
bool Label::draw(int scrW, int scrH)
{
    // Draw label

    // Center coords
    int lCX = alignX(x + width/2, scrW);
    int lCY = alignY(y + height/2, scrH);

    // Try Big size
    if(!drawText(lCX - textWidth(text, "big", font) / 2,
                 lCY - textHeight(text, "big", font) / 2,
                 animationText(), "big", font,
                 alignX(x, scrW), alignY(y, scrH),
                 alignX(width, scrW), alignY(height, scrH), indent))
    {
        // Try Normal size
        if(!drawText(lCX - textWidth(text, "normal", font) / 2,
                     lCY - textHeight(text, "normal", font) / 2,
                     animationText(), "normal", font,
                     alignX(x, scrW), alignY(y, scrH),
                     alignX(width, scrW), alignY(height, scrH), indent))
        {
            // Try Small size
            if(!drawText(lCX - textWidth(text, "small", font) / 2,
                         lCY - textHeight(text, "small", font) / 2,
                         animationText(), "small", font,
                         alignX(x, scrW), alignY(y, scrH),
                         alignX(width, scrW), alignY(height, scrH), indent))
            {
                // Try Natural size
                return drawText(lCX - textWidth(text, "natural", font) / 2,
                                lCY - textHeight(text, "natural", font) / 2,
                                animationText(), "natural", font,
                                alignX(x, scrW), alignY(y, scrH),
                                alignX(width, scrW), alignY(height, scrH), indent);
            }
        }
    }

    return true;
}
Example #4
0
GuiPanel::GuiPanel(QWidget *parent, IniData &id) :
    QWidget(parent),
    inidata(id),
    ui(new Ui::GuiPanel)
{
  reference = NULL;
  curMaterialFocus = DIFFUSEA;

  //mapMT = mm;
  _selectedIndex = -1;

  ui->setupUi(this);

//  ui->attributeData->tabBar()->setContentsMargins(-4,0,-4,0);
  QTabWidget *tw = ui->attributeData;
  int mar = 0;
  tw->setStyleSheet(QString("QTabBar::tab { width: %1px;padding-top: 1px; padding-bottom: 1px;margin-right: %2px;margin-left: %2px;} ")
                    .arg((tw->size().width()+(2*mar*tw->count())-1)/tw->count()).arg(-mar)
                    );

  ui->wiBodyAxisA->setVisible(false);
  ui->wiBodyAxisB->setVisible(false);
  ui->wiBodyRadius->setVisible(false);
  ui->wiBodyNFaces->setVisible(false);
  ui->wiBodyNVerts->setVisible(false);
  ui->wiBodySigns->setVisible(false);
  ui->wiBodyFlags->setVisible(false);

  ui->bodyData->setVisible(false);
  ui->meshData->setVisible(false);
  ui->textureData->setVisible(false);
  ui->animationData->setVisible(false);
  ui->materialData->setVisible(false);
  ui->skeletonData->setVisible(false);
  ui->shaderData->setVisible(false);
  ui->hitboxEdit->setVisible(false);

  ui->viewRuler->setVisible(false);
  ui->viewFloatingProbe->setVisible(false);
  ui->generalView->setVisible(false);
  ui->vertexData->setVisible(false);


  ui->lvTextAcc->setModel( new TextureAccessModel(this) );
  ui->lvBodyPart->setModel( new BodyPartModel(this) );
  ui->lvBones->setModel( new BodyPartModel(this) );


  //ui->frameNumber->setBackgroundRole(QPalette::Foreground);
  //ui->frameNumberAni->setBackgroundRole(QPalette::Foreground);

  alignY(ui->textureData  ,ui->meshData);
  alignY(ui->materialData  ,ui->meshData);
  alignY(ui->animationData,ui->meshData);
  alignY(ui->skeletonData,ui->meshData);
  alignY(ui->shaderData,  ui->meshData);
  alignY(ui->bodyData,  ui->meshData);

  alignYAfter(ui->hitboxEdit, ui->skeletonData);
  alignY(ui->vertexData,  ui->meshData);
  //alignYAfter(ui->vertexData , ui->meshData );

  QString flagMask(">Hhhhhhhh");
  ui->boxFlags->setInputMask(flagMask);
  ui->boxTextureFlags->setInputMask(flagMask);
  ui->leMatFlags->setInputMask(flagMask);
  ui->leShaderFlags->setInputMask(flagMask);
  ui->leShaderTaFlags->setInputMask(flagMask);
  ui->leBodyFlags->setInputMask(flagMask);
  ui->leShaderRequires->setInputMask(flagMask);

  skel = NULL;

  //ui->leMatR->setInputMask("0.0000");
  //ui->leMatG->setInputMask("0.0000");
  //ui->leMatB->setInputMask("0.0000");
  //ui->leMatCoeff->setInputMask("0000");
  //ui->timeOfFrame->setInputMask("0000");

  textureAccessDup = new QAction("Duplicate",this);
  textureAccessDel = new QAction("Remove",this);
  textureAccessAdd = new QAction("Add",this);

  bodyPartDup = new QAction("Duplicate",this);
  bodyPartDel = new QAction("Remove",this);
  bodyPartAdd = new QAction("Add",this);

  connect(ui->cbSkin, SIGNAL(currentIndexChanged(QString)), this, SLOT(updateVisibility()));
  connect(ui->cbRefani, SIGNAL(currentIndexChanged(QString)), this, SLOT(updateVisibility()));
  connect(ui->cbRuler, SIGNAL(stateChanged(int)), this, SLOT(updateVisibility()));
  connect(ui->cbRefani, SIGNAL(currentIndexChanged(QString)), this, SLOT(updateRefAnimation()));

  connect(ui->rulerSlid, SIGNAL(sliderMoved (int)), this, SLOT(setRulerLenght(int)));
  connect(ui->rulerSpin, SIGNAL(valueChanged(int)), this, SLOT(setRulerLenght(int)));

  connect(ui->lvTextAcc->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
          this, SLOT(updateShaderTextaccData()));
  connect(ui->lvBodyPart->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
          this, SLOT(updateBodyPartData()));
  connect(ui->lvBones->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
          this, SLOT(updateSelectedBone()));


  // skeleton direct editing
  connect(ui->editHbRange, SIGNAL(actionTriggered(int)),this,SLOT(onEditHitbox(int)));
  connect(ui->editHbLenTop, SIGNAL(actionTriggered(int)),this,SLOT(onEditHitbox(int)));
  connect(ui->editHbLenBot, SIGNAL(actionTriggered(int)),this,SLOT(onEditHitbox(int)));
  connect(ui->editHbPosX, SIGNAL(actionTriggered(int)),this,SLOT(onEditHitbox(int)));
  connect(ui->editHbPosY, SIGNAL(actionTriggered(int)),this,SLOT(onEditHitbox(int)));
  connect(ui->editHbPosZ, SIGNAL(actionTriggered(int)),this,SLOT(onEditHitbox(int)));
  connect(ui->editHbRotAlpha, SIGNAL(actionTriggered(int)),this,SLOT(onEditHitbox(int)));
  connect(ui->editHbRotBeta, SIGNAL(actionTriggered(int)),this,SLOT(onEditHitbox(int)));

  QString st = tr(" (keep [shift] pressed to nudge)");
  ui->editHbRange->setStatusTip(ui->editHbRange->statusTip()+st);
  ui->editHbLenTop->setStatusTip(ui->editHbLenTop->statusTip()+st);
  ui->editHbLenBot->setStatusTip(ui->editHbLenBot->statusTip()+st);
  ui->editHbPosX->setStatusTip(ui->editHbPosX->statusTip()+st);
  ui->editHbPosY->setStatusTip(ui->editHbPosY->statusTip()+st);
  ui->editHbPosZ->setStatusTip(ui->editHbPosZ->statusTip()+st);
  ui->editHbRotAlpha->setStatusTip(ui->editHbRotAlpha->statusTip()+st);
  ui->editHbRotBeta->setStatusTip(ui->editHbRotBeta->statusTip()+st);

  connect(ui->editHbActive, SIGNAL(stateChanged(int)),this,SLOT(setHbEditVisible(int)));

  connect(ui->floatingProbeX,SIGNAL(valueChanged(double)),this,SLOT(onEditFloatingProbePos()));
  connect(ui->floatingProbeY,SIGNAL(valueChanged(double)),this,SLOT(onEditFloatingProbePos()));
  connect(ui->floatingProbeZ,SIGNAL(valueChanged(double)),this,SLOT(onEditFloatingProbePos()));

  // add a shortcut to hide/show skin
  quickToggleHideSkinAct = new QAction(this);
  quickToggleHideSkinAct->setShortcut(QKeySequence("space"));
  //quickToggleHideSkinAct->setShortcutContext(Qt::ApplicationShortcut);
  connect(quickToggleHideSkinAct, SIGNAL(triggered()),this,SLOT(quickToggleHideSkin()));
  ui->cbSkin->addAction(quickToggleHideSkinAct);

  connect(ui->cbFloatingProbe,SIGNAL(toggled(bool)),parent,SLOT(activateFloatingProbe(bool)));
  connect(ui->cbRuler,SIGNAL(toggled(bool)),parent,SLOT(activateRuler(bool)));

}
void GMapHome::generate(int dW, int dH)
{
    // Generate home

    // Set

    // Width
    int hWidth = 10 + randi(10);

    // Height
    int hHeight = hWidth/2;

    // Create clear slots
    for(int mX = -hWidth; mX < alignX(dW) + hWidth*2; mX++)
    {
        // X
        int x = cameraX(alignX(dW)) + mX;

        for(int mY = -hHeight; mY < alignY(dH) + hHeight*2; mY++)
        {
            // Y
            int y = cameraY(alignY(dH)) + mY;

            // Create

            slot[x][y] = new GMapSlot();
        }
    }

    // Home coords
    const int homeX = -hWidth/2;
    const int homeY = -hHeight/2;

    // Generate

    // Home
    for(int mX = -hWidth/2; mX < hWidth/2; mX++)
    {
        for(int mY = -hHeight/2; mY < hHeight/2; mY++)
        {
            slot[mX][mY] = generateSlot();
        }
    }

    // Walls

    // Up / Down
    for(int mX = -hWidth/2; mX <= hWidth/2; mX++)
    {
        // Wall

        slot[mX][-hHeight/2] = &gMapSlotWall;
        slot[mX][hHeight/2] = &gMapSlotWall;
    }

    // Left / Right
    for(int mY = -hHeight/2; mY <= hHeight/2; mY++)
    {
        // Wall

        slot[-hWidth/2][mY] = &gMapSlotWall;
        slot[hWidth/2][mY] = &gMapSlotWall;
    }

    // Door

    // Select angle (left up / right down)

    // Left Up
    int angleX = homeX;
    int angleY = homeY;

    bool leftUp = true;

    // Right down
    if(luck(50.0f))
    {
        angleX *= -1;
        angleY *= -1;

        leftUp = false;
    }

    // Get indent
    int indentX = 1+randi(hWidth-2);
    int indentY = 1+randi(hHeight-2);

    if(!leftUp)
    {
        indentX *= -1;
        indentY *= -1;
    }

    // Set
    int doorX = angleX + indentX;
    int doorY = angleY + indentY;

    if(luck(50.0f))
    {
        slot[homeX][doorY] = &gMapSlotDoor;
        doorX = angleX;
    }
    else
    {
        slot[doorX][homeY] = &gMapSlotDoor;
        doorY = angleY;
    }

    // Set player coords

    // Get
    int playerX_ = getPlayerX();
    int playerY_ = getPlayerY();

    if(leftUp)
    {
        if(angleX == doorX)
        {
            playerX_ = doorX+1;
            playerY_ = doorY;
        }
        else if(angleY == doorY)
        {
            playerY_ = doorY+1;
            playerX_ = doorX;
        }
    }
    else
    {
        if(angleX == doorX)
        {
            playerX_ = doorX-1;
            playerY_ = doorY;
        }
        else if(angleY == doorY)
        {
            playerY_ = doorY-1;
            playerX_ = doorX;
        }
    }

    // Set
    setPlayerX(playerX_);
    setPlayerY(playerY_);

    // Set free generated slot of player coords
    GMapSlot *slot_;
    while(!slot[getPlayerX()][getPlayerY()]->is_free())
    {
        // Generate
        slot_ = generateSlot();

        // Set
        slot[playerX_][playerY_] = slot_;
    }

    // Generated
    setGenerated(true);
}