diff options
| author | Ben Boeckel <MathStuf@gmail.com> | 2008-05-15 04:58:10 +0000 |
|---|---|---|
| committer | Ben Boeckel <MathStuf@gmail.com> | 2008-05-15 04:58:10 +0000 |
| commit | b46fba7a98595e8be65caaaa8f36b2e28adce137 (patch) | |
| tree | 074518f6554a7764707fc1035a4bf158ca8ae1b3 | |
| parent | 25984412ffc414de66b7fc990bb53cbfcf2a6993 (diff) | |
| download | sigen-b46fba7a98595e8be65caaaa8f36b2e28adce137.tar.gz sigen-b46fba7a98595e8be65caaaa8f36b2e28adce137.tar.xz sigen-b46fba7a98595e8be65caaaa8f36b2e28adce137.zip | |
[ADD] MapEffect widget logic
[FIX] Fixed up some other minor problems
git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@133 6ecfd1a5-f3ed-3746-8530-beee90d26b22
| -rw-r--r-- | Changelog | 8 | ||||
| -rw-r--r-- | pokemod/MapEffect.cpp | 2 | ||||
| -rw-r--r-- | pokemodr/MapEffectUI.cpp | 186 | ||||
| -rw-r--r-- | pokemodr/MapEffectUI.h | 57 | ||||
| -rw-r--r-- | pokemodr/MapTrainerUI.cpp | 2 | ||||
| -rw-r--r-- | pokemodr/MapTrainerUI.h | 2 | ||||
| -rw-r--r-- | pokemodr/TODO | 1 | ||||
| -rw-r--r-- | pokemodr/TileUI.cpp | 4 | ||||
| -rw-r--r-- | pokemodr/TileUI.h | 2 | ||||
| -rw-r--r-- | pokemodr/gui/mapeffect.ui | 25 | ||||
| -rw-r--r-- | pokemodr/gui/tile.ui | 4 | ||||
| -rw-r--r-- | pokemodr/models/MapEffectModel.cpp | 7 | ||||
| -rw-r--r-- | pokemodr/models/MapTrainerModel.cpp | 7 | ||||
| -rw-r--r-- | pokemodr/pokemodr.pro | 2 |
14 files changed, 282 insertions, 27 deletions
@@ -1,4 +1,12 @@ ----------------- +Rev: 133 +Date: 15 May 2008 +User: MathStuf +----------------- +[ADD] MapEffect widget logic +[FIX] Fixed up some other minor problems + +----------------- Rev: 132 Date: 15 May 2008 User: MathStuf diff --git a/pokemod/MapEffect.cpp b/pokemod/MapEffect.cpp index f6fc95b1..4b2fd649 100644 --- a/pokemod/MapEffect.cpp +++ b/pokemod/MapEffect.cpp @@ -153,7 +153,7 @@ void MapEffect::setEffect(const int effect) void MapEffect::setValue1(const int value1) { - if ((m_effect != E_StrengthBlock) && (m_effect != E_Button)) + if ((m_effect != E_Button) && (m_effect != E_StrengthBlock)) { emit(warning(unused("val1"))); return; diff --git a/pokemodr/MapEffectUI.cpp b/pokemodr/MapEffectUI.cpp new file mode 100644 index 00000000..5aefb6fd --- /dev/null +++ b/pokemodr/MapEffectUI.cpp @@ -0,0 +1,186 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +// Header include +#include "MapEffectUI.h" + +// PokeModr includes +#include "FileDialog.h" + +// Pokemod includes +#include "../pokemod/Dialog.h" +#include "../pokemod/Item.h" +#include "../pokemod/Map.h" +#include "../pokemod/MapEffect.h" +#include "../pokemod/Pokemod.h" + +MapEffectUI::MapEffectUI(MapEffect* effect, QWidget* parent) : + ObjectUI(parent) +{ + setupUi(this); + QMetaObject::connectSlotsByName(this); + setObjects(effect, new MapEffect(*effect)); + connect(this, SIGNAL(changed(bool)), boxButtons, SLOT(setEnabled(bool))); + connect(modified(), SIGNAL(error(const QString&)), this, SLOT(setGui())); + connect(modified(), SIGNAL(error(const QString&)), this, SLOT(errorMessage(const QString&))); + connect(modified(), SIGNAL(warning(const QString&)), this, SLOT(warningMessage(const QString&))); + connect(modified(), SIGNAL(changed()), this, SLOT(setChanged())); + init(); +} + +MapEffectUI::~MapEffectUI() +{ +} + +void MapEffectUI::initGui() +{ + varEffect->addItems(MapEffect::EffectStr); + varDirection->addItems(Pokemod::DirectionStr.mid(0, Pokemod::D_End)); +} + +void MapEffectUI::refreshGui() +{ + varCoordinate->setMaximum(static_cast<const Map*>(original()->parent())->size()); + varDialog->clear(); + for (int i = 0; i < static_cast<const Pokemod*>(original()->pokemod())->dialogCount(); ++i) + { + const Dialog* dialog = static_cast<const Pokemod*>(original()->pokemod())->dialog(i); + varDialog->addItem(dialog->dialog().mid(0, 25)); + varDialog->setItemData(i, dialog->id()); + } +} + +void MapEffectUI::setGui() +{ + varName->setText(static_cast<MapEffect*>(modified())->name()); + varCoordinate->setValue(static_cast<MapEffect*>(modified())->coordinate()); + varExistFlag->setValue(static_cast<MapEffect*>(modified())->existFlag()); + varSkin->setIcon(static_cast<MapEffect*>(modified())->skin()); + varEffect->setCurrentIndex(static_cast<MapEffect*>(modified())->effect()); + const int effect = static_cast<MapEffect*>(modified())->effect(); + if ((effect == MapEffect::E_Button) || (effect == MapEffect::E_StrengthBlock)) + { + varValue1->setEnabled(true); + varValue1->setValue(static_cast<MapEffect*>(modified())->value1()); + } + else + varValue1->setEnabled(false); + varValue2->clear(); + switch (effect) + { + case MapEffect::E_Item: + for (int i = 0; i < static_cast<const Pokemod*>(original()->pokemod())->itemCount(); ++i) + { + const Item* item = static_cast<const Pokemod*>(original()->pokemod())->item(i); + varValue2->addItem(item->name()); + varValue2->setItemData(i, item->id()); + } + varValue2->setCurrentIndex(varValue2->findData(static_cast<MapEffect*>(modified())->value2())); + break; + case MapEffect::E_PC: + varValue2->addItems(MapEffect::PCTypeStr); + for (int i = 0; i < MapEffect::PC_End; ++i) + varValue2->setItemData(i, i); + varValue2->setCurrentIndex(static_cast<MapEffect*>(modified())->value2()); + break; + case MapEffect::E_StrengthBlock: + case MapEffect::E_Button: + varValue2->addItems(Flag::ValueStr); + for (int i = 0; i < Flag::End; ++i) + varValue2->setItemData(i, i); + varValue2->setCurrentIndex(static_cast<MapEffect*>(modified())->value2()); + break; + } + varDirection->setCurrentIndex(static_cast<MapEffect*>(modified())->direction()); + varIsGhost->setChecked(static_cast<MapEffect*>(modified())->isGhost() ? Qt::Checked : Qt::Unchecked); + varCanMove->setChecked(static_cast<MapEffect*>(modified())->canMove() ? Qt::Checked : Qt::Unchecked); + varDialog->setCurrentIndex(varDialog->findData(static_cast<MapEffect*>(modified())->dialog())); +} + +void MapEffectUI::on_buttonApply_clicked() +{ + *static_cast<MapEffect*>(original()) = *static_cast<MapEffect*>(modified()); + emit(changed(false)); +} + +void MapEffectUI::on_buttonDiscard_clicked() +{ + *static_cast<MapEffect*>(modified()) = *static_cast<MapEffect*>(original()); + setGui(); + emit(changed(false)); +} + +void MapEffectUI::on_varName_textChanged(const QString& name) +{ + static_cast<MapEffect*>(modified())->setName(name); +} + +void MapEffectUI::on_varCoordinate_valueChanged(const Point& coordinate) +{ + static_cast<MapEffect*>(modified())->setCoordinate(coordinate); +} + +void MapEffectUI::on_varExistFlag_valueChanged(const Flag& existFlag) +{ + static_cast<MapEffect*>(modified())->setExistFlag(existFlag); +} + +void MapEffectUI::on_varSkin_pressed() +{ + FileDialog* dialog = new FileDialog(QSize(192, 128)); + if (dialog->exec() == QDialog::Accepted) + { + static_cast<MapEffect*>(modified())->setSkin(QPixmap(dialog->selectedFile())); + setGui(); + } + delete dialog; +} + +void MapEffectUI::on_varEffect_indexChanged(const int effect) +{ + static_cast<MapEffect*>(modified())->setEffect(effect); +} + +void MapEffectUI::on_varValue1_valueChanged(const int value1) +{ + static_cast<MapEffect*>(modified())->setValue1(value1); +} + +void MapEffectUI::on_varValue2_currentIndexChanged(const int value2) +{ + static_cast<MapEffect*>(modified())->setValue1(varValue2->itemData(value2).toInt()); +} + +void MapEffectUI::on_varDirection_currentIndexChanged(const int direction) +{ + static_cast<MapEffect*>(modified())->setDirection(direction); +} + +void MapEffectUI::on_varIsGhost_clicked(const bool isGhost) +{ + static_cast<MapEffect*>(modified())->setIsGhost(isGhost); +} + +void MapEffectUI::on_varCanMove_clicked(const bool canMove) +{ + static_cast<MapEffect*>(modified())->setCanMove(canMove); +} + +void MapEffectUI::on_varDialog_currentIndexChanged(const int dialog) +{ + static_cast<MapEffect*>(modified())->setDialog(varDialog->itemData(dialog).toInt()); +} diff --git a/pokemodr/MapEffectUI.h b/pokemodr/MapEffectUI.h new file mode 100644 index 00000000..04a24639 --- /dev/null +++ b/pokemodr/MapEffectUI.h @@ -0,0 +1,57 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef __POKEMODR_MAPEFFECTUI__ +#define __POKEMODR_MAPEFFECTUI__ + +// PokeModr includes +#include "ObjectUI.h" + +// Form include +#include "ui_mapeffect.h" + +// Forward declarations +class MapEffect; + +class MapEffectUI : public ObjectUI, private Ui::formMapEffect +{ + Q_OBJECT + + public: + MapEffectUI(MapEffect* effect, QWidget* parent); + ~MapEffectUI(); + public slots: + void on_buttonApply_clicked(); + void on_buttonDiscard_clicked(); + void on_varName_textChanged(const QString& name); + void on_varCoordinate_valueChanged(const Point& coordinate); + void on_varExistFlag_valueChanged(const Flag& existFlag); + void on_varSkin_pressed(); + void on_varEffect_indexChanged(const int effect); + void on_varValue1_valueChanged(const int value1); + void on_varValue2_currentIndexChanged(const int value2); + void on_varDirection_currentIndexChanged(const int direction); + void on_varIsGhost_clicked(const bool isGhost); + void on_varCanMove_clicked(const bool canMove); + void on_varDialog_currentIndexChanged(const int dialog); + private slots: + void initGui(); + void refreshGui(); + void setGui(); +}; + +#endif diff --git a/pokemodr/MapTrainerUI.cpp b/pokemodr/MapTrainerUI.cpp index acf31c6e..47caf9a8 100644 --- a/pokemodr/MapTrainerUI.cpp +++ b/pokemodr/MapTrainerUI.cpp @@ -137,7 +137,7 @@ void MapTrainerUI::on_varNumberFight_valueChanged(const int numberFight) static_cast<MapTrainer*>(modified())->setNumberFight(numberFight); } -void MapTrainerUI::on_varAppearFlag_changed(const Flag& appearFlag) +void MapTrainerUI::on_varAppearFlag_valueChanged(const Flag& appearFlag) { static_cast<MapTrainer*>(modified())->setAppearFlag(appearFlag); } diff --git a/pokemodr/MapTrainerUI.h b/pokemodr/MapTrainerUI.h index fa76d79b..229f4930 100644 --- a/pokemodr/MapTrainerUI.h +++ b/pokemodr/MapTrainerUI.h @@ -43,7 +43,7 @@ class MapTrainerUI : public ObjectUI, private Ui::formMapTrainer void on_varSight_valueChanged(const int sight); void on_varDirection_currentIndexChanged(const int direction); void on_varNumberFight_valueChanged(const int numberFight); - void on_varAppearFlag_changed(const Flag& appearFlag); + void on_varAppearFlag_valueChanged(const Flag& appearFlag); void on_varDialog_currentIndexChanged(const int dialog); void on_varLeadTeamMember_currentIndexChanged(const int leadTeamMember); private slots: diff --git a/pokemodr/TODO b/pokemodr/TODO index 3a530988..264259a3 100644 --- a/pokemodr/TODO +++ b/pokemodr/TODO @@ -1,7 +1,6 @@ AbilityEffect Dialog (with command dialogs) ItemEffect -MapEffect MoveEffect Set Fraction widget behavior correctly diff --git a/pokemodr/TileUI.cpp b/pokemodr/TileUI.cpp index 56889285..d9447880 100644 --- a/pokemodr/TileUI.cpp +++ b/pokemodr/TileUI.cpp @@ -68,7 +68,7 @@ void TileUI::refreshGui() void TileUI::setGui() { varName->setText(static_cast<Tile*>(modified())->name()); - varImage->setIcon(static_cast<Tile*>(modified())->sprite()); + varSprite->setIcon(static_cast<Tile*>(modified())->sprite()); for (int i = 0; i < varAccessibility->count(); ++i) varAccessibility->item(i)->setSelected(static_cast<Tile*>(modified())->from(i)); varWildChance->setValue(static_cast<Tile*>(modified())->wildChance()); @@ -100,7 +100,7 @@ void TileUI::on_varName_textChanged(const QString& name) static_cast<Tile*>(modified())->setName(name); } -void TileUI::on_varImage_pressed() +void TileUI::on_varSprite_pressed() { FileDialog* dialog = new FileDialog(QSize(64, 64)); if (dialog->exec() == QDialog::Accepted) diff --git a/pokemodr/TileUI.h b/pokemodr/TileUI.h index e6b03d9c..4571f005 100644 --- a/pokemodr/TileUI.h +++ b/pokemodr/TileUI.h @@ -38,7 +38,7 @@ class TileUI : public ObjectUI, private Ui::formTile void on_buttonApply_clicked(); void on_buttonDiscard_clicked(); void on_varName_textChanged(const QString& name); - void on_varImage_pressed(); + void on_varSprite_pressed(); void on_varAccessibility_itemSelectionChanged(); void on_varWild_valueChanged(const Fraction& wild); void on_boxHMs_toggled(const bool hm); diff --git a/pokemodr/gui/mapeffect.ui b/pokemodr/gui/mapeffect.ui index 7bac51a7..0399d0f8 100644 --- a/pokemodr/gui/mapeffect.ui +++ b/pokemodr/gui/mapeffect.ui @@ -99,7 +99,7 @@ </spacer> </item> <item> - <widget class="KPushButton" name="kpushbutton" > + <widget class="KPushButton" name="varSkin" > <property name="minimumSize" > <size> <width>192</width> @@ -141,18 +141,18 @@ </widget> </item> <item> - <widget class="QGroupBox" name="boxVal1" > + <widget class="QGroupBox" name="boxValue1" > <property name="title" > <string>Value 1</string> </property> <layout class="QHBoxLayout" > <item> - <widget class="KComboBox" name="varVal1" > + <widget class="KIntNumInput" name="varValue1" > <property name="toolTip" > - <string>Value 1</string> + <string>Value 1 of the effect</string> </property> - <property name="autoCompletion" > - <bool>false</bool> + <property name="minimum" > + <number>0</number> </property> </widget> </item> @@ -160,13 +160,13 @@ </widget> </item> <item> - <widget class="QGroupBox" name="boxVal2" > + <widget class="QGroupBox" name="boxValue2" > <property name="title" > <string>Value 2</string> </property> <layout class="QHBoxLayout" > <item> - <widget class="KComboBox" name="varVal2" > + <widget class="KComboBox" name="varValue2" > <property name="toolTip" > <string>Value 2</string> </property> @@ -201,7 +201,7 @@ </property> <layout class="QVBoxLayout" > <item> - <widget class="QCheckBox" name="varGhost" > + <widget class="QCheckBox" name="varIsGhost" > <property name="toolTip" > <string>If checked, the effect is able to be walked through</string> </property> @@ -211,7 +211,7 @@ </widget> </item> <item> - <widget class="QCheckBox" name="varMovable" > + <widget class="QCheckBox" name="varCanMove" > <property name="toolTip" > <string>If checked, the effect will move around the map randomly</string> </property> @@ -248,6 +248,11 @@ <header>kcombobox.h</header> </customwidget> <customwidget> + <class>KIntNumInput</class> + <extends>QWidget</extends> + <header>knuminput.h</header> + </customwidget> + <customwidget> <class>KLineEdit</class> <extends>QLineEdit</extends> <header>klineedit.h</header> diff --git a/pokemodr/gui/tile.ui b/pokemodr/gui/tile.ui index 603ee65f..ed7944ad 100644 --- a/pokemodr/gui/tile.ui +++ b/pokemodr/gui/tile.ui @@ -48,7 +48,7 @@ </widget> </item> <item> - <widget class="QGroupBox" name="boxImage" > + <widget class="QGroupBox" name="boxSprite" > <property name="title" > <string>Image</string> </property> @@ -67,7 +67,7 @@ </spacer> </item> <item> - <widget class="KPushButton" name="varImage" > + <widget class="KPushButton" name="varSprite" > <property name="minimumSize" > <size> <width>64</width> diff --git a/pokemodr/models/MapEffectModel.cpp b/pokemodr/models/MapEffectModel.cpp index 9f09fd8c..42d963da 100644 --- a/pokemodr/models/MapEffectModel.cpp +++ b/pokemodr/models/MapEffectModel.cpp @@ -19,7 +19,7 @@ #include "MapEffectModel.h" // PokeModr includes -// #include "../MapEffectUI.h" +#include "../MapEffectUI.h" // Pokemod includes #include "../../pokemod/Map.h" @@ -49,9 +49,8 @@ QVariant MapEffectModel::data(int role) const } else if (role == BaseModel::WidgetRole) { - // TODO: MapEffectUI -// QWidget* widget = new MapEffectUI(static_cast<MapEffect*>(m_object), NULL); -// return QVariant::fromValue(widget); + QWidget* widget = new MapEffectUI(static_cast<MapEffect*>(m_object), NULL); + return QVariant::fromValue(widget); } return QVariant(); } diff --git a/pokemodr/models/MapTrainerModel.cpp b/pokemodr/models/MapTrainerModel.cpp index bb9630dc..a6075423 100644 --- a/pokemodr/models/MapTrainerModel.cpp +++ b/pokemodr/models/MapTrainerModel.cpp @@ -22,7 +22,7 @@ #include "MapTrainerTeamMemberModel.h" // PokeModr includes -// #include "../MapTrainerUI.h" +#include "../MapTrainerUI.h" // Pokemod includes #include "../../pokemod/Map.h" @@ -54,9 +54,8 @@ QVariant MapTrainerModel::data(int role) const } else if (role == BaseModel::WidgetRole) { - // TODO: MapTrainerUI -// QWidget* widget = new MapTrainerUI(static_cast<MapTrainer*>(m_object), NULL); -// return QVariant::fromValue(widget); + QWidget* widget = new MapTrainerUI(static_cast<MapTrainer*>(m_object), NULL); + return QVariant::fromValue(widget); } return QVariant(); } diff --git a/pokemodr/pokemodr.pro b/pokemodr/pokemodr.pro index 7c6461f1..48c86082 100644 --- a/pokemodr/pokemodr.pro +++ b/pokemodr/pokemodr.pro @@ -76,6 +76,7 @@ SOURCES += AbilityUI.cpp \ ItemUI.cpp \ ItemTypeUI.cpp \ MapUI.cpp \ + MapEffectUI.cpp \ MapTrainerUI.cpp \ MapTrainerTeamMemberUI.cpp \ MapWarpUI.cpp \ @@ -152,6 +153,7 @@ HEADERS += AbilityUI.h \ ItemUI.h \ ItemTypeUI.h \ MapUI.h \ + MapEffectUI.h \ MapTrainerUI.h \ MapTrainerTeamMemberUI.h \ MapWarpUI.h \ |
