From 42375a0129fdd57355764c58ed27fa3a0a3c5465 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Mon, 21 May 2007 03:04:40 +0000 Subject: Various pokemod fixes (added AbilityEffect and Type) git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@10 6ecfd1a5-f3ed-3746-8530-beee90d26b22 --- pokemod/Matrix.cpp | 258 ----------------------------------------------------- 1 file changed, 258 deletions(-) delete mode 100644 pokemod/Matrix.cpp (limited to 'pokemod/Matrix.cpp') diff --git a/pokemod/Matrix.cpp b/pokemod/Matrix.cpp deleted file mode 100644 index 9fb32398..00000000 --- a/pokemod/Matrix.cpp +++ /dev/null @@ -1,258 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: pokemod/Map.cpp -// Purpose: A 2D vector class -// Author: Ben Boeckel -// Modified by: Ben Boeckel -// Created: Sun Apr 8 12:51:20 2007 -// Copyright: ©2007 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 "Matrix.h" - -template -PokeGen::PokeMod::Matrix::Matrix(unsigned w, unsigned h, const T &d) -{ - matrix.resize(w, std::vector(h, d)); - width = w; - height = h; -} - -template -PokeGen::PokeMod::Matrix::Matrix(Ini &ini) -{ - width = 0; - height = 0; - matrix.clear(); -} - -template<> -PokeGen::PokeMod::Matrix::Matrix(Ini &ini) -{ - ImportIni(ini); -} - -template<> -PokeGen::PokeMod::Matrix::Matrix(Ini &ini) -{ - ImportIni(ini); -} - -template -void PokeGen::PokeMod::Matrix::ImportIni(Ini &ini) -{ -} - -template<> -void PokeGen::PokeMod::Matrix::ImportIni(Ini &ini) -{ - LogImportStart("Matrix"); - ini.GetValue("width", width, 0); - ini.GetValue("height", height, 0); - if (!(width && height)) - return; - matrix.resize(width, std::vector(height, Point(0, 0))); - for (unsigned i = 0; i < width; ++i) - { - for (unsigned j = 0; j < height; ++j) - { - int k; - int l; - ini.GetValue(String("Element-%d-%d-x", i, j), k, 0); - ini.GetValue(String("Element-%d-%d-y", i, j), l, 0); - matrix[i][j].Set(k, l); - } - } - LogImportOver("Matrix"); -} - -template<> -void PokeGen::PokeMod::Matrix::ImportIni(Ini &ini) -{ - LogImportStart("Matrix"); - ini.GetValue("width", width, 0); - ini.GetValue("height", height, 0); - if (!(width && height)) - return; - matrix.resize(width, std::vector(height, Frac(1, 1))); - for (unsigned i = 0; i < width; ++i) - { - for (unsigned j = 0; j < height; ++j) - { - unsigned k; - unsigned l; - bool m; - ini.GetValue(String("Element-%d-%d-n", i, j), k, 0); - ini.GetValue(String("Element-%d-%d-d", i, j), l, 0); - ini.GetValue(String("Element-%d-%d-i", i, j), m, 0); - matrix[i][j].Set(k, l, m); - } - } - LogImportOver("Matrix"); -} - -template<> -void PokeGen::PokeMod::Matrix::ExportIni(const String &val) -{ - Log(String("Matrix Export: Starting %s", val.c_str()), PM_DEBUG_INFO); - // Declare the elements - Ini exMatrix(val); - exMatrix.AddField("height", height); - exMatrix.AddField("width", width); - for (int i = 0; i < width; ++i) - { - for (unsigned j = 0; j < height; ++j) - { - exMatrix.AddField(String("Element-%d-%d-x", i, j), matrix[i][j].GetX()); - exMatrix.AddField(String("Element-%d-%d-y", i, j), matrix[i][j].GetY()); - } - } - Log(String("Matrix Export: Finished %s", val.c_str()), PM_DEBUG_INFO); -} - -template<> -void PokeGen::PokeMod::Matrix::ExportIni(std::ofstream &fout, const String &val) -{ - Log(String("Matrix Export: Starting %s", val.c_str()), PM_DEBUG_INFO); - // Declare the elements - Ini exMatrix(val); - exMatrix.AddField("height", height); - exMatrix.AddField("width", width); - for (unsigned i = 0; i < width; ++i) - { - for (unsigned j = 0; j < height; ++j) - { - exMatrix.AddField(String("Element-%d-%d-i", i, j), matrix[i][j].GetImproper()); - exMatrix.AddField(String("Element-%d-%d-n", i, j), matrix[i][j].GetNum()); - exMatrix.AddField(String("Element-%d-%d-d", i, j), matrix[i][j].GetDenom()); - } - } - exMatrix.Export(fout); - Log(String("Matrix Export: Finished %s", val.c_str()), PM_DEBUG_INFO); -} - -template -void PokeGen::PokeMod::Matrix::AddRow(const T &d) -{ - for (std::vector *i = matrix.begin(); i != matrix.end(); ++i) - i->push_back(d); - ++height; -} - -template -void PokeGen::PokeMod::Matrix::AddCol(const T &d) -{ - matrix.push_back(std::vector(GetHeight(), d)); - ++width; -} - -template -bool PokeGen::PokeMod::Matrix::InsertRow(unsigned pos, const T &d) -{ - if (height < pos) - return false; - for (std::vector *i = matrix.begin(); i != matrix.end(); ++i) - i->insert(pos, d); - ++height; - return true; -} - -template -bool PokeGen::PokeMod::Matrix::InsertCol(unsigned pos, const T &d) -{ - if (width < pos) - return false; - matrix.insert(pos, std::vector(GetHeight(), d)); - ++width; - return true; -} - -template -bool PokeGen::PokeMod::Matrix::DeleteRow(unsigned pos) -{ - if (height <= pos) - return false; - for (std::vector *i = matrix.begin(); i != matrix.end(); ++i) - i->erase(i->begin() + pos); - --height; - return true; -} - -template -bool PokeGen::PokeMod::Matrix::DeleteCol(unsigned pos) -{ - if (width <= pos) - return false; - matrix.erase(matrix.begin() + pos); - --width; - return true; -} - -template -bool PokeGen::PokeMod::Matrix::Set(unsigned row, unsigned col, const T &s) -{ - if ((width <= col) || (height <= col)) - return false; - (matrix.begin() + col)->assign(row, s); - return true; -} - -template -T PokeGen::PokeMod::Matrix::Get(unsigned row, unsigned col) -{ - if ((width <= col) || (height <= col)) - return T(); - return matrix[col][row]; -} - -template -std::vector PokeGen::PokeMod::Matrix::GetRow(unsigned row) -{ - std::vector r; - for (std::vector *i = matrix.begin(); i != matrix.end(); ++i) - r.push_back(i->at(row)); - return r; -} - -template -std::vector PokeGen::PokeMod::Matrix::GetCol(unsigned col) -{ - return matrix[col]; -} - -template -unsigned PokeGen::PokeMod::Matrix::GetHeight() -{ - return height; -} - -template -unsigned PokeGen::PokeMod::Matrix::GetWidth() -{ - return width; -} - -template -T PokeGen::PokeMod::Matrix::operator[](Point &p) -{ - return matrix[p.GetY()][p.GetX()]; -} - -template -std::vector PokeGen::PokeMod::Matrix::operator[](int col) -{ - return matrix[col]; -} -- cgit