File indexing completed on 2024-05-05 05:40:59
0001 /*************************************************************************** 0002 * Copyright (C) 2010 by Renaud Guezennec * 0003 * * 0004 * * 0005 * rolisteam is free software; you can redistribute it and/or modify * 0006 * it under the terms of the GNU General Public License as published by * 0007 * the Free Software Foundation; either version 2 of the License, or * 0008 * (at your option) any later version. * 0009 * * 0010 * This program is distributed in the hope that it will be useful, * 0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0013 * GNU General Public License for more details. * 0014 * * 0015 * You should have received a copy of the GNU General Public License * 0016 * along with this program; if not, write to the * 0017 * Free Software Foundation, Inc., * 0018 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 0019 ***************************************************************************/ 0020 #include <QButtonGroup> 0021 #include <QColorDialog> 0022 0023 #include "ui_vmapwizzarddialog.h" 0024 #include "vmapwizzarddialog.h" 0025 0026 #include "preferences/preferencesmanager.h" 0027 0028 /// @todo make those value to be store in preferences. 0029 #define DEFAULT_VMAP_WIDTH 800 0030 #define DEFAULT_VMAP_HEIGHT 600 0031 0032 MapWizzardDialog::MapWizzardDialog(QWidget* parent) : QDialog(parent), ui(new Ui::MapWizzardDialog) 0033 { 0034 ui->setupUi(this); 0035 m_model= new PatternModel(); 0036 0037 ui->m_gridPattern->setModel(m_model); 0038 0039 m_options= PreferencesManager::getInstance(); 0040 0041 QColor bgColor= m_options->value(QString("MapWizzard/backgroundcolor"), QColor(255, 255, 255)).value<QColor>(); 0042 0043 // ui->m_colorButton->setStyleSheet(QString("background-color: 0044 // rgb(%1,%2,%3)").arg(m_bgColor.red()).arg(m_bgColor.green()).arg(m_bgColor.blue())); 0045 ui->m_colorButton->setColor(bgColor); 0046 // connect(ui->m_colorButton,SIGNAL(clicked()),this,SLOT(clickOnColorButton())); 0047 ui->m_gridColorBtn->setColor(QColor(0, 0, 0)); 0048 0049 m_permissionData << tr("No Right") << tr("His character") << tr("All Permissions"); 0050 ui->m_permissionComboBox->addItems(m_permissionData); 0051 ui->m_permissionComboBox->setCurrentIndex( 0052 PreferencesManager::getInstance()->value("defaultPermissionMap", 0).toInt()); 0053 0054 m_visibilityData << tr("Hidden") << tr("Fog of War") << tr("All visible"); 0055 ui->m_visibilityComboBox->addItems(m_visibilityData); 0056 ui->m_visibilityComboBox->setCurrentIndex( 0057 PreferencesManager::getInstance()->value("defaultMapVisibility", 0).toInt()); 0058 0059 // selectedShapeChanged(); 0060 } 0061 0062 MapWizzardDialog::~MapWizzardDialog() 0063 { 0064 delete ui; 0065 } 0066 0067 QString MapWizzardDialog::name() const 0068 { 0069 return ui->m_titleLineedit->text(); 0070 } 0071 0072 QColor MapWizzardDialog::backgroundColor() const 0073 { 0074 return ui->m_colorButton->color(); 0075 } 0076 0077 int MapWizzardDialog::gridSize() const 0078 { 0079 return ui->m_sizeGrid->value(); 0080 } 0081 0082 QColor MapWizzardDialog::gridColor() const 0083 { 0084 return Qt::black; 0085 } 0086 0087 Core::ScaleUnit MapWizzardDialog::unit() const 0088 { 0089 return static_cast<Core::ScaleUnit>(ui->m_unitPattern->currentIndex()); 0090 } 0091 qreal MapWizzardDialog::scale() const 0092 { 0093 return ui->m_scaleOfGrid->value(); 0094 } 0095 0096 Core::GridPattern MapWizzardDialog::pattern() const 0097 { 0098 Core::GridPattern grid; 0099 switch(ui->m_gridPattern->currentIndex()) 0100 { 0101 case 0: 0102 grid= Core::GridPattern::NONE; 0103 break; 0104 case 1: 0105 grid= Core::GridPattern::SQUARE; 0106 break; 0107 case 3: 0108 grid= Core::GridPattern::OCTOGON; 0109 break; 0110 case 2: 0111 grid= Core::GridPattern::HEXAGON; 0112 break; 0113 default: 0114 grid= Core::GridPattern::NONE; 0115 break; 0116 } 0117 return grid; 0118 } 0119 0120 Core::PermissionMode MapWizzardDialog::permission() const 0121 { 0122 Core::PermissionMode result; 0123 switch(ui->m_permissionComboBox->currentIndex()) 0124 { 0125 case 0: 0126 result= Core::GM_ONLY; 0127 break; 0128 case 1: 0129 result= Core::PC_MOVE; 0130 break; 0131 case 2: 0132 result= Core::PC_ALL; 0133 break; 0134 default: 0135 result= Core::GM_ONLY; 0136 break; 0137 } 0138 return result; 0139 } 0140 0141 Core::VisibilityMode MapWizzardDialog::visibility() const 0142 { 0143 Core::VisibilityMode resultVisibility= Core::HIDDEN; 0144 switch(ui->m_visibilityComboBox->currentIndex()) 0145 { 0146 case 0: 0147 resultVisibility= Core::HIDDEN; 0148 break; 0149 case 1: 0150 resultVisibility= Core::FOGOFWAR; 0151 break; 0152 case 2: 0153 resultVisibility= Core::ALL; 0154 break; 0155 default: 0156 break; 0157 } 0158 return resultVisibility; 0159 } 0160 0161 void MapWizzardDialog::changeEvent(QEvent* e) 0162 { 0163 QDialog::changeEvent(e); 0164 switch(e->type()) 0165 { 0166 case QEvent::LanguageChange: 0167 ui->retranslateUi(this); 0168 break; 0169 default: 0170 break; 0171 } 0172 } 0173 0174 void MapWizzardDialog::updateUI() 0175 { 0176 /*ui->m_gridPattern->setCurrentIndex(map->getOption(VisualItem::GridPattern).toInt()); 0177 ui->m_sizeGrid->setValue(map->getOption(VisualItem::GridSize).toInt()); 0178 ui->m_gridColorBtn->setColor(map->getOption(VisualItem::GridColor).value<QColor>()); 0179 ui->m_permissionComboBox->setCurrentIndex(map->getPermissionMode()); 0180 ui->m_visibilityComboBox->setCurrentIndex(map->getOption(VisualItem::VisibilityMode).toInt()); 0181 ui->m_scaleOfGrid->setValue(map->getOption(VisualItem::GridSize).toInt()); 0182 ui->m_unitPattern->setCurrentIndex(map->getOption(VisualItem::Unit).toInt());*/ 0183 // ui->m_colorButton->setColor(map->getBackGroundColor()); 0184 0185 // selectedShapeChanged(); 0186 // ui->m_titleLineedit->setText(map->getMapTitle()); 0187 }