Files
wagic/projects/mtg/include/CardPrimitive.h
wrenczes@gmail.com ba07ca2334 Improvement on my last change for reducing the formatted text caching: chopped it out altogether. I ran some profiling to see how much time on the psp it took to process the formatting on the description text (ie word wrapping it into several lines to fit on a card), and it ends up taking an average of 0.14 ms per card. For context, 60 fps is 16 ms. So clearly the formatting time is not the bottleneck here, and we gain no real performance caching the text, but lose memory due to pooling. So I cut it out entirely of the base class and we format on the fly during renders.
I also profiled this after the fact, as we have an open bug on poor drawing performance on psp when in text mode - it turns out that in the AlternateRender() function, my numbers look like this: 10.2 seconds were spent in JBLFont::DrawString(); 0.5 seconds were spent in my new helper FormatText() call, so we know where the perf hit is now.

I compared before & after on the psp with this mod, and the difference really isn't perceptible.  (It's still juddery, but no worse than before.)  I'll look at the DrawString() call next to see if we can make it any faster, although at first glance it looks like a pain.
2011-04-23 09:54:19 +00:00

95 lines
2.1 KiB
C++

#ifndef _CARDPRIMITIVE_H_
#define _CARDPRIMITIVE_H_
#include <string>
#include <vector>
#include <map>
#include "ManaCost.h"
#include "ObjectAnalytics.h"
using namespace std;
class CardPrimitive
#ifdef TRACK_OBJECT_USAGE
: public InstanceCounter<CardPrimitive>
#endif
{
protected:
string lcname;
ManaCost manaCost;
public:
string text;
string name;
int init();
int colors[Constants::MTG_NB_COLORS];
map<int,int> basicAbilities;
map<string,string> magicTexts;
string magicText;
int alias;
string spellTargetType;
int power;
int toughness;
bool hasRestriction;
string restriction;
string otherrestriction;
int suspendedTime;
vector<int>types;
CardPrimitive();
CardPrimitive(CardPrimitive * source);
virtual ~CardPrimitive();
void setColor(int _color, int removeAllOthers = 0);
void setColor(string _color, int removeAllOthers = 0);
void removeColor(int color);
int getColor();
int hasColor(int _color);
int countColors();
int has(int ability);
void setText(const string& value);
const string& getText();
void addMagicText(string value);
void addMagicText(string value, string zone);
void setName(const string& value);
const string& getName() const;
const string& getLCName() const;
void addType(char * type_text);
void addType(int id);
void setType(const string& type_text);
void setSubtype(const string& value);
int removeType(string value, int removeAll = 0);
int removeType(int value, int removeAll = 0);
bool hasSubtype(int _subtype);
bool hasSubtype(const char * _subtype);
bool hasSubtype(string _subtype);
bool hasType(int _type);
bool hasType(const char * type);
void setManaCost(string value);
ManaCost * getManaCost();
bool isCreature();
bool isLand();
bool isSpell();
void setPower(int _power);
int getPower();
void setToughness(int _toughness);
int getToughness();
void setRestrictions(string _restriction);
void getRestrictions();
void setOtherRestrictions(string _restriction);
void getOtherRestrictions();
};
#endif