summaryrefslogtreecommitdiffstats
path: root/pokemod/Time.cpp
diff options
context:
space:
mode:
authorBen Boeckel <MathStuf@gmail.com>2008-03-31 01:17:59 +0000
committerBen Boeckel <MathStuf@gmail.com>2008-03-31 01:17:59 +0000
commit9a65bc6bb7c8da1dfa5b101579e52845c75848ef (patch)
tree258900f882a6998ac6fa525bd247e302028a8911 /pokemod/Time.cpp
parent8e1ec2aec50999bae30625303f2c96e5b3b7f318 (diff)
downloadsigen-9a65bc6bb7c8da1dfa5b101579e52845c75848ef.tar.gz
sigen-9a65bc6bb7c8da1dfa5b101579e52845c75848ef.tar.xz
sigen-9a65bc6bb7c8da1dfa5b101579e52845c75848ef.zip
[FIX] Member variables now use m_ prefix
[FIX] Lots of minor fixes git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@95 6ecfd1a5-f3ed-3746-8530-beee90d26b22
Diffstat (limited to 'pokemod/Time.cpp')
-rw-r--r--pokemod/Time.cpp136
1 files changed, 65 insertions, 71 deletions
diff --git a/pokemod/Time.cpp b/pokemod/Time.cpp
index 3040ee38..6807903e 100644
--- a/pokemod/Time.cpp
+++ b/pokemod/Time.cpp
@@ -1,132 +1,126 @@
-/////////////////////////////////////////////////////////////////////////////
-// Name: pokemod/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-2008 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 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/>.
-/////////////////////////////////////////////////////////////////////////////
+/*
+ * Copyright 2007-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/>.
+ */
#include "Pokemod.h"
#include "Time.h"
-Time::Time(const Pokemod* par, const int _id) :
- Object("Time", par, _id),
- name(""),
- startHour(0),
- startMinute(0)
+Time::Time(const Pokemod* pokemod, const int id) :
+ Object("Time", pokemod, id),
+ m_name(""),
+ m_hour(0),
+ m_minute(0)
{
}
-Time::Time(const Pokemod* par, const Time& t, const int _id) :
- Object("Time", par, _id)
+Time::Time(const Pokemod* pokemod, const Time& time, const int id) :
+ Object("Time", pokemod, id)
{
- *this = t;
+ *this = time;
}
-Time::Time(const Pokemod* par, const QString& fname, const int _id) :
- Object("Time", par, _id)
+Time::Time(const Pokemod* pokemod, const QString& fileName, const int id) :
+ Object("Time", pokemod, id)
{
- load(fname, _id);
+ load(fileName, id);
}
bool Time::validate() const
{
bool valid = true;
- pokemod->validationMsg(QString("---Time \"%1\" with id %2---").arg(name).arg(id), Pokemod::V_Msg);
- if (name == "")
+ pokemod()->validationMsg(QString("---Time \"%1\" with id %2---").arg(m_name).arg(id()), Pokemod::V_Msg);
+ if (m_name == "")
{
- pokemod->validationMsg("Name not defined");
+ pokemod()->validationMsg("Name not defined");
valid = false;
}
- if (23 < startHour)
+ if (23 < m_hour)
{
- pokemod->validationMsg("Invalid starting hour");
+ pokemod()->validationMsg("Invalid starting hour");
valid = false;
}
- if (59 < startMinute)
+ if (59 < m_minute)
{
- pokemod->validationMsg("Invalid start minute");
+ pokemod()->validationMsg("Invalid start minute");
valid = false;
}
return valid;
}
-void Time::load(const QString& fname, const int _id) throw(Exception)
+void Time::load(const QString& fileName, int id) throw(Exception)
{
- Ini ini(fname);
- if (_id == -1)
+ Ini ini(fileName);
+ if (id == INT_MAX)
ini.getValue("id", id);
- else
- id = _id;
- ini.getValue("name", name, "");
- ini.getValue("startHour", startHour, 0);
- ini.getValue("startMinute", startMinute, 0);
+ setId(id);
+ ini.getValue("name", m_name);
+ ini.getValue("hour", m_hour, 0);
+ ini.getValue("minute", m_minute, 0);
}
void Time::save() const throw(Exception)
{
Ini ini;
- ini.addField("id", id);
- ini.addField("name", name);
- ini.addField("startHour", startHour);
- ini.addField("startMinute", startMinute);
- ini.save(QString("%1/time/%2.pini").arg(pokemod->getPath()).arg(name));
+ ini.addField("id", id());
+ ini.addField("name", m_name);
+ ini.addField("hour", m_hour);
+ ini.addField("minute", m_minute);
+ ini.save(QString("%1/time/%2.pini").arg(pokemod()->path()).arg(m_name));
}
-void Time::setName(const QString& n)
+void Time::setName(const QString& name)
{
- name = n;
+ m_name = name;
}
-void Time::setStartHour(const int h) throw(BoundsException)
+void Time::setHour(const int hour) throw(BoundsException)
{
- if (24 <= h)
- throw(BoundsException(className, "startHour"));
- startHour = h;
+ if (24 <= hour)
+ throw(BoundsException(className(), "hour"));
+ m_hour = hour;
}
-void Time::setStartMinute(const int m) throw(BoundsException)
+void Time::setMinute(const int minute) throw(BoundsException)
{
- if (60 <= m)
- throw(BoundsException(className, "startMinute"));
- startMinute = m;
+ if (60 <= minute)
+ throw(BoundsException(className(), "minute"));
+ m_minute = minute;
}
-QString Time::getName() const
+QString Time::name() const
{
- return name;
+ return m_name;
}
-int Time::getStartHour() const
+int Time::hour() const
{
- return startHour;
+ return m_hour;
}
-int Time::getStartMinute() const
+int Time::minute() const
{
- return startMinute;
+ return m_minute;
}
Time& Time::operator=(const Time& rhs)
{
if (this == &rhs)
return *this;
- name = rhs.name;
- startHour = rhs.startHour;
- startMinute = rhs.startMinute;
+ m_name = rhs.m_name;
+ m_hour = rhs.m_hour;
+ m_minute = rhs.m_minute;
return *this;
}