From 0fec318eac634e5465c30eb73d47ec82aaed9db8 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Mon, 21 May 2007 04:18:48 +0000 Subject: Added Time, Store, and PokemonItem git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@11 6ecfd1a5-f3ed-3746-8530-beee90d26b22 --- pokemod/Time.cpp | 164 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 164 insertions(+) create mode 100644 pokemod/Time.cpp (limited to 'pokemod/Time.cpp') diff --git a/pokemod/Time.cpp b/pokemod/Time.cpp new file mode 100644 index 00000000..d18d826f --- /dev/null +++ b/pokemod/Time.cpp @@ -0,0 +1,164 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: Time.cpp +// Purpose: Define the start of a time of day in the PokéMod +// Author: Ben Boeckel +// Modified by: Ben Boeckel +// Created: Wed Feb 28 21:00:46 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 "Time.h" + +PokeGen::PokeMod::Time::Time(unsigned _id) +{ + LogCtor("Time", id); + name = ""; + startHour = 0; + startMinute = 0; + id = _id; +} + +PokeGen::PokeMod::Time::Time(Ini &ini, unsigned _id) +{ + LogCtorIni("Time", _id); + ImportIni(ini, _id); + if(_id == UINT_MAX) + LogIdError("Time"); +} + +PokeGen::PokeMod::Time::~Time() +{ + LogDtor("Time", id, name); +} + +void PokeGen::PokeMod::Time::Validate() +{ + isValid = true; + LogValidateStart("Time", id, name); + if (name == "") + { + LogVarNotSet("Time", id, "name", name); + isValid = false; + } + if (23 < startHour) + { + LogVarNotValid("Time", id, "startHour", name); + isValid = false; + } + if (59 < startMinute) + { + LogVarNotValid("Time", id, "startMinute", name); + isValid = false; + } + LogValidateOver("Time", id, isValid, name); +} + +#ifdef PG_DEBUG_WINDOW +void PokeGen::PokeMod::Time::Validate(const wxListBox &output) +{ + isValid = true; + LogValidateStart("Time", id, name); + if (name == "") + { + LogVarNotSet("Time", id, "name", name); + output.Append(ConsoleLogVarNotSet("Time", id, "name", name)); + isValid = false; + } + if (23 < startHour) + { + LogVarNotValid("Time", id, "startHour", name); + output.Append(ConsoleLogVarNotValid("Time", id, "startHour", name)); + isValid = false; + } + if (59 < startMinute) + { + LogVarNotValid("Time", id, "startMinute", name); + output.Append(ConsoleLogVarNotValid("Time", id, "startMinute", name)); + isValid = false; + } + LogValidateOver("Time", id, isValid, name); +} +#endif + +void PokeGen::PokeMod::Time::ImportIni(Ini &ini, unsigned _id) +{ + LogImportStart("Time"); + if (_id == UINT_MAX) + { + ini.GetValue("id", id, UINT_MAX); + // Was there an id associated with the element? + if (id == UINT_MAX) + LogIdNotFound("Time"); + } + else + id = _id; + ini.GetValue("name", name, ""); + ini.GetValue("startHour", startHour, 0); + ini.GetValue("startMinute", startMinute, 0); + LogImportOver("Time", id, name); +} + +void PokeGen::PokeMod::Time::ExportIni(std::ofstream &fout) const +{ + LogExportStart("Time", id, name); + // Make elements + Ini exTime("time"); + exTime.AddField("id", id); + exTime.AddField("name", name); + exTime.AddField("startHour", startHour); + exTime.AddField("startMinute", startMinute); + exTime.Export(fout); + LogExportOver("Time", id, name); +} + +void PokeGen::PokeMod::Time::SetName(const String &n) +{ + LogSetVar("Time", id, "name", n, name); + name = n; +} + +void PokeGen::PokeMod::Time::SetStartHour(unsigned h) +{ + LogSetVar("Time", id, "startHour", h, name); + if (h < 24) + startHour = h; +} + +void PokeGen::PokeMod::Time::SetStartMinute(unsigned m) +{ + LogSetVar("Time", id, "startMinute", m, name); + if (m < 60) + startMinute = m; +} + +PokeGen::PokeMod::String PokeGen::PokeMod::Time::GetName() const +{ + LogFetchVar("Time", id, "name", name, name); + return name; +} + +unsigned PokeGen::PokeMod::Time::GetStartHour() const +{ + LogFetchVar("Time", id, "startHour", startHour, name); + return startHour; +} + +unsigned PokeGen::PokeMod::Time::GetStartMinute() const +{ + LogFetchVar("Time", id, "startMinute", startMinute, name); + return startMinute; +} -- cgit