From 0fe749eb04515ff7ee28cdc5d14c7be6f6fdeca4 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Fri, 23 May 2008 22:39:56 +0000 Subject: [ADD] Added UI classes for GlobalScript [FIX] Script support is now in pokemodr git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@168 6ecfd1a5-f3ed-3746-8530-beee90d26b22 --- Changelog | 15 +++ pokemod/MapWildList.h | 1 - pokemod/Pokemod.cpp | 32 ------- pokemod/Pokemod.h | 8 -- pokemod/SpeciesEvolution.cpp | 126 ------------------------- pokemod/SpeciesEvolution.h | 57 ------------ pokemodr/AbilityUI.cpp | 1 - pokemodr/AuthorUI.cpp | 3 - pokemodr/CoinListUI.cpp | 8 +- pokemodr/CoinListUI.h | 2 +- pokemodr/FlagWidget.cpp | 60 ------------ pokemodr/FlagWidget.h | 50 ---------- pokemodr/FractionWidget.h | 4 +- pokemodr/GlobalScriptUI.cpp | 62 +++++++++++++ pokemodr/GlobalScriptUI.h | 47 ++++++++++ pokemodr/MapEffectUI.cpp | 8 +- pokemodr/MapEffectUI.h | 2 +- pokemodr/MapTrainerUI.cpp | 29 +----- pokemodr/MapTrainerUI.h | 6 +- pokemodr/MapWarpUI.cpp | 53 +---------- pokemodr/MapWarpUI.h | 8 +- pokemodr/MapWildListUI.cpp | 35 +------ pokemodr/MapWildListUI.h | 4 +- pokemodr/MoveUI.cpp | 35 +------ pokemodr/MoveUI.h | 6 +- pokemodr/PokemodUI.cpp | 12 --- pokemodr/PokemodUI.h | 2 - pokemodr/ScriptWidget.cpp | 58 ++++++++++++ pokemodr/ScriptWidget.h | 49 ++++++++++ pokemodr/gui/ability.ui | 17 ++++ pokemodr/gui/badge.ui | 13 ++- pokemodr/gui/coinlist.ui | 17 +--- pokemodr/gui/flag.ui | 39 -------- pokemodr/gui/globalscript.ui | 49 ++++++++++ pokemodr/gui/item.ui | 19 +++- pokemodr/gui/mapeffect.ui | 57 ++++-------- pokemodr/gui/maptrainer.ui | 71 ++------------ pokemodr/gui/mapwarp.ui | 117 ++--------------------- pokemodr/gui/mapwildlist.ui | 48 +++------- pokemodr/gui/mapwildlistencounter.ui | 6 +- pokemodr/gui/move.ui | 86 +++++------------ pokemodr/gui/nature.ui | 2 +- pokemodr/gui/pokemod.ui | 144 +++++++++++++++++------------ pokemodr/gui/script.ui | 52 +++++++++++ pokemodr/gui/species.ui | 109 ++++++++++++++++++---- pokemodr/gui/tile.ui | 4 +- pokemodr/gui/trainer.ui | 4 +- pokemodr/gui/type.ui | 2 +- pokemodr/models/AbilityModel.cpp | 37 +------- pokemodr/models/AbilityModel.h | 11 +-- pokemodr/models/AuthorModel.cpp | 1 - pokemodr/models/BadgeModel.cpp | 1 - pokemodr/models/CoinListModel.cpp | 1 - pokemodr/models/EggGroupModel.cpp | 1 - pokemodr/models/GlobalScriptGroupModel.cpp | 60 ++++++++++++ pokemodr/models/GlobalScriptGroupModel.h | 40 ++++++++ pokemodr/models/GlobalScriptModel.cpp | 77 +++++++++++++++ pokemodr/models/GlobalScriptModel.h | 38 ++++++++ pokemodr/models/ItemModel.cpp | 37 +------- pokemodr/models/ItemModel.h | 11 +-- pokemodr/models/ItemTypeModel.cpp | 1 - pokemodr/models/MapModel.cpp | 1 - pokemodr/models/MoveModel.cpp | 37 +------- pokemodr/models/MoveModel.h | 11 +-- pokemodr/models/PokemodModel.cpp | 4 +- pokemodr/models/SpeciesModel.cpp | 2 - pokemodr/pokemodr.pro | 5 +- 67 files changed, 892 insertions(+), 1123 deletions(-) delete mode 100644 pokemod/SpeciesEvolution.cpp delete mode 100644 pokemod/SpeciesEvolution.h delete mode 100644 pokemodr/FlagWidget.cpp delete mode 100644 pokemodr/FlagWidget.h create mode 100644 pokemodr/GlobalScriptUI.cpp create mode 100644 pokemodr/GlobalScriptUI.h create mode 100644 pokemodr/ScriptWidget.cpp create mode 100644 pokemodr/ScriptWidget.h delete mode 100644 pokemodr/gui/flag.ui create mode 100644 pokemodr/gui/globalscript.ui create mode 100644 pokemodr/gui/script.ui create mode 100644 pokemodr/models/GlobalScriptGroupModel.cpp create mode 100644 pokemodr/models/GlobalScriptGroupModel.h create mode 100644 pokemodr/models/GlobalScriptModel.cpp create mode 100644 pokemodr/models/GlobalScriptModel.h diff --git a/Changelog b/Changelog index eab1bf01..f99c7bbd 100644 --- a/Changelog +++ b/Changelog @@ -1,3 +1,18 @@ +----------------- +Rev: 168 +Date: 23 May 2008 +User: MathStuf +----------------- +[ADD] Added UI classes for GlobalScript +[FIX] Script support is now in pokemodr + +----------------- +Rev: 167 +Date: 23 May 2008 +User: MathStuf +----------------- +[DEL] Cleaned out unneeded files + ----------------- Rev: 166 Date: 23 May 2008 diff --git a/pokemod/MapWildList.h b/pokemod/MapWildList.h index cfc06fc3..22726f38 100644 --- a/pokemod/MapWildList.h +++ b/pokemod/MapWildList.h @@ -87,7 +87,6 @@ class MapWildList : public Object int m_control; Script m_script; QList m_time; - QList m_encounters; }; diff --git a/pokemod/Pokemod.cpp b/pokemod/Pokemod.cpp index 0f52af1f..a0e86ced 100644 --- a/pokemod/Pokemod.cpp +++ b/pokemod/Pokemod.cpp @@ -65,8 +65,6 @@ Pokemod::Pokemod() : m_flySkin(192, 128), m_fishSkin(192, 128), m_surfFishSkin(192, 128), - m_superPCUname(""), - m_superPCPasswd(""), m_typeChart(0, 0), m_rules(new Rules(this)) { @@ -107,10 +105,6 @@ void Pokemod::validate() if (mapById(m_startMap)->warpIndex(m_startWarp) == INT_MAX) emit(error("Invalid starting warp")); } - if (m_superPCUname.isEmpty()) - emit(warning("Super PC username not defined")); - if (m_superPCPasswd.isEmpty()) - emit(warning("Super PC password not defined")); if ((m_typeChart.width() != typeCount()) || (m_typeChart.height() != typeCount())) emit(error("Type chart is invalid")); m_rules->validate(); @@ -395,8 +389,6 @@ void Pokemod::load(const QDomElement& xml, const int) LOAD(QPixmap, flySkin); LOAD(QPixmap, fishSkin); LOAD(QPixmap, surfFishSkin); - LOAD(QString, superPCUname); - LOAD(QString, superPCPasswd); LOAD(Rules, rules); LOAD_SUB(newAbility, Ability); LOAD_SUB(newAuthor, Author); @@ -433,8 +425,6 @@ QDomElement Pokemod::save() const SAVE(QPixmap, flySkin); SAVE(QPixmap, fishSkin); SAVE(QPixmap, surfFishSkin); - SAVE(QString, superPCUname); - SAVE(QString, superPCPasswd); SAVE_Rules(rules); SAVE_MATRIX(Fraction, typeChart); SAVE_SUB(Ability, abilities); @@ -569,16 +559,6 @@ void Pokemod::setSurfFishSkin(const QPixmap& surfFishSkin) emit(changed()); } -void Pokemod::setSuperPCUname(const QString& superPCUname) -{ - CHECK(superPCUname); -} - -void Pokemod::setSuperPCPasswd(const QString& superPCPasswd) -{ - CHECK(superPCPasswd); -} - void Pokemod::setTypeChart(const int attack, const int defense, const Fraction& multiplier) { CHECK_ARRAY(typeChart(attack, defense), multiplier); @@ -649,16 +629,6 @@ QPixmap Pokemod::surfFishSkin() const return m_surfFishSkin; } -QString Pokemod::superPCUname() const -{ - return m_superPCUname; -} - -QString Pokemod::superPCPasswd() const -{ - return m_superPCPasswd; -} - const Matrix* Pokemod::typeChart() const { return &m_typeChart; @@ -2166,8 +2136,6 @@ Pokemod& Pokemod::operator=(const Pokemod& rhs) COPY(description); COPY(startMap); COPY(startWarp); - COPY(superPCUname); - COPY(superPCPasswd); COPY(typeChart); COPY_Rules(rules); COPY_SUB(Ability, abilities); diff --git a/pokemod/Pokemod.h b/pokemod/Pokemod.h index 1509e342..9f4c1d08 100644 --- a/pokemod/Pokemod.h +++ b/pokemod/Pokemod.h @@ -174,8 +174,6 @@ class Pokemod : public Object void setFlySkin(const QPixmap& slySkin); void setFishSkin(const QPixmap& fishSkin); void setSurfFishSkin(const QPixmap& surfFishSkin); - void setSuperPCUname(const QString& superPCUname); - void setSuperPCPasswd(const QString& superPCPasswd); void setTypeChart(const int attack, const int defense, const Fraction& multiplier); void setRules(const Rules& rules); void setRules(const QDomElement& xml); @@ -191,8 +189,6 @@ class Pokemod : public Object QPixmap flySkin() const; QPixmap fishSkin() const; QPixmap surfFishSkin() const; - QString superPCUname() const; - QString superPCPasswd() const; const Matrix* typeChart() const; Matrix* typeChart(); Fraction typeChart(const int attack, const int defense) const; @@ -475,8 +471,6 @@ class Pokemod : public Object void clear(); - void copyDir(const QString& src, const QString& dest) const; - QString m_title; QString m_version; QString m_description; @@ -488,8 +482,6 @@ class Pokemod : public Object QPixmap m_flySkin; QPixmap m_fishSkin; QPixmap m_surfFishSkin; - QString m_superPCUname; - QString m_superPCPasswd; Matrix m_typeChart; Rules* m_rules; QList m_abilities; diff --git a/pokemod/SpeciesEvolution.cpp b/pokemod/SpeciesEvolution.cpp deleted file mode 100644 index 4c2c5c8e..00000000 --- a/pokemod/SpeciesEvolution.cpp +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright 2007-2008 Ben Boeckel - * - * 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 . - */ - -// Header include -#include "SpeciesEvolution.h" - -// Pokemod includes -#include "Item.h" -#include "Pokemod.h" -#include "Rules.h" -#include "Species.h" - -SpeciesEvolution::SpeciesEvolution(const SpeciesEvolution& evolution) : - Object("SpeciesEvolution", evolution.parent(), evolution.id()) -{ - *this = evolution; -} - -SpeciesEvolution::SpeciesEvolution(const Species* parent, const int id) : - Object("SpeciesEvolution", parent, id), - m_species(INT_MAX), - m_script(""), - m_level(0) -{ -} - -SpeciesEvolution::SpeciesEvolution(const SpeciesEvolution& evolution, const Species* parent, const int id) : - Object("SpeciesEvolution", parent, id) -{ - *this = evolution; -} - -SpeciesEvolution::SpeciesEvolution(const QDomElement& xml, const Species* parent, const int id) : - Object("SpeciesEvolution", parent, id) -{ - load(xml, id); -} - -void SpeciesEvolution::validate() -{ - TEST(setSpecies, species); - if (m_script.isEmpty()) - emit(warning("Script is empty")); - TEST(setLevel, level); -} - -void SpeciesEvolution::load(const QDomElement& xml, int id) -{ - LOAD_ID(); - LOAD(int, species); - LOAD(QString, script); - LOAD(int, level); -} - -QDomElement SpeciesEvolution::save() const -{ - SAVE_CREATE(); - SAVE(int, species); - SAVE(QString, script); - SAVE(int, level); - return xml; -} - -void SpeciesEvolution::setSpecies(const int species) -{ - if (static_cast(pokemod())->speciesIndex(species) == INT_MAX) - { - emit(error(bounds("species"))); - return; - } - CHECK(species); -} - -void SpeciesEvolution::setScript(const QString& script) -{ - CHECK(script); -} - -void SpeciesEvolution::setLevel(const int level) -{ - if (static_cast(pokemod())->rules()->maxLevel() < level) - { - emit(error(bounds("level"))); - return; - } - CHECK(level); -} - -int SpeciesEvolution::species() const -{ - return m_species; -} - -QString SpeciesEvolution::script() const -{ - return m_script; -} - -int SpeciesEvolution::level() const -{ - return m_level; -} - -SpeciesEvolution& SpeciesEvolution::operator=(const SpeciesEvolution& rhs) -{ - if (this == &rhs) - return *this; - COPY(species); - COPY(script); - COPY(level); - return *this; -} diff --git a/pokemod/SpeciesEvolution.h b/pokemod/SpeciesEvolution.h deleted file mode 100644 index 126649b8..00000000 --- a/pokemod/SpeciesEvolution.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 2007-2008 Ben Boeckel - * - * 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 . - */ - -#ifndef __POKEMOD_SPECIESEVOLUTION__ -#define __POKEMOD_SPECIESEVOLUTION__ - -// Pokemod includes -#include "Object.h" - -// Forward declarations -class Species; - -class SpeciesEvolution : public Object -{ - Q_OBJECT - - public: - SpeciesEvolution(const SpeciesEvolution& evolution); - SpeciesEvolution(const Species* parent, const int id); - SpeciesEvolution(const SpeciesEvolution& evolution, const Species* parent, const int id); - SpeciesEvolution(const QDomElement& xml, const Species* parent, const int id = INT_MAX); - - void validate(); - - void load(const QDomElement& xml, int id = INT_MAX); - QDomElement save() const; - - void setSpecies(const int species); - void setScript(const QString& script); - void setLevel(const int level); - - int species() const; - QString script() const; - int level() const; - - SpeciesEvolution& operator=(const SpeciesEvolution& rhs); - private: - int m_species; - QString m_script; - int m_level; -}; - -#endif diff --git a/pokemodr/AbilityUI.cpp b/pokemodr/AbilityUI.cpp index bc1d434f..c3e36e4d 100644 --- a/pokemodr/AbilityUI.cpp +++ b/pokemodr/AbilityUI.cpp @@ -53,5 +53,4 @@ void AbilityUI::discard() void AbilityUI::on_varName_textChanged(const QString& name) { static_cast(modified())->setName(name); - emit(changed(true)); } diff --git a/pokemodr/AuthorUI.cpp b/pokemodr/AuthorUI.cpp index 104d9445..33cdb5f6 100644 --- a/pokemodr/AuthorUI.cpp +++ b/pokemodr/AuthorUI.cpp @@ -55,17 +55,14 @@ void AuthorUI::discard() void AuthorUI::on_varName_textChanged(const QString& name) { static_cast(modified())->setName(name); - emit(changed(true)); } void AuthorUI::on_varEmail_textChanged(const QString& email) { static_cast(modified())->setEmail(email); - emit(changed(true)); } void AuthorUI::on_varRole_textChanged(const QString& role) { static_cast(modified())->setRole(role); - emit(changed(true)); } diff --git a/pokemodr/CoinListUI.cpp b/pokemodr/CoinListUI.cpp index 7669f879..b7b4a959 100644 --- a/pokemodr/CoinListUI.cpp +++ b/pokemodr/CoinListUI.cpp @@ -36,7 +36,7 @@ CoinListUI::~CoinListUI() void CoinListUI::setGui() { varName->setText(static_cast(modified())->name()); - varScript->setPlainText(static_cast(modified())->script()); + varScript->setValue(static_cast(modified())->script()); } void CoinListUI::apply() @@ -57,9 +57,7 @@ void CoinListUI::on_varName_textChanged(const QString& name) static_cast(modified())->setName(name); } -void CoinListUI::on_varScript_textChanged() +void CoinListUI::on_varScript_valueChanged(const Script& script) { - QTextCursor cursor = varScript->textCursor(); - static_cast(modified())->setScript(varScript->toPlainText()); - varScript->setTextCursor(cursor); + static_cast(modified())->setScript(script); } diff --git a/pokemodr/CoinListUI.h b/pokemodr/CoinListUI.h index d7f08886..1c82799b 100644 --- a/pokemodr/CoinListUI.h +++ b/pokemodr/CoinListUI.h @@ -39,7 +39,7 @@ class CoinListUI : public ObjectUI, private Ui::formCoinList void discard(); protected slots: void on_varName_textChanged(const QString& name); - void on_varScript_textChanged(); + void on_varScript_valueChanged(const Script& script); private slots: void setGui(); }; diff --git a/pokemodr/FlagWidget.cpp b/pokemodr/FlagWidget.cpp deleted file mode 100644 index ef983cd7..00000000 --- a/pokemodr/FlagWidget.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright 2008 Ben Boeckel - * - * 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 . - */ - -// Header include -#include "FlagWidget.h" - -FlagWidget::FlagWidget(QWidget* parent, const Flag& value) : - QGroupBox(parent), - m_value(value) -{ - setupUi(this); - connect(this, SIGNAL(clicked(bool)), SLOT(boxClicked(bool))); -} - -Flag FlagWidget::value() const -{ - return m_value; -} - -void FlagWidget::setValue(const Flag& value) -{ - if (m_value == value) - return; - m_value = value; - setChecked(m_value.status() == Flag::Ignore); - varFlag->setValue(m_value.flag()); - varState->setCheckState((m_value.status() == Flag::On) ? Qt::Checked : Qt::Unchecked); - emit(valueChanged(m_value)); -} - -void FlagWidget::boxClicked(const bool clicked) -{ - if (!clicked) - m_value.setStatus(Flag::Ignore); -} - -void FlagWidget::on_varFlag_valueChanged(const int flag) -{ - m_value.setFlag(flag); -} - -void FlagWidget::on_varState_toggled(const bool state) -{ - m_value.setStatus(state ? Flag::On : Flag::Off); -} - diff --git a/pokemodr/FlagWidget.h b/pokemodr/FlagWidget.h deleted file mode 100644 index 7e749179..00000000 --- a/pokemodr/FlagWidget.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright 2008 Ben Boeckel - * - * 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 . - */ - -#ifndef __FLAGWIDGET__ -#define __FLAGWIDGET__ - -// Pokemod includes -#include "../pokemod/Flag.h" - -// Qt includes -#include - -// Form include -#include "ui_flag.h" - -class FlagWidget : public QGroupBox, private Ui::formFlag -{ - Q_OBJECT - - public: - FlagWidget(QWidget* parent, const Flag& value = Flag(0, Flag::Off)); - - Flag value() const; - signals: - void valueChanged(const Flag&); - public slots: - void setValue(const Flag& value); - protected slots: - void boxClicked(const bool clicked); - void on_varFlag_valueChanged(const int flag); - void on_varState_toggled(const bool state); - private: - Flag m_value; -}; - -#endif diff --git a/pokemodr/FractionWidget.h b/pokemodr/FractionWidget.h index 38990c72..f20e8dc9 100644 --- a/pokemodr/FractionWidget.h +++ b/pokemodr/FractionWidget.h @@ -15,8 +15,8 @@ * with this program. If not, see . */ -#ifndef __FRACTIONWIDGET__ -#define __FRACTIONWIDGET__ +#ifndef __POKEMODR_FRACTIONWIDGET__ +#define __POKEMODR_FRACTIONWIDGET__ // Pokemod includes #include "../pokemod/Fraction.h" diff --git a/pokemodr/GlobalScriptUI.cpp b/pokemodr/GlobalScriptUI.cpp new file mode 100644 index 00000000..3aab8f08 --- /dev/null +++ b/pokemodr/GlobalScriptUI.cpp @@ -0,0 +1,62 @@ +/* + * Copyright 2008 Ben Boeckel + * + * 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 . + */ + +// Header include +#include "GlobalScriptUI.h" + +// Pokemod includes +#include "../pokemod/GlobalScript.h" + +GlobalScriptUI::GlobalScriptUI(GlobalScript* globalScript, QWidget* parent) : + ObjectUI(parent) +{ + setupUi(this); + setObjects(globalScript, new GlobalScript(*globalScript)); +} + +GlobalScriptUI::~GlobalScriptUI() +{ +} + +void GlobalScriptUI::setGui() +{ + varName->setText(static_cast(modified())->name()); + varScript->setValue(static_cast(modified())->script()); +} + +void GlobalScriptUI::apply() +{ + *static_cast(original()) = *static_cast(modified()); + emit(changed(false)); +} + +void GlobalScriptUI::discard() +{ + *static_cast(modified()) = *static_cast(original()); + setGui(); + emit(changed(false)); +} + +void GlobalScriptUI::on_varName_textChanged(const QString& name) +{ + static_cast(modified())->setName(name); +} + +void GlobalScriptUI::on_varScript_valueChanged(const Script& script) +{ + static_cast(modified())->setScript(script); +} diff --git a/pokemodr/GlobalScriptUI.h b/pokemodr/GlobalScriptUI.h new file mode 100644 index 00000000..3ca6acca --- /dev/null +++ b/pokemodr/GlobalScriptUI.h @@ -0,0 +1,47 @@ +/* + * Copyright 2008 Ben Boeckel + * + * 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 . + */ + +#ifndef __POKEMODR_GLOBALSCRIPTUI__ +#define __POKEMODR_GLOBALSCRIPTUI__ + +// PokeModr includes +#include "ObjectUI.h" + +// Form include +#include "ui_globalscript.h" + +// Forward declarations +class GlobalScript; + +class GlobalScriptUI : public ObjectUI, private Ui::formGlobalScript +{ + Q_OBJECT + + public: + GlobalScriptUI(GlobalScript* globalScript, QWidget* parent); + ~GlobalScriptUI(); + public slots: + void apply(); + void discard(); + protected slots: + void on_varName_textChanged(const QString& name); + void on_varScript_valueChanged(const Script& script); + private slots: + void setGui(); +}; + +#endif diff --git a/pokemodr/MapEffectUI.cpp b/pokemodr/MapEffectUI.cpp index 2008d4b9..9727eb1c 100644 --- a/pokemodr/MapEffectUI.cpp +++ b/pokemodr/MapEffectUI.cpp @@ -48,7 +48,7 @@ void MapEffectUI::setGui() varName->setText(static_cast(modified())->name()); varCoordinate->setValue(static_cast(modified())->coordinate()); varSkin->setIcon(static_cast(modified())->skin()); - varScript->setPlainText(static_cast(modified())->script()); + varScript->setValue(static_cast(modified())->script()); varIsGhost->setChecked(static_cast(modified())->isGhost() ? Qt::Checked : Qt::Unchecked); } @@ -86,11 +86,9 @@ void MapEffectUI::on_varSkin_pressed() delete dialog; } -void MapEffectUI::on_varScript_textChanged() +void MapEffectUI::on_varScript_valueChanged(const Script& script) { - QTextCursor cursor = varScript->textCursor(); - static_cast(modified())->setScript(varScript->toPlainText()); - varScript->setTextCursor(cursor); + static_cast(modified())->setScript(script); } void MapEffectUI::on_varIsGhost_clicked(const bool isGhost) diff --git a/pokemodr/MapEffectUI.h b/pokemodr/MapEffectUI.h index 927da32b..1e4feb00 100644 --- a/pokemodr/MapEffectUI.h +++ b/pokemodr/MapEffectUI.h @@ -41,7 +41,7 @@ class MapEffectUI : public ObjectUI, private Ui::formMapEffect void on_varName_textChanged(const QString& name); void on_varCoordinate_valueChanged(const Point& coordinate); void on_varSkin_pressed(); - void on_varScript_textChanged(); + void on_varScript_valueChanged(const Script& script); void on_varIsGhost_clicked(const bool isGhost); private slots: void refreshGui(); diff --git a/pokemodr/MapTrainerUI.cpp b/pokemodr/MapTrainerUI.cpp index ad4c02cd..c56c72dc 100644 --- a/pokemodr/MapTrainerUI.cpp +++ b/pokemodr/MapTrainerUI.cpp @@ -38,11 +38,6 @@ MapTrainerUI::~MapTrainerUI() { } -void MapTrainerUI::initGui() -{ - varDirection->addItems(Pokemod::DirectionStr.mid(0, Pokemod::D_End)); -} - void MapTrainerUI::refreshGui() { varTrainerClass->clear(); @@ -70,11 +65,8 @@ void MapTrainerUI::setGui() varName->setText(static_cast(modified())->name()); varTrainerClass->setCurrentIndex(varTrainerClass->findData(static_cast(modified())->trainerClass())); varCoordinate->setValue(static_cast(modified())->coordinate()); - varSight->setValue(static_cast(modified())->sight()); - varDirection->setCurrentIndex(static_cast(modified())->direction()); varNumberFight->setValue(static_cast(modified())->numberFight()); - varAppearFlag->setValue(static_cast(modified())->appearFlag()); - varDialog->setCurrentIndex(varDialog->findData(static_cast(modified())->dialog())); + varScript->setValue(static_cast(modified())->script()); varLeadTeamMember->setCurrentIndex(varLeadTeamMember->findData(static_cast(modified())->leadTeamMember())); } @@ -106,29 +98,14 @@ void MapTrainerUI::on_varCoordinate_valueChanged(const Point& coordinate) static_cast(modified())->setCoordinate(coordinate); } -void MapTrainerUI::on_varSight_valueChanged(const int sight) -{ - static_cast(modified())->setSight(sight); -} - -void MapTrainerUI::on_varDirection_activated(const int direction) -{ - static_cast(modified())->setDirection(direction); -} - void MapTrainerUI::on_varNumberFight_valueChanged(const int numberFight) { static_cast(modified())->setNumberFight(numberFight); } -void MapTrainerUI::on_varAppearFlag_valueChanged(const Flag& appearFlag) -{ - static_cast(modified())->setAppearFlag(appearFlag); -} - -void MapTrainerUI::on_varDialog_activated(const int dialog) +void MapTrainerUI::on_varScript_valueChanged(const Script& script) { - static_cast(modified())->setDialog(varDialog->itemData(dialog).toInt()); + static_cast(modified())->setScript(script); } void MapTrainerUI::on_varLeadTeamMember_activated(const int leadTeamMember) diff --git a/pokemodr/MapTrainerUI.h b/pokemodr/MapTrainerUI.h index 2c0665bd..43f4f92f 100644 --- a/pokemodr/MapTrainerUI.h +++ b/pokemodr/MapTrainerUI.h @@ -41,14 +41,10 @@ class MapTrainerUI : public ObjectUI, private Ui::formMapTrainer void on_varName_textChanged(const QString& name); void on_varTrainerClass_activated(const int trainerClass); void on_varCoordinate_valueChanged(const Point& coordinate); - void on_varSight_valueChanged(const int sight); - void on_varDirection_activated(const int direction); void on_varNumberFight_valueChanged(const int numberFight); - void on_varAppearFlag_valueChanged(const Flag& appearFlag); - void on_varDialog_activated(const int dialog); + void on_varScript_valueChanged(const Script& script); void on_varLeadTeamMember_activated(const int leadTeamMember); private slots: - void initGui(); void refreshGui(); void setGui(); }; diff --git a/pokemodr/MapWarpUI.cpp b/pokemodr/MapWarpUI.cpp index 29774e13..f0f887a6 100644 --- a/pokemodr/MapWarpUI.cpp +++ b/pokemodr/MapWarpUI.cpp @@ -19,7 +19,6 @@ #include "MapWarpUI.h" // Pokemod includes -#include "../pokemod/Dialog.h" #include "../pokemod/Map.h" #include "../pokemod/MapWarp.h" #include "../pokemod/Pokemod.h" @@ -38,7 +37,6 @@ MapWarpUI::~MapWarpUI() void MapWarpUI::initGui() { - varActivation->addItems(Pokemod::DirectionStr.mid(0, Pokemod::D_End)); varType->addItems(MapWarp::TypeStr); } @@ -51,12 +49,6 @@ void MapWarpUI::refreshGui() const Map* map = static_cast(original()->pokemod())->map(i); varToMap->addItem(map->name(), map->id()); } - varDialog->clear(); - for (int i = 0; i < static_cast(original()->pokemod())->dialogCount(); ++i) - { - const Dialog* dialog = static_cast(original()->pokemod())->dialog(i); - varDialog->addItem(dialog->dialog().mid(0, 25), dialog->id()); - } } void MapWarpUI::setGui() @@ -64,13 +56,7 @@ void MapWarpUI::setGui() const bool resetWarps = (static_cast(modified())->toMap() != m_lastMap); varName->setText(static_cast(modified())->name()); varCoordinate->setValue(static_cast(modified())->coordinate()); - for (int i = 0; i < varActivation->count(); ++i) - varActivation->item(i)->setSelected(static_cast(modified())->from(i)); - varDirectionOut->setCurrentIndex(static_cast(modified())->directionOut()); varType->setCurrentIndex(static_cast(modified())->type()); - varBiking->setCheckState((static_cast(modified())->isBiking() == Flag::On) ? Qt::Checked : ((static_cast(modified())->isBiking() == Flag::Off) ? Qt::Unchecked : Qt::PartiallyChecked)); - varFlash->setCheckState((static_cast(modified())->isFlash() == Flag::On) ? Qt::Checked : ((static_cast(modified())->isFlash() == Flag::Off) ? Qt::Unchecked : Qt::PartiallyChecked)); - varFog->setCheckState((static_cast(modified())->isFoggy() == Flag::On) ? Qt::Checked : ((static_cast(modified())->isFoggy() == Flag::Off) ? Qt::Unchecked : Qt::PartiallyChecked)); varToMap->setCurrentIndex(varToMap->findData(static_cast(modified())->toMap())); m_lastMap = static_cast(modified())->toMap(); if (resetWarps) @@ -87,8 +73,7 @@ void MapWarpUI::setGui() } } varToWarp->setCurrentIndex(varToMap->findData(static_cast(modified())->toWarp())); - varWorkingFlag->setValue(static_cast(modified())->workingFlag()); - varDialog->setCurrentIndex(varDialog->findData(static_cast(modified())->dialog())); + varScript->setValue(static_cast(modified())->script()); } void MapWarpUI::apply() @@ -114,37 +99,11 @@ void MapWarpUI::on_varCoordinate_valueChanged(const Point& coordinate) static_cast(modified())->setCoordinate(coordinate); } -void MapWarpUI::on_varActivation_itemSelectionChanged() -{ - for (int i = 0; i < varActivation->count(); ++i) - static_cast(modified())->setFrom(i, varActivation->item(i)->isSelected()); -} - -void MapWarpUI::on_varDirectionOut_activated(const int directionOut) -{ - static_cast(modified())->setDirectionOut(directionOut); -} - void MapWarpUI::on_varType_activated(const int type) { static_cast(modified())->setType(type); } -void MapWarpUI::on_varBiking_toggled(const int biking) -{ - static_cast(modified())->setIsBiking(biking); -} - -void MapWarpUI::on_varFlash_toggled(const int flash) -{ - static_cast(modified())->setIsFlash(flash); -} - -void MapWarpUI::on_varFog_toggled(const int fog) -{ - static_cast(modified())->setIsFoggy(fog); -} - void MapWarpUI::on_varToMap_activated(const int toMap) { static_cast(modified())->setToMap(toMap); @@ -155,13 +114,7 @@ void MapWarpUI::on_varToWarp_activated(const int toWarp) static_cast(modified())->setToWarp(toWarp); } -void MapWarpUI::on_varWorkingFlag_valueChanged(const Flag& workingFlag) -{ - static_cast(modified())->setWorkingFlag(workingFlag); -} - - -void MapWarpUI::on_varDialog_activated(const int dialog) +void MapWarpUI::on_varScript_valueChanged(const Script& script) { - static_cast(modified())->setDialog(varDialog->itemData(dialog).toInt()); + static_cast(modified())->setScript(script); } diff --git a/pokemodr/MapWarpUI.h b/pokemodr/MapWarpUI.h index 8ffb40a3..d5d0846f 100644 --- a/pokemodr/MapWarpUI.h +++ b/pokemodr/MapWarpUI.h @@ -40,16 +40,10 @@ class MapWarpUI : public ObjectUI, private Ui::formMapWarp protected slots: void on_varName_textChanged(const QString& name); void on_varCoordinate_valueChanged(const Point& coordinate); - void on_varActivation_itemSelectionChanged(); - void on_varDirectionOut_activated(const int directionOut); void on_varType_activated(const int type); - void on_varBiking_toggled(const int biking); - void on_varFlash_toggled(const int flash); - void on_varFog_toggled(const int fog); void on_varToMap_activated(const int toMap); void on_varToWarp_activated(const int toWarp); - void on_varWorkingFlag_valueChanged(const Flag& workingFlag); - void on_varDialog_activated(const int dialog); + void on_varScript_valueChanged(const Script& script); private slots: void initGui(); void refreshGui(); diff --git a/pokemodr/MapWildListUI.cpp b/pokemodr/MapWildListUI.cpp index e754abf0..c9e39b69 100644 --- a/pokemodr/MapWildListUI.cpp +++ b/pokemodr/MapWildListUI.cpp @@ -20,7 +20,6 @@ // Pokemod includes #include "../pokemod/Item.h" -#include "../pokemod/ItemEffect.h" #include "../pokemod/Pokemod.h" #include "../pokemod/MapWildList.h" #include "../pokemod/Time.h" @@ -43,20 +42,6 @@ void MapWildListUI::initGui() void MapWildListUI::refreshGui() { - varValue->clear(); - varScope->clear(); - for (int i = 0; i < static_cast(original()->pokemod())->itemCount(); ++i) - { - const Item* item = static_cast(original()->pokemod())->item(i); - for (int j = 0; j < item->effectCount(); ++j) - { - const ItemEffect* effect = item->effect(j); - if (effect->effect() == ItemEffect::E_Fish) - varValue->addItem(item->name(), effect->value2()); - else if (effect->effect() == ItemEffect::E_Scope) - varScope->addItem(item->name(), effect->value2()); - } - } varTimes->clear(); for (int i = 0; i < static_cast(original()->pokemod())->timeCount(); ++i) { @@ -69,15 +54,12 @@ void MapWildListUI::refreshGui() void MapWildListUI::setGui() { varControl->setCurrentIndex(static_cast(modified())->control()); - varValue->setEnabled(static_cast(modified())->control() == MapWildList::Fishing); - varValue->setCurrentIndex(varValue->findData(static_cast(modified())->value())); + varScript->setValue(static_cast(modified())->script()); for (int i = 0; i < varTimes->count(); ++i) { QListWidgetItem* widgetItem = varTimes->item(i); widgetItem->setSelected(static_cast(modified())->time(widgetItem->data(Qt::UserRole).toInt())); } - boxScope->setChecked(static_cast(modified())->scope() == INT_MAX); - varScope->setCurrentIndex(varScope->findData(static_cast(modified())->scope())); } void MapWildListUI::apply() @@ -98,9 +80,9 @@ void MapWildListUI::on_varControl_activated(const int control) static_cast(modified())->setControl(control); } -void MapWildListUI::on_varValue_activated(const int value) +void MapWildListUI::on_varScript_valueChanged(const Script& script) { - static_cast(modified())->setValue(varValue->itemData(value).toInt()); + static_cast(modified())->setScript(script); } void MapWildListUI::on_varTimes_itemSelectionChanged() @@ -111,14 +93,3 @@ void MapWildListUI::on_varTimes_itemSelectionChanged() static_cast(modified())->setTime(widgetItem->data(Qt::UserRole).toInt(), widgetItem->isSelected()); } } - -void MapWildListUI::on_boxScope_toggled(const bool scopeUsed) -{ - if (!scopeUsed) - static_cast(modified())->setScope(INT_MAX); -} - -void MapWildListUI::on_varScope_activated(const int scope) -{ - static_cast(modified())->setScope(varScope->itemData(scope).toInt()); -} diff --git a/pokemodr/MapWildListUI.h b/pokemodr/MapWildListUI.h index 3f9b1900..7bc56fbe 100644 --- a/pokemodr/MapWildListUI.h +++ b/pokemodr/MapWildListUI.h @@ -39,10 +39,8 @@ class MapWildListUI : public ObjectUI, private Ui::formMapWildList void discard(); protected slots: void on_varControl_activated(const int control); - void on_varValue_activated(const int value); + void on_varScript_valueChanged(const Script& script); void on_varTimes_itemSelectionChanged(); - void on_boxScope_toggled(const bool scopeUsed); - void on_varScope_activated(const int scope); private slots: void initGui(); void refreshGui(); diff --git a/pokemodr/MoveUI.cpp b/pokemodr/MoveUI.cpp index ccd68438..f531c46b 100644 --- a/pokemodr/MoveUI.cpp +++ b/pokemodr/MoveUI.cpp @@ -61,11 +61,6 @@ void MoveUI::setGui() varNumTargets->setValue(static_cast(modified())->numTargets()); varTargetChoice->setCurrentIndex(static_cast(modified())->targetChoice()); varSpecial->setChecked(static_cast(modified())->special() ? Qt::Checked : Qt::Unchecked); - varIgnoreAccuracy->setChecked(static_cast(modified())->ignoreAccuracy() ? Qt::Checked : Qt::Unchecked); - varCanFlinch->setChecked(static_cast(modified())->canFlinch() ? Qt::Checked : Qt::Unchecked); - varCanRandom->setChecked(static_cast(modified())->canRandom() ? Qt::Checked : Qt::Unchecked); - varCanSnatch->setChecked(static_cast(modified())->canSnatch() ? Qt::Checked : Qt::Unchecked); - varMakesSound->setChecked(static_cast(modified())->sound() ? Qt::Checked : Qt::Unchecked); varDescription->setPlainText(static_cast(modified())->description()); } @@ -122,34 +117,14 @@ void MoveUI::on_varSpecial_toggled(const bool special) static_cast(modified())->setSpecial(special); } -void MoveUI::on_varIgnoreAccuracy_toggled(const bool ignoreAccuracy) -{ - static_cast(modified())->setIgnoreAccuracy(ignoreAccuracy); -} - -void MoveUI::on_varCanFlinch_toggled(const bool canFlinch) -{ - static_cast(modified())->setCanFlinch(canFlinch); -} - -void MoveUI::on_varCanRandom_toggled(const bool canRandom) -{ - static_cast(modified())->setCanRandom(canRandom); -} - -void MoveUI::on_varCanSnatch_toggled(const bool canSnatch) -{ - static_cast(modified())->setCanSnatch(canSnatch); -} - -void MoveUI::on_varSound_toggled(const bool sound) -{ - static_cast(modified())->setSound(sound); -} - void MoveUI::on_varDescription_textChanged() { QTextCursor cursor = varDescription->textCursor(); static_cast(modified())->setDescription(varDescription->toPlainText()); varDescription->setTextCursor(cursor); } + +void MoveUI::on_varScript_valueChanged(const Script& script) +{ + static_cast(modified())->setScript(script); +} diff --git a/pokemodr/MoveUI.h b/pokemodr/MoveUI.h index 4ba00e3f..0b1d8719 100644 --- a/pokemodr/MoveUI.h +++ b/pokemodr/MoveUI.h @@ -46,12 +46,8 @@ class MoveUI : public ObjectUI, private Ui::formMove void on_varNumTargets_valueChanged(const int numTargets); void on_varTargetChoice_activated(const int targetChoice); void on_varSpecial_toggled(const bool special); - void on_varIgnoreAccuracy_toggled(const bool ignoreAccuracy); - void on_varCanFlinch_toggled(const bool canFlinch); - void on_varCanRandom_toggled(const bool canRandom); - void on_varCanSnatch_toggled(const bool canSnatch); - void on_varSound_toggled(const bool sound); void on_varDescription_textChanged(); + void on_varScript_valueChanged(const Script& script); private slots: void initGui(); void refreshGui(); diff --git a/pokemodr/PokemodUI.cpp b/pokemodr/PokemodUI.cpp index 1475b6d4..a3df0af0 100644 --- a/pokemodr/PokemodUI.cpp +++ b/pokemodr/PokemodUI.cpp @@ -85,8 +85,6 @@ void PokemodUI::setGui() } } varWarp->setCurrentIndex(varWarp->findData(static_cast(modified())->startWarp())); - varSuperPCUsername->setText(static_cast(modified())->superPCUname()); - varSuperPCPassword->setText(static_cast(modified())->superPCPasswd()); varWalkSkin->setIcon(static_cast(original())->walkSkin()); varBikeSkin->setIcon(static_cast(original())->bikeSkin()); varFlySkin->setIcon(static_cast(original())->flySkin()); @@ -135,16 +133,6 @@ void PokemodUI::on_varWarp_activated(const int warp) static_cast(modified())->setStartWarp(warp); } -void PokemodUI::on_varSuperPCUsername_textChanged(const QString& username) -{ - static_cast(modified())->setSuperPCUname(username); -} - -void PokemodUI::on_varSuperPCPassword_textChanged(const QString& password) -{ - static_cast(modified())->setSuperPCPasswd(password); -} - void PokemodUI::on_varWalkSkin_pressed() { FileDialog* dialog = new FileDialog(QSize(192, 168)); diff --git a/pokemodr/PokemodUI.h b/pokemodr/PokemodUI.h index f5064325..63038a0b 100644 --- a/pokemodr/PokemodUI.h +++ b/pokemodr/PokemodUI.h @@ -42,8 +42,6 @@ class PokemodUI : public ObjectUI, private Ui::formPokemod void on_varDescription_textChanged(); void on_varMap_activated(const int map); void on_varWarp_activated(const int warp); - void on_varSuperPCUsername_textChanged(const QString& username); - void on_varSuperPCPassword_textChanged(const QString& password); void on_varWalkSkin_pressed(); void on_varBikeSkin_pressed(); void on_varFlySkin_pressed(); diff --git a/pokemodr/ScriptWidget.cpp b/pokemodr/ScriptWidget.cpp new file mode 100644 index 00000000..8001199b --- /dev/null +++ b/pokemodr/ScriptWidget.cpp @@ -0,0 +1,58 @@ +/* + * Copyright 2008 Ben Boeckel + * + * 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 . + */ + +// Header include +#include "ScriptWidget.h" + +ScriptWidget::ScriptWidget(QWidget* parent, const Script& value) : + QWidget(parent), + m_value(value) +{ + setupUi(this); + varInterpreter->addItem("python"); + varInterpreter->addItem("ruby"); + varInterpreter->addItem("kjs"); +} + +Script ScriptWidget::value() const +{ + return m_value; +} + +void ScriptWidget::setValue(const Script& value) +{ + if (m_value == value) + return; + m_value = value; + varInterpreter->setEditText(m_value.interpreter()); + varScript->setPlainText(m_value.script()); + emit(valueChanged(m_value)); +} + +void ScriptWidget::on_varInterpreter_activated(const QString& interpreter) +{ + m_value.setInterpreter(interpreter); + emit(valueChanged(m_value)); +} + +void ScriptWidget::on_varScript_textChanged(const QString& script) +{ + QTextCursor cursor = varScript->textCursor(); + m_value.setScript(script); + varScript->setTextCursor(cursor); + emit(valueChanged(m_value)); +} diff --git a/pokemodr/ScriptWidget.h b/pokemodr/ScriptWidget.h new file mode 100644 index 00000000..1b0d536e --- /dev/null +++ b/pokemodr/ScriptWidget.h @@ -0,0 +1,49 @@ +/* + * Copyright 2008 Ben Boeckel + * + * 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 . + */ + +#ifndef __POKEMODR_SCRIPTWIDGET__ +#define __POKEMODR_SCRIPTWIDGET__ + +// Pokemod includes +#include "../pokemod/Script.h" + +// Qt includes +#include + +// Form include +#include "ui_script.h" + +class ScriptWidget : public QWidget, private Ui::formScript +{ + Q_OBJECT + + public: + ScriptWidget(QWidget* parent, const Script& value = Script("", "")); + + Script value() const; + signals: + void valueChanged(const Script&); + public slots: + void setValue(const Script& value); + protected slots: + void on_varInterpreter_activated(const QString& interpreter); + void on_varScript_textChanged(const QString& script); + private: + Script m_value; +}; + +#endif diff --git a/pokemodr/gui/ability.ui b/pokemodr/gui/ability.ui index cb9636a2..00641dbc 100644 --- a/pokemodr/gui/ability.ui +++ b/pokemodr/gui/ability.ui @@ -21,6 +21,18 @@ + + + + Script + + + + + + + + @@ -29,6 +41,11 @@ QLineEdit
klineedit.h
+ + ScriptWidget + QWidget +
../ScriptWidget.h
+
diff --git a/pokemodr/gui/badge.ui b/pokemodr/gui/badge.ui index 8727dba4..daa950f8 100644 --- a/pokemodr/gui/badge.ui +++ b/pokemodr/gui/badge.ui @@ -51,7 +51,7 @@ Qt::Horizontal - + 20 40 @@ -74,7 +74,7 @@ Qt::Horizontal - + 20 40 @@ -97,7 +97,7 @@ Qt::Horizontal - + 20 40 @@ -132,7 +132,7 @@ The multiplier to the stat in-game battles - + 1 @@ -182,6 +182,11 @@ QListWidget
klistwidget.h
+ + KPushButton + QPushButton +
kpushbutton.h
+
FractionWidget QWidget diff --git a/pokemodr/gui/coinlist.ui b/pokemodr/gui/coinlist.ui index 5a21eb60..ae4aa1ef 100644 --- a/pokemodr/gui/coinlist.ui +++ b/pokemodr/gui/coinlist.ui @@ -28,11 +28,7 @@
- - - The script that is used to determine whether the coin list is aple to be used or not - - + @@ -40,20 +36,15 @@ - - KComboBox - QComboBox -
kcombobox.h
-
KLineEdit QLineEdit
klineedit.h
- KTextEdit - QTextEdit -
ktextedit.h
+ ScriptWidget + QWidget +
../ScriptWidget.h
diff --git a/pokemodr/gui/flag.ui b/pokemodr/gui/flag.ui deleted file mode 100644 index 49ae08b8..00000000 --- a/pokemodr/gui/flag.ui +++ /dev/null @@ -1,39 +0,0 @@ - - formFlag - - - true - - - - - - The number of the flag - - - 0 - - - - - - - Whether the flag has to be on or off - - - State - - - - - - - - KIntNumInput - QWidget -
knuminput.h
-
-
- - -
diff --git a/pokemodr/gui/globalscript.ui b/pokemodr/gui/globalscript.ui new file mode 100644 index 00000000..8d1a8854 --- /dev/null +++ b/pokemodr/gui/globalscript.ui @@ -0,0 +1,49 @@ + + formGlobalScript + + + + + + Name + + + + + + true + + + + + + + + + + Script + + + + + + + + + + + + + KLineEdit + QLineEdit +
klineedit.h
+
+ + ScriptWidget + QWidget +
../ScriptWidget.h
+
+
+ + +
diff --git a/pokemodr/gui/item.ui b/pokemodr/gui/item.ui index fe1a1418..e3732693 100644 --- a/pokemodr/gui/item.ui +++ b/pokemodr/gui/item.ui @@ -88,12 +88,24 @@ + + + + Script + + + + + + + + Qt::Vertical - + 20 40 @@ -124,6 +136,11 @@ QTextEdit
ktextedit.h
+ + ScriptWidget + QWidget +
../ScriptWidget.h
+
diff --git a/pokemodr/gui/mapeffect.ui b/pokemodr/gui/mapeffect.ui index cb2cf18b..a4c4375a 100644 --- a/pokemodr/gui/mapeffect.ui +++ b/pokemodr/gui/mapeffect.ui @@ -51,7 +51,7 @@ Qt::Horizontal - + 20 40 @@ -77,7 +77,7 @@ Qt::Horizontal - + 20 40 @@ -89,36 +89,27 @@
- + - Script + Is Transparent - - - - - The script that controls the effect - - - - + + true + + + false + + - + - Flags + Script - - - If checked, the effect is able to be walked through - - - Ghost - - + @@ -126,16 +117,6 @@ - - KComboBox - QComboBox -
kcombobox.h
-
- - KIntNumInput - QWidget -
knuminput.h
-
KLineEdit QLineEdit @@ -147,14 +128,14 @@
kpushbutton.h
- PointWidget + ScriptWidget QWidget -
../PointWidget.h
+
../ScriptWidget.h
- KTextEdit - QTextEdit -
ktextedit.h
+ PointWidget + QWidget +
../PointWidget.h
diff --git a/pokemodr/gui/maptrainer.ui b/pokemodr/gui/maptrainer.ui index 5a784455..58c5126f 100644 --- a/pokemodr/gui/maptrainer.ui +++ b/pokemodr/gui/maptrainer.ui @@ -49,41 +49,6 @@
- - - - Sight - - - - - - How far the trainer can see - - - 0 - - - - - - - - - - Direction - - - - - - Direction the trainer faces - - - - - - @@ -104,30 +69,13 @@ - - - The flag that determines whether the trainer is active or not - + - Appear Flag + Script - - true - - - - - - - Dialog - - + - - - The dialog used when the trainer is encountered - - + @@ -167,15 +115,14 @@
klineedit.h
- PointWidget + ScriptWidget QWidget -
../PointWidget.h
+
../ScriptWidget.h
- FlagWidget - QGroupBox -
../FlagWidget.h
- 1 + PointWidget + QWidget +
../PointWidget.h
diff --git a/pokemodr/gui/mapwarp.ui b/pokemodr/gui/mapwarp.ui index f4600225..844cffc2 100644 --- a/pokemodr/gui/mapwarp.ui +++ b/pokemodr/gui/mapwarp.ui @@ -37,38 +37,6 @@
- - - - Activation - - - - - - Directions, that when walked into from, the warp is activated - - - - - - - - - - Direction Out - - - - - - Direction the warp pushes things when arrived at - - - - - - @@ -85,54 +53,6 @@ - - - - Flags - - - - - - Whether to force, allow, of disable biking when going through - - - Biking - - - true - - - - - - - Whether to force, allow, of disable darkness when going through - - - Flash - - - true - - - - - - - Whether to force, allow, of disable fog when going through - - - Fog - - - true - - - - - - @@ -160,36 +80,21 @@ + varToWarp + boxScript - - - The flag that controls whether the warp is active or not - + - Working Flag - - - true - - - - - - - Dialog + Script - - - The dialog to parse when the warp is activated - - + @@ -208,21 +113,15 @@
klineedit.h
- KListWidget - QListWidget -
klistwidget.h
+ ScriptWidget + QWidget +
../ScriptWidget.h
PointWidget QWidget
../PointWidget.h
- - FlagWidget - QGroupBox -
../FlagWidget.h
- 1 -
diff --git a/pokemodr/gui/mapwildlist.ui b/pokemodr/gui/mapwildlist.ui index ba0e9aac..00897af7 100644 --- a/pokemodr/gui/mapwildlist.ui +++ b/pokemodr/gui/mapwildlist.ui @@ -15,57 +15,34 @@
- - - - Value - - - - - - Value of the controlling factor - - - - - - - + - Times + Script - - - Times when the list is active - - - QAbstractItemView::ExtendedSelection - - + - + - Scope - - - true + Times - + - Scope needed to see encounters (-1 for none) + Times when the list is active + + + QAbstractItemView::ExtendedSelection @@ -85,6 +62,11 @@ QListWidget
klistwidget.h
+ + ScriptWidget + QWidget +
../ScriptWidget.h
+
diff --git a/pokemodr/gui/mapwildlistencounter.ui b/pokemodr/gui/mapwildlistencounter.ui index a0b2928d..df8e1fc2 100644 --- a/pokemodr/gui/mapwildlistencounter.ui +++ b/pokemodr/gui/mapwildlistencounter.ui @@ -3,7 +3,7 @@ - + Species @@ -19,7 +19,7 @@ - + Level @@ -38,7 +38,7 @@ - + Weight diff --git a/pokemodr/gui/move.ui b/pokemodr/gui/move.ui index bf10657a..a236cb09 100644 --- a/pokemodr/gui/move.ui +++ b/pokemodr/gui/move.ui @@ -143,72 +143,11 @@ - + - Flags + Special - - - - - If checked, the move uses the Special stat(s) rather than the physical - - - Special - - - - - - - If checked, the move ignores any accuracy-affecting items the enemy may be holding - - - Ignore Accuracy - - - - - - - If checked, the move can make the target flinch with items - - - Can Flinch - - - - - - - If checked, Metronome-like moves can use this move - - - Randomizable - - - - - - - If checked, the effects can be stolen - - - Can Snatch - - - - - - - If checked, the move makes sound - - - Makes Sound - - - - + @@ -235,7 +174,7 @@ Qt::Vertical - + 20 40 @@ -243,6 +182,18 @@ + + + + Script + + + + + + + + @@ -271,6 +222,11 @@ QWidget
../FractionWidget.h
+ + ScriptWidget + QWidget +
../ScriptWidget.h
+
diff --git a/pokemodr/gui/nature.ui b/pokemodr/gui/nature.ui index 98aeb4f2..13271169 100644 --- a/pokemodr/gui/nature.ui +++ b/pokemodr/gui/nature.ui @@ -42,7 +42,7 @@ The multiplier of the stat - + 1
diff --git a/pokemodr/gui/pokemod.ui b/pokemodr/gui/pokemod.ui index 618375e4..1660f9e8 100644 --- a/pokemodr/gui/pokemod.ui +++ b/pokemodr/gui/pokemod.ui @@ -4,6 +4,9 @@ + + 0 + General @@ -98,59 +101,12 @@
- - - - Super PC - - - - - - Username - - - - - - Username to access the Super PC - - - true - - - - - - - - - - Password - - - - - - Password to access the Super PC - - - true - - - - - - - - - Qt::Vertical - + 20 40 @@ -176,6 +132,12 @@ Qt::Horizontal + + + 0 + 0 + + @@ -193,6 +155,12 @@ Qt::Horizontal + + + 0 + 0 + + @@ -209,6 +177,12 @@ Qt::Horizontal + + + 0 + 0 + + @@ -226,6 +200,12 @@ Qt::Horizontal + + + 0 + 0 + + @@ -242,6 +222,12 @@ Qt::Horizontal + + + 0 + 0 + + @@ -259,6 +245,12 @@ Qt::Horizontal + + + 0 + 0 + + @@ -275,6 +267,12 @@ Qt::Horizontal + + + 0 + 0 + + @@ -292,6 +290,12 @@ Qt::Horizontal + + + 0 + 0 + + @@ -308,6 +312,12 @@ Qt::Horizontal + + + 0 + 0 + + @@ -325,6 +335,12 @@ Qt::Horizontal + + + 0 + 0 + + @@ -341,6 +357,12 @@ Qt::Horizontal + + + 0 + 0 + + @@ -358,6 +380,12 @@ Qt::Horizontal + + + 0 + 0 + + @@ -368,7 +396,7 @@ Qt::Vertical - + 20 40 @@ -404,7 +432,7 @@ Qt::Vertical - + 20 40 @@ -424,11 +452,6 @@ QComboBox
kcombobox.h
- - KIntNumInput - QWidget -
knuminput.h
-
KLineEdit QLineEdit @@ -439,15 +462,16 @@ QPushButton
kpushbutton.h
- - KTextEdit - QTextEdit -
ktextedit.h
-
KTabWidget QTabWidget
ktabwidget.h
+ 1 +
+ + KTextEdit + QTextEdit +
ktextedit.h
FractionWidget diff --git a/pokemodr/gui/script.ui b/pokemodr/gui/script.ui new file mode 100644 index 00000000..62d6a2ce --- /dev/null +++ b/pokemodr/gui/script.ui @@ -0,0 +1,52 @@ + + formScript + + + + + + Interpreter + + + + + + true + + + false + + + + + + + + + + Code + + + + + + + + + + + + + KComboBox + QComboBox +
kcombobox.h
+
+ + KTextEdit + QTextEdit +
ktextedit.h
+
+
+ + +
diff --git a/pokemodr/gui/species.ui b/pokemodr/gui/species.ui index cd87a91d..30d25a07 100644 --- a/pokemodr/gui/species.ui +++ b/pokemodr/gui/species.ui @@ -4,6 +4,9 @@ + + 3 + General @@ -96,11 +99,11 @@ - + Qt::Vertical - + 20 40 @@ -229,7 +232,7 @@ Qt::Vertical - + 20 40 @@ -241,7 +244,7 @@ - PokéDex + Pokédex @@ -332,7 +335,7 @@ Qt::Vertical - + 20 40 @@ -427,12 +430,24 @@ + + + + Evolution Script + + + + + + + + Qt::Vertical - + 20 40 @@ -458,14 +473,20 @@ Qt::Horizontal + + + 0 + 0 + + - 64 - 64 + 128 + 128 @@ -475,14 +496,20 @@ Qt::Horizontal + + + 0 + 0 + + - 64 - 64 + 128 + 128 @@ -492,6 +519,12 @@ Qt::Horizontal + + + 0 + 0 + + @@ -508,14 +541,20 @@ Qt::Horizontal + + + 0 + 0 + + - 64 - 64 + 128 + 128 @@ -525,14 +564,20 @@ Qt::Horizontal + + + 0 + 0 + + - 64 - 64 + 128 + 128 @@ -542,6 +587,12 @@ Qt::Horizontal + + + 0 + 0 + + @@ -558,6 +609,12 @@ Qt::Horizontal + + + 0 + 0 + + @@ -575,6 +632,12 @@ Qt::Horizontal + + + 0 + 0 + + @@ -585,7 +648,7 @@ Qt::Vertical - + 20 40 @@ -626,21 +689,27 @@ QPushButton
kpushbutton.h
- - KTextEdit - QTextEdit -
ktextedit.h
-
KTabWidget QTabWidget
ktabwidget.h
+ 1 +
+ + KTextEdit + QTextEdit +
ktextedit.h
FractionWidget QWidget
../FractionWidget.h
+ + ScriptWidget + QWidget +
../ScriptWidget.h
+
diff --git a/pokemodr/gui/tile.ui b/pokemodr/gui/tile.ui index 0382f871..808a839a 100644 --- a/pokemodr/gui/tile.ui +++ b/pokemodr/gui/tile.ui @@ -32,7 +32,7 @@ Qt::Horizontal - + 20 40 @@ -58,7 +58,7 @@ Qt::Horizontal - + 20 40 diff --git a/pokemodr/gui/trainer.ui b/pokemodr/gui/trainer.ui index d95a72d5..7a6ef271 100644 --- a/pokemodr/gui/trainer.ui +++ b/pokemodr/gui/trainer.ui @@ -45,7 +45,7 @@ Qt::Horizontal - + 20 40 @@ -71,7 +71,7 @@ Qt::Horizontal - + 20 40 diff --git a/pokemodr/gui/type.ui b/pokemodr/gui/type.ui index 8615bbd2..71dc8903 100644 --- a/pokemodr/gui/type.ui +++ b/pokemodr/gui/type.ui @@ -32,7 +32,7 @@ Multiplier for species with this type for using a move of this type - + 1 diff --git a/pokemodr/models/AbilityModel.cpp b/pokemodr/models/AbilityModel.cpp index 9a3f6b76..a76a6c87 100644 --- a/pokemodr/models/AbilityModel.cpp +++ b/pokemodr/models/AbilityModel.cpp @@ -18,28 +18,22 @@ // Header include #include "AbilityModel.h" -// Model includes -#include "AbilityEffectModel.h" - // PokeModr includes #include "../AbilityUI.h" // Pokemod includes #include "../../pokemod/Ability.h" -#include "../../pokemod/Pokemod.h" // Qt includes #include AbilityModel::AbilityModel(BaseModel* parent, Ability* ability) : - GroupObjectModel(parent, ability) + ObjectModel(parent, ability) { - setupData(); } AbilityModel::~AbilityModel() { - clearData(); } QVariant AbilityModel::data(int role) const @@ -57,7 +51,7 @@ QVariant AbilityModel::data(int role) const QWidget* widget = new AbilityUI(static_cast(m_object), NULL); return QVariant::fromValue(widget); } - return GroupObjectModel::data(role); + return ObjectModel::data(role); } bool AbilityModel::setData(const QVariant& value, int role) @@ -72,9 +66,7 @@ bool AbilityModel::setData(const QVariant& value, int role) { if (xml.doctype().name() == m_object->className()) { - clearData(); m_object->load(xml.documentElement()); - setupData(); return true; } file.close(); @@ -83,28 +75,3 @@ bool AbilityModel::setData(const QVariant& value, int role) } return false; } - -bool AbilityModel::insertRows(const int rows) -{ - for (int i = 0; i < rows; ++i) - m_objects.append(new AbilityEffectModel(this, static_cast(m_object)->newEffect())); - return true; -} - -bool AbilityModel::removeRows(const int position, const int rows) -{ - for (int i = 0; i < rows; ++i) - { - static_cast(m_object)->deleteEffect(position); - delete m_objects[position]; - m_objects.removeAt(position); - } - return true; -} - -void AbilityModel::setupData() -{ - Ability* ability = static_cast(m_object); - for (int i = 0; i < ability->effectCount(); ++i) - m_objects.append(new AbilityEffectModel(this, ability->effect(i))); -} diff --git a/pokemodr/models/AbilityModel.h b/pokemodr/models/AbilityModel.h index 23a87699..005b1066 100644 --- a/pokemodr/models/AbilityModel.h +++ b/pokemodr/models/AbilityModel.h @@ -19,13 +19,12 @@ #define __POKEMODR_ABILITYMODEL__ // Model includes -#include "GroupObjectModel.h" +#include "ObjectModel.h" // Forward declarations class Ability; -class AbilityEffectModel; -class AbilityModel : public GroupObjectModel +class AbilityModel : public ObjectModel { public: AbilityModel(BaseModel* parent, Ability* ability); @@ -34,12 +33,6 @@ class AbilityModel : public GroupObjectModel QVariant data(int role = Qt::DisplayRole) const; bool setData(const QVariant& value, int role = Qt::EditRole); - - bool insertRows(const int rows); - - bool removeRows(const int position, const int rows); - protected: - void setupData(); }; #endif diff --git a/pokemodr/models/AuthorModel.cpp b/pokemodr/models/AuthorModel.cpp index 2daa76ab..c2597098 100644 --- a/pokemodr/models/AuthorModel.cpp +++ b/pokemodr/models/AuthorModel.cpp @@ -23,7 +23,6 @@ // Pokemod includes #include "../../pokemod/Author.h" -#include "../../pokemod/Pokemod.h" // Qt includes #include diff --git a/pokemodr/models/BadgeModel.cpp b/pokemodr/models/BadgeModel.cpp index 275016eb..f750255e 100644 --- a/pokemodr/models/BadgeModel.cpp +++ b/pokemodr/models/BadgeModel.cpp @@ -23,7 +23,6 @@ // Pokemod includes #include "../../pokemod/Badge.h" -#include "../../pokemod/Pokemod.h" // Qt includes #include diff --git a/pokemodr/models/CoinListModel.cpp b/pokemodr/models/CoinListModel.cpp index 167d9070..fa5f8a0d 100644 --- a/pokemodr/models/CoinListModel.cpp +++ b/pokemodr/models/CoinListModel.cpp @@ -26,7 +26,6 @@ // Pokemod includes #include "../../pokemod/CoinList.h" -#include "../../pokemod/Pokemod.h" // Qt includes #include diff --git a/pokemodr/models/EggGroupModel.cpp b/pokemodr/models/EggGroupModel.cpp index 1e25b26d..78adf60b 100644 --- a/pokemodr/models/EggGroupModel.cpp +++ b/pokemodr/models/EggGroupModel.cpp @@ -23,7 +23,6 @@ // Pokemod includes #include "../../pokemod/EggGroup.h" -#include "../../pokemod/Pokemod.h" // Qt includes #include diff --git a/pokemodr/models/GlobalScriptGroupModel.cpp b/pokemodr/models/GlobalScriptGroupModel.cpp new file mode 100644 index 00000000..ad2ee2b6 --- /dev/null +++ b/pokemodr/models/GlobalScriptGroupModel.cpp @@ -0,0 +1,60 @@ +/* + * Copyright 2008 Ben Boeckel + * + * 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 . + */ + +// Header include +#include "GlobalScriptGroupModel.h" + +// Model includes +#include "GlobalScriptModel.h" + +// Pokemod includes +#include "../../pokemod/Pokemod.h" + +GlobalScriptGroupModel::GlobalScriptGroupModel(BaseModel* parent, Pokemod* pokemod) : + GroupModel(parent, pokemod, "Global Scripts") +{ + setupData(); +} + +GlobalScriptGroupModel::~GlobalScriptGroupModel() +{ +} + +bool GlobalScriptGroupModel::insertRows(const int rows) +{ + for (int i = 0; i < rows; ++i) + m_objects.append(new GlobalScriptModel(this, static_cast(m_object)->newGlobalScript())); + return true; +} + +bool GlobalScriptGroupModel::removeRows(const int position, const int rows) +{ + for (int i = 0; i < rows; ++i) + { + static_cast(m_object)->deleteGlobalScript(position); + delete m_objects[position]; + m_objects.removeAt(position); + } + return true; +} + +void GlobalScriptGroupModel::setupData() +{ + Pokemod* pokemod = static_cast(m_object); + for (int i = 0; i < pokemod->globalScriptCount(); ++i) + m_objects.append(new GlobalScriptModel(this, pokemod->globalScript(i))); +} diff --git a/pokemodr/models/GlobalScriptGroupModel.h b/pokemodr/models/GlobalScriptGroupModel.h new file mode 100644 index 00000000..40796e41 --- /dev/null +++ b/pokemodr/models/GlobalScriptGroupModel.h @@ -0,0 +1,40 @@ +/* + * Copyright 2008 Ben Boeckel + * + * 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 . + */ + +#ifndef __POKEMODR_GLOBALSCRIPTGROUPMODEL__ +#define __POKEMODR_GLOBALSCRIPTGROUPMODEL__ + +// Model includes +#include "GroupModel.h" + +// Forward declarations +class Pokemod; + +class GlobalScriptGroupModel : public GroupModel +{ + public: + GlobalScriptGroupModel(BaseModel* parent, Pokemod* pokemod); + ~GlobalScriptGroupModel(); + + bool insertRows(const int rows); + + bool removeRows(const int position, const int rows); + protected: + void setupData(); +}; + +#endif diff --git a/pokemodr/models/GlobalScriptModel.cpp b/pokemodr/models/GlobalScriptModel.cpp new file mode 100644 index 00000000..25db22b6 --- /dev/null +++ b/pokemodr/models/GlobalScriptModel.cpp @@ -0,0 +1,77 @@ +/* + * Copyright 2008 Ben Boeckel + * + * 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 . + */ + +// Header include +#include "GlobalScriptModel.h" + +// PokeModr includes +#include "../GlobalScriptUI.h" + +// Pokemod includes +#include "../../pokemod/GlobalScript.h" + +// Qt includes +#include + +GlobalScriptModel::GlobalScriptModel(BaseModel* parent, GlobalScript* globalScript) : + ObjectModel(parent, globalScript) +{ +} + +GlobalScriptModel::~GlobalScriptModel() +{ +} + +QVariant GlobalScriptModel::data(int role) const +{ + if (role == Qt::DisplayRole) + return static_cast(m_object)->name(); + else if (role == BaseModel::XmlRole) + { + QDomDocument xml(m_object->className()); + xml.appendChild(m_object->save()); + return xml.toString(); + } + else if (role == BaseModel::WidgetRole) + { + QWidget* widget = new GlobalScriptUI(static_cast(m_object), NULL); + return QVariant::fromValue(widget); + } + return ObjectModel::data(role); +} + +bool GlobalScriptModel::setData(const QVariant& value, int role) +{ + if (role == BaseModel::XmlRole) + { + if (value.canConvert()) + { + QFile file(value.toString()); + QDomDocument xml; + if ((file.open(QIODevice::ReadOnly) && xml.setContent(&file)) || xml.setContent(value.toString())) + { + if (xml.doctype().name() == m_object->className()) + { + m_object->load(xml.documentElement()); + return true; + } + file.close(); + } + } + } + return false; +} diff --git a/pokemodr/models/GlobalScriptModel.h b/pokemodr/models/GlobalScriptModel.h new file mode 100644 index 00000000..29a0028d --- /dev/null +++ b/pokemodr/models/GlobalScriptModel.h @@ -0,0 +1,38 @@ +/* + * Copyright 2008 Ben Boeckel + * + * 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 . + */ + +#ifndef __POKEMODR_GLOBALSCRIPTMODEL__ +#define __POKEMODR_GLOBALSCRIPTMODEL__ + +// Model includes +#include "ObjectModel.h" + +// Forward declarations +class GlobalScript; + +class GlobalScriptModel : public ObjectModel +{ + public: + GlobalScriptModel(BaseModel* parent, GlobalScript* globalScript); + ~GlobalScriptModel(); + + QVariant data(int role = Qt::DisplayRole) const; + + bool setData(const QVariant& value, int role = Qt::EditRole); +}; + +#endif diff --git a/pokemodr/models/ItemModel.cpp b/pokemodr/models/ItemModel.cpp index daa5f903..66968cf7 100644 --- a/pokemodr/models/ItemModel.cpp +++ b/pokemodr/models/ItemModel.cpp @@ -18,28 +18,22 @@ // Header include #include "ItemModel.h" -// Model includes -#include "ItemEffectModel.h" - // PokeModr includes #include "../ItemUI.h" // Pokemod includes #include "../../pokemod/Item.h" -#include "../../pokemod/Pokemod.h" // Qt includes #include ItemModel::ItemModel(BaseModel* parent, Item* item) : - GroupObjectModel(parent, item) + ObjectModel(parent, item) { - setupData(); } ItemModel::~ItemModel() { - clearData(); } QVariant ItemModel::data(int role) const @@ -57,7 +51,7 @@ QVariant ItemModel::data(int role) const QWidget* widget = new ItemUI(static_cast(m_object), NULL); return QVariant::fromValue(widget); } - return GroupObjectModel::data(role); + return ObjectModel::data(role); } bool ItemModel::setData(const QVariant& value, int role) @@ -72,9 +66,7 @@ bool ItemModel::setData(const QVariant& value, int role) { if (xml.doctype().name() == m_object->className()) { - clearData(); m_object->load(xml.documentElement()); - setupData(); return true; } file.close(); @@ -83,28 +75,3 @@ bool ItemModel::setData(const QVariant& value, int role) } return false; } - -bool ItemModel::insertRows(const int rows) -{ - for (int i = 0; i < rows; ++i) - m_objects.append(new ItemEffectModel(this, static_cast(m_object)->newEffect())); - return true; -} - -bool ItemModel::removeRows(const int position, const int rows) -{ - for (int i = 0; i < rows; ++i) - { - static_cast(m_object)->deleteEffect(position); - delete m_objects[position]; - m_objects.removeAt(position); - } - return true; -} - -void ItemModel::setupData() -{ - Item* item = static_cast(m_object); - for (int i = 0; i < item->effectCount(); ++i) - m_objects.append(new ItemEffectModel(this, item->effect(i))); -} diff --git a/pokemodr/models/ItemModel.h b/pokemodr/models/ItemModel.h index bc0419d6..ad126f20 100644 --- a/pokemodr/models/ItemModel.h +++ b/pokemodr/models/ItemModel.h @@ -19,13 +19,12 @@ #define __POKEMODR_ITEMMODEL__ // Model includes -#include "GroupObjectModel.h" +#include "ObjectModel.h" // Forward declarations class Item; -class ItemEffectModel; -class ItemModel : public GroupObjectModel +class ItemModel : public ObjectModel { public: ItemModel(BaseModel* parent, Item* item); @@ -34,12 +33,6 @@ class ItemModel : public GroupObjectModel QVariant data(int role = Qt::DisplayRole) const; bool setData(const QVariant& value, int role = Qt::EditRole); - - bool insertRows(const int rows); - - bool removeRows(const int position, const int rows); - protected: - void setupData(); }; #endif diff --git a/pokemodr/models/ItemTypeModel.cpp b/pokemodr/models/ItemTypeModel.cpp index ffe92bc3..5ed25951 100644 --- a/pokemodr/models/ItemTypeModel.cpp +++ b/pokemodr/models/ItemTypeModel.cpp @@ -23,7 +23,6 @@ // Pokemod includes #include "../../pokemod/ItemType.h" -#include "../../pokemod/Pokemod.h" // Qt includes #include diff --git a/pokemodr/models/MapModel.cpp b/pokemodr/models/MapModel.cpp index 4fc65ae1..57d5e5ee 100644 --- a/pokemodr/models/MapModel.cpp +++ b/pokemodr/models/MapModel.cpp @@ -29,7 +29,6 @@ // Map includes #include "../../pokemod/Map.h" -#include "../../pokemod/Pokemod.h" // Qt includes #include diff --git a/pokemodr/models/MoveModel.cpp b/pokemodr/models/MoveModel.cpp index f0db1dfd..5799e374 100644 --- a/pokemodr/models/MoveModel.cpp +++ b/pokemodr/models/MoveModel.cpp @@ -18,28 +18,22 @@ // Header include #include "MoveModel.h" -// Model includes -#include "MoveEffectModel.h" - // PokeModr includes #include "../MoveUI.h" // Pokemod includes #include "../../pokemod/Move.h" -#include "../../pokemod/Pokemod.h" // Qt includes #include MoveModel::MoveModel(BaseModel* parent, Move* move) : - GroupObjectModel(parent, move) + ObjectModel(parent, move) { - setupData(); } MoveModel::~MoveModel() { - clearData(); } QVariant MoveModel::data(int role) const @@ -57,7 +51,7 @@ QVariant MoveModel::data(int role) const QWidget* widget = new MoveUI(static_cast(m_object), NULL); return QVariant::fromValue(widget); } - return GroupObjectModel::data(role); + return ObjectModel::data(role); } bool MoveModel::setData(const QVariant& value, int role) @@ -72,9 +66,7 @@ bool MoveModel::setData(const QVariant& value, int role) { if (xml.doctype().name() == m_object->className()) { - clearData(); m_object->load(xml.documentElement()); - setupData(); return true; } file.close(); @@ -83,28 +75,3 @@ bool MoveModel::setData(const QVariant& value, int role) } return false; } - -bool MoveModel::insertRows(const int rows) -{ - for (int i = 0; i < rows; ++i) - m_objects.append(new MoveEffectModel(this, static_cast(m_object)->newEffect())); - return true; -} - -bool MoveModel::removeRows(const int position, const int rows) -{ - for (int i = 0; i < rows; ++i) - { - static_cast(m_object)->deleteEffect(position); - delete m_objects[position]; - m_objects.removeAt(position); - } - return true; -} - -void MoveModel::setupData() -{ - Move* move = static_cast(m_object); - for (int i = 0; i < move->effectCount(); ++i) - m_objects.append(new MoveEffectModel(this, move->effect(i))); -} diff --git a/pokemodr/models/MoveModel.h b/pokemodr/models/MoveModel.h index f6b89de5..cc8df8ac 100644 --- a/pokemodr/models/MoveModel.h +++ b/pokemodr/models/MoveModel.h @@ -19,13 +19,12 @@ #define __POKEMODR_MOVEMODEL__ // Model includes -#include "GroupObjectModel.h" +#include "ObjectModel.h" // Forward declarations class Move; -class MoveEffectModel; -class MoveModel : public GroupObjectModel +class MoveModel : public ObjectModel { public: MoveModel(BaseModel* parent, Move* move); @@ -34,12 +33,6 @@ class MoveModel : public GroupObjectModel QVariant data(int role = Qt::DisplayRole) const; bool setData(const QVariant& value, int role = Qt::EditRole); - - bool insertRows(const int rows); - - bool removeRows(const int position, const int rows); - protected: - void setupData(); }; #endif diff --git a/pokemodr/models/PokemodModel.cpp b/pokemodr/models/PokemodModel.cpp index 3309107a..01c9cf5a 100644 --- a/pokemodr/models/PokemodModel.cpp +++ b/pokemodr/models/PokemodModel.cpp @@ -23,8 +23,8 @@ #include "AuthorGroupModel.h" #include "BadgeGroupModel.h" #include "CoinListGroupModel.h" -#include "DialogGroupModel.h" #include "EggGroupGroupModel.h" +#include "GlobalScriptGroupModel.h" #include "ItemGroupModel.h" #include "ItemTypeGroupModel.h" #include "MapGroupModel.h" @@ -118,8 +118,8 @@ void PokemodModel::setupData() m_objects.append(new AuthorGroupModel(this, static_cast(m_object))); m_objects.append(new BadgeGroupModel(this, static_cast(m_object))); m_objects.append(new CoinListGroupModel(this, static_cast(m_object))); - m_objects.append(new DialogGroupModel(this, static_cast(m_object))); m_objects.append(new EggGroupGroupModel(this, static_cast(m_object))); + m_objects.append(new GlobalScriptGroupModel(this, static_cast(m_object))); m_objects.append(new ItemGroupModel(this, static_cast(m_object))); m_objects.append(new ItemTypeGroupModel(this, static_cast(m_object))); m_objects.append(new MapGroupModel(this, static_cast(m_object))); diff --git a/pokemodr/models/SpeciesModel.cpp b/pokemodr/models/SpeciesModel.cpp index 60463cbf..4bacbeff 100644 --- a/pokemodr/models/SpeciesModel.cpp +++ b/pokemodr/models/SpeciesModel.cpp @@ -20,7 +20,6 @@ // Model includes #include "SpeciesAbilityGroupModel.h" -#include "SpeciesEvolutionGroupModel.h" #include "SpeciesItemGroupModel.h" #include "SpeciesMoveGroupModel.h" @@ -100,7 +99,6 @@ bool SpeciesModel::removeRows(const int /*position*/, const int /*rows*/) void SpeciesModel::setupData() { m_objects.append(new SpeciesAbilityGroupModel(this, static_cast(m_object))); - m_objects.append(new SpeciesEvolutionGroupModel(this, static_cast(m_object))); m_objects.append(new SpeciesItemGroupModel(this, static_cast(m_object))); m_objects.append(new SpeciesMoveGroupModel(this, static_cast(m_object))); } diff --git a/pokemodr/pokemodr.pro b/pokemodr/pokemodr.pro index d7366f94..62f0cee6 100644 --- a/pokemodr/pokemodr.pro +++ b/pokemodr/pokemodr.pro @@ -38,7 +38,6 @@ SOURCES += AbilityUI.cpp \ CoinListObjectUI.cpp \ EggGroupUI.cpp \ FileDialog.cpp \ - FlagWidget.cpp \ FractionWidget.cpp \ GlobalScriptUI.cpp \ ItemUI.cpp \ @@ -142,7 +141,6 @@ HEADERS += AbilityUI.h \ CoinListObjectUI.h \ EggGroupUI.h \ FileDialog.h \ - FlagWidget.h \ FractionWidget.h \ GlobalScriptUI.h \ ItemUI.h \ @@ -246,10 +244,9 @@ FORMS += gui/ability.ui \ gui/badge.ui \ gui/coinlist.ui \ gui/coinlistobject.ui \ - gui/dialog.ui \ gui/egggroup.ui \ - gui/flag.ui \ gui/fraction.ui \ + gui/globalscript.ui \ gui/item.ui \ gui/itemtype.ui \ gui/map.ui \ -- cgit