From e858d98977a09b3c8faf4df87ada4abc1399e8e5 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Tue, 22 May 2007 03:51:45 +0000 Subject: Added a lot of minor PokéMod modules MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@12 6ecfd1a5-f3ed-3746-8530-beee90d26b22 --- pokemod/ItemStorage.cpp | 152 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 152 insertions(+) create mode 100644 pokemod/ItemStorage.cpp (limited to 'pokemod/ItemStorage.cpp') diff --git a/pokemod/ItemStorage.cpp b/pokemod/ItemStorage.cpp new file mode 100644 index 00000000..b7466f3e --- /dev/null +++ b/pokemod/ItemStorage.cpp @@ -0,0 +1,152 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: pokemod/ItemStorage.cpp +// Purpose: Define a type of item and how much can be stored +// Author: Ben Boeckel +// Modified by: Ben Boeckel +// Created: Tue Mar 20 18:06:40 2007 +// Copyright: ©2007 Ben Boeckel and Nerdy Productions +// Licence: +// 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 2 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, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +///////////////////////////////////////////////////////////////////////////// + +#include "ItemStorage.h" + +PokeGen::PokeMod::ItemStorage::ItemStorage(unsigned _id) +{ + LogCtor("ItemStorage", _id); + name = ""; + computer = 0; + player = 1; + id = _id; +} + +PokeGen::PokeMod::ItemStorage::ItemStorage(Ini &ini, unsigned _id) +{ + LogCtorIni("ItemStorage", _id); + ImportIni(ini); + if(_id == UINT_MAX) + LogIdError("ItemStorage"); +} + +PokeGen::PokeMod::ItemStorage::~ItemStorage() +{ + LogDtor("ItemStorage", id, name); +} + +void PokeGen::PokeMod::ItemStorage::Validate() +{ + isValid = true; + LogValidateStart("ItemStorage", id, name); + if (name == "") + { + LogVarNotSet("ItemStorage", id, "name"); + isValid = false; + } + if (!player) + { + LogVarNotValid("ItemStorage", id, "player"); + isValid = false; + } + LogValidateOver("ItemStorage", id, isValid, name); +} + +#ifdef PG_DEBUG_WINDOW +void PokeGen::PokeMod::ItemStorage::Validate(const wxListBox &output) +{ + isValid = true; + LogValidateStart("ItemStorage", id, name); + if (name == "") + { + LogVarNotSet("ItemStorage", id, "name"); + output.Append(ConsoleLogVarNotSet("ItemStorage", id, "name")); + isValid = false; + } + if (!player) + { + LogVarNotValid("ItemStorage", id, "player"); + output.Append(ConsoleLogVarNotValid("ItemStorage", id, "player")); + isValid = false; + } + LogValidateOver("ItemStorage", id, isValid, name); +} +#endif + +void PokeGen::PokeMod::ItemStorage::ImportIni(Ini &ini, unsigned _id) +{ + LogImportStart("ItemStorage"); + if (_id == UINT_MAX) + { + ini.GetValue("id", id, UINT_MAX); + // Was there an id associated with the element? + if (id == UINT_MAX) + LogIdNotFound("ItemStorage"); + } + else + id = _id; + ini.GetValue("name", name, ""); + ini.GetValue("computer", computer, 0); + ini.GetValue("player", player, 1); + LogImportOver("ItemStorage", id, name); +} + +void PokeGen::PokeMod::ItemStorage::ExportIni(std::ofstream &fout) const +{ + LogExportStart("ItemStorage", id, name); + // Make elements + Ini exItemStorage("ItemStorage"); + exItemStorage.AddField("id", id); + exItemStorage.AddField("name", name); + exItemStorage.AddField("computer", computer); + exItemStorage.AddField("player", player); + exItemStorage.Export(fout); + LogExportOver("ItemStorage", id, name); +} + +void PokeGen::PokeMod::ItemStorage::SetName(const String &n) +{ + LogSetVar("ItemStorage", id, "name", n, name); + name = n; +} + +void PokeGen::PokeMod::ItemStorage::SetComputer(unsigned c) +{ + LogSetVar("ItemStorage", id, "computer", c, name); + computer = c; +} + +void PokeGen::PokeMod::ItemStorage::SetPlayer(unsigned p) +{ + LogSetVar("ItemStorage", id, "player", p, name); + if (p) + player = p; +} + +PokeGen::PokeMod::String PokeGen::PokeMod::ItemStorage::GetName() const +{ + LogFetchVar("ItemStorage", id, "name", name); + return name; +} + +unsigned PokeGen::PokeMod::ItemStorage::GetComputer() const +{ + LogFetchVar("ItemStorage", id, "computer", computer, name); + return computer; +} + +unsigned PokeGen::PokeMod::ItemStorage::GetPlayer() const +{ + LogFetchVar("ItemStorage", id, "player", player, name); + return player; +} -- cgit