Example #1
0
LoginWindow::LoginWindow(IMAPClient* client, QWidget *parent, Qt::WindowFlags flags) :
    QDialog(parent, flags)
{
    m_client = client;
    createUI();
    setConnections();
}
// List network shares
void mxfindshares::listShares(QString option) {
    setCursor(QCursor(Qt::WaitCursor));
    QString cmd = QString("findshares %1").arg(option);
    ui->stackedWidget->setCurrentWidget(ui->outputPage);
    setConnections(timer, proc);
    proc->start(cmd);
}
Example #3
0
SettingsWindow::SettingsWindow(const std::weak_ptr<Settings> settings, QWidget *parent) :
    QWidget(parent),
    ui(new Ui::SettingsWindow)
{
    this->settings = settings.lock();
    ui->setupUi(this);
    QRegExpValidator *dateValidator = new QRegExpValidator(QRegExp("((d{0,4}|M{0,4}|y{0,4})[/\\s\\.\\,\\:\\\\])*"));
    ui->dateFormatEdit->setValidator(dateValidator);    
    ui->iconLabel->setPixmap(QIcon(":/images/qMarkIcon").pixmap(20,20));
    ui->iconLabel->setToolTip("Date format can be formedwith the following expressions:<br>"
                              "<table>"
                              "<tr><td><b>d</b></td><td>the day as number without a leading zero (1 to 31)</td></tr>"
                              "<tr><td><b>dd</b></td><td>the day as number with a leading zero (01 to 31)</td></tr>"
                              "<tr><td><b>ddd</b></td><td>the abbreviated day name ('Mon' to 'Sun')</td></tr>"
                              "<tr><td><b>dddd</b></td><td>the long day name ('Monday' to 'Sunday')</td></tr>"
                              "<tr><td><b>M</b></td><td>the month as number without a leading zero (1 to 12)</td></tr>"
                              "<tr><td><b>MM</b></td><td>the month as number with a leading zero (01 to 12)</td></tr>"
                              "<tr><td><b>MMM</b></td><td>the abbreviated month name ('Jan' to 'Dec')</td></tr>"
                              "<tr><td><b>MMMM &nbsp;</b></td><td>the long month name ('January' to 'December')</td></tr>"
                              "<tr><td><b>yy</b></td><td>the year as two digit number (00 to 99)</td></tr>"
                              "<tr><td><b>yyyy</b></td><td>the year as four digit number (1993)</td></tr>"
                              "</table>"
                              "<br><br>You can use white spaces and . , : / \\ symbols to separate"
                              "<br>the expressions.");
    setConnections();
    loadSettings();
    prevFormat = ui->dateFormatEdit->text();
}
Example #4
0
AlarmWidget::AlarmWidget(QFrame *parent)
     : QFrame(parent)

     , nCounter(0)
     , radioButtonsTime(0) // 0 - minutes, 1 - seconds
     , radioButtonsSound(0) //
     , m_ButtonFontSize(15)
     , m_LabelFontSize (20)
     , nSeconds(60)
     , m_FontName("arial")
     , isPause(false)
     , isRunning(false)

 {
     // by default it is minutes

    m_timer_ctd = new QTimer();

    initMainWindow();
    m_settings = new AppSettings(STR_COMPANY_NAME, STR_APP_NAME);
    restoreSettingsFromINI();

    nCounter = timerValue->value() * nSeconds; //  set to minutes
    updateRemainTxt();
    setConnections();
 }
Example #5
0
CWindowAlarm::CWindowAlarm(QWidget *parent, Qt::WindowFlags flags)
{
	//Groupe de la liste des alarmes
	formGroupBox = new QGroupBox(tr("Alarmes"));
	listWidget = new QListWidget();
	QFormLayout *formLayout = new QFormLayout(formGroupBox);
	formLayout->addWidget(listWidget);
	formGroupBox->setLayout(formLayout);
	
	//Groupe du bouton close
	btClose = new QPushButton("Close");
	btAcquitter = new QPushButton("Acquitter");
	verticalGroupBox = new QGroupBox(tr("Actions"));
	QHBoxLayout *HBoxLayout = new QHBoxLayout(verticalGroupBox);
	HBoxLayout->addWidget(btClose);
	HBoxLayout->addWidget(btAcquitter);

	verticalGroupBox->setLayout(HBoxLayout);


	mainLayout = new QGridLayout(this);
	//this->setLayout(mainLayout);

	mainLayout->addWidget(formGroupBox,0,0);
	mainLayout->addWidget(verticalGroupBox,1,0);
	mainLayout->setRowStretch ( 0, 90 );
	mainLayout->setRowStretch ( 1, 10 );
	//mainLayout->setColumnStretch( 1, 10 );

	setConnections();

}
Example #6
0
// ---
QGAMES::Board* QGAMES::BasicBoardAddsOn::createBoard 
	(const QGAMES::BoardBuilder::BoardDefinition& def, const std::string& bP)
{
	TiXmlDocument doc (def._fileDefinition.c_str ());
	int e = doc.LoadFile ();
	assert (e); // Is it a valid doc?

	TiXmlElement* rootElement = doc.RootElement ();
	assert (rootElement); // One element minimum...

	// Read all parts of the file defining the 
	QGAMES::BoardResources resources; QGAMES::BoardSquares squares;
	std::list <QGAMES::BasicBoardAddsOn::SquareConnectionDefinition> connections;
	for (TiXmlElement* groupElement = rootElement -> FirstChildElement ();
		groupElement != NULL; groupElement = groupElement -> NextSiblingElement ())
	{
		if (strcmp (groupElement -> Value (), __QGAMES_BOARDRESOURCESTAG__) == 0)
			resources = createBoardResources (readResources (groupElement));
		if (strcmp (groupElement -> Value (), __QGAMES_BOARDSQUARESTAG__) == 0)
			squares = createBoardSquares (readSquares (groupElement));
		if (strcmp (groupElement -> Value (), __QGAMES_BOARDSQUARECONNECTIONSTAG__) == 0)
			connections = readConnections (groupElement);
	}

	// Once everything has been read, the instance is created...
	// and then the squares connected.
	QGAMES::Board* result = createBoardInstance (def._id, squares, resources); 
	setConnections (squares, connections);
	return (result); // The result is returned!
}
Example #7
0
MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent), ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    setMainFrame();
    setToolBarActions();
    setConnections();
}
Example #8
0
void EditServer::addServer(){
    _server = new IcalServer(QString("A unique name"), QString("http://example.org/"));
    uiCalendarInput->setText("Calendar name");
    setConnections();
    updateUI();
    uiServerNameLine->setReadOnly(false);
    _cancelEdit=false;
}
Example #9
0
void EditServer::editServer(IcalServer *server){
    // We need to copy server to be sure to not have segfault when give it back
    _server = new IcalServer(*server);
    setConnections();
    updateUI();
    uiServerNameLine->setReadOnly(true); // Prevent modification for server name because it's not really well supported right now
    _cancelEdit=false;
}
Example #10
0
CLogInPage::CLogInPage(QWidget* pParent) 
			: QWidget( pParent )
{
	QHBoxLayout* pLayout = new QHBoxLayout( this );
	setLayout( pLayout );

	makePageLeftSide( pLayout );

	setConnections();
}
Example #11
0
mainView::mainView(QWidget *parent)
     : QWidget(parent),
     timer(new QTimer(this))
 {
    setWindowTitle(tr("Life on Qt4."));
    //setFixedSize(550, 420);
    timer->setInterval(250);
    initWidgets();
    setWidgetLayout();
    setConnections();
 }
Example #12
0
MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
{
    if (objectName().isEmpty())
        setObjectName(QString::fromUtf8("MainWindow"));

    // set the current version
    _majorVersion = 0;
    _minorVersion = 1;

    // set the user interface
    _mdiArea = new QMdiArea(this);
    _mdiArea->setViewMode(QMdiArea::TabbedView);
    _mdiArea->setTabShape(QTabWidget::Triangular);
    setCentralWidget(_mdiArea);
    connect(_mdiArea, SIGNAL(subWindowActivated(QMdiSubWindow*)),
            this, SLOT(updateMenus()));
    connect(_mdiArea, SIGNAL(subWindowActivated(QMdiSubWindow*)),
            this, SLOT(updateToolBars()));

    _paramDiag = new ParametersDialog(this);

    _qmPath = qApp->applicationDirPath() + "/translations";
    _appTranslator.load("monofin_" + QLocale::system().name(),
                        _qmPath);
    _qtTranslator.load("qt_" + QLocale::system().name(),
                       _qmPath);
    _currentLanguage = _appTranslator.translate("MainWindow", "English");
    qApp->installTranslator(&_qtTranslator);
    qApp->installTranslator(&_appTranslator);

    qDebug("create actions");
    createActions();
    qDebug("create menus");
    createMenus();
    qDebug("create docks");
    createDocks();
    qDebug("create statusbar");
    createStatusBar();
    qDebug("create toolbars");
    createToolBars();
    qDebug("set connections");
    setConnections();

    qDebug("read settings");
    readSettings();

    retranslateUi();

    setWindowTitle(tr("Monofin"));
    setWindowIcon(QPixmap(":/images/icon.png"));
}
Example #13
0
//------------------------------------------------------------------------------
// Ctor
//------------------------------------------------------------------------------
CaptureForm::CaptureForm(const QtSerializerWrapper &writer, QWidget *parent)
    : QDialog(parent),
      m_item(new QtItemWrapper),
      m_titleEdit(0),
      m_tagsEdit(0),
      m_tagsBox(0),
      m_contentEdit(0),
      m_okButton(0),
      m_cancelButton(0) {

    m_item->id = 0;
    initGui(writer);
    setConnections(writer);
}
Example #14
0
Dialog::Dialog(QWidget *parent): QDialog(parent),
	myTicks1(0), myTicks2(0),
	myTimer1(0), myTimer2(0) {

	setWindowTitle("Timers tricking");
	myMutex1 = new QMutex();
	myMutex2 = new QMutex();

	createWidgets();
	addWidgets();
	setConnections();

	myTimer_id = startTimer(10);
}
Example #15
0
imageCompareBase::imageCompareBase(windowManager* windowMgr)
  : imageSaverWindow(tr("Colors"), windowMgr),
    leftImageSavedSize_(QSize()), rightImageSavedSize_(QSize()) {

  constructScrolling();

  splitter_ = new QSplitter;
  splitter_->addWidget(leftScroll_);
  splitter_->addWidget(rightScroll_);
  setCentralWidget(splitter_);

  leftFocusAction_ = new QAction(QIcon(":leftImage.png"),
                                tr("Focus left side"), this);
  rightFocusAction_ = new QAction(QIcon(":rightImage.png"),
                                tr("Focus right side"), this);

  leftImageListBox_ = new comboBox(this);
  leftImageListBox_->setToolTip(tr("Select the left side image"));
  rightImageListBox_ = new comboBox(this);
  rightImageListBox_->setToolTip(tr("Select the right side image"));

  addZoomActionsToImageMenu();
  //: Whether zooming zooms both images at once, or just one
  dualZoomingAction_ = new QAction(tr("Dual zooming"), this);
  dualZoomingAction_->setCheckable(true);
  dualZoomingAction_->setChecked(true);

  imageMenu()->addAction(dualZoomingAction_);
  imageMenu()->addAction(dualScrollingAction_);

  switchAction_ = imageMenu()->addAction(tr("Switch sides"));
  centerSplitterAction_ = imageMenu()->addAction(tr("Center splitter"));

  leftImageMenu_ = new QMenu(tr("&Left Image"), this);
  menuBar()->insertMenu(helpMenu()->menuAction(), leftImageMenu_);
  leftShowHide_ = leftImageMenu_->addAction(tr("Show left image"));
  leftShowHide_->setCheckable(true);
  leftDelete_ = leftImageMenu_->addAction(tr("Delete left image"));
  leftImageMenu_->addSeparator();

  rightImageMenu_ = new QMenu(tr("&Right Image"), this);
  menuBar()->insertMenu(helpMenu()->menuAction(), rightImageMenu_);
  rightShowHide_ = rightImageMenu_->addAction(tr("Show right image"));
  rightShowHide_->setCheckable(true);
  rightDelete_ = rightImageMenu_->addAction(tr("Delete right image"));
  rightImageMenu_->addSeparator();

  setConnections();
}
MainWindow::MainWindow() : QMainWindow(), m_eRefreshingState(E_RS_READY_TO_REFRESH)
{
    setupUI();
    setupActions();
    CDataThread::getInstance()->start();
    setConnections();
    CDataThread::getInstance()->onUpdateRecentFileActions();
    m_ptrProxySettings = new ProxySettingsGUI;
    m_ptrProxySettings->hide();

    m_ptCompConfView->setModel(CDataThread::getInstance()->getConfigurationModel());
    m_ptCompConfView->setMinimumWidth(ciSize.width());
    m_ptCompConfView->setMinimumHeight(ciSize.height());
    statusBar()->showMessage("Ready");
}
Example #17
0
AboutDlg::AboutDlg(QWidget *parent) :
    QDialog(parent)
{
    // Initialize the About dialog parameters

    initAbout();

    // Initialize the layout

    initLayout();

    // Connect signals and slots

    setConnections();

    // Translate the UI strings as needed

    retranslateUi();
}
Example #18
0
void Monofin::initialize()
{
    qDebug("Monofin::initialize()");
    if (!_layerView.isNull()) {
        _layout->removeWidget(_layerView.data());
        _layerView->close();
    }
    _layerView = new LayerView(_projectFile);
    if (!_scene.isNull())
        _scene->deleteLater();
    _scene = new PaintingScene(800, 600, _projectFile);

    _layout->addWidget(new PaintingView(_scene.data(), this));
    _layout->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Ignored, QSizePolicy::MinimumExpanding));
    _layout->addWidget(_layerView.data());
    retranslateUi();
    setLayout(_layout);
    setConnections();
    clean();
}
Example #19
0
TrackThread::TrackThread(const QSharedPointer<Session>& session, const QSharedPointer<Channel>& channel, const QSharedPointer<DataMark>& tag)
{
  m_query = new WriteTagQuery(session,channel,tag);
  setConnections();
}
Example #20
0
LoadTagsThread::LoadTagsThread(QSharedPointer<Session> session)
{
  m_query = new LoadTagsQuery(session,DEFAULT_LATITUDE,DEFAULT_LONGITUDE,(double)DEFAULT_RADIUS);
  setConnections();
}
Example #21
0
QGroupBox* Shape:: getContourFilterUI(void){
contourFiltersGroupBox = new QGroupBox(tr("ContourFilter_Menu"));
QVBoxLayout *cFVLayout= new QVBoxLayout;
QHBoxLayout *cFHLayout1= new QHBoxLayout;
QHBoxLayout *cFHLayout2= new QHBoxLayout;
QHBoxLayout *cFHLayout3= new QHBoxLayout;
QHBoxLayout *cFHLayout4= new QHBoxLayout;
QHBoxLayout *cFHLayout5= new QHBoxLayout;

contoursSlider=new QSlider(Qt::Horizontal);
contoursSpinBox=new QSpinBox();
startRangeSlider=new QDoubleSpinBox();
startRangeSlider->setRange(0,5);
startRangeSlider->setSingleStep(0.1);
stopRangeSlider=new QDoubleSpinBox();
stopRangeSlider->setRange(0,5);
stopRangeSlider->setSingleStep(0.1);

xSampleDimmensionSlider=new QDoubleSpinBox();
ySampleDimmensionSlider=new QDoubleSpinBox();
zSampleDimmensionSlider=new QDoubleSpinBox();

rColourSlider=new QSlider(Qt::Horizontal);
gColourSlider=new QSlider(Qt::Horizontal);
bColourSlider=new QSlider(Qt::Horizontal);

QLabel* cFTitleNumberOfCountours= new QLabel(tr("nr of countours [0..10]:"));
QLabel* cFTitleMinValue= new QLabel(tr("min Value:"));
QLabel* cFTitleMaxValue= new QLabel(tr("max Value"));

QLabel* cFTitleSampleDimmension= new QLabel(tr("dimmensions:"));
QLabel* cFxSampleDimmension= new QLabel(tr("x:"));
QLabel* cFySampleDimmension= new QLabel(tr("y:"));
QLabel* cFzSampleDimmension= new QLabel(tr("z:"));

QLabel* cFTitleColours= new QLabel(tr("colours:"));
QLabel* cFRColours= new QLabel(tr("R:"));
QLabel* cFGColours= new QLabel(tr("G:"));
QLabel* cFBColours= new QLabel(tr("B:"));

// for (int i = 0; i < 10; ++i) {
//     coeffsSlider[i] = new QSlider(Qt::Horizontal);
 cFHLayout1->addWidget(cFTitleNumberOfCountours)   ;
 contoursSlider->setRange(0,10); //cuz of my laptop was being dead with bigger values
 contoursSpinBox->setRange(0,10);
 cFHLayout1->addWidget(contoursSlider);
 cFHLayout1->addWidget(contoursSpinBox);
 cFVLayout->addLayout(cFHLayout1);
 cFHLayout2->addWidget(cFTitleMinValue)   ;
 cFHLayout2->addWidget(startRangeSlider);
 cFHLayout2->addWidget(cFTitleMaxValue);
 cFHLayout2->addWidget(stopRangeSlider);
 cFVLayout->addLayout(cFHLayout2);

 cFHLayout4->addWidget(cFTitleSampleDimmension);
 cFHLayout4->addSpacing(50);
 cFHLayout4->addWidget(cFxSampleDimmension);
 cFHLayout4->addWidget(xSampleDimmensionSlider);
 cFHLayout4->addWidget(cFySampleDimmension);
 cFHLayout4->addWidget(ySampleDimmensionSlider);
 cFHLayout4->addWidget(cFzSampleDimmension);
 cFHLayout4->addWidget(zSampleDimmensionSlider);
 cFHLayout4->addSpacing(50);
 cFVLayout->addLayout(cFHLayout4);


 /*
 cFHLayout5->addWidget(cFTitleColours);
 cFHLayout5->addWidget(cFRColours);
 cFHLayout5->addWidget(rColourSlider);
 cFHLayout5->addWidget(cFGColours);
 cFHLayout5->addWidget(gColourSlider);
 cFHLayout5->addWidget(cFBColours);
 cFHLayout5->addWidget(bColourSlider);
 cFVLayout->addLayout(cFHLayout5);
 */

 contourFiltersGroupBox->setLayout( cFVLayout);
 Shape::loadDefaultSettings();
 setConnections();
 return contourFiltersGroupBox;
}
Example #22
0
MainWindow::MainWindow(QWidget *parent, Qt::WindowFlags flags)
	: QMainWindowEx( parent, flags )
{
	QCoreApplication::setOrganizationName( "Horns and Hooves" );
	QCoreApplication::setOrganizationDomain( "hornsnhooves.com" );
	QCoreApplication::setApplicationName( "composer" );

	ui.setupUi(this);

	ui.actionSaveProject->setEnabled(false);

	connect( ui.actionSaveProject, SIGNAL( triggered() ), this, SLOT( actionProjectSave() ) );
	connect( ui.actionSaveProjectAs, SIGNAL( triggered() ), this, SLOT( actionProjectSaveAs() ) );
	connect( ui.actionOpenProject, SIGNAL( triggered() ), this, SLOT( actionProjectOpen() ) );
	connect( ui.actionNewProject, SIGNAL( triggered() ), this, SLOT( actionProjectNew() ) );
	connect( ui.actionRemoveRulers, SIGNAL( triggered() ), this, SLOT( actionRemoveRulers() ) );

	undoStack = new QUndoStack(this);
	createUndoView();
	undoAction = undoStack->createUndoAction(this, tr("&Undo"));
	undoAction->setShortcuts(QKeySequence::Undo);
	redoAction = undoStack->createRedoAction(this, tr("&Redo"));
	redoAction->setShortcuts(QKeySequence::Redo);
	uiSetupUndoRedoAction();

	createAboutDialog();

	spriteModel = new SpriteModel( &project, this );
	createSpriteView(spriteModel);

	animationModel = new AnimationModel( &project, spriteView, this );
	createAnimationView(animationModel);

	compositionModel = new CompositionModel( &project, spriteView, animationView, this );
	createCompositionView(compositionModel);

	commandEnvFabric = new CommandEnvFabric(&project, spriteView, animationView, compositionView);

	createScene();

	optionsDialog = new OptionsDialog( this );
	connect( ui.actionOptions, SIGNAL( triggered() ), this, SLOT( actionOptions() ) );

	spriteMoveDialog = new SpriteMoveDialog( this );

	connect( spriteMoveDialog, SIGNAL( accepted() ), this, SLOT( moveSpriteDialogAccepted() ) );

	createRecentActions();
	readRecentFileList();

	loadSettings();

	graphicsScene->triggerStickToBorder( ui.actionSnapToBorder->isChecked() );
	graphicsScene->triggerStickToPictures( ui.actionSnapToPictures->isChecked() );
	graphicsScene->triggerStickToGuides( ui.actionSnapToGuides->isChecked() );

	connect( ui.actionSnapToBorder, SIGNAL( triggered( bool ) ), graphicsScene, SLOT( triggerStickToBorder( bool ) ) );
	connect( ui.actionSnapToPictures, SIGNAL( triggered( bool ) ), graphicsScene, SLOT( triggerStickToPictures( bool ) ) );
	connect( ui.actionSnapToGuides, SIGNAL( triggered( bool ) ), graphicsScene, SLOT( triggerStickToGuides( bool ) ) );

	QComboBox* comboBoxZoom = new QComboBox;
	ui.mainToolBar->addSeparator();
	ui.mainToolBar->addWidget( new QLabel( "    " ) );
	ui.mainToolBar->addWidget( comboBoxZoom );
	ui.mainToolBar->addWidget( new QLabel( "   " ) );
	graphicsView->setComboBoxZoom( comboBoxZoom );

	connect( &project, SIGNAL( compositionModelReset() ), compositionModel, SLOT( resetModel() ) );
	connect( &project, SIGNAL( sceneModelReset() ), graphicsScene, SLOT( resetModel() ) );
	connect( &project, SIGNAL( animBeginRemoveRows( int, int ) ), animationModel, SLOT( animBeginRemoveRows( int, int ) ) );
	connect( &project, SIGNAL( animEndRemoveRows() ), animationModel, SLOT( animEndRemoveRows() ) );
	connect( &project, SIGNAL( animBeginInsertRows( int, int ) ), animationModel, SLOT( animBeginInsertRows( int, int ) ) );
	connect( &project, SIGNAL( animEndInsertRows() ), animationModel, SLOT( animEndInsertRows() ) );
	connect( &project, SIGNAL( compositionBeginRemoveRows( int, int ) ), compositionModel, SLOT( compositionBeginRemoveRows( int, int )  ) );
	connect( &project, SIGNAL( compositionEndRemoveRows() ), compositionModel, SLOT( compositionEndRemoveRows() ) );
	connect( &project, SIGNAL( compositionBeginInsertRows( int, int ) ), compositionModel, SLOT( compositionBeginInsertRows( int, int )  ) );
	connect( &project, SIGNAL( compositionEndInsertRows() ), compositionModel, SLOT( compositionEndInsertRows() ) );
	connect( &project, SIGNAL( setLineEditFrameTag( const QString & ) ), lineEditFrameTag, SLOT( setText( const QString & ) ) );
	connect(spriteModel, &SpriteModel::renameNode, this, &MainWindow::renameSpriteNode);
	connect(spriteModel, &SpriteModel::dragDropNode, this, &MainWindow::dragDropSpriteNode);
	connect(compositionModel, &CompositionModel::dropPictures, this, &MainWindow::dropPictures);
	connect(graphicsScene, &GraphicsScene::dropPictures, this, &MainWindow::dropPictures);

	setConnections();

	spriteView->setCurrentIndex(spriteModel->getRootIndex());
	onResetCurrentSprite();

	if ( isLoadLastProjectAtStartup() )
		loadLastProject();
}
Example #23
0
void CJsonRmgTemplateLoader::loadTemplates()
{
	const JsonNode rootNode(ResourceID("config/rmg.json"));
	for(const auto & templatePair : rootNode.Struct())
	{
		auto tpl = new CRmgTemplate();
		try
		{
			tpl->setName(templatePair.first);
			const auto & templateNode = templatePair.second;

			// Parse main template data
			tpl->setMinSize(parseMapTemplateSize(templateNode["minSize"].String()));
			tpl->setMaxSize(parseMapTemplateSize(templateNode["maxSize"].String()));
			tpl->setPlayers(parsePlayers(templateNode["players"].String()));
			tpl->setCpuPlayers(parsePlayers(templateNode["cpu"].String()));

			// Parse zones
			std::map<TRmgTemplateZoneId, CRmgTemplateZone *> zones;
			for (const auto & zonePair : templateNode["zones"].Struct())
			{
				auto zone = new CRmgTemplateZone();
				auto zoneId = boost::lexical_cast<TRmgTemplateZoneId>(zonePair.first);
				zone->setId(zoneId);

				const auto & zoneNode = zonePair.second;
				zone->setType(parseZoneType(zoneNode["type"].String()));
				zone->setSize(zoneNode["size"].Float());
				if (!zoneNode["owner"].isNull()) zone->setOwner(zoneNode["owner"].Float());

				zone->setPlayerTowns(parseTemplateZoneTowns(zoneNode["playerTowns"]));
				zone->setNeutralTowns(parseTemplateZoneTowns(zoneNode["neutralTowns"]));
				if (!zoneNode["matchTerrainToTown"].isNull()) //default : true
					zone->setMatchTerrainToTown(zoneNode["matchTerrainToTown"].Bool());
				zone->setTerrainTypes(parseTerrainTypes(zoneNode["terrainTypes"].Vector(), zone->getDefaultTerrainTypes()));

				if (!zoneNode["townsAreSameType"].isNull()) //default : false
					zone->setTownsAreSameType((zoneNode["townsAreSameType"].Bool()));

				for (int i = 0; i < 2; ++i)
				{
					std::set<TFaction> allowedTownTypes;
					if (i)
					{
						if (zoneNode["allowedTowns"].isNull())
							allowedTownTypes = zone->getDefaultTownTypes();
					}
					else
					{
						if (zoneNode["allowedMonsters"].isNull())
							allowedTownTypes = VLC->townh->getAllowedFactions(false);
					}

					if (allowedTownTypes.empty())
					{
						for (const JsonNode & allowedTown : zoneNode[i ? "allowedTowns" : "allowedMonsters"].Vector())
						{
							//complain if the town type is not present in our game
							if (auto id = VLC->modh->identifiers.getIdentifier("faction", allowedTown, false))
								allowedTownTypes.insert(id.get());
						}
					}

					if (!zoneNode[i ? "bannedTowns" : "bannedMonsters"].isNull())
					{
						for (const JsonNode & bannedTown : zoneNode[i ? "bannedTowns" : "bannedMonsters"].Vector())
						{
							//erase unindentified towns silently
							if (auto id = VLC->modh->identifiers.getIdentifier("faction", bannedTown, true))
								vstd::erase_if_present(allowedTownTypes, id.get());
						}
					}
					if (i)
						zone->setTownTypes(allowedTownTypes);
					else
						zone->setMonsterTypes(allowedTownTypes);
				}

				const std::string monsterStrength = zoneNode["monsters"].String();
				if (monsterStrength == "weak")
					zone->setMonsterStrength(EMonsterStrength::ZONE_WEAK);
				else if (monsterStrength == "normal")
					zone->setMonsterStrength(EMonsterStrength::ZONE_NORMAL);
				else if (monsterStrength == "strong")
					zone->setMonsterStrength(EMonsterStrength::ZONE_STRONG);
				else
					throw (rmgException("incorrect monster power"));

				if (!zoneNode["mines"].isNull())
				{
					auto mines = zoneNode["mines"].Struct();
					//FIXME: maybe there is a smarter way to parse it already?
					zone->setMinesAmount(Res::WOOD, mines["wood"].Float());
					zone->setMinesAmount(Res::ORE, mines["ore"].Float());
					zone->setMinesAmount(Res::GEMS, mines["gems"].Float());
					zone->setMinesAmount(Res::CRYSTAL, mines["crystal"].Float());
					zone->setMinesAmount(Res::SULFUR, mines["sulfur"].Float());
					zone->setMinesAmount(Res::MERCURY, mines["mercury"].Float());
					zone->setMinesAmount(Res::GOLD, mines["gold"].Float());
					//TODO: Mithril
				}

				//treasures
				if (!zoneNode["treasure"].isNull())
				{
					//TODO: parse vector of different treasure settings
					if (zoneNode["treasure"].getType() == JsonNode::DATA_STRUCT)
					{
						auto treasureInfo = zoneNode["treasure"].Struct();
						{
							CTreasureInfo ti;
							ti.min = treasureInfo["min"].Float();
							ti.max = treasureInfo["max"].Float();
							ti.density = treasureInfo["density"].Float(); //TODO: use me
							zone->addTreasureInfo(ti);
						}
					}
					else if (zoneNode["treasure"].getType() == JsonNode::DATA_VECTOR)
					{
						for (auto treasureInfo : zoneNode["treasure"].Vector())
						{
							CTreasureInfo ti;
							ti.min = treasureInfo["min"].Float();
							ti.max = treasureInfo["max"].Float();
							ti.density = treasureInfo["density"].Float();
							zone->addTreasureInfo(ti);
						}
					}
				}

				zones[zone->getId()] = zone;
			}

			//copy settings from already parsed zones
			for (const auto & zonePair : templateNode["zones"].Struct())
			{
				auto zoneId = boost::lexical_cast<TRmgTemplateZoneId>(zonePair.first);
				auto zone = zones[zoneId];

				const auto & zoneNode = zonePair.second;

				if (!zoneNode["terrainTypeLikeZone"].isNull())
				{
					int id = zoneNode["terrainTypeLikeZone"].Float();
					zone->setTerrainTypes(zones[id]->getTerrainTypes());
					zone->setMatchTerrainToTown(zones[id]->getMatchTerrainToTown());
				}

				if (!zoneNode["townTypeLikeZone"].isNull())
					zone->setTownTypes (zones[zoneNode["townTypeLikeZone"].Float()]->getTownTypes());

				if (!zoneNode["treasureLikeZone"].isNull())
				{
					for (auto treasureInfo : zones[zoneNode["treasureLikeZone"].Float()]->getTreasureInfo())
					{
						zone->addTreasureInfo(treasureInfo);
					}
				}

				if (!zoneNode["minesLikeZone"].isNull())
				{
					for (auto mineInfo : zones[zoneNode["minesLikeZone"].Float()]->getMinesInfo())
					{
						zone->setMinesAmount (mineInfo.first, mineInfo.second);
					}
					
				}
			}

			tpl->setZones(zones);

			// Parse connections
			std::list<CRmgTemplateZoneConnection> connections;
			for(const auto & connPair : templateNode["connections"].Vector())
			{
				CRmgTemplateZoneConnection conn;
				conn.setZoneA(zones.find(boost::lexical_cast<TRmgTemplateZoneId>(connPair["a"].String()))->second);
				conn.setZoneB(zones.find(boost::lexical_cast<TRmgTemplateZoneId>(connPair["b"].String()))->second);
				conn.setGuardStrength(connPair["guard"].Float());
				connections.push_back(conn);
			}
			tpl->setConnections(connections);
			{
				auto zones = tpl->getZones();
				for (auto con : tpl->getConnections())
				{
					auto idA = con.getZoneA()->getId();
					auto idB = con.getZoneB()->getId();
					zones[idA]->addConnection(idB);
					zones[idB]->addConnection(idA);
				}
			}
			tpl->validate();
			templates[tpl->getName()] = tpl;
		}
		catch(const std::exception & e)
		{
			logGlobal->errorStream() << boost::format("Template %s has errors. Message: %s.") % tpl->getName() % std::string(e.what());
		}
	}
}
Example #24
0
CSettingsDlgPrivate::CSettingsDlgPrivate(CSettingsDlg * ptrPublic):m_ptrPublic(ptrPublic)
{
	setupUI();
	setConnections();
}
Example #25
0
// Contructor
Application::Application()
{
	GUI();
	setConnections();
	showisotog();
}