Example #1
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent), ui(new Ui::MainWindow),factor(1),
	mapImage(NULL), mapItem(NULL),scene(new QGraphicsScene()),
	control(new Control(this)),disableSimOutput(false),
	postControl(new PostControl(this)),zBlocks(NULL),
	eventScene(new QGraphicsScene()), zmap(NULL), eventMapScene(new QGraphicsScene()),
    PPactiveAgents(NULL), zMapTimer(new QTimer(this)),initializeTimer(new QTimer(this)),
    runTimer(new QTimer(this)),disableLiveView(true),playingMap(false), running(false)
{
    ui->setupUi(this);
    ui->progressBar->setMaximum(100);
    ui->progressBar->setMinimum(0);
    ui->progressBar->setValue(0);
    ui->graphicsView->setScene(scene);
    scene->setBackgroundBrush(Qt::gray);
	ui->runButton->setDisabled(true);
//dr.	ui->adv_spinBox->hide();

    this->setWindowTitle("Rana 1.8");
    qRegisterMetaType<INFOLIST>("INFOLIST");

    QObject::connect(this,SIGNAL(map_updateSignal(INFOLIST)),
                     this,SLOT(on_updateMap(INFOLIST)));

    QObject::connect(this,SIGNAL(writeStringSignal(QString)),
                     this,SLOT(on_writeOutput(QString)));

	QObject::connect(this,SIGNAL(writeRegularSignal(QString)),
					 this,SLOT(on_writeRegularOutput(QString)));

	QObject::connect(this,SIGNAL(writeStatusSignal(unsigned long long,unsigned long long)),
					 this,SLOT(on_udateStatus(unsigned long long,unsigned long long)));

	QObject::connect(this,SIGNAL(addGraphicAgentSignal(int,int,int)),
						this,SLOT(on_addGraphicAgent(int,int,int)));

	QObject::connect(this, SIGNAL(removeGraphicAgentSignal(int)),
					 this, SLOT(on_removeGraphicAgent(int)));

    QObject::connect(this, SIGNAL(changeGraphicAgentColorSignal(int,int,int,int,int)),
                     this, SLOT(on_changeGraphicAgentColor(int,int,int,int,int)));

    QObject::connect(this,SIGNAL(enableRunButtonSignal(bool)),
                     this, SLOT(on_enableRunButton(bool)));

    resizeTimer.setSingleShot(true);
    QObject::connect(&resizeTimer, SIGNAL(timeout()), SLOT(on_resizeTimerTimeout()));

    initializeTimer->setSingleShot(true);
    QObject::connect(initializeTimer, SIGNAL(timeout()), SLOT(on_initializeTimerTimeout()));

    runTimer->setSingleShot(true);
    QObject::connect(runTimer, SIGNAL(timeout()), SLOT(on_runTimerTimeout()));


    //connect actions:
    QObject::connect(ui->action_Exit, SIGNAL(triggered()),this, SLOT(actionExit()));
    QObject::connect(ui->action_Info, SIGNAL(triggered()),this, SLOT(actionPrintInfo()));

    //versionString = QString("<b><font color=\"green\">RANA</b></font> version 1.7.14:0.8.2");

    //ui->statusBar->addWidget(new QLabel(versionString));
	ui->graphicsView->setDragMode(QGraphicsView::ScrollHandDrag);

	sim_controlTab = ui->simControlTab;
	sim_viewTab = ui->simLiveView;
    //sim_advancedTab = ui->simAdvancedTab;
	sim_general = ui->simGeneralWidget;

	ppConstruction();
    dialogConstruction();

	ui->graphicsView->viewport()->installEventFilter(this);

	Output::Inst()->RanaDir =
			QCoreApplication::applicationDirPath().toUtf8().constData();
}
Example #2
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    itemTableModal(this),
    ui(new Ui::MainWindow),
    mapUpdateTimer(this)
{
    ui->setupUi(this);
    ui->actionShowAnimation->setChecked(true);

    ui->mapView->pMainWindow=this;
    ui->mapView->pBlockStore=ui->blockStore;
    ui->blockStore->pMainWindow=this;

    ui->itemTable->setModel(&itemTableModal);
    ui->itemTable->setItemDelegate(new ItemTableDelegate(this));
    ui->itemTable->resizeRowsToContents();
    ui->itemTable->resizeColumnsToContents();

    ui->splitterMain->setStretchFactor(1,1);
    ui->splitterRight->setStretchFactor(0,1);

    connect(ui->mapView,SIGNAL(showStatusTip(const QString&)),
            ui->statusBar,SLOT(showMessage(const QString&)));
    connect(ui->blockStore,SIGNAL(showStatusTip(const QString&)),
            ui->statusBar,SLOT(showMessage(const QString&)));
    connect(ui->mapView,SIGNAL(selectItem(int)),
            this,SLOT(onSelectItem(int)));
    connect(ui->mapView,SIGNAL(itemDragging(bool)),
            this,SLOT(onItemDragging(bool)));

    QToolButton* scrollAreaCornerResize=new QToolButton(this);
    scrollAreaCornerResize->setDefaultAction(ui->actionResizeMap);
    ui->mapViewScrollArea->setCornerWidget(scrollAreaCornerResize);

    MapOperation::pMap=&map;
    MapOperation::pMainWindow=this;

    connect(&mapUpdateTimer, SIGNAL(timeout()), this, SLOT(on_updateMap()));
    connect(ui->actionUndo, SIGNAL(triggered()), this, SLOT(undo()));
    connect(ui->actionRedo, SIGNAL(triggered()), this, SLOT(redo()));


    loadRoomList();

    clearOperationStack();


    //Open a file
    QString fileName=commandLineFile;
    std::FILE* file=fopenQ(fileName,"rb");
    if(!file)return;
    mapdata.fromFile(file);
    std::fclose(file);
    currentFileName=fileName;
    ui->actionSave->setEnabled(true);
    ui->actionSaveAs->setEnabled(true);
    ui->actionMakeRom->setEnabled(true);




}