Exemple #1
0
    void refineEvents(refined_events_t* events, uint32_t activeArea)
    {
        assert(events);

        events->eventMask &= ~(EVENT_LEFT_CLICK|EVENT_ACTIVATED);

        if (mouseWasPressed(SDL_BUTTON_LEFT))
        {
            events->eventMask |= EVENT_ACTIVATED|EVENT_ACTIVE;
            events->activeArea = activeArea;
        }
        else if (mouseWasReleased(SDL_BUTTON_LEFT))
        {
            if (activeArea == events->activeArea)
                events->eventMask |= EVENT_LEFT_CLICK;
            else
                events->activeArea = INVALID_ID;

            events->eventMask &= ~(EVENT_ACTIVE);
        }
        else if (!mouseIsPressed(SDL_BUTTON_LEFT))
        {
            events->activeArea = activeArea;
        }
    }
Exemple #2
0
Window::Window() : QWidget(), isPainting(false), cursorPosX (0), cursorPosY (0), wdtPathSaveTo( QString() )
{
    mainLayout = new QVBoxLayout;

    mainTabWidget = new QTabWidget;

    tabGeneral = new QWidget;
    tabArray = new QWidget;
    tabWMO = new QWidget;

    // Tab General
    generalLayout = new QVBoxLayout;

    genInfosLayout = new QVBoxLayout;
    genFileButtonsLayout = new QHBoxLayout;
    new_b = new QPushButton("New...", this);
    QObject::connect(new_b, SIGNAL(clicked()), this, SLOT(newWDT()));
    load_b = new QPushButton("Load...", this);
    QObject::connect(load_b, SIGNAL(clicked()), this, SLOT(loadWDT()));
    save_b = new QPushButton("Save", this);
    QObject::connect(save_b, SIGNAL(clicked()), this, SLOT(saveWDT()));
    saveAs_b = new QPushButton("Save as...", this);
    QObject::connect(saveAs_b, SIGNAL(clicked()), this, SLOT(saveWDTas()));
    genFileButtonsLayout->addWidget(new_b);
    genFileButtonsLayout->addWidget(load_b);
    genFileButtonsLayout->addWidget(save_b);
    genFileButtonsLayout->addWidget(saveAs_b);
    wdtPath_label = new QLabel("No WDT loaded.");
    wdtPath_label->setAlignment(Qt::AlignCenter);
    flags_gb = new QGroupBox("WDT Flags");
    flags_gb->setAlignment(Qt::AlignCenter);
    flags_layout = new QVBoxLayout;
    flag1_cb = new QCheckBox("0x1 : use WMO based definition (gruuuuul)");
    QObject::connect(flag1_cb, SIGNAL(stateChanged(int)), this, SLOT(toggleWMOtab(int)));
    flag2_cb = new QCheckBox("0x2 : use vertex shading (MCCV)");
    flag4_cb = new QCheckBox("0x4 : use _env terrain shaders");
    flag8_cb = new QCheckBox("0x8 : use rendering thing");
    flag10_cb = new QCheckBox("0x10 : use vertex lighting (MCLV) [Cata]");
    flag20_cb = new QCheckBox("0x20 : use ceiling mode, flips ground upside down [Cata]");
    flag40_cb = new QCheckBox("0x40 : ? [Cata]");
    flag80_cb = new QCheckBox("0x80 : ? [MoP]");
    flags_layout->addWidget(flag1_cb);
    flags_layout->addWidget(flag2_cb);
    flags_layout->addWidget(flag4_cb);
    flags_layout->addWidget(flag8_cb);
    flags_layout->addWidget(flag10_cb);
    flags_layout->addWidget(flag20_cb);
    flags_layout->addWidget(flag40_cb);
    flags_layout->addWidget(flag80_cb);
    flags_gb->setLayout(flags_layout);
    genInfosLayout->addLayout(genFileButtonsLayout);
    genInfosLayout->addWidget(wdtPath_label);

    generalLayout->addLayout(genInfosLayout);
    generalLayout->addWidget(flags_gb);

    tabGeneral->setLayout(generalLayout);

    // Tab array
    arrayLayout = new QHBoxLayout;

    gps = new QLabel ( QString("X : 0, Y : 0") );
    gps->setAlignment(Qt::AlignCenter);

    arrayGScene = new AdtArrayScene;
    arrayGView = new AdtArray;
    arrayGView->setScene(arrayGScene);
    arrayGView->setFixedSize(515, 515);

    QObject::connect(arrayGView, SIGNAL(mousePos(int,int)), this, SLOT(refreshGPS(int,int)));
    QObject::connect(arrayGScene, SIGNAL(mouseIsPressed()), this, SLOT(applyBrush()));

    brush0 = new QRadioButton ("Delete tile");
    brush1 = new QRadioButton ("Add ADT");
    brush2 = new QRadioButton ("Add fake water");
    brush1->setChecked(true);
    arrayBrushHBL = new QVBoxLayout;
    arrayBrushHBL->addWidget(brush0);
    arrayBrushHBL->addWidget(brush1);
    arrayBrushHBL->addWidget(brush2);
    arrayBrushGB = new QGroupBox;
    arrayBrushGB->setLayout(arrayBrushHBL);

    arrayTools = new QVBoxLayout;
    autoscan_b = new QPushButton ("Scan dir");
    QObject::connect(autoscan_b, SIGNAL(clicked()), this, SLOT(autoscan()));
    deleteAll_b = new QPushButton ("Delete all");
    QObject::connect(deleteAll_b, SIGNAL(clicked()), this, SLOT(fillAll0()));
    fillAllGround_b = new QPushButton ("Fill with ground");
    QObject::connect(fillAllGround_b, SIGNAL(clicked()), this, SLOT(fillAll1()));
    fillAllWater_b = new QPushButton ("Fill with water");
    QObject::connect(fillAllWater_b, SIGNAL(clicked()), this, SLOT(fillAll2()));
    arrayTools->addWidget(gps);
    arrayTools->addWidget(arrayBrushGB);
    arrayTools->addWidget(autoscan_b);
    arrayTools->addWidget(deleteAll_b);
    arrayTools->addWidget(fillAllGround_b);
    arrayTools->addWidget(fillAllWater_b);

    arrayLayout->addLayout(arrayTools);
    arrayLayout->addWidget(arrayGView);
    tabArray->setLayout(arrayLayout);

    // Tab WMO
    wmoLayout = new QFormLayout;
    wmoPath_le = new QLineEdit;
    wmoID_sb = new QSpinBox;
    wmoUID_sb = new QSpinBox;
    posX_dsb = new QDoubleSpinBox; posX_dsb->setRange(-10000000,10000000); posX_dsb->setDecimals(5);
    posY_dsb = new QDoubleSpinBox; posY_dsb->setRange(-10000000,10000000); posY_dsb->setDecimals(5);
    posZ_dsb = new QDoubleSpinBox; posZ_dsb->setRange(-10000000,10000000); posZ_dsb->setDecimals(5);
    oriA_dsb = new QDoubleSpinBox; oriA_dsb->setRange(-10000000,10000000); oriA_dsb->setDecimals(5);
    oriB_dsb = new QDoubleSpinBox; oriB_dsb->setRange(-10000000,10000000); oriB_dsb->setDecimals(5);
    oriC_dsb = new QDoubleSpinBox; oriC_dsb->setRange(-10000000,10000000); oriC_dsb->setDecimals(5);
    upe1_dsb = new QDoubleSpinBox; upe1_dsb->setRange(-10000000,10000000); upe1_dsb->setDecimals(5);
    upe2_dsb = new QDoubleSpinBox; upe2_dsb->setRange(-10000000,10000000); upe2_dsb->setDecimals(5);
    upe3_dsb = new QDoubleSpinBox; upe3_dsb->setRange(-10000000,10000000); upe3_dsb->setDecimals(5);
    loe1_dsb = new QDoubleSpinBox; loe1_dsb->setRange(-10000000,10000000); loe1_dsb->setDecimals(5);
    loe2_dsb = new QDoubleSpinBox; loe2_dsb->setRange(-10000000,10000000); loe2_dsb->setDecimals(5);
    loe3_dsb = new QDoubleSpinBox; loe3_dsb->setRange(-10000000,10000000); loe3_dsb->setDecimals(5);
    wmoFlags_sb = new QSpinBox;
    wmoDDset_sb = new QSpinBox;
    wmoNameSet_sb = new QSpinBox;
    wmoLayout->addRow("WMO Path", wmoPath_le);
    wmoLayout->addRow("Index in MWID", wmoID_sb);
    wmoLayout->addRow("Unique ID", wmoUID_sb);
    wmoLayout->addRow("Position X", posX_dsb);
    wmoLayout->addRow("Position Y", posY_dsb);
    wmoLayout->addRow("Position Z", posZ_dsb);
    wmoLayout->addRow("Orientation A", oriA_dsb);
    wmoLayout->addRow("Orientation B", oriB_dsb);
    wmoLayout->addRow("Orientation C", oriC_dsb);
    wmoLayout->addRow("Upper extents 1", upe1_dsb);
    wmoLayout->addRow("Upper extents 2", upe2_dsb);
    wmoLayout->addRow("Upper extents 3", upe3_dsb);
    wmoLayout->addRow("Lower extents 1", loe1_dsb);
    wmoLayout->addRow("Lower extents 2", loe2_dsb);
    wmoLayout->addRow("Lower extents 3", loe3_dsb);
    wmoLayout->addRow("Flags (WMO)", wmoFlags_sb);
    wmoLayout->addRow("Doodad set index", wmoDDset_sb);
    wmoLayout->addRow("Name set", wmoNameSet_sb);

    tabWMO->setLayout(wmoLayout);

    // Bottom buttons
    genButtonsLayout = new QHBoxLayout;
    exit_b = new QPushButton("Close", this);
    QObject::connect(exit_b, SIGNAL(clicked()), qApp, SLOT(quit()));
    about_b = new QPushButton("About", this);
    QObject::connect(about_b, SIGNAL(clicked()), this, SLOT(aboutGruulMe()));
    genButtonsLayout->addWidget(about_b);
    genButtonsLayout->addWidget(exit_b);

    // and finally
    mainTabWidget->addTab(tabGeneral, "General");
    mainTabWidget->addTab(tabArray, "ADT Array");
    mainTabWidget->addTab(tabWMO, "WMO infos");

    mainLayout->addWidget(mainTabWidget);
    mainLayout->addLayout(genButtonsLayout);

    arrayGView->setStyleSheet("background-image: url(./adtarraybg.png);");

    setWindowTitle("GruulMe");
    setLayout(mainLayout);

    arrayGView->setMouseTracking(true);
}